fix lint errors
This commit is contained in:
parent
a9fd9f3624
commit
75c89c39ec
@ -386,8 +386,8 @@ func (c *Container) ResolveId(ctx context.Context) string {
|
||||
Filters: filterArgs,
|
||||
})
|
||||
if err != nil {
|
||||
c.StateMachine().Trigger("notexists")
|
||||
panic(fmt.Errorf("%w: %s %s", err, c.Type(), c.Name))
|
||||
triggerErr := c.StateMachine().Trigger("notexists")
|
||||
panic(fmt.Errorf("%w: %s %s, %w", err, c.Type(), c.Name, triggerErr))
|
||||
}
|
||||
|
||||
slog.Info("Container.ResolveId()", "containers", containers)
|
||||
@ -398,12 +398,16 @@ func (c *Container) ResolveId(ctx context.Context) string {
|
||||
if c.Id == "" {
|
||||
c.Id = container.ID
|
||||
}
|
||||
c.StateMachine().Trigger("exists")
|
||||
if triggerErr := c.StateMachine().Trigger("exists"); triggerErr != nil {
|
||||
panic(fmt.Errorf("%w: %s %s", triggerErr, c.Type(), c.Name))
|
||||
}
|
||||
slog.Info("Container.ResolveId() trigger created", "machine", c.StateMachine(), "state", c.StateMachine().CurrentState())
|
||||
return container.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
c.StateMachine().Trigger("notexists")
|
||||
if triggerErr := c.StateMachine().Trigger("notexists"); triggerErr != nil {
|
||||
panic(fmt.Errorf("%w: %s %s", triggerErr, c.Type(), c.Name))
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/client"
|
||||
"gopkg.in/yaml.v3"
|
||||
_ "gopkg.in/yaml.v3"
|
||||
@ -24,7 +25,7 @@ _ "os/exec"
|
||||
type ContainerImageClient interface {
|
||||
ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
|
||||
ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
|
||||
ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
|
||||
ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error)
|
||||
Close() error
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,9 @@ import (
|
||||
_ "encoding/json"
|
||||
_ "fmt"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
_ "net/http"
|
||||
_ "net/http/httptest"
|
||||
_ "net/url"
|
||||
@ -25,7 +25,7 @@ func TestNewContainerImageResource(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestReadContainerImage(t *testing.T) {
|
||||
output := ioutil.NopCloser(strings.NewReader("testdata"))
|
||||
output := io.NopCloser(strings.NewReader("testdata"))
|
||||
ctx := context.Background()
|
||||
decl := `
|
||||
name: "alpine:latest"
|
||||
@ -35,7 +35,7 @@ func TestReadContainerImage(t *testing.T) {
|
||||
InjectImagePull: func(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) {
|
||||
return output, nil
|
||||
},
|
||||
InjectImageRemove: func(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) {
|
||||
InjectImageRemove: func(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
||||
return nil, nil
|
||||
},
|
||||
InjectImageInspectWithRaw: func(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/network"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
"io"
|
||||
)
|
||||
@ -22,7 +23,7 @@ type MockContainerClient struct {
|
||||
InjectContainerWait func(ctx context.Context, containerID string, condition container.WaitCondition) (<-chan container.WaitResponse, <-chan error)
|
||||
InjectImagePull func(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
|
||||
InjectImageInspectWithRaw func(ctx context.Context, imageID string) (types.ImageInspect, []byte, error)
|
||||
InjectImageRemove func(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
|
||||
InjectImageRemove func(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error)
|
||||
InjectClose func() error
|
||||
}
|
||||
|
||||
@ -30,7 +31,7 @@ func (m *MockContainerClient) ContainerWait(ctx context.Context, containerID str
|
||||
return m.InjectContainerWait(ctx, containerID, condition)
|
||||
}
|
||||
|
||||
func (m *MockContainerClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) {
|
||||
func (m *MockContainerClient) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]image.DeleteResponse, error) {
|
||||
return m.InjectImageRemove(ctx, imageID, options)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user