From c848ac469b4262e3d7c6cfc3b629ba301a18d2b0 Mon Sep 17 00:00:00 2001 From: Bryce Palmer Date: Sun, 10 Oct 2021 12:22:05 -0400 Subject: [PATCH 1/2] package -> pim --- package_list.hcl | 2 +- subcommands/install_sc.go | 70 ++++++++-------- subcommands/install_sc_test.go | 40 ++++----- subcommands/run_sc.go | 54 ++++++------ subcommands/run_sc_test.go | 36 ++++---- subcommands/uninstall_sc.go | 68 +++++++-------- subcommands/uninstall_sc_test.go | 38 ++++----- subcommands/upgrade_sc.go | 74 ++++++++-------- subcommands/upgrade_sc_test.go | 44 +++++----- testing/test_package_list.hcl | 2 +- utils/hcl_parse.go | 16 ++-- utils/hcl_parse_test.go | 140 +++++++++++++++---------------- utils/mocks.go | 10 +-- 13 files changed, 297 insertions(+), 297 deletions(-) diff --git a/package_list.hcl b/package_list.hcl index 6e83dcf..1a37ffd 100644 --- a/package_list.hcl +++ b/package_list.hcl @@ -1,4 +1,4 @@ -package "python" { +pim "python" { base_dir="/python/" version "latest" { diff --git a/subcommands/install_sc.go b/subcommands/install_sc.go index bbf5844..630c99b 100644 --- a/subcommands/install_sc.go +++ b/subcommands/install_sc.go @@ -18,7 +18,7 @@ type InstallCommand struct { //FlagSet so that we can create a custom flag fs *flag.FlagSet - //String for the name of the package to install + //String for the name of the pim to install name string //Tools that can be used by the command @@ -51,7 +51,7 @@ func (ic *InstallCommand) Name() string { func (ic *InstallCommand) Init(args []string) error { if len(args) <= 0 { - return errors.New("No package name was found. You must include the name of the package you wish to install.") + return errors.New("No pim name was found. You must include the name of the pim you wish to install.") } ic.name = args[0] @@ -62,19 +62,19 @@ func (ic *InstallCommand) Init(args []string) error { func (ic *InstallCommand) Run() error { //Create variables to use later var found bool - var pack utils.Package + var pim utils.PackageImage var version utils.Version - var packName string - var packVersion string + var pimName string + var pimVersion string if strings.Contains(ic.name, ":") { split := strings.Split(ic.name, ":") - packName = split[0] - packVersion = split[1] + pimName = split[0] + pimVersion = split[1] } else { - packName = ic.name - packVersion = "latest" + pimName = ic.name + pimVersion = "latest" } //Create the Docker client @@ -90,33 +90,33 @@ func (ic *InstallCommand) Run() error { } ed := filepath.Dir(ex) - //Default location of the package list - packageList := ed + "/package_list.hcl" + //Default location of the pim list + pimList := ed + "/package_list.hcl" - packageListBody, err := ic.tools.GetHCLBody(packageList) + pimListBody, err := ic.tools.GetHCLBody(pimList) if err != nil { return err } - //Parse the package list - parseOut, err := ic.tools.ParseBody(packageListBody, utils.PackageHCLUtil{}) + //Parse the pim list + parseOut, err := ic.tools.ParseBody(pimListBody, utils.PimHCLUtil{}) - packages := parseOut.(utils.PackageHCLUtil) + pims := parseOut.(utils.PimHCLUtil) //Check for errors if err != nil { return err } - //Look for the package we want in the package list - for _, packs := range packages.Packages { + //Look for the pim we want in the pim list + for _, pimItem := range pims.Pims { //If we find it, set some variables and break - if packs.Name == packName { - pack = packs + if pimItem.Name == pimName { + pim = pimItem - for _, ver := range pack.Versions { - if ver.Version == packVersion { + for _, ver := range pim.Versions { + if ver.Version == pimVersion { found = true version = ver break @@ -125,12 +125,12 @@ func (ic *InstallCommand) Run() error { } } - //Make sure we have found the package in the package list + //Make sure we have found the pim in the pim list if !found { - return errors.New("Could not find package " + packName + " with version '" + packVersion + "' in the package list") + return errors.New("Could not find pim " + pimName + " with version '" + pimVersion + "' in the pim list") } - //Check if the corresponding package image is already installed + //Check if the corresponding pim image is already installed imgExist, err := ic.tools.ImageExists(version.Image, cli) //Check for errors @@ -138,12 +138,12 @@ func (ic *InstallCommand) Run() error { return err } - //If the image exists the package is already installed + //If the image exists the pim is already installed if imgExist { - return errors.New("Package " + pack.Name + " is already installed") + return errors.New("pim " + pim.Name + " is already installed") } - fmt.Println("Installing", pack.Name+":"+version.Version) + fmt.Println("Installing", pim.Name+":"+version.Version) //Pull the image down from Docker Hub err = ic.tools.PullImage(version.Image, cli) @@ -151,10 +151,10 @@ func (ic *InstallCommand) Run() error { return err } - fmt.Println("Creating package directories") + fmt.Println("Creating pim directories") - //Create the base directory for the package - err = ic.tools.MakeDir(ed + pack.BaseDir) + //Create the base directory for the pim + err = ic.tools.MakeDir(ed + pim.BaseDir) if err != nil { return err @@ -209,15 +209,15 @@ func (ic *InstallCommand) Run() error { if runtime.GOOS == "windows" { if version.Version != "latest" { - err = ic.tools.AddAliasWin(pack.Name+":"+version.Version, ed) + err = ic.tools.AddAliasWin(pim.Name+":"+version.Version, ed) } else { - err = ic.tools.AddAliasWin(pack.Name, ed) + err = ic.tools.AddAliasWin(pim.Name, ed) } } else { if version.Version != "latest" { - err = ic.tools.AddAliasUnix(pack.Name+":"+version.Version, ed) + err = ic.tools.AddAliasUnix(pim.Name+":"+version.Version, ed) } else { - err = ic.tools.AddAliasUnix(pack.Name, ed) + err = ic.tools.AddAliasUnix(pim.Name, ed) } } @@ -226,7 +226,7 @@ func (ic *InstallCommand) Run() error { } } - fmt.Println(pack.Name, "successfully installed") + fmt.Println(pim.Name, "successfully installed") return nil } diff --git a/subcommands/install_sc_test.go b/subcommands/install_sc_test.go index d5fe1bb..961fb25 100644 --- a/subcommands/install_sc_test.go +++ b/subcommands/install_sc_test.go @@ -53,7 +53,7 @@ func TestInstallInit(t *testing.T) { } if ic.name != args[0] { - t.Fatal("Package Name should have been initialized as: " + args[0] + " but is: " + ic.name) + t.Fatal("pim Name should have been initialized as: " + args[0] + " but is: " + ic.name) } } @@ -128,25 +128,25 @@ func TestInstallFlow(t *testing.T) { var aliasCmds []string //Fill lists - for _, pack := range mu.Pack.Packages { + for _, pim := range mu.Pim.Pims { //Just use the first version - version := pack.Versions[0] + version := pim.Versions[0] images = append(images, version.Image) - mkdirs = append(mkdirs, ed+pack.BaseDir) - aliasCmds = append(aliasCmds, pack.Name) + mkdirs = append(mkdirs, ed+pim.BaseDir) + aliasCmds = append(aliasCmds, pim.Name) - //Loop through volumes in the package + //Loop through volumes in the pim for _, vol := range version.Volumes { mkdirs = append(mkdirs, ed+vol.Path) } - //Loop through the copies in the package + //Loop through the copies in the pim for _, copy := range version.Copies { copySources = append(copySources, copy.Source) copyDests = append(copyDests, ed+copy.Dest) } - //Just use the first package + //Just use the first pim break } @@ -652,7 +652,7 @@ func TestInstallImageExists(t *testing.T) { mu.ImgExist = true - expectedErr := "Package python is already installed" + expectedErr := "pim python is already installed" mcp := &utils.MockCopyTool{} @@ -699,7 +699,7 @@ func TestInstallImageExists(t *testing.T) { func TestInstallNoPackage(t *testing.T) { mu := utils.NewMockUtility() - expectedErr := "No package name was found. You must include the name of the package you wish to install." + expectedErr := "No pim name was found. You must include the name of the pim you wish to install." mcp := &utils.MockCopyTool{} @@ -725,7 +725,7 @@ func TestInstallNoPackage(t *testing.T) { } } -//Test the install subcommand if the passed in package does not exist +//Test the install subcommand if the passed in pim does not exist func TestInstallNonExistPackage(t *testing.T) { mu := utils.NewMockUtility() @@ -742,7 +742,7 @@ func TestInstallNonExistPackage(t *testing.T) { args := []string{"nonexistent"} - expectedErr := "Could not find package nonexistent with version 'latest' in the package list" + expectedErr := "Could not find pim nonexistent with version 'latest' in the pim list" err := ic.Init(args) @@ -838,24 +838,24 @@ func TestInstallAliasFalse(t *testing.T) { var mkdirs []string //Fill lists - for _, pack := range mu.Pack.Packages { + for _, pim := range mu.Pim.Pims { //Just use the first version - version := pack.Versions[0] + version := pim.Versions[0] images = append(images, version.Image) - mkdirs = append(mkdirs, ed+pack.BaseDir) + mkdirs = append(mkdirs, ed+pim.BaseDir) - //Loop through volumes in the package + //Loop through volumes in the pim for _, vol := range version.Volumes { mkdirs = append(mkdirs, ed+vol.Path) } - //Loop through the copies in the package + //Loop through the copies in the pim for _, copy := range version.Copies { copySources = append(copySources, copy.Source) copyDests = append(copyDests, ed+copy.Dest) } - //Just use the first package + //Just use the first pim break } @@ -896,7 +896,7 @@ func TestInstallAliasFalse(t *testing.T) { } -//Test the install function with a nonexistent package version +//Test the install function with a nonexistent pim version func TestInstallNonExistVersion(t *testing.T) { mu := utils.NewMockUtility() @@ -913,7 +913,7 @@ func TestInstallNonExistVersion(t *testing.T) { args := []string{"python:idontexist"} - expectedErr := "Could not find package python with version 'idontexist' in the package list" + expectedErr := "Could not find pim python with version 'idontexist' in the pim list" err := ic.Init(args) diff --git a/subcommands/run_sc.go b/subcommands/run_sc.go index 94dbd6a..5849958 100644 --- a/subcommands/run_sc.go +++ b/subcommands/run_sc.go @@ -17,7 +17,7 @@ type RunCommand struct { //FlagSet so that we can create a custom flag fs *flag.FlagSet - //String for the name of the package to run + //String for the name of the pim to run name string args []string @@ -48,7 +48,7 @@ func (rc *RunCommand) Name() string { func (rc *RunCommand) Init(args []string) error { if len(args) <= 0 { - return errors.New("No package name was found. You must include the name of the package you wish to run.") + return errors.New("No pim name was found. You must include the name of the pim you wish to run.") } rc.name = args[0] @@ -62,19 +62,19 @@ func (rc *RunCommand) Init(args []string) error { func (rc *RunCommand) Run() error { //Create variables to use later var found bool - var pack utils.Package + var pim utils.PackageImage var version utils.Version - var packName string - var packVersion string + var pimName string + var pimVersion string if strings.Contains(rc.name, ":") { split := strings.Split(rc.name, ":") - packName = split[0] - packVersion = split[1] + pimName = split[0] + pimVersion = split[1] } else { - packName = rc.name - packVersion = "latest" + pimName = rc.name + pimVersion = "latest" } //Create the Docker client @@ -90,33 +90,33 @@ func (rc *RunCommand) Run() error { } ed := filepath.Dir(ex) - //Default location of the package list - packageList := ed + "/package_list.hcl" + //Default location of the pim list + pimList := ed + "/package_list.hcl" - packageListBody, err := rc.tools.GetHCLBody(packageList) + pimListBody, err := rc.tools.GetHCLBody(pimList) if err != nil { return err } - //Parse the package list - parseOut, err := rc.tools.ParseBody(packageListBody, utils.PackageHCLUtil{}) + //Parse the pim list + parseOut, err := rc.tools.ParseBody(pimListBody, utils.PimHCLUtil{}) //Check for errors if err != nil { return err } - packages := parseOut.(utils.PackageHCLUtil) + pims := parseOut.(utils.PimHCLUtil) - //Look for the package we want in the package list - for _, packs := range packages.Packages { + //Look for the pim we want in the pim list + for _, pimItem := range pims.Pims { //If we find it, set some variables and break - if packs.Name == packName { - pack = packs + if pimItem.Name == pimName { + pim = pimItem - for _, ver := range pack.Versions { - if ver.Version == packVersion { + for _, ver := range pim.Versions { + if ver.Version == pimVersion { found = true version = ver break @@ -125,12 +125,12 @@ func (rc *RunCommand) Run() error { } } - //Make sure we have found the package in the package list + //Make sure we have found the pim in the pim list if !found { - return errors.New("Could not find package " + packName + " with version '" + packVersion + "' in the package list") + return errors.New("Could not find pim " + pimName + " with version '" + pimVersion + "' in the pim list") } - //Check if the corresponding package image is already installed + //Check if the corresponding pim image is already installed imgExist, err := rc.tools.ImageExists(version.Image, cli) //Check for errors @@ -138,9 +138,9 @@ func (rc *RunCommand) Run() error { return err } - //If the image exists the package is already installed + //If the image exists the pim is already installed if !imgExist { - return errors.New("Package " + pack.Name + " with version '" + version.Version + "' is not installed. You must install the package before running it.") + return errors.New("pim " + pim.Name + " with version '" + version.Version + "' is not installed. You must install the pim before running it.") } //Create the variables to use when running the container @@ -164,7 +164,7 @@ func (rc *RunCommand) Run() error { } //Run the container - _, err = rc.tools.RunContainer(version.Image, ports, volumes, pack.Name, rc.args) + _, err = rc.tools.RunContainer(version.Image, ports, volumes, pim.Name, rc.args) if err != nil { return err diff --git a/subcommands/run_sc_test.go b/subcommands/run_sc_test.go index 40140ce..ce98249 100644 --- a/subcommands/run_sc_test.go +++ b/subcommands/run_sc_test.go @@ -50,15 +50,15 @@ func TestRunInit(t *testing.T) { } if rc.name != args[0] { - t.Fatal("Package Name should have been initialized as: " + args[0] + " but is: " + rc.name) + t.Fatal("pim Name should have been initialized as: " + args[0] + " but is: " + rc.name) } } -//Test the Run subcommand with no package specified +//Test the Run subcommand with no pim specified func TestRunNoPackage(t *testing.T) { mu := utils.NewMockUtility() - expectedErr := "No package name was found. You must include the name of the package you wish to run." + expectedErr := "No pim name was found. You must include the name of the pim you wish to run." config := utils.Config{ BaseDir: "./", @@ -82,7 +82,7 @@ func TestRunNoPackage(t *testing.T) { } } -//Test the Run subcommand with a non existent package specified +//Test the Run subcommand with a non existent pim specified func TestRunNonExistPackage(t *testing.T) { mu := utils.NewMockUtility() @@ -97,7 +97,7 @@ func TestRunNonExistPackage(t *testing.T) { args := []string{"nonexistent"} - expectedErr := "Could not find package nonexistent with version 'latest' in the package list" + expectedErr := "Could not find pim nonexistent with version 'latest' in the pim list" err := rc.Init(args) @@ -143,7 +143,7 @@ func TestRunImageNotExist(t *testing.T) { args := []string{"python"} - expectedErr := "Package python with version 'latest' is not installed. You must install the package before running it." + expectedErr := "pim python with version 'latest' is not installed. You must install the pim before running it." err := rc.Init(args) @@ -224,13 +224,13 @@ func TestRunFlowNoRunArgs(t *testing.T) { t.Fatalf("Call Stack does not match the expected call stack. Call Stack: %v | Expected Call Stack: %v", mu.Calls, callStack) } - //Make sure the image that was ran matches the package image - if mu.RunImage != mu.Pack.Packages[0].Versions[0].Image { - t.Fatalf("RunContainer: Image does not match the expected Image. Received Image: %s | Expected Image: %s", mu.RunImage, mu.Pack.Packages[0].Versions[0].Image) + //Make sure the image that was ran matches the pim image + if mu.RunImage != mu.Pim.Pims[0].Versions[0].Image { + t.Fatalf("RunContainer: Image does not match the expected Image. Received Image: %s | Expected Image: %s", mu.RunImage, mu.Pim.Pims[0].Versions[0].Image) } - port := []string{strconv.Itoa(mu.Conf.StartPort) + ":" + mu.Pack.Packages[0].Versions[0].Port} - volume := []string{ed + mu.Pack.Packages[0].Versions[0].Volumes[0].Path + ":" + mu.Pack.Packages[0].Versions[0].Volumes[0].Mount} + port := []string{strconv.Itoa(mu.Conf.StartPort) + ":" + mu.Pim.Pims[0].Versions[0].Port} + volume := []string{ed + mu.Pim.Pims[0].Versions[0].Volumes[0].Path + ":" + mu.Pim.Pims[0].Versions[0].Volumes[0].Mount} //Make sure the ports passed in matches if !reflect.DeepEqual(mu.RunPorts, port) { @@ -303,13 +303,13 @@ func TestRunFlowRunArgs(t *testing.T) { t.Fatalf("Call Stack does not match the expected call stack. Call Stack: %v | Expected Call Stack: %v", mu.Calls, callStack) } - //Make sure the image that was ran matches the package image - if mu.RunImage != mu.Pack.Packages[0].Versions[0].Image { - t.Fatalf("RunContainer: Image does not match the expected Image. Received Image: %s | Expected Image: %s", mu.RunImage, mu.Pack.Packages[0].Versions[0].Image) + //Make sure the image that was ran matches the pim image + if mu.RunImage != mu.Pim.Pims[0].Versions[0].Image { + t.Fatalf("RunContainer: Image does not match the expected Image. Received Image: %s | Expected Image: %s", mu.RunImage, mu.Pim.Pims[0].Versions[0].Image) } - port := []string{strconv.Itoa(mu.Conf.StartPort) + ":" + mu.Pack.Packages[0].Versions[0].Port} - volume := []string{ed + mu.Pack.Packages[0].Versions[0].Volumes[0].Path + ":" + mu.Pack.Packages[0].Versions[0].Volumes[0].Mount} + port := []string{strconv.Itoa(mu.Conf.StartPort) + ":" + mu.Pim.Pims[0].Versions[0].Port} + volume := []string{ed + mu.Pim.Pims[0].Versions[0].Volumes[0].Path + ":" + mu.Pim.Pims[0].Versions[0].Volumes[0].Mount} //Make sure the ports passed in matches if !reflect.DeepEqual(mu.RunPorts, port) { @@ -514,7 +514,7 @@ func TestRunErrorAtRunContainer(t *testing.T) { } } -//Test the Run subcommand with a package with a nonexistent version specified +//Test the Run subcommand with a pim with a nonexistent version specified func TestRunNonExistVersion(t *testing.T) { mu := utils.NewMockUtility() @@ -529,7 +529,7 @@ func TestRunNonExistVersion(t *testing.T) { args := []string{"python:idontexist"} - expectedErr := "Could not find package python with version 'idontexist' in the package list" + expectedErr := "Could not find pim python with version 'idontexist' in the pim list" err := rc.Init(args) diff --git a/subcommands/uninstall_sc.go b/subcommands/uninstall_sc.go index 88f957b..bd5d191 100644 --- a/subcommands/uninstall_sc.go +++ b/subcommands/uninstall_sc.go @@ -18,7 +18,7 @@ type UninstallCommand struct { //FlagSet so that we can create a custom flag fs *flag.FlagSet - //String for the name of the package to Uninstall + //String for the name of the pim to Uninstall name string tools utils.Tools @@ -47,7 +47,7 @@ func (uc *UninstallCommand) Name() string { func (uc *UninstallCommand) Init(args []string) error { if len(args) <= 0 { - return errors.New("No package name was found. You must include the name of the package you wish to uninstall.") + return errors.New("No pim name was found. You must include the name of the pim you wish to uninstall.") } uc.name = args[0] @@ -59,19 +59,19 @@ func (uc *UninstallCommand) Init(args []string) error { func (uc *UninstallCommand) Run() error { //Create variables to use later var found bool - var pack utils.Package + var pim utils.PackageImage var version utils.Version - var packName string - var packVersion string + var pimName string + var pimVersion string if strings.Contains(uc.name, ":") { split := strings.Split(uc.name, ":") - packName = split[0] - packVersion = split[1] + pimName = split[0] + pimVersion = split[1] } else { - packName = uc.name - packVersion = "latest" + pimName = uc.name + pimVersion = "latest" } //Create the Docker client @@ -87,38 +87,38 @@ func (uc *UninstallCommand) Run() error { } ed := filepath.Dir(ex) - //Default location of the package list - packageList := ed + "/package_list.hcl" + //Default location of the pim list + pimList := ed + "/package_list.hcl" - packageListBody, err := uc.tools.GetHCLBody(packageList) + pimListBody, err := uc.tools.GetHCLBody(pimList) if err != nil { return err } - //Parse the package list - parseOut, err := uc.tools.ParseBody(packageListBody, utils.PackageHCLUtil{}) + //Parse the pim list + parseOut, err := uc.tools.ParseBody(pimListBody, utils.PimHCLUtil{}) //Check for errors if err != nil { return err } - packages := parseOut.(utils.PackageHCLUtil) + pims := parseOut.(utils.PimHCLUtil) //Check for errors if err != nil { return err } - //Look for the package we want in the package list - for _, packs := range packages.Packages { + //Look for the pim we want in the pim list + for _, pimItem := range pims.Pims { //If we find it, set some variables and break - if packs.Name == packName { - pack = packs + if pimItem.Name == pimName { + pim = pimItem - for _, ver := range pack.Versions { - if ver.Version == packVersion { + for _, ver := range pim.Versions { + if ver.Version == pimVersion { found = true version = ver break @@ -127,12 +127,12 @@ func (uc *UninstallCommand) Run() error { } } - //Make sure we have found the package in the package list + //Make sure we have found the pim in the pim list if !found { - return errors.New("Could not find package " + packName + " with version '" + packVersion + "' in the package list") + return errors.New("Could not find pim " + pimName + " with version '" + pimVersion + "' in the pim list") } - //Check if the corresponding package image is already Uninstalled + //Check if the corresponding pim is already Uninstalled imgExist, err := uc.tools.ImageExists(version.Image, cli) //Check for errors @@ -142,13 +142,13 @@ func (uc *UninstallCommand) Run() error { //If the image doesn't exist it can't be uninstalled if !imgExist { - return errors.New("Package " + pack.Name + " with version '" + version.Version + "' is not installed.") + return errors.New("pim " + pim.Name + " with version '" + version.Version + "' is not installed.") } - fmt.Println("Removing", pack.Name+":"+version.Version) + fmt.Println("Removing", pim.Name+":"+version.Version) - //Check for the directories that correspond to this packages volumes - fmt.Println("Removing package directories") + //Check for the directories that correspond to this pims volumes + fmt.Println("Removing pim directories") //Check the volumes and remove the directories if they exist for _, vol := range version.Volumes { @@ -162,8 +162,8 @@ func (uc *UninstallCommand) Run() error { } } - //Remove the base directory for the package - err = uc.tools.RemoveDir(ed + pack.BaseDir) + //Remove the base directory for the pim + err = uc.tools.RemoveDir(ed + pim.BaseDir) if err != nil { return err @@ -185,15 +185,15 @@ func (uc *UninstallCommand) Run() error { if runtime.GOOS == "windows" { if version.Version != "latest" { - err = uc.tools.RemoveAliasWin(pack.Name+":"+version.Version, ed) + err = uc.tools.RemoveAliasWin(pim.Name+":"+version.Version, ed) } else { - err = uc.tools.RemoveAliasWin(pack.Name, ed) + err = uc.tools.RemoveAliasWin(pim.Name, ed) } } else { if version.Version != "latest" { - err = uc.tools.RemoveAliasUnix(pack.Name+":"+version.Version, ed) + err = uc.tools.RemoveAliasUnix(pim.Name+":"+version.Version, ed) } else { - err = uc.tools.RemoveAliasUnix(pack.Name, ed) + err = uc.tools.RemoveAliasUnix(pim.Name, ed) } } diff --git a/subcommands/uninstall_sc_test.go b/subcommands/uninstall_sc_test.go index 4357dc3..d35800e 100644 --- a/subcommands/uninstall_sc_test.go +++ b/subcommands/uninstall_sc_test.go @@ -49,15 +49,15 @@ func TestUninstallInit(t *testing.T) { } if uc.name != args[0] { - t.Fatal("Package Name should have been initialized as: " + args[0] + " but is: " + uc.name) + t.Fatal("pim Name should have been initialized as: " + args[0] + " but is: " + uc.name) } } -//Test the uninstall subcommand with no package specified +//Test the uninstall subcommand with no pim specified func TestUninstallNoPackage(t *testing.T) { mu := utils.NewMockUtility() - expectedErr := "No package name was found. You must include the name of the package you wish to uninstall." + expectedErr := "No pim name was found. You must include the name of the pim you wish to uninstall." config := utils.Config{ BaseDir: "./", @@ -81,7 +81,7 @@ func TestUninstallNoPackage(t *testing.T) { } } -//Test the uninstall subcommand with a non existent package specified +//Test the uninstall subcommand with a non existent pim specified func TestUninstallNonExistPackage(t *testing.T) { mu := utils.NewMockUtility() @@ -96,7 +96,7 @@ func TestUninstallNonExistPackage(t *testing.T) { args := []string{"nonexistent"} - expectedErr := "Could not find package nonexistent with version 'latest' in the package list" + expectedErr := "Could not find pim nonexistent with version 'latest' in the pim list" err := uc.Init(args) @@ -142,7 +142,7 @@ func TestUninstallImageNotExist(t *testing.T) { args := []string{"python"} - expectedErr := "Package python with version 'latest' is not installed." + expectedErr := "pim python with version 'latest' is not installed." err := uc.Init(args) @@ -236,19 +236,19 @@ func TestUninstallFlow(t *testing.T) { var aliasCmds []string //Fill lists - for _, pack := range mu.Pack.Packages { + for _, pim := range mu.Pim.Pims { //Just use the first version - version := pack.Versions[0] + version := pim.Versions[0] images = append(images, version.Image) - aliasCmds = append(aliasCmds, pack.Name) + aliasCmds = append(aliasCmds, pim.Name) - //Loop through volumes in the package + //Loop through volumes in the pim for _, vol := range version.Volumes { rmdirs = append(rmdirs, ed+vol.Path) } - rmdirs = append(rmdirs, ed+pack.BaseDir) - //Just use the first package for the test + rmdirs = append(rmdirs, ed+pim.BaseDir) + //Just use the first pim for the test break } @@ -616,19 +616,19 @@ func TestUninstallAliasFalse(t *testing.T) { var rmdirs []string //Fill lists - for _, pack := range mu.Pack.Packages { + for _, pim := range mu.Pim.Pims { //Just use the first version - version := pack.Versions[0] + version := pim.Versions[0] images = append(images, version.Image) - //Loop through volumes in the package + //Loop through volumes in the pim for _, vol := range version.Volumes { rmdirs = append(rmdirs, ed+vol.Path) } - rmdirs = append(rmdirs, ed+pack.BaseDir) + rmdirs = append(rmdirs, ed+pim.BaseDir) - //Just use the first package + //Just use the first pim break } @@ -643,7 +643,7 @@ func TestUninstallAliasFalse(t *testing.T) { } } -//Test the uninstall subcommand with a package with a nonexistent version specified +//Test the uninstall subcommand with a pim with a nonexistent version specified func TestUninstallNonExistVersion(t *testing.T) { mu := utils.NewMockUtility() @@ -658,7 +658,7 @@ func TestUninstallNonExistVersion(t *testing.T) { args := []string{"python:idontexist"} - expectedErr := "Could not find package python with version 'idontexist' in the package list" + expectedErr := "Could not find pim python with version 'idontexist' in the pim list" err := uc.Init(args) diff --git a/subcommands/upgrade_sc.go b/subcommands/upgrade_sc.go index 22a5b56..bf94091 100644 --- a/subcommands/upgrade_sc.go +++ b/subcommands/upgrade_sc.go @@ -17,7 +17,7 @@ type UpgradeCommand struct { //FlagSet so that we can create a custom flag fs *flag.FlagSet - //String for the name of the package to upgrade + //String for the name of the pim to upgrade name string tools utils.Tools @@ -45,7 +45,7 @@ func (ic *UpgradeCommand) Name() string { //Init - Parses and Populates values of the Upgrade subcommand func (ic *UpgradeCommand) Init(args []string) error { if len(args) <= 0 { - fmt.Println("No package specified, upgrading all currently installed packages.") + fmt.Println("No pim specified, upgrading all currently installed pims.") } else { ic.name = args[0] } @@ -56,19 +56,19 @@ func (ic *UpgradeCommand) Init(args []string) error { func (ic *UpgradeCommand) Run() error { //Create variables to use later var found bool - var pack utils.Package + var pim utils.PackageImage var version utils.Version - var packName string - var packVersion string + var pimName string + var pimVersion string if strings.Contains(ic.name, ":") { split := strings.Split(ic.name, ":") - packName = split[0] - packVersion = split[1] + pimName = split[0] + pimVersion = split[1] } else { - packName = ic.name - packVersion = "latest" + pimName = ic.name + pimVersion = "latest" } //Create the Docker client @@ -84,19 +84,19 @@ func (ic *UpgradeCommand) Run() error { } ed := filepath.Dir(ex) - //Default location of the package list - packageList := ed + "/package_list.hcl" + //Default location of the pim list + pimList := ed + "/package_list.hcl" - packageListBody, err := ic.tools.GetHCLBody(packageList) + pimListBody, err := ic.tools.GetHCLBody(pimList) if err != nil { return err } - //Parse the package list - parseOut, err := ic.tools.ParseBody(packageListBody, utils.PackageHCLUtil{}) + //Parse the pim list + parseOut, err := ic.tools.ParseBody(pimListBody, utils.PimHCLUtil{}) - packages := parseOut.(utils.PackageHCLUtil) + pims := parseOut.(utils.PimHCLUtil) //Check for errors if err != nil { @@ -104,14 +104,14 @@ func (ic *UpgradeCommand) Run() error { } if ic.name != "" { - //Look for the package we want in the package list - for _, packs := range packages.Packages { + //Look for the pim we want in the pim list + for _, pimItem := range pims.Pims { //If we find it, set some variables and break - if packs.Name == packName { - pack = packs + if pimItem.Name == pimName { + pim = pimItem - for _, ver := range pack.Versions { - if ver.Version == packVersion { + for _, ver := range pim.Versions { + if ver.Version == pimVersion { found = true version = ver break @@ -120,12 +120,12 @@ func (ic *UpgradeCommand) Run() error { } } - //Make sure we have found the package in the package list + //Make sure we have found the pim in the pim list if !found { - return errors.New("Could not find package " + packName + " with version '" + packVersion + "' in the package list") + return errors.New("Could not find pim " + pimName + " with version '" + pimVersion + "' in the pim list") } - //Check if the corresponding package image is already installed + //Check if the corresponding pim image is already installed imgExist, err := ic.tools.ImageExists(version.Image, cli) //Check for errors @@ -133,12 +133,12 @@ func (ic *UpgradeCommand) Run() error { return err } - //If the image exists the package is already installed + //If the image exists the pim is already installed if !imgExist { - return errors.New("Package: " + pack.Name + " with version '" + version.Version + "' is not installed. It must be installed before it can be upgraded.") + return errors.New("pim: " + pim.Name + " with version '" + version.Version + "' is not installed. It must be installed before it can be upgraded.") } - fmt.Println("Upgrading", pack.Name+":"+version.Version) + fmt.Println("Upgrading", pim.Name+":"+version.Version) //Pull the image down from Docker Hub err = ic.tools.PullImage(version.Image, cli) @@ -146,7 +146,7 @@ func (ic *UpgradeCommand) Run() error { return err } - fmt.Println("Updating package directories") + fmt.Println("Updating pim directories") //Check the volumes and create the directories for them if they don't already exist for _, vol := range version.Volumes { @@ -189,15 +189,15 @@ func (ic *UpgradeCommand) Run() error { return err } - fmt.Println(pack.Name, "successfully upgraded") + fmt.Println(pim.Name, "successfully upgraded") } } else { - //Loop through the packages in the package list - for _, pack := range packages.Packages { + //Loop through the pims in the pim list + for _, pim := range pims.Pims { - for _, ver := range pack.Versions { - //Check if the corresponding package image is already installed + for _, ver := range pim.Versions { + //Check if the corresponding pim image is already installed imgExist, err := ic.tools.ImageExists(ver.Image, cli) //Check for errors @@ -205,12 +205,12 @@ func (ic *UpgradeCommand) Run() error { return err } - //If the image exists the package is already installed + //If the image exists the pim is already installed if !imgExist { continue } - fmt.Println("Upgrading", pack.Name+":"+ver.Version) + fmt.Println("Upgrading", pim.Name+":"+ver.Version) //Pull the image down from Docker Hub err = ic.tools.PullImage(ver.Image, cli) @@ -218,7 +218,7 @@ func (ic *UpgradeCommand) Run() error { return err } - fmt.Println("Updating package directories") + fmt.Println("Updating pim directories") //Check the volumes and create the directories for them if they don't already exist for _, vol := range ver.Volumes { @@ -261,7 +261,7 @@ func (ic *UpgradeCommand) Run() error { return err } - fmt.Println(pack.Name, "successfully upgraded") + fmt.Println(pim.Name, "successfully upgraded") } } diff --git a/subcommands/upgrade_sc_test.go b/subcommands/upgrade_sc_test.go index e78214b..b157bb3 100644 --- a/subcommands/upgrade_sc_test.go +++ b/subcommands/upgrade_sc_test.go @@ -39,7 +39,7 @@ func TestUpgradeInit(t *testing.T) { } if ic.name != args[0] { - t.Fatal("Package Name should have been initialized as: " + args[0] + " but is: " + ic.name) + t.Fatal("pim Name should have been initialized as: " + args[0] + " but is: " + ic.name) } } @@ -104,17 +104,17 @@ func TestUpgradeFlow(t *testing.T) { var updirs []string //Fill lists - for _, pack := range mu.Pack.Packages { + for _, pim := range mu.Pim.Pims { //Just use the first version - version := pack.Versions[0] + version := pim.Versions[0] images = append(images, version.Image) - //Loop through volumes in the package + //Loop through volumes in the pim for _, vol := range version.Volumes { updirs = append(updirs, ed+vol.Path) } - //Loop through the copies in the package + //Loop through the copies in the pim for _, copy := range version.Copies { copySources = append(copySources, copy.Source) copyDests = append(copyDests, ed+copy.Dest) @@ -522,7 +522,7 @@ func TestUpgradeImageNotExists(t *testing.T) { mu.ImgExist = false args := []string{"python"} - expectedErr := "Package: python with version 'latest' is not installed. It must be installed before it can be upgraded." + expectedErr := "pim: python with version 'latest' is not installed. It must be installed before it can be upgraded." mcp := &utils.MockCopyTool{} @@ -556,21 +556,21 @@ func TestUpgradeImageNotExists(t *testing.T) { } } -//Test the Upgrade subcommand with no arguments passed and 2 packages in the package list +//Test the Upgrade subcommand with no arguments passed and 2 packages in the pim list func TestUpgradeNoPackageWithTwoPacks(t *testing.T) { mu := utils.NewMockUtility() - mu.Pack.Packages = append(mu.Pack.Packages, utils.Package{ - Name: "package", - BaseDir: "/package", + mu.Pim.Pims = append(mu.Pim.Pims, utils.PackageImage{ + Name: "pim", + BaseDir: "/pim", Versions: []utils.Version{ { Version: "latest", - Image: "packageless/package", + Image: "packageless/pim", Volumes: []utils.Volume{ { - Path: "/package/config/", - Mount: "/package/config_data/", + Path: "/pim/config/", + Mount: "/pim/config_data/", }, }, Port: "4000", @@ -620,7 +620,7 @@ func TestUpgradeNoPackageWithTwoPacks(t *testing.T) { "ImageExists", "PullImage", "UpgradeDir", - //Second Package has no Copy fields so it should end at UpgradeDir + //Second pim has no Copy fields so it should end at UpgradeDir } //If the call stack doesn't match the test fails @@ -639,17 +639,17 @@ func TestUpgradeNoPackageWithTwoPacks(t *testing.T) { var updirs []string //Fill lists - for _, pack := range mu.Pack.Packages { + for _, pim := range mu.Pim.Pims { //Just get the first version - version := pack.Versions[0] + version := pim.Versions[0] images = append(images, version.Image) - //Loop through volumes in the package + //Loop through volumes in the pim for _, vol := range version.Volumes { updirs = append(updirs, ed+vol.Path) } - //Loop through the copies in the package + //Loop through the copies in the pim for _, copy := range version.Copies { copySources = append(copySources, copy.Source) copyDests = append(copyDests, ed+copy.Dest) @@ -694,7 +694,7 @@ func TestUpgradeNoPackageWithTwoPacks(t *testing.T) { } -//Test the Upgrade subcommand if the passed in package does not exist +//Test the Upgrade subcommand if the passed in pim does not exist func TestUpgradeNonExistPackage(t *testing.T) { mu := utils.NewMockUtility() @@ -704,7 +704,7 @@ func TestUpgradeNonExistPackage(t *testing.T) { args := []string{"nonexistent"} - expectedErr := "Could not find package nonexistent with version 'latest' in the package list" + expectedErr := "Could not find pim nonexistent with version 'latest' in the pim list" err := ic.Init(args) @@ -733,7 +733,7 @@ func TestUpgradeNonExistPackage(t *testing.T) { } } -//Test the Upgrade subcommand if the passed in package version does not exist +//Test the Upgrade subcommand if the passed in pim version does not exist func TestUpgradeNonExistVersion(t *testing.T) { mu := utils.NewMockUtility() @@ -743,7 +743,7 @@ func TestUpgradeNonExistVersion(t *testing.T) { args := []string{"python:idontexist"} - expectedErr := "Could not find package python with version 'idontexist' in the package list" + expectedErr := "Could not find pim python with version 'idontexist' in the pim list" err := ic.Init(args) diff --git a/testing/test_package_list.hcl b/testing/test_package_list.hcl index 84d128e..b7c98a0 100644 --- a/testing/test_package_list.hcl +++ b/testing/test_package_list.hcl @@ -1,4 +1,4 @@ -package "test" { +pim "test" { base_dir="/base" version "latest" { diff --git a/utils/hcl_parse.go b/utils/hcl_parse.go index b9156d4..f32e53f 100644 --- a/utils/hcl_parse.go +++ b/utils/hcl_parse.go @@ -21,7 +21,7 @@ type Volume struct { } //Package object to parse the package block in the package list -type Package struct { +type PackageImage struct { Name string `hcl:"name,label"` BaseDir string `hcl:"base_dir,attr"` Versions []Version `hcl:"version,block"` @@ -36,8 +36,8 @@ type Version struct { } //PackageHCLUtil object to contain a list of packages and all their attributes after the parsing of the package list -type PackageHCLUtil struct { - Packages []Package `hcl:"package,block"` +type PimHCLUtil struct { + Pims []PackageImage `hcl:"pim,block"` } //Config object to contain the configuration details @@ -55,19 +55,19 @@ func (u *Utility) ParseBody(body hcl.Body, out interface{}) (interface{}, error) default: return nil, errors.New("Unexpected type passed into the HCL parse function") - case PackageHCLUtil: + case PimHCLUtil: //Create the object to be decoded to - var packages PackageHCLUtil + var pims PimHCLUtil //Decode the parsed HCL to the Object - decodeDiags := gohcl.DecodeBody(body, nil, &packages) + decodeDiags := gohcl.DecodeBody(body, nil, &pims) //Check for errors if decodeDiags.HasErrors() { - return packages, errors.New("DecodeDiags: " + decodeDiags.Error()) + return pims, errors.New("DecodeDiags: " + decodeDiags.Error()) } - return packages, nil + return pims, nil case Config: //Create the object to be decoded to diff --git a/utils/hcl_parse_test.go b/utils/hcl_parse_test.go index 62d12ce..0b558a3 100644 --- a/utils/hcl_parse_test.go +++ b/utils/hcl_parse_test.go @@ -61,10 +61,10 @@ func TestParseBodyConfig(t *testing.T) { } } -//Test the parse body function with a package object that contains the optional copy fields +//Test the parse body function with a pim object that contains the optional copy fields func TestParseBodyPackageWithCopy(t *testing.T) { //Create the HCL byte array - hcl := []byte(`package "test_pack" { + hcl := []byte(`pim "test_pack" { base_dir="/base" version "latest" { image="test" @@ -99,29 +99,29 @@ func TestParseBodyPackageWithCopy(t *testing.T) { util := NewUtility() //Parse the HCL Body - parseOut, err := util.ParseBody(f.Body, PackageHCLUtil{}) + parseOut, err := util.ParseBody(f.Body, PimHCLUtil{}) if err != nil { t.Fatal(err) } - //Get the package object - packs := parseOut.(PackageHCLUtil) + //Get the pim object + packs := parseOut.(PimHCLUtil) - //If there is more or less than one package, the test should fail - if len(packs.Packages) != 1 { - t.Fatal("The # of packages expected is '1' | Received: " + strconv.Itoa(len(packs.Packages))) + //If there is more or less than one pim, the test should fail + if len(packs.Pims) != 1 { + t.Fatal("The # of packages expected is '1' | Received: " + strconv.Itoa(len(packs.Pims))) } - pack := packs.Packages[0] - //Make sure the package name is correct + pack := packs.Pims[0] + //Make sure the pim name is correct if pack.Name != "test_pack" { - t.Fatal("Package name should be 'test_pack' | Received: " + pack.Name) + t.Fatal("pim name should be 'test_pack' | Received: " + pack.Name) } - //Make sure the package base directory is correct + //Make sure the pim base directory is correct if pack.BaseDir != "/base" { - t.Fatal("Package base directory should be '/base' | Received: " + pack.BaseDir) + t.Fatal("pim base directory should be '/base' | Received: " + pack.BaseDir) } //Make sure there is only one version @@ -130,63 +130,63 @@ func TestParseBodyPackageWithCopy(t *testing.T) { t.Fatal("The # of versions expected is '1' | Received: " + strconv.Itoa(len(pack.Versions))) } - //Get the package version and make sure the fields are correct + //Get the pim version and make sure the fields are correct version := pack.Versions[0] if version.Version != "latest" { - t.Fatal("Package version should be 'latest' | Received: " + version.Version) + t.Fatal("pim version should be 'latest' | Received: " + version.Version) } - //Make sure the package port is correct + //Make sure the pim port is correct if version.Port != "3000" { - t.Fatal("Package port should be '3000' | Received: " + version.Port) + t.Fatal("pim port should be '3000' | Received: " + version.Port) } - //Make sure the package image is correct + //Make sure the pim image is correct if version.Image != "test" { - t.Fatal("Package image should be 'test' | Received: " + version.Image) + t.Fatal("pim image should be 'test' | Received: " + version.Image) } //Make sure the volumes array is of length 1 if len(version.Volumes) != 1 { - t.Fatal("Package # of volumes should be '1' | Received: " + strconv.Itoa(len(version.Volumes))) + t.Fatal("pim # of volumes should be '1' | Received: " + strconv.Itoa(len(version.Volumes))) } vol := version.Volumes[0] //Make sure the volumes array path is correct if vol.Path != "/test/path" { - t.Fatal("Package volume host path should be '/python/packages/' | Received: " + vol.Path) + t.Fatal("pim volume host path should be '/python/packages/' | Received: " + vol.Path) } //Make sure the volumes mount path is correct if vol.Mount != "/test/" { - t.Fatal("Package volume mount should be '/test/' | Received: " + vol.Mount) + t.Fatal("pim volume mount should be '/test/' | Received: " + vol.Mount) } //Make sure the copies array is of length 1 if len(version.Copies) != 1 { - t.Fatal("Package # of copies should be '1' | Received: " + strconv.Itoa(len(version.Copies))) + t.Fatal("pim # of copies should be '1' | Received: " + strconv.Itoa(len(version.Copies))) } cp := version.Copies[0] //Make sure the copy source is correct if cp.Source != "/test_source/" { - t.Fatal("Package copy source should be '/test_source/' | Received: " + cp.Source) + t.Fatal("pim copy source should be '/test_source/' | Received: " + cp.Source) } //Make sure the copy destination is correct if cp.Dest != "/test_dest/" { - t.Fatal("Package copy dest should be '/test_dest/' | Received: " + cp.Dest) + t.Fatal("pim copy dest should be '/test_dest/' | Received: " + cp.Dest) } } //Test -//Test the parse body function with a package object that does not container the optional copy fields +//Test the parse body function with a pim object that does not container the optional copy fields func TestParseBodyPackageNoCopy(t *testing.T) { //Create the HCL byte array - hcl := []byte(`package "test_pack" { + hcl := []byte(`pim "test_pack" { base_dir="/base" version "latest" { image="test" @@ -215,29 +215,29 @@ func TestParseBodyPackageNoCopy(t *testing.T) { util := NewUtility() //Parse the HCL Body - parseOut, err := util.ParseBody(f.Body, PackageHCLUtil{}) + parseOut, err := util.ParseBody(f.Body, PimHCLUtil{}) if err != nil { t.Fatal(err) } - //Get the package object - packs := parseOut.(PackageHCLUtil) + //Get the pim object + packs := parseOut.(PimHCLUtil) - //If there is more or less than one package, the test should fail - if len(packs.Packages) != 1 { - t.Fatal("The # of packages expected is '1' | Received: " + strconv.Itoa(len(packs.Packages))) + //If there is more or less than one pim, the test should fail + if len(packs.Pims) != 1 { + t.Fatal("The # of packages expected is '1' | Received: " + strconv.Itoa(len(packs.Pims))) } - pack := packs.Packages[0] - //Make sure the package name is correct + pack := packs.Pims[0] + //Make sure the pim name is correct if pack.Name != "test_pack" { - t.Fatal("Package name should be 'test_pack' | Received: " + pack.Name) + t.Fatal("pim name should be 'test_pack' | Received: " + pack.Name) } - //Make sure the package base directory is correct + //Make sure the pim base directory is correct if pack.BaseDir != "/base" { - t.Fatal("Package base directory should be '/base' | Received: " + pack.BaseDir) + t.Fatal("pim base directory should be '/base' | Received: " + pack.BaseDir) } //Make sure the number of versions is correct @@ -249,39 +249,39 @@ func TestParseBodyPackageNoCopy(t *testing.T) { version := pack.Versions[0] if version.Version != "latest" { - t.Fatal("Package version should be 'latest' | Received: " + version.Version) + t.Fatal("pim version should be 'latest' | Received: " + version.Version) } - //Make sure the package port is correct + //Make sure the pim port is correct if version.Port != "3000" { - t.Fatal("Package port should be '3000' | Received: " + version.Port) + t.Fatal("pim port should be '3000' | Received: " + version.Port) } - //Make sure the package image is correct + //Make sure the pim image is correct if version.Image != "test" { - t.Fatal("Package image should be 'test' | Received: " + version.Image) + t.Fatal("pim image should be 'test' | Received: " + version.Image) } //Make sure the volumes array is of length 1 if len(version.Volumes) != 1 { - t.Fatal("Package # of volumes should be '1' | Received: " + strconv.Itoa(len(version.Volumes))) + t.Fatal("pim # of volumes should be '1' | Received: " + strconv.Itoa(len(version.Volumes))) } vol := version.Volumes[0] //Make sure the volumes array path is correct if vol.Path != "/test/path" { - t.Fatal("Package volume host path should be '/python/packages/' | Received: " + vol.Path) + t.Fatal("pim volume host path should be '/python/packages/' | Received: " + vol.Path) } //Make sure the volumes mount path is correct if vol.Mount != "/test/" { - t.Fatal("Package volume mount should be '/test/' | Received: " + vol.Mount) + t.Fatal("pim volume mount should be '/test/' | Received: " + vol.Mount) } //Make sure the copies array is empty if len(version.Copies) > 0 { - t.Fatal("Package # of copies should be '0' | Received: " + strconv.Itoa(len(version.Copies))) + t.Fatal("pim # of copies should be '0' | Received: " + strconv.Itoa(len(version.Copies))) } } @@ -339,7 +339,7 @@ func TestHCLParse_Integration_Config(t *testing.T) { } -//Integration test for reading the test package list file +//Integration test for reading the test pim list file func TestHCLParse_Integration_PackageList(t *testing.T) { //Create the util tool util := NewUtility() @@ -353,7 +353,7 @@ func TestHCLParse_Integration_PackageList(t *testing.T) { } //Parse the HCL Body into an object - parseOut, err := util.ParseBody(body, PackageHCLUtil{}) + parseOut, err := util.ParseBody(body, PimHCLUtil{}) //Shouldn't throw an error if err != nil { @@ -361,7 +361,7 @@ func TestHCLParse_Integration_PackageList(t *testing.T) { } //Get the parsed object - packs := parseOut.(PackageHCLUtil) + packs := parseOut.(PimHCLUtil) //Set expected variables pLen := 1 @@ -380,80 +380,80 @@ func TestHCLParse_Integration_PackageList(t *testing.T) { cpDest := "/a/dest" //Ensure packages length is correct - if len(packs.Packages) != pLen { - t.Fatalf("Parse HCL Integration: Expected Packages Length: %d | Received: %d", pLen, len(packs.Packages)) + if len(packs.Pims) != pLen { + t.Fatalf("Parse HCL Integration: Expected Packages Length: %d | Received: %d", pLen, len(packs.Pims)) } - p := packs.Packages[0] + p := packs.Pims[0] version := p.Versions[0] if version.Version != pVersion { - t.Fatalf("Parse HCL Intergration: Expected Package Version: %s | Received: %s", pVersion, version.Version) + t.Fatalf("Parse HCL Intergration: Expected pim Version: %s | Received: %s", pVersion, version.Version) } - //Ensure the package name is correct + //Ensure the pim name is correct if p.Name != pName { - t.Fatalf("Parse HCL Integration: Expected Package Name: %s | Received: %s", pName, p.Name) + t.Fatalf("Parse HCL Integration: Expected pim Name: %s | Received: %s", pName, p.Name) } - //Ensure the package image is correct + //Ensure the pim image is correct if version.Image != pImage { - t.Fatalf("Parse HCL Integration: Expected Package Image: %s | Received: %s", pImage, version.Image) + t.Fatalf("Parse HCL Integration: Expected pim Image: %s | Received: %s", pImage, version.Image) } - //Ensure the package base directory is correct + //Ensure the pim base directory is correct if p.BaseDir != pBD { - t.Fatalf("ParseHCL Integration: Expected Package BaseDir: %s | Received: %s", pBD, p.BaseDir) + t.Fatalf("ParseHCL Integration: Expected pim BaseDir: %s | Received: %s", pBD, p.BaseDir) } - //Ensure the package port is correct + //Ensure the pim port is correct if version.Port != pPort { - t.Fatalf("ParseHCL Integration: Expected Package Port: %s | Received: %s", pPort, version.Port) + t.Fatalf("ParseHCL Integration: Expected pim Port: %s | Received: %s", pPort, version.Port) } //Ensure the volumes length matches if len(version.Volumes) != vLen { - t.Fatalf("ParseHCL Integration: Expected Package Volumes Len: %d | Received: %d", vLen, len(version.Volumes)) + t.Fatalf("ParseHCL Integration: Expected pim Volumes Len: %d | Received: %d", vLen, len(version.Volumes)) } vols := version.Volumes //Ensure the first volume path matches if vols[0].Path != v1Path { - t.Fatalf("ParseHCL Integration: Expected Package Volume 1 Path: %s | Received: %s", v1Path, vols[0].Path) + t.Fatalf("ParseHCL Integration: Expected pim Volume 1 Path: %s | Received: %s", v1Path, vols[0].Path) } //Ensure the first volume mount path matches if vols[0].Mount != v1Mount { - t.Fatalf("ParseHCL Integration: Expected Package Volume 1 Mount: %s | Received: %s", v1Mount, vols[0].Mount) + t.Fatalf("ParseHCL Integration: Expected pim Volume 1 Mount: %s | Received: %s", v1Mount, vols[0].Mount) } //Ensure the second volume path matches if vols[1].Path != v2Path { - t.Fatalf("ParseHCL Integration: Expected Package Volume 2 Path: %s | Received: %s", v2Path, vols[1].Path) + t.Fatalf("ParseHCL Integration: Expected pim Volume 2 Path: %s | Received: %s", v2Path, vols[1].Path) } //Ensure the second volume mount matches if vols[1].Mount != v2Mount { - t.Fatalf("ParseHCL Integration: Expected Package Volume 2 Mount: %s | Received: %s", v2Mount, vols[1].Mount) + t.Fatalf("ParseHCL Integration: Expected pim Volume 2 Mount: %s | Received: %s", v2Mount, vols[1].Mount) } //Ensure the copies length matches if len(version.Copies) != cpLen { - t.Fatalf("ParseHCL Integration: Expected Package Copies Len: %d | Received: %d", cpLen, len(version.Copies)) + t.Fatalf("ParseHCL Integration: Expected pim Copies Len: %d | Received: %d", cpLen, len(version.Copies)) } cp := version.Copies[0] //Ensure the copy source matches if cp.Source != cpSource { - t.Fatalf("ParseHCL Integration: Expected Package Copy Source: %s | Received: %s", cpSource, cp.Source) + t.Fatalf("ParseHCL Integration: Expected pim Copy Source: %s | Received: %s", cpSource, cp.Source) } //Ensure the copy dest matches if cp.Dest != cpDest { - t.Fatalf("ParseHCL Integration: Expected Package Copy Dest: %s | Received: %s", cpDest, cp.Dest) + t.Fatalf("ParseHCL Integration: Expected pim Copy Dest: %s | Received: %s", cpDest, cp.Dest) } } diff --git a/utils/mocks.go b/utils/mocks.go index 4b06a6d..451227c 100644 --- a/utils/mocks.go +++ b/utils/mocks.go @@ -20,7 +20,7 @@ type MockUtility struct { Calls []string //Package object that can be changed for different tests - Pack PackageHCLUtil + Pim PimHCLUtil //Config Object that can be changed for different tests Conf Config @@ -86,8 +86,8 @@ type MockUtility struct { //Create a new Mock Utility and set any default variables func NewMockUtility() *MockUtility { mu := &MockUtility{ - Pack: PackageHCLUtil{ - Packages: []Package{ + Pim: PimHCLUtil{ + Pims: []PackageImage{ { Name: "python", BaseDir: "/base", @@ -186,8 +186,8 @@ func (mu *MockUtility) ParseBody(body hcl.Body, out interface{}) (interface{}, e switch out.(type) { default: return nil, errors.New("Unexpected type in parse") - case PackageHCLUtil: - return mu.Pack, nil + case PimHCLUtil: + return mu.Pim, nil case Config: return mu.Conf, nil } From cfa13af1498497a6bff34fe1acbe0c8e1d4893f2 Mon Sep 17 00:00:00 2001 From: Bryce Palmer Date: Sun, 10 Oct 2021 12:25:16 -0400 Subject: [PATCH 2/2] doc changes --- docs/docs/cli/subcommands/install.md | 8 ++++---- docs/docs/cli/subcommands/run.md | 4 ++-- docs/docs/cli/subcommands/uninstall.md | 8 ++++---- docs/docs/cli/subcommands/upgrade.md | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/docs/cli/subcommands/install.md b/docs/docs/cli/subcommands/install.md index abe98d9..6e3c39d 100644 --- a/docs/docs/cli/subcommands/install.md +++ b/docs/docs/cli/subcommands/install.md @@ -5,19 +5,19 @@ title: install ## Usage ``` -packageless install [PACKAGE] +packageless install [pim] ``` -Packages follow a particular format. If you specify just the package that you want installed, the latest version of the package that **packageless** has will be installed. +Packages follow a particular format. If you specify just the pim that you want installed, the latest version of the pim that **packageless** has will be installed. You can also specify a particular version by following this format: ``` -package:version +pim:version ``` To manually specify that you want the latest version you can use: ``` -package:latest +pim:latest ``` however, **packageless** defaults to getting the latest version if one is not specified diff --git a/docs/docs/cli/subcommands/run.md b/docs/docs/cli/subcommands/run.md index bd76910..4c0719d 100644 --- a/docs/docs/cli/subcommands/run.md +++ b/docs/docs/cli/subcommands/run.md @@ -5,10 +5,10 @@ title: run ## Usage ``` -packageless run [PACKAGE] +packageless run [pim] ``` -When using this subcommand, **packageless** will run the package that is specified as long as it is installed. If the package is not installed the command will exit with text stating that the package specified is not installed. If you installed a specific version of a package, you will need to use the same syntax for the package for this command as well. +When using this subcommand, **packageless** will run the pim that is specified as long as it is installed. If the pim is not installed the command will exit with text stating that the pim specified is not installed. If you installed a specific version of a pim, you will need to use the same syntax for the pim for this command as well. ## Examples :::note diff --git a/docs/docs/cli/subcommands/uninstall.md b/docs/docs/cli/subcommands/uninstall.md index a3eeebe..171328a 100644 --- a/docs/docs/cli/subcommands/uninstall.md +++ b/docs/docs/cli/subcommands/uninstall.md @@ -5,19 +5,19 @@ title: uninstall ## Usage ``` -packageless uninstall [PACKAGE] +packageless uninstall [pim] ``` -Packages follow a particular format. If you specify just the package that you want uninstalled, the latest version of the package that **packageless** has will be uninstalled. +Packages follow a particular format. If you specify just the pim that you want uninstalled, the latest version of the pim that **packageless** has will be uninstalled. You can also specify a particular version by following this format: ``` -package:version +pim:version ``` To manually specify that you want the latest version you can use: ``` -package:latest +pim:latest ``` however, **packageless** defaults to getting the latest version if one is not specified diff --git a/docs/docs/cli/subcommands/upgrade.md b/docs/docs/cli/subcommands/upgrade.md index bceb2a3..3546775 100644 --- a/docs/docs/cli/subcommands/upgrade.md +++ b/docs/docs/cli/subcommands/upgrade.md @@ -5,21 +5,21 @@ title: upgrade ## Usage ``` -packageless upgrade [OPTIONAL: PACKAGE] +packageless upgrade [OPTIONAL: PIM] ``` -This subcommand will upgrade the package with the current package information in the package list as long as the package is already installed. If a package is not specified it will upgrade all installed packages. +This subcommand will upgrade the pim with the current pim information in the pim list as long as the pim is already installed. If a pim is not specified it will upgrade all installed packages. -Packages follow a particular format. If you specify just the package that you want upgraded, the latest version of the package that **packageless** has will be upgraded. +Packages follow a particular format. If you specify just the pim that you want upgraded, the latest version of the pim that **packageless** has will be upgraded. You can also specify a particular version by following this format: ``` -package:version +pim:version ``` To manually specify that you want the latest version you can use: ``` -package:latest +pim:latest ``` however, **packageless** defaults to getting the latest version if one is not specified