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:
Anton Ovchinnikov
2025-06-09 22:10:53 +02:00
committed by GitHub
parent 971b21d6c1
commit 2f55af0cab
11 changed files with 196 additions and 19 deletions
+12
View File
@@ -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