mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 19:13:34 +00:00
test: Add an e2e test for build&push (#69)
* test: Add an e2e test for build&push * test: Add image cleanup * test: Switch to assert.NoError
This commit is contained in:
@@ -42,6 +42,8 @@ func (m *Machine) Connect(ctx context.Context) (*client.Client, error) {
|
||||
type CreateMachineOptions struct {
|
||||
Name string
|
||||
Image string
|
||||
// Ports to forward from the machine to the host.
|
||||
PortMap nat.PortMap
|
||||
}
|
||||
|
||||
func (p *Provisioner) CreateMachine(ctx context.Context, clusterName string, opts CreateMachineOptions) (Machine, error) {
|
||||
@@ -88,6 +90,16 @@ func (p *Provisioner) CreateMachine(ctx context.Context, clusterName string, opt
|
||||
Name: container.RestartPolicyAlways,
|
||||
},
|
||||
}
|
||||
// Forward ports, if requested
|
||||
if opts.PortMap != nil {
|
||||
for port, bindings := range opts.PortMap {
|
||||
if len(bindings) == 0 {
|
||||
continue
|
||||
}
|
||||
config.ExposedPorts[port] = struct{}{}
|
||||
hostConfig.PortBindings[port] = bindings
|
||||
}
|
||||
}
|
||||
|
||||
if _, err := p.createContainerWithImagePull(ctx, containerName, config, hostConfig); err != nil {
|
||||
return m, err
|
||||
|
||||
Reference in New Issue
Block a user