d78cbe96a1
This also moves KRM related logic from executors package to container package, and creates ClientV1Alpha1 interface that would allow us to have versioned clients for generic container executor. Change-Id: I4b32fd8dd089b9ccea2ed64a805702e6a8705706
70 lines
2.2 KiB
Go
Executable File
70 lines
2.2 KiB
Go
Executable File
/*
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package container
|
|
|
|
import (
|
|
"io"
|
|
|
|
"opendev.org/airship/airshipctl/pkg/container"
|
|
)
|
|
|
|
// MockContainer implements Container for unit test purposes
|
|
type MockContainer struct {
|
|
MockImagePull func() error
|
|
MockRunCommand func() error
|
|
MockGetContainerLogs func() (io.ReadCloser, error)
|
|
MockRmContainer func() error
|
|
MockGetID func() string
|
|
MockWaitUntilFinished func() error
|
|
MockInspectContainer func() (container.State, error)
|
|
}
|
|
|
|
var _ container.Container = &MockContainer{}
|
|
|
|
// ImagePull Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) ImagePull() error {
|
|
return mc.MockImagePull()
|
|
}
|
|
|
|
// RunCommand Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) RunCommand(container.RunCommandOptions) error {
|
|
return mc.MockRunCommand()
|
|
}
|
|
|
|
// GetContainerLogs Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) GetContainerLogs(container.GetLogOptions) (io.ReadCloser, error) {
|
|
return mc.MockGetContainerLogs()
|
|
}
|
|
|
|
// RmContainer Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) RmContainer() error {
|
|
return mc.MockRmContainer()
|
|
}
|
|
|
|
// GetID Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) GetID() string {
|
|
return mc.MockGetID()
|
|
}
|
|
|
|
// WaitUntilFinished Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) WaitUntilFinished() error {
|
|
return mc.MockWaitUntilFinished()
|
|
}
|
|
|
|
// InspectContainer Container interface implementation for unit test purposes
|
|
func (mc *MockContainer) InspectContainer() (container.State, error) {
|
|
return mc.MockInspectContainer()
|
|
}
|