Documentation
¶
Index ¶
- func RenderMarkdown(input string, colors []string) error
- type Client
- type Config
- type Copier
- type Copy
- type CopyTool
- type DockMock
- func (dm *DockMock) ContainerCreate(ctx context.Context, config *container.Config, ...) (container.ContainerCreateCreatedBody, error)
- func (dm *DockMock) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
- func (dm *DockMock) CopyFromContainer(ctx context.Context, containerID string, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
- func (dm *DockMock) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
- func (dm *DockMock) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
- func (dm *DockMock) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
- type MockCopyTool
- type MockUtility
- func (mu *MockUtility) AddAliasUnix(name string, ed string) error
- func (mu *MockUtility) AddAliasWin(name string, ed string) error
- func (mu *MockUtility) CopyFromContainer(source string, dest string, containerID string, cli Client, cp Copier) error
- func (mu *MockUtility) CreateContainer(image string, cli Client) (string, error)
- func (mu *MockUtility) FetchPimConfig(baseUrl string, pimName string, savePath string) error
- func (mu *MockUtility) FileExists(path string) bool
- func (mu *MockUtility) GetHCLBody(filepath string) (hcl.Body, error)
- func (mu *MockUtility) GetListOfInstalledPimConfigs(pimConfigDir string) ([]string, error)
- func (mu *MockUtility) Getwd() (dir string, err error)
- func (mu *MockUtility) ImageExists(imageID string, cli Client) (bool, error)
- func (mu *MockUtility) MakeDir(path string) error
- func (mu *MockUtility) OpenFile(path string) (*os.File, error)
- func (mu *MockUtility) ParseBody(body hcl.Body, out interface{}) (interface{}, error)
- func (mu *MockUtility) PullImage(name string, cli Client) error
- func (mu *MockUtility) RemoveAliasUnix(name string, ed string) error
- func (mu *MockUtility) RemoveAliasWin(name string, ed string) error
- func (mu *MockUtility) RemoveContainer(containerID string, cli Client) error
- func (mu *MockUtility) RemoveDir(path string) error
- func (mu *MockUtility) RemoveFile(path string) error
- func (mu *MockUtility) RemoveImage(image string, cli Client) error
- func (mu *MockUtility) RenderErrorMarkdown(input string)
- func (mu *MockUtility) RenderInfoMarkdown(input string)
- func (mu *MockUtility) RunContainer(image string, ports []string, volumes []string, containerName string, ...) (string, error)
- func (mu *MockUtility) UpgradeDir(path string) error
- type PackageImage
- type PimHCLUtil
- type Tools
- type Utility
- func (u *Utility) AddAliasUnix(name string, ed string) error
- func (u *Utility) AddAliasWin(name string, ed string) error
- func (u *Utility) CopyFromContainer(source string, dest string, containerID string, cli Client, cp Copier) error
- func (u *Utility) CreateContainer(image string, cli Client) (string, error)
- func (u *Utility) FetchPimConfig(baseUrl string, pimName string, savePath string) error
- func (u *Utility) FileExists(path string) bool
- func (u *Utility) GetHCLBody(filepath string) (hcl.Body, error)
- func (u *Utility) GetListOfInstalledPimConfigs(pimConfigDir string) ([]string, error)
- func (u *Utility) Getwd() (string, error)
- func (u *Utility) ImageExists(imageID string, cli Client) (bool, error)
- func (u *Utility) MakeDir(path string) error
- func (u *Utility) OpenFile(path string) (*os.File, error)
- func (u *Utility) OverwriteFile(path string) (*os.File, error)
- func (u *Utility) ParseBody(body hcl.Body, out interface{}) (interface{}, error)
- func (u *Utility) PullImage(name string, cli Client) error
- func (u *Utility) RemoveAliasUnix(name string, ed string) error
- func (u *Utility) RemoveAliasWin(name string, ed string) error
- func (u *Utility) RemoveContainer(containerID string, cli Client) error
- func (u *Utility) RemoveDir(path string) error
- func (u *Utility) RemoveFile(path string) error
- func (u *Utility) RemoveImage(image string, cli Client) error
- func (u *Utility) RenderErrorMarkdown(input string)
- func (u *Utility) RenderInfoMarkdown(input string)
- func (u *Utility) RunContainer(image string, ports []string, volumes []string, containerName string, ...) (string, error)
- func (u *Utility) UpgradeDir(path string) error
- type Version
- type Volume
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RenderMarkdown ¶ added in v0.1.3
RenderMarkdown - renders markdown and outputs it to the console
Types ¶
type Client ¶
type Client interface { ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error) CopyFromContainer(ctx context.Context, containerID string, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) }
Client interface so that we can create a mock of the docker SDK interactions in our unit tests
type Config ¶
type Config struct { BaseDir string `hcl:"base_dir,attr"` StartPort int `hcl:"start_port,attr"` PortInc int `hcl:"port_increment,attr"` Alias bool `hcl:"alias,attr"` RepositoryHost string `hcl:"repository_host,attr"` PimsConfigDir string `hcl:"pims_config_dir,attr"` PimsDir string `hcl:"pims_dir,attr"` }
Config object to contain the configuration details
type Copier ¶
type Copier interface {
CopyFiles(reader io.ReadCloser, dest string, source string) error
}
Create an interface to house the CopyFiles implementation. This will allow us to make a mock of the CopyFiles Function.
type DockMock ¶
type DockMock struct { //Variable to know what function to return an error from ErrorAt string //Variable to store the error message ErrorMsg string //Keep track of the values from ImagePull Function IPRefStr string //Keep track of the values from the ContainerCreate Function CCConfig *container.Config CCName string CCRet container.ContainerCreateCreatedBody //Keep track of the values from the CopyFromContainer Function CFCID string CFCSource string //Keep track of the values from the ContainerRemove Function CRContainer string CROptions types.ContainerRemoveOptions //Keep track of the values from the ImageRemove Function IRImgID string IROptions types.ImageRemoveOptions //ImageList return value ILRet []types.ImageSummary }
Create a Mock for the Docker client
func (*DockMock) ContainerCreate ¶
func (dm *DockMock) ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *specs.Platform, containerName string) (container.ContainerCreateCreatedBody, error)
Mock function of the Docker SDK ContainerCreate function
func (*DockMock) ContainerRemove ¶
func (dm *DockMock) ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
Mock function of the Docker SDK ContainerRemove function
func (*DockMock) CopyFromContainer ¶
func (dm *DockMock) CopyFromContainer(ctx context.Context, containerID string, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
Mock function of the Docker SDK CopyFromContainer function
func (*DockMock) ImageList ¶
func (dm *DockMock) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error)
Mock function of the Docker SDK ImagePull function
func (*DockMock) ImagePull ¶
func (dm *DockMock) ImagePull(ctx context.Context, refStr string, options types.ImagePullOptions) (io.ReadCloser, error)
Mock function of the Docker SDK ImagePull function
func (*DockMock) ImageRemove ¶
func (dm *DockMock) ImageRemove(ctx context.Context, imageID string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
Mock function of the Docker SDK ImageRemove function
type MockCopyTool ¶
CopyTool Mock
func (*MockCopyTool) CopyFiles ¶
func (mcp *MockCopyTool) CopyFiles(reader io.ReadCloser, dest string, source string) error
Mock of the CopyFiles Utility function
type MockUtility ¶
type MockUtility struct { //Keeps track of the function calls that are made during a test Calls []string //Package object that can be changed for different tests Pim PimHCLUtil //Config Object that can be changed for different tests Conf Config //HCL Body that can be changed for different tests HCLBody hcl.Body //Set if the image should exist or not for testing ImgExist bool //Set the function name that should throw an error when called ErrorAt string //Set an error message for the tests ErrorMsg string //Keep track of the directories that are created MadeDirs []string //Keep track of the files that are opened/created OpenedFiles []string //Keep track of the directories that are removed RemovedDirs []string //Keep track of the upgraded directories UpgradedDirs []string //Keep track of the HCLFiles read HCLFiles []string //Keep track of the images that are pulled PulledImgs []string //Use a fake containerID to make sure it is being used correctly ContainerID string //CreateContainer data CreateImages []string //Keep track of the CopyFromContainer data CopySources []string CopyDests []string CopyContainerID string //Keep track of the RemoveContainer data RemoveContainerID string //Keep track of the RunContainer data RunImage string RunPorts []string RunVolumes []string RunContainerName string RunArgs []string //Keep track of the RemoveImage data RemovedImgs []string //Keep track of the alias data CmdToAlias []string //Should the Pim Configuration file exist PimConfigShouldExist bool //Pim Config Directory passed in PimConfigDir string //List of pim names to return InstalledPims []string //List of pims fetched using FetchPimConfigs FetchedPims []string }
Mock utility and its functions
func NewMockUtility ¶
func NewMockUtility() *MockUtility
Create a new Mock Utility and set any default variables
func (*MockUtility) AddAliasUnix ¶
func (mu *MockUtility) AddAliasUnix(name string, ed string) error
Mock of the AddAliasUnix Utility function
func (*MockUtility) AddAliasWin ¶
func (mu *MockUtility) AddAliasWin(name string, ed string) error
Mock of the AddAliasWin Utility function
func (*MockUtility) CopyFromContainer ¶
func (mu *MockUtility) CopyFromContainer(source string, dest string, containerID string, cli Client, cp Copier) error
Mock of the CopyFromContainer Utility function
func (*MockUtility) CreateContainer ¶
func (mu *MockUtility) CreateContainer(image string, cli Client) (string, error)
Mock of the CreateContainer Utility function
func (*MockUtility) FetchPimConfig ¶
func (mu *MockUtility) FetchPimConfig(baseUrl string, pimName string, savePath string) error
func (*MockUtility) FileExists ¶
func (mu *MockUtility) FileExists(path string) bool
func (*MockUtility) GetHCLBody ¶
func (mu *MockUtility) GetHCLBody(filepath string) (hcl.Body, error)
Mock of the GetHCLBody Utility function
func (*MockUtility) GetListOfInstalledPimConfigs ¶
func (mu *MockUtility) GetListOfInstalledPimConfigs(pimConfigDir string) ([]string, error)
func (*MockUtility) Getwd ¶ added in v0.1.3
func (mu *MockUtility) Getwd() (dir string, err error)
Mock of the Getwd Utility function
func (*MockUtility) ImageExists ¶
func (mu *MockUtility) ImageExists(imageID string, cli Client) (bool, error)
Mock of the ImageExists Utility function
func (*MockUtility) MakeDir ¶
func (mu *MockUtility) MakeDir(path string) error
Mock of the MakeDir Utility function
func (*MockUtility) OpenFile ¶
func (mu *MockUtility) OpenFile(path string) (*os.File, error)
Mock of the OpenFile Utility function
func (*MockUtility) ParseBody ¶
func (mu *MockUtility) ParseBody(body hcl.Body, out interface{}) (interface{}, error)
Mock of the ParseBody Utility function
func (*MockUtility) PullImage ¶
func (mu *MockUtility) PullImage(name string, cli Client) error
Mock of the PullImage Utility function
func (*MockUtility) RemoveAliasUnix ¶
func (mu *MockUtility) RemoveAliasUnix(name string, ed string) error
Mock of the RemoveAliasUnix Utility function
func (*MockUtility) RemoveAliasWin ¶
func (mu *MockUtility) RemoveAliasWin(name string, ed string) error
Mock of the RemoveAliasWin Utility function
func (*MockUtility) RemoveContainer ¶
func (mu *MockUtility) RemoveContainer(containerID string, cli Client) error
Mock of the RemoveContainer Utility function
func (*MockUtility) RemoveDir ¶
func (mu *MockUtility) RemoveDir(path string) error
Mock of the RemoveDir Utility function
func (*MockUtility) RemoveFile ¶
func (mu *MockUtility) RemoveFile(path string) error
func (*MockUtility) RemoveImage ¶
func (mu *MockUtility) RemoveImage(image string, cli Client) error
Mock of the RemoveImage Utility function
func (*MockUtility) RenderErrorMarkdown ¶ added in v0.1.3
func (mu *MockUtility) RenderErrorMarkdown(input string)
Mock of the RenderErrorMarkdown utility function
func (*MockUtility) RenderInfoMarkdown ¶ added in v0.1.3
func (mu *MockUtility) RenderInfoMarkdown(input string)
Mock of the RenderInfoMarkdown utility function
func (*MockUtility) RunContainer ¶
func (mu *MockUtility) RunContainer(image string, ports []string, volumes []string, containerName string, args []string) (string, error)
Mock of the RunContainer Utility function
func (*MockUtility) UpgradeDir ¶
func (mu *MockUtility) UpgradeDir(path string) error
Mock of the UpgradeDir Utility function
type PackageImage ¶
type PackageImage struct { Name string `hcl:"name,label"` BaseDir string `hcl:"base_dir,attr"` Versions []Version `hcl:"version,block"` }
Package object to parse the package block in the package list
type PimHCLUtil ¶
type PimHCLUtil struct {
Pims []PackageImage `hcl:"pim,block"`
}
PackageHCLUtil object to contain a list of packages and all their attributes after the parsing of the package list
type Tools ¶
type Tools interface { MakeDir(path string) error OpenFile(path string) (*os.File, error) RemoveDir(path string) error UpgradeDir(path string) error ParseBody(body hcl.Body, out interface{}) (interface{}, error) GetHCLBody(filepath string) (hcl.Body, error) PullImage(name string, cli Client) error ImageExists(imageID string, cli Client) (bool, error) CreateContainer(image string, cli Client) (string, error) CopyFromContainer(source string, dest string, containerID string, cli Client, cp Copier) error RemoveContainer(containerID string, cli Client) error RunContainer(image string, ports []string, volumes []string, containerName string, args []string) (string, error) RemoveImage(image string, cli Client) error AddAliasWin(name string, ed string) error RemoveAliasWin(name string, ed string) error AddAliasUnix(name string, ed string) error RemoveAliasUnix(name string, ed string) error FetchPimConfig(baseUrl string, pimName string, savePath string) error FileExists(path string) bool RemoveFile(path string) error GetListOfInstalledPimConfigs(pimConfigDir string) ([]string, error) Getwd() (string, error) RenderInfoMarkdown(input string) RenderErrorMarkdown(input string) }
Tools interface so that we can create a mock of our utility functions in our unit tests
type Utility ¶
type Utility struct{}
Utility Tool struct with its functions
func NewUtility ¶
func NewUtility() *Utility
func (*Utility) AddAliasUnix ¶
AddAlias will add the alias for the package name specified
func (*Utility) AddAliasWin ¶
AddAlias will add the alias for the package name specified
func (*Utility) CopyFromContainer ¶
func (u *Utility) CopyFromContainer(source string, dest string, containerID string, cli Client, cp Copier) error
CopyFromContainer will copy files from within a Docker Container to the source location on the host
func (*Utility) CreateContainer ¶
CreateContainer - Create a Docker Container from a Docker Image. Returns the containerID and any errors
func (*Utility) FetchPimConfig ¶
FetchPimConfig will get download the latest pim configuration for specified pim
func (*Utility) FileExists ¶
FileExists - checks to see if a file exists
func (*Utility) GetHCLBody ¶
GetHCLBody gets the HCL Body from a given filepath
func (*Utility) GetListOfInstalledPimConfigs ¶
GetListOfInstalledPimConfigs - returns a string array of the names of the pims with configuration files currently in the pim configuration directory
func (*Utility) Getwd ¶ added in v0.1.3
Getwd returns a rooted path name corresponding to the current directory
func (*Utility) ImageExists ¶
ImageExists - Function to check and see if Docker has the image downloaded
func (*Utility) OverwriteFile ¶
OverwriteFile opens the specified file with overwrite mode, creating it if it does not exist
func (*Utility) PullImage ¶
PullImage - This function pulls a Docker Image from the packageless organization in Docker Hub
func (*Utility) RemoveAliasUnix ¶
Remove Alias will remove the alias for the specified package name from the corresponding files
func (*Utility) RemoveAliasWin ¶
Remove Alias will remove the alias for the specified package name from the corresponding files
func (*Utility) RemoveContainer ¶
RemoveContainer is used to remove a container Docker given the container ID
func (*Utility) RemoveFile ¶
RemoveFile - will delete the file at the specified path
func (*Utility) RemoveImage ¶
RemoveImage removes the image with the given name from local Docker
func (*Utility) RenderErrorMarkdown ¶ added in v0.1.3
RenderErrorMarkdown - Renders markdown and outputs it with a color scheme specific to error messages
func (*Utility) RenderInfoMarkdown ¶ added in v0.1.3
RenderInfoMarkdown - Renders markdown and outputs it with a color scheme specific to info messages
func (*Utility) RunContainer ¶
func (u *Utility) RunContainer(image string, ports []string, volumes []string, containerName string, args []string) (string, error)
RunContainer - Runs a container for the specified package
func (*Utility) UpgradeDir ¶
UpgradeDir resets the directory by removing it if it exists and then recreating it