diff --git a/Makefile b/Makefile index 8d336182..601656f5 100644 --- a/Makefile +++ b/Makefile @@ -49,7 +49,7 @@ dagger_release: --src=. generate_mocks: - go install github.com/vektra/mockery/v2@v2.20.0 + go install github.com/vektra/mockery/v2@v2.46.0 go generate ./... install_local: diff --git a/pkg/clients/command/mocks/command.go b/pkg/clients/command/mocks/command.go index 536c66cf..95d30480 100644 --- a/pkg/clients/command/mocks/command.go +++ b/pkg/clients/command/mocks/command.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -16,6 +16,10 @@ type Command struct { func (_m *Command) Execute(config types.CommandConfig) (int, error) { ret := _m.Called(config) + if len(ret) == 0 { + panic("no return value specified for Execute") + } + var r0 int var r1 error if rf, ok := ret.Get(0).(func(types.CommandConfig) (int, error)); ok { @@ -40,6 +44,10 @@ func (_m *Command) Execute(config types.CommandConfig) (int, error) { func (_m *Command) Kill(pid int) error { ret := _m.Called(pid) + if len(ret) == 0 { + panic("no return value specified for Kill") + } + var r0 error if rf, ok := ret.Get(0).(func(int) error); ok { r0 = rf(pid) @@ -50,13 +58,12 @@ func (_m *Command) Kill(pid int) error { return r0 } -type mockConstructorTestingTNewCommand interface { +// NewCommand creates a new instance of Command. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewCommand(t interface { mock.TestingT Cleanup(func()) -} - -// NewCommand creates a new instance of Command. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewCommand(t mockConstructorTestingTNewCommand) *Command { +}) *Command { mock := &Command{} mock.Mock.Test(t) diff --git a/pkg/clients/connector/mocks/connector.go b/pkg/clients/connector/mocks/connector.go index ac82c0ef..15f64495 100644 --- a/pkg/clients/connector/mocks/connector.go +++ b/pkg/clients/connector/mocks/connector.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -17,6 +17,10 @@ type Connector struct { func (_m *Connector) ExposeService(name string, port int, remoteAddr string, destAddr string, direction string) (string, error) { ret := _m.Called(name, port, remoteAddr, destAddr, direction) + if len(ret) == 0 { + panic("no return value specified for ExposeService") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(string, int, string, string, string) (string, error)); ok { @@ -41,6 +45,10 @@ func (_m *Connector) ExposeService(name string, port int, remoteAddr string, des func (_m *Connector) GenerateLeafCert(privateKey string, rootCA string, hosts []string, ips []string, dir string) (*types.CertBundle, error) { ret := _m.Called(privateKey, rootCA, hosts, ips, dir) + if len(ret) == 0 { + panic("no return value specified for GenerateLeafCert") + } + var r0 *types.CertBundle var r1 error if rf, ok := ret.Get(0).(func(string, string, []string, []string, string) (*types.CertBundle, error)); ok { @@ -67,6 +75,10 @@ func (_m *Connector) GenerateLeafCert(privateKey string, rootCA string, hosts [] func (_m *Connector) GenerateLocalCertBundle(out string) (*types.CertBundle, error) { ret := _m.Called(out) + if len(ret) == 0 { + panic("no return value specified for GenerateLocalCertBundle") + } + var r0 *types.CertBundle var r1 error if rf, ok := ret.Get(0).(func(string) (*types.CertBundle, error)); ok { @@ -93,6 +105,10 @@ func (_m *Connector) GenerateLocalCertBundle(out string) (*types.CertBundle, err func (_m *Connector) GetLocalCertBundle(dir string) (*types.CertBundle, error) { ret := _m.Called(dir) + if len(ret) == 0 { + panic("no return value specified for GetLocalCertBundle") + } + var r0 *types.CertBundle var r1 error if rf, ok := ret.Get(0).(func(string) (*types.CertBundle, error)); ok { @@ -119,6 +135,10 @@ func (_m *Connector) GetLocalCertBundle(dir string) (*types.CertBundle, error) { func (_m *Connector) IsRunning() bool { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for IsRunning") + } + var r0 bool if rf, ok := ret.Get(0).(func() bool); ok { r0 = rf() @@ -133,6 +153,10 @@ func (_m *Connector) IsRunning() bool { func (_m *Connector) ListServices() ([]*shipyard.Service, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for ListServices") + } + var r0 []*shipyard.Service var r1 error if rf, ok := ret.Get(0).(func() ([]*shipyard.Service, error)); ok { @@ -159,6 +183,10 @@ func (_m *Connector) ListServices() ([]*shipyard.Service, error) { func (_m *Connector) RemoveService(id string) error { ret := _m.Called(id) + if len(ret) == 0 { + panic("no return value specified for RemoveService") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(id) @@ -173,6 +201,10 @@ func (_m *Connector) RemoveService(id string) error { func (_m *Connector) Start(_a0 *types.CertBundle) error { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Start") + } + var r0 error if rf, ok := ret.Get(0).(func(*types.CertBundle) error); ok { r0 = rf(_a0) @@ -187,6 +219,10 @@ func (_m *Connector) Start(_a0 *types.CertBundle) error { func (_m *Connector) Stop() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Stop") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -197,13 +233,12 @@ func (_m *Connector) Stop() error { return r0 } -type mockConstructorTestingTNewConnector interface { +// NewConnector creates a new instance of Connector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewConnector(t interface { mock.TestingT Cleanup(func()) -} - -// NewConnector creates a new instance of Connector. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewConnector(t mockConstructorTestingTNewConnector) *Connector { +}) *Connector { mock := &Connector{} mock.Mock.Test(t) diff --git a/pkg/clients/container/mocks/container_tasks.go b/pkg/clients/container/mocks/container_tasks.go index 179401ce..5216fb70 100644 --- a/pkg/clients/container/mocks/container_tasks.go +++ b/pkg/clients/container/mocks/container_tasks.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -18,6 +18,10 @@ type ContainerTasks struct { func (_m *ContainerTasks) AttachNetwork(network string, containerid string, aliases []string, ipaddress string) error { ret := _m.Called(network, containerid, aliases, ipaddress) + if len(ret) == 0 { + panic("no return value specified for AttachNetwork") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string, []string, string) error); ok { r0 = rf(network, containerid, aliases, ipaddress) @@ -32,6 +36,10 @@ func (_m *ContainerTasks) AttachNetwork(network string, containerid string, alia func (_m *ContainerTasks) BuildContainer(config *types.Build, force bool) (string, error) { ret := _m.Called(config, force) + if len(ret) == 0 { + panic("no return value specified for BuildContainer") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(*types.Build, bool) (string, error)); ok { @@ -56,6 +64,10 @@ func (_m *ContainerTasks) BuildContainer(config *types.Build, force bool) (strin func (_m *ContainerTasks) ContainerInfo(id string) (interface{}, error) { ret := _m.Called(id) + if len(ret) == 0 { + panic("no return value specified for ContainerInfo") + } + var r0 interface{} var r1 error if rf, ok := ret.Get(0).(func(string) (interface{}, error)); ok { @@ -82,6 +94,10 @@ func (_m *ContainerTasks) ContainerInfo(id string) (interface{}, error) { func (_m *ContainerTasks) ContainerLogs(id string, stdOut bool, stdErr bool) (io.ReadCloser, error) { ret := _m.Called(id, stdOut, stdErr) + if len(ret) == 0 { + panic("no return value specified for ContainerLogs") + } + var r0 io.ReadCloser var r1 error if rf, ok := ret.Get(0).(func(string, bool, bool) (io.ReadCloser, error)); ok { @@ -108,6 +124,10 @@ func (_m *ContainerTasks) ContainerLogs(id string, stdOut bool, stdErr bool) (io func (_m *ContainerTasks) CopyFileToContainer(id string, src string, dst string) error { ret := _m.Called(id, src, dst) + if len(ret) == 0 { + panic("no return value specified for CopyFileToContainer") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string, string) error); ok { r0 = rf(id, src, dst) @@ -122,6 +142,10 @@ func (_m *ContainerTasks) CopyFileToContainer(id string, src string, dst string) func (_m *ContainerTasks) CopyFilesToVolume(volume string, files []string, path string, force bool) ([]string, error) { ret := _m.Called(volume, files, path, force) + if len(ret) == 0 { + panic("no return value specified for CopyFilesToVolume") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func(string, []string, string, bool) ([]string, error)); ok { @@ -148,6 +172,10 @@ func (_m *ContainerTasks) CopyFilesToVolume(volume string, files []string, path func (_m *ContainerTasks) CopyFromContainer(id string, src string, dst string) error { ret := _m.Called(id, src, dst) + if len(ret) == 0 { + panic("no return value specified for CopyFromContainer") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string, string) error); ok { r0 = rf(id, src, dst) @@ -162,6 +190,10 @@ func (_m *ContainerTasks) CopyFromContainer(id string, src string, dst string) e func (_m *ContainerTasks) CopyLocalDockerImagesToVolume(images []string, volume string, force bool) ([]string, error) { ret := _m.Called(images, volume, force) + if len(ret) == 0 { + panic("no return value specified for CopyLocalDockerImagesToVolume") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func([]string, string, bool) ([]string, error)); ok { @@ -188,6 +220,10 @@ func (_m *ContainerTasks) CopyLocalDockerImagesToVolume(images []string, volume func (_m *ContainerTasks) CreateContainer(_a0 *types.Container) (string, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for CreateContainer") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(*types.Container) (string, error)); ok { @@ -212,6 +248,10 @@ func (_m *ContainerTasks) CreateContainer(_a0 *types.Container) (string, error) func (_m *ContainerTasks) CreateFileInContainer(containerID string, contents string, filename string, path string) error { ret := _m.Called(containerID, contents, filename, path) + if len(ret) == 0 { + panic("no return value specified for CreateFileInContainer") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string, string, string) error); ok { r0 = rf(containerID, contents, filename, path) @@ -226,6 +266,10 @@ func (_m *ContainerTasks) CreateFileInContainer(containerID string, contents str func (_m *ContainerTasks) CreateShell(id string, command []string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error { ret := _m.Called(id, command, stdin, stdout, stderr) + if len(ret) == 0 { + panic("no return value specified for CreateShell") + } + var r0 error if rf, ok := ret.Get(0).(func(string, []string, io.ReadCloser, io.Writer, io.Writer) error); ok { r0 = rf(id, command, stdin, stdout, stderr) @@ -240,6 +284,10 @@ func (_m *ContainerTasks) CreateShell(id string, command []string, stdin io.Read func (_m *ContainerTasks) CreateVolume(name string) (string, error) { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for CreateVolume") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(string) (string, error)); ok { @@ -264,6 +312,10 @@ func (_m *ContainerTasks) CreateVolume(name string) (string, error) { func (_m *ContainerTasks) DetachNetwork(network string, containerid string) error { ret := _m.Called(network, containerid) + if len(ret) == 0 { + panic("no return value specified for DetachNetwork") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string) error); ok { r0 = rf(network, containerid) @@ -278,6 +330,10 @@ func (_m *ContainerTasks) DetachNetwork(network string, containerid string) erro func (_m *ContainerTasks) EngineInfo() *types.EngineInfo { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for EngineInfo") + } + var r0 *types.EngineInfo if rf, ok := ret.Get(0).(func() *types.EngineInfo); ok { r0 = rf() @@ -294,6 +350,10 @@ func (_m *ContainerTasks) EngineInfo() *types.EngineInfo { func (_m *ContainerTasks) ExecuteCommand(id string, command []string, env []string, workingDirectory string, user string, group string, timeout int, writer io.Writer) (int, error) { ret := _m.Called(id, command, env, workingDirectory, user, group, timeout, writer) + if len(ret) == 0 { + panic("no return value specified for ExecuteCommand") + } + var r0 int var r1 error if rf, ok := ret.Get(0).(func(string, []string, []string, string, string, string, int, io.Writer) (int, error)); ok { @@ -318,6 +378,10 @@ func (_m *ContainerTasks) ExecuteCommand(id string, command []string, env []stri func (_m *ContainerTasks) ExecuteScript(id string, contents string, env []string, workingDirectory string, user string, group string, timeout int, writer io.Writer) (int, error) { ret := _m.Called(id, contents, env, workingDirectory, user, group, timeout, writer) + if len(ret) == 0 { + panic("no return value specified for ExecuteScript") + } + var r0 int var r1 error if rf, ok := ret.Get(0).(func(string, string, []string, string, string, string, int, io.Writer) (int, error)); ok { @@ -342,6 +406,10 @@ func (_m *ContainerTasks) ExecuteScript(id string, contents string, env []string func (_m *ContainerTasks) FindContainerIDs(containerName string) ([]string, error) { ret := _m.Called(containerName) + if len(ret) == 0 { + panic("no return value specified for FindContainerIDs") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func(string) ([]string, error)); ok { @@ -368,6 +436,10 @@ func (_m *ContainerTasks) FindContainerIDs(containerName string) ([]string, erro func (_m *ContainerTasks) FindImageInLocalRegistry(image types.Image) (string, error) { ret := _m.Called(image) + if len(ret) == 0 { + panic("no return value specified for FindImageInLocalRegistry") + } + var r0 string var r1 error if rf, ok := ret.Get(0).(func(types.Image) (string, error)); ok { @@ -392,6 +464,10 @@ func (_m *ContainerTasks) FindImageInLocalRegistry(image types.Image) (string, e func (_m *ContainerTasks) FindImagesInLocalRegistry(filter string) ([]string, error) { ret := _m.Called(filter) + if len(ret) == 0 { + panic("no return value specified for FindImagesInLocalRegistry") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func(string) ([]string, error)); ok { @@ -418,6 +494,10 @@ func (_m *ContainerTasks) FindImagesInLocalRegistry(filter string) ([]string, er func (_m *ContainerTasks) FindNetwork(id string) (types.NetworkAttachment, error) { ret := _m.Called(id) + if len(ret) == 0 { + panic("no return value specified for FindNetwork") + } + var r0 types.NetworkAttachment var r1 error if rf, ok := ret.Get(0).(func(string) (types.NetworkAttachment, error)); ok { @@ -442,6 +522,10 @@ func (_m *ContainerTasks) FindNetwork(id string) (types.NetworkAttachment, error func (_m *ContainerTasks) ListNetworks(id string) []types.NetworkAttachment { ret := _m.Called(id) + if len(ret) == 0 { + panic("no return value specified for ListNetworks") + } + var r0 []types.NetworkAttachment if rf, ok := ret.Get(0).(func(string) []types.NetworkAttachment); ok { r0 = rf(id) @@ -458,6 +542,10 @@ func (_m *ContainerTasks) ListNetworks(id string) []types.NetworkAttachment { func (_m *ContainerTasks) PullImage(image types.Image, force bool) error { ret := _m.Called(image, force) + if len(ret) == 0 { + panic("no return value specified for PullImage") + } + var r0 error if rf, ok := ret.Get(0).(func(types.Image, bool) error); ok { r0 = rf(image, force) @@ -472,6 +560,10 @@ func (_m *ContainerTasks) PullImage(image types.Image, force bool) error { func (_m *ContainerTasks) PushImage(image types.Image) error { ret := _m.Called(image) + if len(ret) == 0 { + panic("no return value specified for PushImage") + } + var r0 error if rf, ok := ret.Get(0).(func(types.Image) error); ok { r0 = rf(image) @@ -486,6 +578,10 @@ func (_m *ContainerTasks) PushImage(image types.Image) error { func (_m *ContainerTasks) RemoveContainer(id string, force bool) error { ret := _m.Called(id, force) + if len(ret) == 0 { + panic("no return value specified for RemoveContainer") + } + var r0 error if rf, ok := ret.Get(0).(func(string, bool) error); ok { r0 = rf(id, force) @@ -500,6 +596,10 @@ func (_m *ContainerTasks) RemoveContainer(id string, force bool) error { func (_m *ContainerTasks) RemoveImage(id string) error { ret := _m.Called(id) + if len(ret) == 0 { + panic("no return value specified for RemoveImage") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(id) @@ -514,6 +614,10 @@ func (_m *ContainerTasks) RemoveImage(id string) error { func (_m *ContainerTasks) RemoveVolume(name string) error { ret := _m.Called(name) + if len(ret) == 0 { + panic("no return value specified for RemoveVolume") + } + var r0 error if rf, ok := ret.Get(0).(func(string) error); ok { r0 = rf(name) @@ -533,6 +637,10 @@ func (_m *ContainerTasks) SetForce(_a0 bool) { func (_m *ContainerTasks) TagImage(source string, destination string) error { ret := _m.Called(source, destination) + if len(ret) == 0 { + panic("no return value specified for TagImage") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string) error); ok { r0 = rf(source, destination) @@ -543,13 +651,12 @@ func (_m *ContainerTasks) TagImage(source string, destination string) error { return r0 } -type mockConstructorTestingTNewContainerTasks interface { +// NewContainerTasks creates a new instance of ContainerTasks. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewContainerTasks(t interface { mock.TestingT Cleanup(func()) -} - -// NewContainerTasks creates a new instance of ContainerTasks. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewContainerTasks(t mockConstructorTestingTNewContainerTasks) *ContainerTasks { +}) *ContainerTasks { mock := &ContainerTasks{} mock.Mock.Test(t) diff --git a/pkg/clients/container/mocks/docker.go b/pkg/clients/container/mocks/docker.go index 5088490b..19861488 100644 --- a/pkg/clients/container/mocks/docker.go +++ b/pkg/clients/container/mocks/docker.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -28,6 +28,10 @@ type Docker struct { func (_m *Docker) CheckpointCreate(ctx context.Context, _a1 string, options types.CheckpointCreateOptions) error { ret := _m.Called(ctx, _a1, options) + if len(ret) == 0 { + panic("no return value specified for CheckpointCreate") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, types.CheckpointCreateOptions) error); ok { r0 = rf(ctx, _a1, options) @@ -42,6 +46,10 @@ func (_m *Docker) CheckpointCreate(ctx context.Context, _a1 string, options type func (_m *Docker) CheckpointList(ctx context.Context, _a1 string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { ret := _m.Called(ctx, _a1, options) + if len(ret) == 0 { + panic("no return value specified for CheckpointList") + } + var r0 []types.Checkpoint var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.CheckpointListOptions) ([]types.Checkpoint, error)); ok { @@ -68,6 +76,10 @@ func (_m *Docker) CheckpointList(ctx context.Context, _a1 string, options types. func (_m *Docker) ContainerCreate(ctx context.Context, config *typescontainer.Config, hostConfig *typescontainer.HostConfig, networkingConfig *network.NetworkingConfig, platform *v1.Platform, containerName string) (typescontainer.CreateResponse, error) { ret := _m.Called(ctx, config, hostConfig, networkingConfig, platform, containerName) + if len(ret) == 0 { + panic("no return value specified for ContainerCreate") + } + var r0 typescontainer.CreateResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, *typescontainer.Config, *typescontainer.HostConfig, *network.NetworkingConfig, *v1.Platform, string) (typescontainer.CreateResponse, error)); ok { @@ -92,6 +104,10 @@ func (_m *Docker) ContainerCreate(ctx context.Context, config *typescontainer.Co func (_m *Docker) ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error) { ret := _m.Called(ctx, execID, config) + if len(ret) == 0 { + panic("no return value specified for ContainerExecAttach") + } + var r0 types.HijackedResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ExecStartCheck) (types.HijackedResponse, error)); ok { @@ -116,6 +132,10 @@ func (_m *Docker) ContainerExecAttach(ctx context.Context, execID string, config func (_m *Docker) ContainerExecCreate(ctx context.Context, _a1 string, config types.ExecConfig) (types.IDResponse, error) { ret := _m.Called(ctx, _a1, config) + if len(ret) == 0 { + panic("no return value specified for ContainerExecCreate") + } + var r0 types.IDResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ExecConfig) (types.IDResponse, error)); ok { @@ -140,6 +160,10 @@ func (_m *Docker) ContainerExecCreate(ctx context.Context, _a1 string, config ty func (_m *Docker) ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error) { ret := _m.Called(ctx, execID) + if len(ret) == 0 { + panic("no return value specified for ContainerExecInspect") + } + var r0 types.ContainerExecInspect var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (types.ContainerExecInspect, error)); ok { @@ -164,6 +188,10 @@ func (_m *Docker) ContainerExecInspect(ctx context.Context, execID string) (type func (_m *Docker) ContainerExecResize(ctx context.Context, execID string, config types.ResizeOptions) error { ret := _m.Called(ctx, execID, config) + if len(ret) == 0 { + panic("no return value specified for ContainerExecResize") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ResizeOptions) error); ok { r0 = rf(ctx, execID, config) @@ -178,6 +206,10 @@ func (_m *Docker) ContainerExecResize(ctx context.Context, execID string, config func (_m *Docker) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error { ret := _m.Called(ctx, execID, config) + if len(ret) == 0 { + panic("no return value specified for ContainerExecStart") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ExecStartCheck) error); ok { r0 = rf(ctx, execID, config) @@ -192,6 +224,10 @@ func (_m *Docker) ContainerExecStart(ctx context.Context, execID string, config func (_m *Docker) ContainerInspect(ctx context.Context, containerID string) (types.ContainerJSON, error) { ret := _m.Called(ctx, containerID) + if len(ret) == 0 { + panic("no return value specified for ContainerInspect") + } + var r0 types.ContainerJSON var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (types.ContainerJSON, error)); ok { @@ -216,6 +252,10 @@ func (_m *Docker) ContainerInspect(ctx context.Context, containerID string) (typ func (_m *Docker) ContainerList(ctx context.Context, options types.ContainerListOptions) ([]types.Container, error) { ret := _m.Called(ctx, options) + if len(ret) == 0 { + panic("no return value specified for ContainerList") + } + var r0 []types.Container var r1 error if rf, ok := ret.Get(0).(func(context.Context, types.ContainerListOptions) ([]types.Container, error)); ok { @@ -242,6 +282,10 @@ func (_m *Docker) ContainerList(ctx context.Context, options types.ContainerList func (_m *Docker) ContainerLogs(ctx context.Context, _a1 string, options types.ContainerLogsOptions) (io.ReadCloser, error) { ret := _m.Called(ctx, _a1, options) + if len(ret) == 0 { + panic("no return value specified for ContainerLogs") + } + var r0 io.ReadCloser var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ContainerLogsOptions) (io.ReadCloser, error)); ok { @@ -268,6 +312,10 @@ func (_m *Docker) ContainerLogs(ctx context.Context, _a1 string, options types.C func (_m *Docker) ContainerRemove(ctx context.Context, containerID string, options types.ContainerRemoveOptions) error { ret := _m.Called(ctx, containerID, options) + if len(ret) == 0 { + panic("no return value specified for ContainerRemove") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ContainerRemoveOptions) error); ok { r0 = rf(ctx, containerID, options) @@ -282,6 +330,10 @@ func (_m *Docker) ContainerRemove(ctx context.Context, containerID string, optio func (_m *Docker) ContainerStart(_a0 context.Context, _a1 string, _a2 types.ContainerStartOptions) error { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for ContainerStart") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ContainerStartOptions) error); ok { r0 = rf(_a0, _a1, _a2) @@ -296,6 +348,10 @@ func (_m *Docker) ContainerStart(_a0 context.Context, _a1 string, _a2 types.Cont func (_m *Docker) ContainerStop(ctx context.Context, containerID string, options typescontainer.StopOptions) error { ret := _m.Called(ctx, containerID, options) + if len(ret) == 0 { + panic("no return value specified for ContainerStop") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, typescontainer.StopOptions) error); ok { r0 = rf(ctx, containerID, options) @@ -310,6 +366,10 @@ func (_m *Docker) ContainerStop(ctx context.Context, containerID string, options func (_m *Docker) CopyFromContainer(ctx context.Context, containerID string, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) { ret := _m.Called(ctx, containerID, srcPath) + if len(ret) == 0 { + panic("no return value specified for CopyFromContainer") + } + var r0 io.ReadCloser var r1 types.ContainerPathStat var r2 error @@ -343,6 +403,10 @@ func (_m *Docker) CopyFromContainer(ctx context.Context, containerID string, src func (_m *Docker) CopyToContainer(ctx context.Context, _a1 string, path string, content io.Reader, options types.CopyToContainerOptions) error { ret := _m.Called(ctx, _a1, path, content, options) + if len(ret) == 0 { + panic("no return value specified for CopyToContainer") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string, io.Reader, types.CopyToContainerOptions) error); ok { r0 = rf(ctx, _a1, path, content, options) @@ -357,6 +421,10 @@ func (_m *Docker) CopyToContainer(ctx context.Context, _a1 string, path string, func (_m *Docker) ImageBuild(ctx context.Context, buildContext io.Reader, options types.ImageBuildOptions) (types.ImageBuildResponse, error) { ret := _m.Called(ctx, buildContext, options) + if len(ret) == 0 { + panic("no return value specified for ImageBuild") + } + var r0 types.ImageBuildResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, io.Reader, types.ImageBuildOptions) (types.ImageBuildResponse, error)); ok { @@ -381,6 +449,10 @@ func (_m *Docker) ImageBuild(ctx context.Context, buildContext io.Reader, option func (_m *Docker) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) { ret := _m.Called(ctx, options) + if len(ret) == 0 { + panic("no return value specified for ImageList") + } + var r0 []types.ImageSummary var r1 error if rf, ok := ret.Get(0).(func(context.Context, types.ImageListOptions) ([]types.ImageSummary, error)); ok { @@ -407,6 +479,10 @@ func (_m *Docker) ImageList(ctx context.Context, options types.ImageListOptions) func (_m *Docker) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) { ret := _m.Called(ctx, refStr, options) + if len(ret) == 0 { + panic("no return value specified for ImagePull") + } + var r0 io.ReadCloser var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ImagePullOptions) (io.ReadCloser, error)); ok { @@ -433,6 +509,10 @@ func (_m *Docker) ImagePull(ctx context.Context, refStr string, options types.Im func (_m *Docker) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) { ret := _m.Called(ctx, image, options) + if len(ret) == 0 { + panic("no return value specified for ImagePush") + } + var r0 io.ReadCloser var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ImagePushOptions) (io.ReadCloser, error)); ok { @@ -459,6 +539,10 @@ func (_m *Docker) ImagePush(ctx context.Context, image string, options types.Ima func (_m *Docker) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) { ret := _m.Called(ctx, imageID, options) + if len(ret) == 0 { + panic("no return value specified for ImageRemove") + } + var r0 []types.ImageDeleteResponseItem var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)); ok { @@ -485,6 +569,10 @@ func (_m *Docker) ImageRemove(ctx context.Context, imageID string, options types func (_m *Docker) ImageSave(ctx context.Context, imageIDs []string) (io.ReadCloser, error) { ret := _m.Called(ctx, imageIDs) + if len(ret) == 0 { + panic("no return value specified for ImageSave") + } + var r0 io.ReadCloser var r1 error if rf, ok := ret.Get(0).(func(context.Context, []string) (io.ReadCloser, error)); ok { @@ -511,6 +599,10 @@ func (_m *Docker) ImageSave(ctx context.Context, imageIDs []string) (io.ReadClos func (_m *Docker) ImageTag(ctx context.Context, source string, target string) error { ret := _m.Called(ctx, source, target) + if len(ret) == 0 { + panic("no return value specified for ImageTag") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { r0 = rf(ctx, source, target) @@ -525,6 +617,10 @@ func (_m *Docker) ImageTag(ctx context.Context, source string, target string) er func (_m *Docker) Info(ctx context.Context) (types.Info, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Info") + } + var r0 types.Info var r1 error if rf, ok := ret.Get(0).(func(context.Context) (types.Info, error)); ok { @@ -549,6 +645,10 @@ func (_m *Docker) Info(ctx context.Context) (types.Info, error) { func (_m *Docker) NetworkConnect(ctx context.Context, networkID string, containerID string, config *network.EndpointSettings) error { ret := _m.Called(ctx, networkID, containerID, config) + if len(ret) == 0 { + panic("no return value specified for NetworkConnect") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string, *network.EndpointSettings) error); ok { r0 = rf(ctx, networkID, containerID, config) @@ -563,6 +663,10 @@ func (_m *Docker) NetworkConnect(ctx context.Context, networkID string, containe func (_m *Docker) NetworkCreate(ctx context.Context, name string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { ret := _m.Called(ctx, name, options) + if len(ret) == 0 { + panic("no return value specified for NetworkCreate") + } + var r0 types.NetworkCreateResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.NetworkCreate) (types.NetworkCreateResponse, error)); ok { @@ -587,6 +691,10 @@ func (_m *Docker) NetworkCreate(ctx context.Context, name string, options types. func (_m *Docker) NetworkDisconnect(ctx context.Context, networkID string, containerID string, force bool) error { ret := _m.Called(ctx, networkID, containerID, force) + if len(ret) == 0 { + panic("no return value specified for NetworkDisconnect") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) error); ok { r0 = rf(ctx, networkID, containerID, force) @@ -601,6 +709,10 @@ func (_m *Docker) NetworkDisconnect(ctx context.Context, networkID string, conta func (_m *Docker) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { ret := _m.Called(ctx, networkID, options) + if len(ret) == 0 { + panic("no return value specified for NetworkInspect") + } + var r0 types.NetworkResource var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, types.NetworkInspectOptions) (types.NetworkResource, error)); ok { @@ -625,6 +737,10 @@ func (_m *Docker) NetworkInspect(ctx context.Context, networkID string, options func (_m *Docker) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { ret := _m.Called(ctx, options) + if len(ret) == 0 { + panic("no return value specified for NetworkList") + } + var r0 []types.NetworkResource var r1 error if rf, ok := ret.Get(0).(func(context.Context, types.NetworkListOptions) ([]types.NetworkResource, error)); ok { @@ -651,6 +767,10 @@ func (_m *Docker) NetworkList(ctx context.Context, options types.NetworkListOpti func (_m *Docker) NetworkRemove(ctx context.Context, networkID string) error { ret := _m.Called(ctx, networkID) + if len(ret) == 0 { + panic("no return value specified for NetworkRemove") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { r0 = rf(ctx, networkID) @@ -665,6 +785,10 @@ func (_m *Docker) NetworkRemove(ctx context.Context, networkID string) error { func (_m *Docker) ServerVersion(ctx context.Context) (types.Version, error) { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for ServerVersion") + } + var r0 types.Version var r1 error if rf, ok := ret.Get(0).(func(context.Context) (types.Version, error)); ok { @@ -689,6 +813,10 @@ func (_m *Docker) ServerVersion(ctx context.Context) (types.Version, error) { func (_m *Docker) VolumeCreate(ctx context.Context, options volume.CreateOptions) (volume.Volume, error) { ret := _m.Called(ctx, options) + if len(ret) == 0 { + panic("no return value specified for VolumeCreate") + } + var r0 volume.Volume var r1 error if rf, ok := ret.Get(0).(func(context.Context, volume.CreateOptions) (volume.Volume, error)); ok { @@ -713,6 +841,10 @@ func (_m *Docker) VolumeCreate(ctx context.Context, options volume.CreateOptions func (_m *Docker) VolumeList(ctx context.Context, opts volume.ListOptions) (volume.ListResponse, error) { ret := _m.Called(ctx, opts) + if len(ret) == 0 { + panic("no return value specified for VolumeList") + } + var r0 volume.ListResponse var r1 error if rf, ok := ret.Get(0).(func(context.Context, volume.ListOptions) (volume.ListResponse, error)); ok { @@ -737,6 +869,10 @@ func (_m *Docker) VolumeList(ctx context.Context, opts volume.ListOptions) (volu func (_m *Docker) VolumeRemove(ctx context.Context, volumeID string, force bool) error { ret := _m.Called(ctx, volumeID, force) + if len(ret) == 0 { + panic("no return value specified for VolumeRemove") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, string, bool) error); ok { r0 = rf(ctx, volumeID, force) @@ -747,13 +883,12 @@ func (_m *Docker) VolumeRemove(ctx context.Context, volumeID string, force bool) return r0 } -type mockConstructorTestingTNewDocker interface { +// NewDocker creates a new instance of Docker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewDocker(t interface { mock.TestingT Cleanup(func()) -} - -// NewDocker creates a new instance of Docker. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewDocker(t mockConstructorTestingTNewDocker) *Docker { +}) *Docker { mock := &Docker{} mock.Mock.Test(t) diff --git a/pkg/clients/getter/mocks/getter.go b/pkg/clients/getter/mocks/getter.go index 746c3307..c188f4f7 100644 --- a/pkg/clients/getter/mocks/getter.go +++ b/pkg/clients/getter/mocks/getter.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks diff --git a/pkg/clients/http/mocks/http.go b/pkg/clients/http/mocks/http.go index 3f742693..a3bafca1 100644 --- a/pkg/clients/http/mocks/http.go +++ b/pkg/clients/http/mocks/http.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -18,6 +18,10 @@ type HTTP struct { func (_m *HTTP) Do(r *http.Request) (*http.Response, error) { ret := _m.Called(r) + if len(ret) == 0 { + panic("no return value specified for Do") + } + var r0 *http.Response var r1 error if rf, ok := ret.Get(0).(func(*http.Request) (*http.Response, error)); ok { @@ -44,6 +48,10 @@ func (_m *HTTP) Do(r *http.Request) (*http.Response, error) { func (_m *HTTP) HealthCheckHTTP(uri string, method string, headers map[string][]string, body string, codes []int, timeout time.Duration) error { ret := _m.Called(uri, method, headers, body, codes, timeout) + if len(ret) == 0 { + panic("no return value specified for HealthCheckHTTP") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string, map[string][]string, string, []int, time.Duration) error); ok { r0 = rf(uri, method, headers, body, codes, timeout) @@ -58,6 +66,10 @@ func (_m *HTTP) HealthCheckHTTP(uri string, method string, headers map[string][] func (_m *HTTP) HealthCheckTCP(uri string, timeout time.Duration) error { ret := _m.Called(uri, timeout) + if len(ret) == 0 { + panic("no return value specified for HealthCheckTCP") + } + var r0 error if rf, ok := ret.Get(0).(func(string, time.Duration) error); ok { r0 = rf(uri, timeout) @@ -68,13 +80,12 @@ func (_m *HTTP) HealthCheckTCP(uri string, timeout time.Duration) error { return r0 } -type mockConstructorTestingTNewHTTP interface { +// NewHTTP creates a new instance of HTTP. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewHTTP(t interface { mock.TestingT Cleanup(func()) -} - -// NewHTTP creates a new instance of HTTP. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewHTTP(t mockConstructorTestingTNewHTTP) *HTTP { +}) *HTTP { mock := &HTTP{} mock.Mock.Test(t) diff --git a/pkg/clients/images/mocks/imagelog.go b/pkg/clients/images/mocks/imagelog.go index 6ccc16b2..e0b53405 100644 --- a/pkg/clients/images/mocks/imagelog.go +++ b/pkg/clients/images/mocks/imagelog.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -13,6 +13,10 @@ type ImageLog struct { func (_m *ImageLog) Clear() error { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Clear") + } + var r0 error if rf, ok := ret.Get(0).(func() error); ok { r0 = rf() @@ -27,6 +31,10 @@ func (_m *ImageLog) Clear() error { func (_m *ImageLog) Log(_a0 string, _a1 string) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for Log") + } + var r0 error if rf, ok := ret.Get(0).(func(string, string) error); ok { r0 = rf(_a0, _a1) @@ -41,6 +49,10 @@ func (_m *ImageLog) Log(_a0 string, _a1 string) error { func (_m *ImageLog) Read(_a0 string) ([]string, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for Read") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func(string) ([]string, error)); ok { @@ -63,13 +75,12 @@ func (_m *ImageLog) Read(_a0 string) ([]string, error) { return r0, r1 } -type mockConstructorTestingTNewImageLog interface { +// NewImageLog creates a new instance of ImageLog. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewImageLog(t interface { mock.TestingT Cleanup(func()) -} - -// NewImageLog creates a new instance of ImageLog. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewImageLog(t mockConstructorTestingTNewImageLog) *ImageLog { +}) *ImageLog { mock := &ImageLog{} mock.Mock.Test(t) diff --git a/pkg/clients/nomad/mocks/nomad.go b/pkg/clients/nomad/mocks/nomad.go index eae77dc5..4c5d1aa2 100644 --- a/pkg/clients/nomad/mocks/nomad.go +++ b/pkg/clients/nomad/mocks/nomad.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -19,6 +19,10 @@ type Nomad struct { func (_m *Nomad) Create(files []string) error { ret := _m.Called(files) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 error if rf, ok := ret.Get(0).(func([]string) error); ok { r0 = rf(files) @@ -33,6 +37,10 @@ func (_m *Nomad) Create(files []string) error { func (_m *Nomad) Endpoints(job string, group string, task string) ([]map[string]string, error) { ret := _m.Called(job, group, task) + if len(ret) == 0 { + panic("no return value specified for Endpoints") + } + var r0 []map[string]string var r1 error if rf, ok := ret.Get(0).(func(string, string, string) ([]map[string]string, error)); ok { @@ -59,6 +67,10 @@ func (_m *Nomad) Endpoints(job string, group string, task string) ([]map[string] func (_m *Nomad) HealthCheckAPI(_a0 context.Context, _a1 time.Duration) error { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for HealthCheckAPI") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, time.Duration) error); ok { r0 = rf(_a0, _a1) @@ -73,6 +85,10 @@ func (_m *Nomad) HealthCheckAPI(_a0 context.Context, _a1 time.Duration) error { func (_m *Nomad) JobRunning(job string) (bool, error) { ret := _m.Called(job) + if len(ret) == 0 { + panic("no return value specified for JobRunning") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func(string) (bool, error)); ok { @@ -97,6 +113,10 @@ func (_m *Nomad) JobRunning(job string) (bool, error) { func (_m *Nomad) ParseJob(file string) ([]byte, error) { ret := _m.Called(file) + if len(ret) == 0 { + panic("no return value specified for ParseJob") + } + var r0 []byte var r1 error if rf, ok := ret.Get(0).(func(string) ([]byte, error)); ok { @@ -123,6 +143,10 @@ func (_m *Nomad) ParseJob(file string) ([]byte, error) { func (_m *Nomad) SetConfig(address string, port int, nodes int) error { ret := _m.Called(address, port, nodes) + if len(ret) == 0 { + panic("no return value specified for SetConfig") + } + var r0 error if rf, ok := ret.Get(0).(func(string, int, int) error); ok { r0 = rf(address, port, nodes) @@ -137,6 +161,10 @@ func (_m *Nomad) SetConfig(address string, port int, nodes int) error { func (_m *Nomad) Stop(files []string) error { ret := _m.Called(files) + if len(ret) == 0 { + panic("no return value specified for Stop") + } + var r0 error if rf, ok := ret.Get(0).(func([]string) error); ok { r0 = rf(files) @@ -147,13 +175,12 @@ func (_m *Nomad) Stop(files []string) error { return r0 } -type mockConstructorTestingTNewNomad interface { +// NewNomad creates a new instance of Nomad. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewNomad(t interface { mock.TestingT Cleanup(func()) -} - -// NewNomad creates a new instance of Nomad. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewNomad(t mockConstructorTestingTNewNomad) *Nomad { +}) *Nomad { mock := &Nomad{} mock.Mock.Test(t) diff --git a/pkg/clients/system/mocks/system.go b/pkg/clients/system/mocks/system.go index d8960450..b104bad1 100644 --- a/pkg/clients/system/mocks/system.go +++ b/pkg/clients/system/mocks/system.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.42.3. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks diff --git a/pkg/config/mocks/provider.go b/pkg/config/mocks/provider.go index 5e225ab4..31b44ace 100644 --- a/pkg/config/mocks/provider.go +++ b/pkg/config/mocks/provider.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -20,6 +20,10 @@ type Provider struct { func (_m *Provider) Changed() (bool, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Changed") + } + var r0 bool var r1 error if rf, ok := ret.Get(0).(func() (bool, error)); ok { @@ -44,6 +48,10 @@ func (_m *Provider) Changed() (bool, error) { func (_m *Provider) Create(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Create") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -58,6 +66,10 @@ func (_m *Provider) Create(ctx context.Context) error { func (_m *Provider) Destroy(ctx context.Context, force bool) error { ret := _m.Called(ctx, force) + if len(ret) == 0 { + panic("no return value specified for Destroy") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, bool) error); ok { r0 = rf(ctx, force) @@ -72,6 +84,10 @@ func (_m *Provider) Destroy(ctx context.Context, force bool) error { func (_m *Provider) Init(cfg types.Resource, log sdk.Logger) error { ret := _m.Called(cfg, log) + if len(ret) == 0 { + panic("no return value specified for Init") + } + var r0 error if rf, ok := ret.Get(0).(func(types.Resource, sdk.Logger) error); ok { r0 = rf(cfg, log) @@ -86,6 +102,10 @@ func (_m *Provider) Init(cfg types.Resource, log sdk.Logger) error { func (_m *Provider) Lookup() ([]string, error) { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Lookup") + } + var r0 []string var r1 error if rf, ok := ret.Get(0).(func() ([]string, error)); ok { @@ -112,6 +132,10 @@ func (_m *Provider) Lookup() ([]string, error) { func (_m *Provider) Refresh(ctx context.Context) error { ret := _m.Called(ctx) + if len(ret) == 0 { + panic("no return value specified for Refresh") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context) error); ok { r0 = rf(ctx) @@ -122,13 +146,12 @@ func (_m *Provider) Refresh(ctx context.Context) error { return r0 } -type mockConstructorTestingTNewProvider interface { +// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewProvider(t interface { mock.TestingT Cleanup(func()) -} - -// NewProvider creates a new instance of Provider. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewProvider(t mockConstructorTestingTNewProvider) *Provider { +}) *Provider { mock := &Provider{} mock.Mock.Test(t) diff --git a/pkg/jumppad/constants/consts.go b/pkg/jumppad/constants/consts.go index b0c6f19b..24ef783f 100644 --- a/pkg/jumppad/constants/consts.go +++ b/pkg/jumppad/constants/consts.go @@ -18,3 +18,28 @@ const ( // resources have been created StatusDisabled = "disabled" ) + +type LifecycleEvent string + +const ( + // LifecycleEventParsed is sent once the resource has been successfully parsed + LifecycleEventParsed LifecycleEvent = "parsed" + + // LifecycleEventCreating is sent once the resource is about to be created + LifecycleEventCreating LifecycleEvent = "creating" + + // LifecycleEventCreated is sent once the resource has been successfully created + LifecycleEventCreated LifecycleEvent = "created" + + // LifecycleEventCreatedFailed is sent once the resource has failed to create + LifecycleEventCreatedFailed LifecycleEvent = "create_failed" + + // LifecycleEventDestroying is sent once the resource is about to be destroyed + LifecycleEventDestroying LifecycleEvent = "destroying" + + // LifecycleEventDestroyed is sent once the resource has been destroyed + LifecycleEventDestroyed LifecycleEvent = "destroyed" + + // LifecycleEventDestroyFailed is sent once the resource has failed to create + LifecycleEventDestroyFailed LifecycleEvent = "destroy_failed" +) diff --git a/pkg/jumppad/engine.go b/pkg/jumppad/engine.go index 9bd676e5..3b61e9e7 100644 --- a/pkg/jumppad/engine.go +++ b/pkg/jumppad/engine.go @@ -5,6 +5,7 @@ import ( // "fmt" "context" + "errors" "fmt" "log" "os" @@ -39,6 +40,12 @@ type Engine interface { Destroy(ctx context.Context, force bool) error Config() *hclconfig.Config Diff(path string, variables map[string]string, variablesFile string) (new []types.Resource, changed []types.Resource, removed []types.Resource, cfg *hclconfig.Config, err error) + Events() (<-chan Event, error) +} + +type Event struct { + Resource types.Resource + Status constants.LifecycleEvent } // EngineImpl is responsible for creating and destroying resources @@ -48,6 +55,7 @@ type EngineImpl struct { config *hclconfig.Config ctx context.Context force bool + events chan Event } // New creates a new Jumppad engine @@ -98,6 +106,10 @@ func (e *EngineImpl) ParseConfigWithVariables(path string, vars map[string]strin err = e.readAndProcessConfig(path, vars, variablesFile, func(r types.Resource) error { e.config.AppendResource(r) + e.emitLifecycleEvent(Event{ + Resource: r, + Status: constants.LifecycleEventParsed, + }) return nil }) @@ -360,6 +372,15 @@ func (e *EngineImpl) ResourceCountForType(t string) int { return len(r) } +// Events returns the events channels to broadcast resource lifecycle events +func (e *EngineImpl) Events() (<-chan Event, error) { + if e.events != nil { + return nil, errors.New("events channel already created") + } + e.events = make(chan Event) + return e.events, nil +} + func (e *EngineImpl) readAndProcessConfig(path string, variables map[string]string, variablesFile string, callback hclconfig.WalkCallback) error { var parseError error var parsedConfig *hclconfig.Config @@ -468,14 +489,28 @@ func (e *EngineImpl) appendDisabledResources(c *hclconfig.Config) error { } func (e *EngineImpl) createCallback(r types.Resource) error { + e.emitLifecycleEvent(Event{ + Resource: r, + Status: constants.LifecycleEventCreating, + }) + lifecycleStatus := constants.LifecycleEventCreated + defer func() { + e.emitLifecycleEvent(Event{ + Resource: r, + Status: lifecycleStatus, + }) + }() + // if the context is cancelled skip if e.ctx.Err() != nil { + lifecycleStatus = constants.LifecycleEventCreatedFailed return nil } p := e.providers.GetProvider(r) if p == nil { r.Metadata().Properties[constants.PropertyStatus] = constants.StatusFailed + lifecycleStatus = constants.LifecycleEventCreatedFailed return fmt.Errorf("unable to create provider for resource Name: %s, Type: %s", r.Metadata().Name, r.Metadata().Type) } @@ -489,6 +524,7 @@ func (e *EngineImpl) createCallback(r types.Resource) error { // remove the resource, we will add the new version to the state err = e.config.RemoveResource(r) if err != nil { + lifecycleStatus = constants.LifecycleEventCreatedFailed return fmt.Errorf(`unable to remove resource "%s" from state, %s`, r.Metadata().ID, err) } } @@ -498,6 +534,7 @@ func (e *EngineImpl) createCallback(r types.Resource) error { case constants.StatusCreated: providerError = p.Refresh(e.ctx) if providerError != nil { + lifecycleStatus = constants.LifecycleEventCreatedFailed r.Metadata().Properties[constants.PropertyStatus] = constants.StatusFailed } @@ -511,15 +548,18 @@ func (e *EngineImpl) createCallback(r types.Resource) error { case constants.StatusFailed: providerError = p.Destroy(e.ctx, false) if providerError != nil { + lifecycleStatus = constants.LifecycleEventCreatedFailed r.Metadata().Properties[constants.PropertyStatus] = constants.StatusFailed } fallthrough // failed resources should always attempt recreation default: + lifecycleStatus = constants.LifecycleEventCreated r.Metadata().Properties[constants.PropertyStatus] = constants.StatusCreated providerError = p.Create(e.ctx) if providerError != nil { + lifecycleStatus = constants.LifecycleEventCreatedFailed r.Metadata().Properties[constants.PropertyStatus] = constants.StatusFailed } } @@ -527,6 +567,7 @@ func (e *EngineImpl) createCallback(r types.Resource) error { // add the resource to the state err = e.config.AppendResource(r) if err != nil { + lifecycleStatus = constants.LifecycleEventCreatedFailed return fmt.Errorf(`unable add resource "%s" to state, %s`, r.Metadata().ID, err) } @@ -593,6 +634,18 @@ func (e *EngineImpl) createCallback(r types.Resource) error { } func (e *EngineImpl) destroyCallback(r types.Resource) error { + e.emitLifecycleEvent(Event{ + Resource: r, + Status: constants.LifecycleEventDestroying, + }) + lifecycleStatus := constants.LifecycleEventDestroyed + defer func() { + e.emitLifecycleEvent(Event{ + Resource: r, + Status: lifecycleStatus, + }) + }() + // if the context is cancelled skip if e.ctx.Err() != nil { return nil @@ -611,12 +664,14 @@ func (e *EngineImpl) destroyCallback(r types.Resource) error { p := e.providers.GetProvider(r) if p == nil { + lifecycleStatus = constants.LifecycleEventDestroyFailed r.Metadata().Properties[constants.PropertyStatus] = constants.StatusFailed return fmt.Errorf("unable to create provider for resource Name: %s, Type: %s", r.Metadata().Name, r.Metadata().Type) } err := p.Destroy(e.ctx, e.force) if err != nil && !e.force { + lifecycleStatus = constants.LifecycleEventDestroyFailed r.Metadata().Properties[constants.PropertyStatus] = constants.StatusFailed return fmt.Errorf("unable to destroy resource Name: %s, Type: %s, Error: %s", r.Metadata().Name, r.Metadata().Type, err) } @@ -627,6 +682,12 @@ func (e *EngineImpl) destroyCallback(r types.Resource) error { return nil } +func (e *EngineImpl) emitLifecycleEvent(event Event) { + if e.events != nil { + e.events <- event + } +} + // checks if a string exists in an array if not it appends and returns a new // copy func appendIfNotContains(existing []string, s string) []string { diff --git a/pkg/jumppad/engine_test.go b/pkg/jumppad/engine_test.go index 56560006..1ee9ee1e 100644 --- a/pkg/jumppad/engine_test.go +++ b/pkg/jumppad/engine_test.go @@ -99,6 +99,61 @@ func TestApplyWithSingleFile(t *testing.T) { ) } +func TestApplyWithSingleFileWithEvents(t *testing.T) { + e, mp := setupTests(t, nil) + + events, err := e.Events() + require.NoError(t, err) + + parsedEventCount := 0 + creatingEventCount := 0 + createdEventCount := 0 + + go func() { + for event := range events { + require.Contains(t, []constants.LifecycleEvent{constants.LifecycleEventParsed, constants.LifecycleEventCreating, constants.LifecycleEventCreated}, event.Status) + switch event.Status { + case constants.LifecycleEventParsed: + parsedEventCount += 1 + case constants.LifecycleEventCreating: + creatingEventCount += 1 + case constants.LifecycleEventCreated: + createdEventCount += 1 + } + } + }() + + _, err = e.Apply(context.Background(), "../../examples/single_file/container.hcl") + require.NoError(t, err) + + require.Len(t, e.config.Resources, 7) // 6 resources in the file plus the image cache + + // Check the provider was called for each resource + require.ElementsMatch(t, + []string{ + "default", + "onprem", + "default", + "consul_config", + "port_range", + "version", + }, + []string{ + getMetaFromMock(mp, 0).Name, + getMetaFromMock(mp, 1).Name, + getMetaFromMock(mp, 2).Name, + getMetaFromMock(mp, 3).Name, + getMetaFromMock(mp, 4).Name, + getMetaFromMock(mp, 5).Name, + }, + ) + + require.Equal(t, 6, parsedEventCount) + require.Equal(t, 6, createdEventCount) + require.Equal(t, 6, creatingEventCount) + require.Empty(t, events) +} + func TestApplyAddsImageCache(t *testing.T) { e, _ := setupTests(t, nil) @@ -389,6 +444,41 @@ func TestDestroyCallsProviderDestroyForEachProvider(t *testing.T) { require.NoFileExists(t, utils.StatePath()) } +func TestDestroyCallsProviderDestroyForEachProviderWithEvents(t *testing.T) { + e, mp := setupTestsWithState(t, nil, existingState) + + events, err := e.Events() + require.NoError(t, err) + + destroyingEventCount := 0 + destroyedEventCount := 0 + + go func() { + for event := range events { + require.Contains(t, []constants.LifecycleEvent{constants.LifecycleEventDestroying, constants.LifecycleEventDestroyed}, event.Status) + switch event.Status { + case constants.LifecycleEventDestroying: + destroyingEventCount += 1 + case constants.LifecycleEventDestroyed: + destroyedEventCount += 1 + } + } + }() + + err = e.Destroy(context.Background(), false) + require.NoError(t, err) + + // should have call create for each provider + // and once for the image cache + testAssertMethodCalled(t, mp, "Destroy", 4) + + // state should be removed + require.NoFileExists(t, utils.StatePath()) + require.Equal(t, 4, destroyingEventCount) + require.Equal(t, 4, destroyingEventCount) + require.Empty(t, events) +} + func TestDestroyNotCallsProviderDestroyForResourcesDisabled(t *testing.T) { e, mp := setupTestsWithState(t, nil, disabledState) @@ -426,6 +516,42 @@ func TestDestroyFailSetsStatus(t *testing.T) { require.Equal(t, constants.StatusFailed, r.Metadata().Properties[constants.PropertyStatus]) } +func TestDestroyFailSetsStatusWithEvents(t *testing.T) { + e, _ := setupTestsWithState(t, map[string]error{"mycontainer": fmt.Errorf("boom")}, complexState) + + events, err := e.Events() + require.NoError(t, err) + + destroyingEventCount := 0 + destroyedEventCount := 0 + destroyFailedEventCount := 0 + + go func() { + for event := range events { + require.Contains(t, []constants.LifecycleEvent{constants.LifecycleEventDestroying, constants.LifecycleEventDestroyed, constants.LifecycleEventDestroyFailed}, event.Status) + switch event.Status { + case constants.LifecycleEventDestroying: + destroyingEventCount += 1 + case constants.LifecycleEventDestroyed: + destroyedEventCount += 1 + case constants.LifecycleEventDestroyFailed: + destroyFailedEventCount += 1 + } + } + }() + + err = e.Destroy(context.Background(), false) + require.Error(t, err) + + r, _ := e.config.FindResource("resource.container.mycontainer") + require.Equal(t, constants.StatusFailed, r.Metadata().Properties[constants.PropertyStatus]) + + require.Equal(t, 2, destroyingEventCount) + require.Equal(t, 1, destroyedEventCount) + require.Equal(t, 1, destroyFailedEventCount) + require.Empty(t, events) +} + func TestParseConfig(t *testing.T) { e, mp := setupTests(t, nil) @@ -435,10 +561,38 @@ func TestParseConfig(t *testing.T) { require.Len(t, r.Resources, 6) // should not have created any providers + testAssertMethodCalled(t, mp, "Events", 0) testAssertMethodCalled(t, mp, "Create", 0) testAssertMethodCalled(t, mp, "Destroy", 0) } +func TestParseConfigWithEvents(t *testing.T) { + e, mp := setupTests(t, nil) + + events, err := e.Events() + require.NoError(t, err) + + eventCount := 0 + go func() { + for event := range events { + eventCount += 1 + require.Equal(t, constants.LifecycleEventParsed, event.Status) + } + }() + + r, err := e.ParseConfig("../../examples/single_file/container.hcl") + require.NoError(t, err) + + require.Len(t, r.Resources, 6) + + // should not have created any providers + testAssertMethodCalled(t, mp, "Create", 0) + testAssertMethodCalled(t, mp, "Destroy", 0) + + require.Equal(t, 6, eventCount) + require.Empty(t, events) +} + func TestParseWithVariables(t *testing.T) { e, mp := setupTests(t, nil) @@ -476,6 +630,16 @@ func TestParseWithEnvironmentVariables(t *testing.T) { require.Equal(t, "consul:1.8.1", c.(*container.Container).Image.Name) } +func TestMultipleEventsCallsFail(t *testing.T) { + e, _ := setupTests(t, nil) + + _, err := e.Events() + require.NoError(t, err) + + _, err = e.Events() + require.Error(t, err) +} + func testAssertMethodCalled(t *testing.T, p *mocks.Providers, method string, n int, resource ...types.Resource) { if len(resource) > 1 { panic("testAssertMethodCalled only expects 0 or 1 resources") diff --git a/pkg/jumppad/mocks/engine.go b/pkg/jumppad/mocks/engine.go index 607bc5ef..148c3f93 100644 --- a/pkg/jumppad/mocks/engine.go +++ b/pkg/jumppad/mocks/engine.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.20.0. DO NOT EDIT. +// Code generated by mockery v2.46.0. DO NOT EDIT. package mocks @@ -6,6 +6,7 @@ import ( context "context" hclconfig "github.com/jumppad-labs/hclconfig" + jumppad "github.com/jumppad-labs/jumppad/pkg/jumppad" mock "github.com/stretchr/testify/mock" @@ -21,6 +22,10 @@ type Engine struct { func (_m *Engine) Apply(_a0 context.Context, _a1 string) (*hclconfig.Config, error) { ret := _m.Called(_a0, _a1) + if len(ret) == 0 { + panic("no return value specified for Apply") + } + var r0 *hclconfig.Config var r1 error if rf, ok := ret.Get(0).(func(context.Context, string) (*hclconfig.Config, error)); ok { @@ -47,6 +52,10 @@ func (_m *Engine) Apply(_a0 context.Context, _a1 string) (*hclconfig.Config, err func (_m *Engine) ApplyWithVariables(ctx context.Context, path string, variables map[string]string, variablesFile string) (*hclconfig.Config, error) { ret := _m.Called(ctx, path, variables, variablesFile) + if len(ret) == 0 { + panic("no return value specified for ApplyWithVariables") + } + var r0 *hclconfig.Config var r1 error if rf, ok := ret.Get(0).(func(context.Context, string, map[string]string, string) (*hclconfig.Config, error)); ok { @@ -73,6 +82,10 @@ func (_m *Engine) ApplyWithVariables(ctx context.Context, path string, variables func (_m *Engine) Config() *hclconfig.Config { ret := _m.Called() + if len(ret) == 0 { + panic("no return value specified for Config") + } + var r0 *hclconfig.Config if rf, ok := ret.Get(0).(func() *hclconfig.Config); ok { r0 = rf() @@ -89,6 +102,10 @@ func (_m *Engine) Config() *hclconfig.Config { func (_m *Engine) Destroy(ctx context.Context, force bool) error { ret := _m.Called(ctx, force) + if len(ret) == 0 { + panic("no return value specified for Destroy") + } + var r0 error if rf, ok := ret.Get(0).(func(context.Context, bool) error); ok { r0 = rf(ctx, force) @@ -103,6 +120,10 @@ func (_m *Engine) Destroy(ctx context.Context, force bool) error { func (_m *Engine) Diff(path string, variables map[string]string, variablesFile string) ([]types.Resource, []types.Resource, []types.Resource, *hclconfig.Config, error) { ret := _m.Called(path, variables, variablesFile) + if len(ret) == 0 { + panic("no return value specified for Diff") + } + var r0 []types.Resource var r1 []types.Resource var r2 []types.Resource @@ -152,10 +173,44 @@ func (_m *Engine) Diff(path string, variables map[string]string, variablesFile s return r0, r1, r2, r3, r4 } +// Events provides a mock function with given fields: +func (_m *Engine) Events() (<-chan jumppad.Event, error) { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for Events") + } + + var r0 <-chan jumppad.Event + var r1 error + if rf, ok := ret.Get(0).(func() (<-chan jumppad.Event, error)); ok { + return rf() + } + if rf, ok := ret.Get(0).(func() <-chan jumppad.Event); ok { + r0 = rf() + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(<-chan jumppad.Event) + } + } + + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + // ParseConfig provides a mock function with given fields: _a0 func (_m *Engine) ParseConfig(_a0 string) (*hclconfig.Config, error) { ret := _m.Called(_a0) + if len(ret) == 0 { + panic("no return value specified for ParseConfig") + } + var r0 *hclconfig.Config var r1 error if rf, ok := ret.Get(0).(func(string) (*hclconfig.Config, error)); ok { @@ -182,6 +237,10 @@ func (_m *Engine) ParseConfig(_a0 string) (*hclconfig.Config, error) { func (_m *Engine) ParseConfigWithVariables(_a0 string, _a1 map[string]string, _a2 string) (*hclconfig.Config, error) { ret := _m.Called(_a0, _a1, _a2) + if len(ret) == 0 { + panic("no return value specified for ParseConfigWithVariables") + } + var r0 *hclconfig.Config var r1 error if rf, ok := ret.Get(0).(func(string, map[string]string, string) (*hclconfig.Config, error)); ok { @@ -204,13 +263,12 @@ func (_m *Engine) ParseConfigWithVariables(_a0 string, _a1 map[string]string, _a return r0, r1 } -type mockConstructorTestingTNewEngine interface { +// NewEngine creates a new instance of Engine. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewEngine(t interface { mock.TestingT Cleanup(func()) -} - -// NewEngine creates a new instance of Engine. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewEngine(t mockConstructorTestingTNewEngine) *Engine { +}) *Engine { mock := &Engine{} mock.Mock.Test(t)