Refactor subPath out of config manifests

This change removes the SubPath entry portion of the config manifests, and
refactors several areas that used it. This also updates unit tests to
reflect the new changes.

Closes: #255

Change-Id: Ibbb519a3f1fb28a1594e971274c5de54b99c867e
This commit is contained in:
Michael Beaver 2020-10-01 11:04:14 -05:00
parent c86bbeaed9
commit 193dc935f1
29 changed files with 14 additions and 86 deletions

View File

@ -25,8 +25,8 @@ const (
initLong = ` initLong = `
Initialize cluster-api providers based on airshipctl document set. Initialize cluster-api providers based on airshipctl document set.
document set must contain document of Kind: Clusterctl in phase initinfra. document set must contain document of Kind: Clusterctl in phase initinfra.
Path to initinfra phase is built based on airshipctl config Path to initinfra phase is defined in the initinfra phase document located
<manifest.target-path>/<subpath>/ephemeral/initinfra. in the manifest repository.
Clusterctl document example: Clusterctl document example:
--- ---
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1

View File

@ -1,8 +1,8 @@
Initialize cluster-api providers based on airshipctl document set. Initialize cluster-api providers based on airshipctl document set.
document set must contain document of Kind: Clusterctl in phase initinfra. document set must contain document of Kind: Clusterctl in phase initinfra.
Path to initinfra phase is built based on airshipctl config Path to initinfra phase is defined in the initinfra phase document located
<manifest.target-path>/<subpath>/ephemeral/initinfra. in the manifest repository.
Clusterctl document example: Clusterctl document example:
--- ---
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1

View File

@ -35,7 +35,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \ --url https://github.com/site \
--branch master \ --branch master \
--phase \ --phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath --target-path exampleTargetpath
# Change the phase repo for manifest # Change the phase repo for manifest
@ -43,10 +42,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \ --repo exampleRepo \
--phase --phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest # Change the target-path for manifest
airshipctl config set-manifest e2e \ airshipctl config set-manifest e2e \
--target-path /tmp/e2e --target-path /tmp/e2e
@ -135,12 +130,6 @@ func addSetManifestFlags(o *config.ManifestOptions, cmd *cobra.Command) {
false, false,
"if set, enable this repository as phase repository to be used with this manifest") "if set, enable this repository as phase repository to be used with this manifest")
flags.StringVar(
&o.SubPath,
"sub-path",
"",
"the sub path to be set for this manifest")
flags.StringVar( flags.StringVar(
&o.TargetPath, &o.TargetPath,
"target-path", "target-path",

View File

@ -32,7 +32,6 @@ const (
mRepoName = "treasuremap" mRepoName = "treasuremap"
mURL = "https://github.com/airshipit/treasuremap" mURL = "https://github.com/airshipit/treasuremap"
mBranch = "master" mBranch = "master"
mSubPath = "manifests/test-site"
mTargetPath = "/tmp/airship" mTargetPath = "/tmp/airship"
mMetadataPath = "manifests/metadata.yaml" mMetadataPath = "manifests/metadata.yaml"
@ -94,7 +93,6 @@ func TestSetManifest(t *testing.T) {
"--url " + mURL, "--url " + mURL,
"--branch " + mBranch, "--branch " + mBranch,
"--phase", "--phase",
"--sub-path " + mSubPath,
"--target-path " + mTargetPath, "--target-path " + mTargetPath,
"--metadata-path " + mMetadataPath, "--metadata-path " + mMetadataPath,
}, },

View File

@ -10,7 +10,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \ --url https://github.com/site \
--branch master \ --branch master \
--phase \ --phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath --target-path exampleTargetpath
# Change the phase repo for manifest # Change the phase repo for manifest
@ -18,10 +17,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \ --repo exampleRepo \
--phase --phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest # Change the target-path for manifest
airshipctl config set-manifest e2e \ airshipctl config set-manifest e2e \
--target-path /tmp/e2e --target-path /tmp/e2e
@ -35,7 +30,6 @@ Flags:
--metadata-path string the metadata path to be set for this manifest --metadata-path string the metadata path to be set for this manifest
--phase if set, enable this repository as phase repository to be used with this manifest --phase if set, enable this repository as phase repository to be used with this manifest
--repo string the name of the repository to be associated with this manifest --repo string the name of the repository to be associated with this manifest
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest --tag string the tag to be associated with repository in this manifest
--target-path string the target path to be set for 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 --url string the repository url to be associated with this manifest

View File

@ -10,7 +10,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \ --url https://github.com/site \
--branch master \ --branch master \
--phase \ --phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath --target-path exampleTargetpath
# Change the phase repo for manifest # Change the phase repo for manifest
@ -18,10 +17,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \ --repo exampleRepo \
--phase --phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest # Change the target-path for manifest
airshipctl config set-manifest e2e \ airshipctl config set-manifest e2e \
--target-path /tmp/e2e --target-path /tmp/e2e
@ -35,7 +30,6 @@ Flags:
--metadata-path string the metadata path to be set for this manifest --metadata-path string the metadata path to be set for this manifest
--phase if set, enable this repository as phase repository to be used with this manifest --phase if set, enable this repository as phase repository to be used with this manifest
--repo string the name of the repository to be associated with this manifest --repo string the name of the repository to be associated with this manifest
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest --tag string the tag to be associated with repository in this manifest
--target-path string the target path to be set for 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 --url string the repository url to be associated with this manifest

View File

@ -11,7 +11,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \ --url https://github.com/site \
--branch master \ --branch master \
--phase \ --phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath --target-path exampleTargetpath
# Change the phase repo for manifest # Change the phase repo for manifest
@ -19,10 +18,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \ --repo exampleRepo \
--phase --phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest # Change the target-path for manifest
airshipctl config set-manifest e2e \ airshipctl config set-manifest e2e \
--target-path /tmp/e2e --target-path /tmp/e2e
@ -36,7 +31,6 @@ Flags:
--metadata-path string the metadata path to be set for this manifest --metadata-path string the metadata path to be set for this manifest
--phase if set, enable this repository as phase repository to be used with this manifest --phase if set, enable this repository as phase repository to be used with this manifest
--repo string the name of the repository to be associated with this manifest --repo string the name of the repository to be associated with this manifest
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest --tag string the tag to be associated with repository in this manifest
--target-path string the target path to be set for 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 --url string the repository url to be associated with this manifest

View File

@ -1,15 +1,12 @@
metadataPath: "" metadataPath: ""
phaseRepositoryName: bar_phase_repo phaseRepositoryName: bar_phase_repo
subPath: ""
targetPath: bar_target_path targetPath: bar_target_path
metadataPath: "" metadataPath: ""
phaseRepositoryName: baz_phase_repo phaseRepositoryName: baz_phase_repo
subPath: ""
targetPath: baz_target_path targetPath: baz_target_path
metadataPath: "" metadataPath: ""
phaseRepositoryName: foo_phase_repo phaseRepositoryName: foo_phase_repo
subPath: ""
targetPath: foo_target_path targetPath: foo_target_path

View File

@ -1,5 +1,4 @@
metadataPath: "" metadataPath: ""
phaseRepositoryName: foo_phase_repo phaseRepositoryName: foo_phase_repo
subPath: ""
targetPath: foo_target_path targetPath: foo_target_path

View File

@ -155,7 +155,8 @@ managementConfiguration:
type: azure type: azure
manifests: manifests:
azure_manifest: azure_manifest:
primaryRepositoryName: primary phaseRepositoryName: primary
metadataPath: manifests/site/az-test-site/metadata.yaml
repositories: repositories:
primary: primary:
checkout: checkout:
@ -164,10 +165,10 @@ manifests:
force: false force: false
tag: "" tag: ""
url: https://review.opendev.org/airship/airshipctl url: https://review.opendev.org/airship/airshipctl
subPath: airshipctl/manifests/site/az-test-site
targetPath: /tmp/airship targetPath: /tmp/airship
default: default:
primaryRepositoryName: primary phaseRepositoryName: primary
metadataPath: manifests/metadata.yaml
repositories: repositories:
primary: primary:
checkout: checkout:
@ -176,6 +177,5 @@ manifests:
force: false force: false
tag: "" tag: ""
url: https://opendev.org/airship/treasuremap url: https://opendev.org/airship/treasuremap
subPath: treasuremap/manifests/site
targetPath: /tmp/default targetPath: /tmp/default
``` ```

View File

@ -7,8 +7,8 @@ Deploy cluster-api provider components
Initialize cluster-api providers based on airshipctl document set. Initialize cluster-api providers based on airshipctl document set.
document set must contain document of Kind: Clusterctl in phase initinfra. document set must contain document of Kind: Clusterctl in phase initinfra.
Path to initinfra phase is built based on airshipctl config Path to initinfra phase is defined in the initinfra phase document located
<manifest.target-path>/<subpath>/ephemeral/initinfra. in the manifest repository.
Clusterctl document example: Clusterctl document example:
--- ---
apiVersion: airshipit.org/v1alpha1 apiVersion: airshipit.org/v1alpha1

View File

@ -21,7 +21,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \ --url https://github.com/site \
--branch master \ --branch master \
--phase \ --phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath --target-path exampleTargetpath
# Change the phase repo for manifest # Change the phase repo for manifest
@ -29,10 +28,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \ --repo exampleRepo \
--phase --phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest # Change the target-path for manifest
airshipctl config set-manifest e2e \ airshipctl config set-manifest e2e \
--target-path /tmp/e2e --target-path /tmp/e2e
@ -49,7 +44,6 @@ airshipctl config set-manifest e2e \
--metadata-path string the metadata path to be set for this manifest --metadata-path string the metadata path to be set for this manifest
--phase if set, enable this repository as phase repository to be used with this manifest --phase if set, enable this repository as phase repository to be used with this manifest
--repo string the name of the repository to be associated with this manifest --repo string the name of the repository to be associated with this manifest
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest --tag string the tag to be associated with repository in this manifest
--target-path string the target path to be set for 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 --url string the repository url to be associated with this manifest

View File

View File

@ -19,5 +19,4 @@ manifests:
remoteRef: "" remoteRef: ""
tag: v1.0.1 tag: v1.0.1
url: http://dummy.url.com/primary.git url: http://dummy.url.com/primary.git
subPath: site
targetPath: testdata targetPath: testdata

View File

@ -46,7 +46,6 @@ func TestNewCommand(t *testing.T) {
manifests: map[string]*config.Manifest{ manifests: map[string]*config.Manifest{
manifestName: { manifestName: {
TargetPath: "testdata", TargetPath: "testdata",
SubPath: "valid",
PhaseRepositoryName: "primary", PhaseRepositoryName: "primary",
MetadataPath: "metadata.yaml", MetadataPath: "metadata.yaml",
Repositories: map[string]*config.Repository{ Repositories: map[string]*config.Repository{
@ -62,7 +61,6 @@ func TestNewCommand(t *testing.T) {
manifests: map[string]*config.Manifest{ manifests: map[string]*config.Manifest{
manifestName: { manifestName: {
TargetPath: "testdata", TargetPath: "testdata",
SubPath: "invalid-path",
PhaseRepositoryName: "primary", PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{ Repositories: map[string]*config.Repository{
"primary": {}, "primary": {},
@ -77,7 +75,6 @@ func TestNewCommand(t *testing.T) {
manifests: map[string]*config.Manifest{ manifests: map[string]*config.Manifest{
manifestName: { manifestName: {
TargetPath: "testdata", TargetPath: "testdata",
SubPath: "no-clusterctl",
PhaseRepositoryName: "primary", PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{ Repositories: map[string]*config.Repository{
"primary": {}, "primary": {},
@ -89,9 +86,7 @@ func TestNewCommand(t *testing.T) {
name: "no phase repo", name: "no phase repo",
expectErr: true, expectErr: true,
manifests: map[string]*config.Manifest{ manifests: map[string]*config.Manifest{
manifestName: { manifestName: {},
SubPath: "no-clusterctl",
},
}, },
}, },
{ {
@ -101,7 +96,6 @@ func TestNewCommand(t *testing.T) {
manifests: map[string]*config.Manifest{ manifests: map[string]*config.Manifest{
manifestName: { manifestName: {
TargetPath: "testdata", TargetPath: "testdata",
SubPath: "can't build bundle",
PhaseRepositoryName: "primary", PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{ Repositories: map[string]*config.Repository{
"primary": {}, "primary": {},

View File

@ -19,5 +19,4 @@ manifests:
remoteRef: "" remoteRef: ""
tag: v1.0.1 tag: v1.0.1
url: http://dummy.url.com/primary.git url: http://dummy.url.com/primary.git
subPath: site
targetPath: testdata targetPath: testdata

View File

@ -375,9 +375,6 @@ func (c *Config) ModifyManifest(manifest *Manifest, theManifest *ManifestOptions
if theManifest.IsPhase { if theManifest.IsPhase {
manifest.PhaseRepositoryName = theManifest.RepoName manifest.PhaseRepositoryName = theManifest.RepoName
} }
if theManifest.SubPath != "" {
manifest.SubPath = theManifest.SubPath
}
if theManifest.TargetPath != "" { if theManifest.TargetPath != "" {
manifest.TargetPath = theManifest.TargetPath manifest.TargetPath = theManifest.TargetPath
} }

View File

@ -62,8 +62,6 @@ const (
DefaultTestPhaseRepo = "primary" DefaultTestPhaseRepo = "primary"
// DefaultTargetPath holds default target path // DefaultTargetPath holds default target path
DefaultTargetPath = "/tmp/default" DefaultTargetPath = "/tmp/default"
// DefaultSubPath holds default sub path
DefaultSubPath = "manifest/default"
// DefaultManifestMetadataFile default path to manifest metadata file // DefaultManifestMetadataFile default path to manifest metadata file
DefaultManifestMetadataFile = "manifests/site/test-site/metadata.yaml" DefaultManifestMetadataFile = "manifests/site/test-site/metadata.yaml"
) )

View File

@ -26,13 +26,6 @@ type Manifest struct {
Repositories map[string]*Repository `json:"repositories,omitempty"` Repositories map[string]*Repository `json:"repositories,omitempty"`
// TargetPath Local Target path for working or home directory for all Manifest Cloned/Returned/Generated // TargetPath Local Target path for working or home directory for all Manifest Cloned/Returned/Generated
TargetPath string `json:"targetPath"` TargetPath string `json:"targetPath"`
// SubPath is a path relative to TargetPath + Path where PhaseRepository is cloned and contains
// directories with ClusterType and Phase bundles, example:
// Repositories[PhaseRepositoryName].Url = 'https://github.com/airshipit/treasuremap'
// SubPath = "manifests"
// you would expect that at treasuremap/manifests you would have ephemeral/initinfra and
// ephemera/target directories, containing kustomize.yaml.
SubPath string `json:"subPath"`
// MetadataPath path to a metadata file relative to TargetPath // MetadataPath path to a metadata file relative to TargetPath
MetadataPath string `json:"metadataPath"` MetadataPath string `json:"metadataPath"`
} }

View File

@ -41,7 +41,6 @@ type ManifestOptions struct {
RemoteRef string RemoteRef string
Force bool Force bool
IsPhase bool IsPhase bool
SubPath string
TargetPath string TargetPath string
MetadataPath string MetadataPath string
} }

View File

@ -30,7 +30,6 @@ manifests:
force: false force: false
tag: v1.0.1 tag: v1.0.1
url: http://dummy.url.com/manifests.git url: http://dummy.url.com/manifests.git
subPath: manifests/site/test-site
targetPath: /var/tmp/ targetPath: /var/tmp/
permissions: permissions:
DirectoryPermission: 488 DirectoryPermission: 488

View File

@ -11,5 +11,4 @@ repositories:
force: false force: false
tag: v1.0.1 tag: v1.0.1
url: http://dummy.url.com/manifests.git url: http://dummy.url.com/manifests.git
subPath: manifests/site/test-site
targetPath: /var/tmp/ targetPath: /var/tmp/

View File

@ -51,7 +51,6 @@ func NewConfig() *Config {
}, },
TargetPath: "/tmp/" + AirshipDefaultManifest, TargetPath: "/tmp/" + AirshipDefaultManifest,
PhaseRepositoryName: DefaultTestPhaseRepo, PhaseRepositoryName: DefaultTestPhaseRepo,
SubPath: AirshipDefaultManifestRepo + "/manifests/site",
MetadataPath: DefaultManifestMetadataFile, MetadataPath: DefaultManifestMetadataFile,
}, },
}, },
@ -91,7 +90,6 @@ func NewManifest() *Manifest {
return &Manifest{ return &Manifest{
PhaseRepositoryName: DefaultTestPhaseRepo, PhaseRepositoryName: DefaultTestPhaseRepo,
TargetPath: DefaultTargetPath, TargetPath: DefaultTargetPath,
SubPath: DefaultSubPath,
Repositories: map[string]*Repository{DefaultTestPhaseRepo: NewRepository()}, Repositories: map[string]*Repository{DefaultTestPhaseRepo: NewRepository()},
MetadataPath: DefaultManifestMetadataFile, MetadataPath: DefaultManifestMetadataFile,
} }

View File

@ -484,7 +484,6 @@ manifests:
phaseRepositoryName: primary phaseRepositoryName: primary
targetPath: testdata targetPath: testdata
metadataPath: valid_site/metadata.yaml metadataPath: valid_site/metadata.yaml
subPath: valid_site
repositories: repositories:
primary: primary:
url: "empty/filename/" url: "empty/filename/"

View File

@ -39,7 +39,6 @@ func TestRender(t *testing.T) {
URLString: "", URLString: "",
}, },
} }
dummyManifest.SubPath = ""
dummyManifest.MetadataPath = "metadata.yaml" dummyManifest.MetadataPath = "metadata.yaml"
fixturePath := "phase" fixturePath := "phase"
tests := []struct { tests := []struct {

View File

@ -21,4 +21,3 @@ manifests:
remoteRef: "" remoteRef: ""
tag: v1.0.1 tag: v1.0.1
url: http://dummy.url.com/primary.git url: http://dummy.url.com/primary.git
subPath: valid_site

View File

@ -71,7 +71,6 @@ func DummyManifest() *config.Manifest {
m.PhaseRepositoryName = "primary" m.PhaseRepositoryName = "primary"
m.MetadataPath = "metadata.yaml" m.MetadataPath = "metadata.yaml"
m.TargetPath = "/var/tmp/" m.TargetPath = "/var/tmp/"
m.SubPath = "manifests/site/test-site"
return m return m
} }
@ -153,7 +152,6 @@ func DummyManagementConfiguration() *config.ManagementConfiguration {
func DummyManifestOptions() *config.ManifestOptions { func DummyManifestOptions() *config.ManifestOptions {
return &config.ManifestOptions{ return &config.ManifestOptions{
Name: "dummy_manifest", Name: "dummy_manifest",
SubPath: "manifests/dummy_site",
TargetPath: "/tmp/dummy_site", TargetPath: "/tmp/dummy_site",
IsPhase: true, IsPhase: true,
RepoName: "dummy_repo", RepoName: "dummy_repo",

View File

@ -12,7 +12,7 @@ managementConfiguration:
type: azure type: azure
manifests: manifests:
azure_manifest: azure_manifest:
primaryRepositoryName: primary phaseRepositoryName: primary
repositories: repositories:
primary: primary:
checkout: checkout:
@ -21,7 +21,6 @@ manifests:
force: false force: false
tag: "" tag: ""
url: https://review.opendev.org/airship/airshipctl url: https://review.opendev.org/airship/airshipctl
subPath: manifests/site/az-test-site targetPath: /home/zuul/src/opendev.org/airship
targetPath: /home/zuul/src/opendev.org/airship/airshipctl
users: users:
kind-capi-azure: {} kind-capi-azure: {}

View File

@ -46,7 +46,7 @@ export KUSTOMIZE_PLUGIN_HOME
export KUBECONFIG export KUBECONFIG
# TODO: use `airshipctl config` to do this once all the needed knobs are exposed # TODO: use `airshipctl config` to do this once all the needed knobs are exposed
# The non-default parts are to set the targetPath and subPath appropriately, # The non-default parts are to set the targetPath appropriately,
# and to craft up cluster/contexts to avoid the need for automatic kubectl reconciliation # and to craft up cluster/contexts to avoid the need for automatic kubectl reconciliation
function generate_airshipconf { function generate_airshipconf {
cluster=$1 cluster=$1