Update metadataPath using set-manifest in cli

* Added metatada-path as a flag to set-manifest

Change-Id: Id26f20c4a6350b4aae34da850bbfcab42cbe9f21
This commit is contained in:
Sirajudeen 2020-09-24 14:28:30 +00:00
parent 29088b7b42
commit 2769c62c8a
7 changed files with 83 additions and 61 deletions

View File

@ -145,5 +145,11 @@ func addSetManifestFlags(o *config.ManifestOptions, cmd *cobra.Command) {
&o.TargetPath, &o.TargetPath,
"target-path", "target-path",
"", "",
"the target path for to be set for this manifest") "the target path to be set for this manifest")
flags.StringVar(
&o.MetadataPath,
"metadata-path",
"",
"the metadata path to be set for this manifest")
} }

View File

@ -28,21 +28,24 @@ import (
) )
const ( const (
mName = "dummymanifest" mName = "dummymanifest"
mRepoName = "treasuremap" mRepoName = "treasuremap"
mURL = "https://github.com/airshipit/treasuremap" mURL = "https://github.com/airshipit/treasuremap"
mBranch = "master" mBranch = "master"
mSubPath = "manifests/test-site" mSubPath = "manifests/test-site"
mTargetPath = "/tmp/airship" mTargetPath = "/tmp/airship"
mMetadataPath = "manifests/metadata.yaml"
testTargetPath = "/tmp/e2e" testTargetPath = "/tmp/e2e"
testMetadataPath = "manifests/docker_metadata.yaml"
) )
type setManifestTest struct { type setManifestTest struct {
inputConfig *config.Config inputConfig *config.Config
cmdTest *testutil.CmdTest cmdTest *testutil.CmdTest
manifestName string manifestName string
manifestTargetPath string manifestTargetPath string
manifestMetadataPath string
} }
func TestConfigSetManifest(t *testing.T) { func TestConfigSetManifest(t *testing.T) {
@ -81,6 +84,7 @@ func TestSetManifest(t *testing.T) {
flags []string flags []string
givenConfig *config.Config givenConfig *config.Config
targetPath string targetPath string
metadataPath string
}{ }{
{ {
testName: "set-manifest", testName: "set-manifest",
@ -92,18 +96,22 @@ func TestSetManifest(t *testing.T) {
"--primary", "--primary",
"--sub-path " + mSubPath, "--sub-path " + mSubPath,
"--target-path " + mTargetPath, "--target-path " + mTargetPath,
"--metadata-path " + mMetadataPath,
}, },
givenConfig: given, givenConfig: given,
targetPath: mTargetPath, targetPath: mTargetPath,
metadataPath: mMetadataPath,
}, },
{ {
testName: "modify-manifest", testName: "modify-manifest",
manifestName: mName, manifestName: mName,
flags: []string{ flags: []string{
"--target-path " + testTargetPath, "--target-path " + testTargetPath,
"--metadata-path " + testMetadataPath,
}, },
givenConfig: given, givenConfig: given,
targetPath: testTargetPath, targetPath: testTargetPath,
metadataPath: mMetadataPath,
}, },
} }
@ -114,10 +122,11 @@ func TestSetManifest(t *testing.T) {
CmdLine: fmt.Sprintf("%s %s", tt.manifestName, strings.Join(tt.flags, " ")), CmdLine: fmt.Sprintf("%s %s", tt.manifestName, strings.Join(tt.flags, " ")),
} }
test := setManifestTest{ test := setManifestTest{
inputConfig: tt.givenConfig, inputConfig: tt.givenConfig,
cmdTest: cmd, cmdTest: cmd,
manifestName: tt.manifestName, manifestName: tt.manifestName,
manifestTargetPath: tt.targetPath, manifestTargetPath: tt.targetPath,
manifestMetadataPath: tt.metadataPath,
} }
test.run(t) test.run(t)
} }

View File

@ -28,14 +28,15 @@ airshipctl config set-manifest e2e \
Flags: Flags:
--branch string the branch to be associated with repository in this manifest --branch string the branch to be associated with repository in this manifest
--commithash string the commit hash to be associated with repository in this manifest --commithash string the commit hash to be associated with repository in this manifest
--force if set, enable force checkout in repository with this manifest --force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest -h, --help help for set-manifest
--primary if set, enable this repository as primary repository to be used with this manifest --metadata-path string the metadata path to be set for this manifest
--repo string the name of the repository to be associated with this manifest --primary if set, enable this repository as primary repository to be used with this manifest
--sub-path string the sub path to be set for this manifest --repo string the name of the repository to be associated with this manifest
--tag string the tag to be associated with repository in this manifest --sub-path string the sub path to be set for this manifest
--target-path string the target path for to be set for this manifest --tag string the tag to be associated with repository in this manifest
--url string the repository url to be associated with this manifest --target-path string the target path to be set for this manifest
--url string the repository url to be associated with this manifest

View File

@ -28,14 +28,15 @@ airshipctl config set-manifest e2e \
Flags: Flags:
--branch string the branch to be associated with repository in this manifest --branch string the branch to be associated with repository in this manifest
--commithash string the commit hash to be associated with repository in this manifest --commithash string the commit hash to be associated with repository in this manifest
--force if set, enable force checkout in repository with this manifest --force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest -h, --help help for set-manifest
--primary if set, enable this repository as primary repository to be used with this manifest --metadata-path string the metadata path to be set for this manifest
--repo string the name of the repository to be associated with this manifest --primary if set, enable this repository as primary repository to be used with this manifest
--sub-path string the sub path to be set for this manifest --repo string the name of the repository to be associated with this manifest
--tag string the tag to be associated with repository in this manifest --sub-path string the sub path to be set for this manifest
--target-path string the target path for to be set for this manifest --tag string the tag to be associated with repository in this manifest
--url string the repository url to be associated with this manifest --target-path string the target path to be set for this manifest
--url string the repository url to be associated with this manifest

View File

@ -29,13 +29,14 @@ airshipctl config set-manifest e2e \
Flags: Flags:
--branch string the branch to be associated with repository in this manifest --branch string the branch to be associated with repository in this manifest
--commithash string the commit hash to be associated with repository in this manifest --commithash string the commit hash to be associated with repository in this manifest
--force if set, enable force checkout in repository with this manifest --force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest -h, --help help for set-manifest
--primary if set, enable this repository as primary repository to be used with this manifest --metadata-path string the metadata path to be set for this manifest
--repo string the name of the repository to be associated with this manifest --primary if set, enable this repository as primary repository to be used with this manifest
--sub-path string the sub path to be set for this manifest --repo string the name of the repository to be associated with this manifest
--tag string the tag to be associated with repository in this manifest --sub-path string the sub path to be set for this manifest
--target-path string the target path for to be set for this manifest --tag string the tag to be associated with repository in this manifest
--url string the repository url to be associated with this manifest --target-path string the target path to be set for this manifest
--url string the repository url to be associated with this manifest

View File

@ -515,6 +515,9 @@ func (c *Config) ModifyManifest(manifest *Manifest, theManifest *ManifestOptions
if theManifest.TargetPath != "" { if theManifest.TargetPath != "" {
manifest.TargetPath = theManifest.TargetPath manifest.TargetPath = theManifest.TargetPath
} }
if theManifest.MetadataPath != "" {
manifest.MetadataPath = theManifest.MetadataPath
}
// There is no repository details to be updated // There is no repository details to be updated
if theManifest.RepoName == "" { if theManifest.RepoName == "" {
return nil return nil

View File

@ -33,17 +33,18 @@ type ContextOptions struct {
// ManifestOptions holds all configurable options for manifest configuration // ManifestOptions holds all configurable options for manifest configuration
type ManifestOptions struct { type ManifestOptions struct {
Name string Name string
RepoName string RepoName string
URL string URL string
Branch string Branch string
CommitHash string CommitHash string
Tag string Tag string
RemoteRef string RemoteRef string
Force bool Force bool
IsPrimary bool IsPrimary bool
SubPath string SubPath string
TargetPath string TargetPath string
MetadataPath string
} }
// EncryptionConfigOptions holds all configurable options for encryption configuration // EncryptionConfigOptions holds all configurable options for encryption configuration