From ae8e129ce7f470a2f28a843e68fed41503c7682a Mon Sep 17 00:00:00 2001 From: Matthew Rich Date: Wed, 3 Apr 2024 14:23:57 -0700 Subject: [PATCH] fix linting errors --- internal/resource/container.go | 10 +++++----- internal/resource/network_route.go | 2 -- tests/mocks/container.go | 4 ++-- tests/mocks/resource.go | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-) diff --git a/internal/resource/container.go b/internal/resource/container.go index 1bcafae..8c97664 100644 --- a/internal/resource/container.go +++ b/internal/resource/container.go @@ -27,7 +27,7 @@ import ( type ContainerClient interface { ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) ContainerStart(ctx context.Context, containerID string, options container.StartOptions) error - ContainerList(context.Context, types.ContainerListOptions) ([]types.Container, error) + ContainerList(context.Context, container.ListOptions) ([]types.Container, error) ContainerInspect(context.Context, string) (types.ContainerJSON, error) ContainerRemove(context.Context, string, container.RemoveOptions) error Close() error @@ -163,7 +163,7 @@ func (c *Container) Create(ctx context.Context) error { } */ - if startErr := c.apiClient.ContainerStart(ctx, c.Id, types.ContainerStartOptions{}); startErr != nil { + if startErr := c.apiClient.ContainerStart(ctx, c.Id, container.StartOptions{}); startErr != nil { return startErr } return err @@ -175,7 +175,7 @@ func (c *Container) Read(ctx context.Context) ([]byte, error) { var containerID string filterArgs := filters.NewArgs() filterArgs.Add("name", "/"+c.Name) - containers, err := c.apiClient.ContainerList(ctx, types.ContainerListOptions{ + containers, err := c.apiClient.ContainerList(ctx, container.ListOptions{ All: true, Filters: filterArgs, }) @@ -219,7 +219,7 @@ func (c *Container) Read(ctx context.Context) ([]byte, error) { } func (c *Container) Delete(ctx context.Context) error { - err := c.apiClient.ContainerRemove(ctx, c.Id, types.ContainerRemoveOptions{ + err := c.apiClient.ContainerRemove(ctx, c.Id, container.RemoveOptions{ RemoveVolumes: true, Force: false, }) @@ -235,7 +235,7 @@ func (c *Container) Type() string { return "container" } func (c *Container) ResolveId(ctx context.Context) string { filterArgs := filters.NewArgs() filterArgs.Add("name", "/"+c.Name) - containers, err := c.apiClient.ContainerList(ctx, types.ContainerListOptions{ + containers, err := c.apiClient.ContainerList(ctx, container.ListOptions{ All: true, Filters: filterArgs, }) diff --git a/internal/resource/network_route.go b/internal/resource/network_route.go index 59841f7..b8ee68d 100644 --- a/internal/resource/network_route.go +++ b/internal/resource/network_route.go @@ -349,8 +349,6 @@ func (n *NetworkRouteProto) UnmarshalYAML(value *yaml.Node) error { } func (n *NetworkRoute) UnmarshalJSON(data []byte) error { - fmt.Printf("UnmarshalJSON %#v\n", string(data)) - panic(data) if err := json.Unmarshal(data, n); err != nil { return err } diff --git a/tests/mocks/container.go b/tests/mocks/container.go index fda6551..1e6d94c 100644 --- a/tests/mocks/container.go +++ b/tests/mocks/container.go @@ -12,7 +12,7 @@ import ( type MockContainerClient struct { InjectContainerStart func(ctx context.Context, containerID string, options container.StartOptions) error InjectContainerCreate func(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error) - InjectContainerList func(context.Context, types.ContainerListOptions) ([]types.Container, error) + InjectContainerList func(context.Context, container.ListOptions) ([]types.Container, error) InjectContainerInspect func(context.Context, string) (types.ContainerJSON, error) InjectContainerRemove func(context.Context, string, container.RemoveOptions) error InjectClose func() error @@ -29,7 +29,7 @@ func (m *MockContainerClient) ContainerStart(ctx context.Context, containerID st return m.InjectContainerStart(ctx, containerID, options) } -func (m *MockContainerClient) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { +func (m *MockContainerClient) ContainerList(ctx context.Context, options container.ListOptions) ([]types.Container, error) { return m.InjectContainerList(ctx, options) } diff --git a/tests/mocks/resource.go b/tests/mocks/resource.go index 1b17041..8085002 100644 --- a/tests/mocks/resource.go +++ b/tests/mocks/resource.go @@ -22,7 +22,7 @@ func (m *MockResource) URI() string { } func (m *MockResource) ResolveId(ctx context.Context) string { - return m.ResolveId(ctx) + return m.InjectResolveId(ctx) } func (m *MockResource) LoadDecl(yamlResourceDeclaration string) error {