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 = `
Initialize cluster-api providers based on airshipctl document set.
document set must contain document of Kind: Clusterctl in phase initinfra.
Path to initinfra phase is built based on airshipctl config
<manifest.target-path>/<subpath>/ephemeral/initinfra.
Path to initinfra phase is defined in the initinfra phase document located
in the manifest repository.
Clusterctl document example:
---
apiVersion: airshipit.org/v1alpha1

View File

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

View File

@ -35,7 +35,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \
--branch master \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the phase repo for manifest
@ -43,10 +42,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest
airshipctl config set-manifest e2e \
--target-path /tmp/e2e
@ -135,12 +130,6 @@ func addSetManifestFlags(o *config.ManifestOptions, cmd *cobra.Command) {
false,
"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(
&o.TargetPath,
"target-path",

View File

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

View File

@ -10,7 +10,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \
--branch master \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the phase repo for manifest
@ -18,10 +17,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest
airshipctl config set-manifest e2e \
--target-path /tmp/e2e
@ -35,7 +30,6 @@ Flags:
--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
--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
--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

@ -10,7 +10,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \
--branch master \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the phase repo for manifest
@ -18,10 +17,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest
airshipctl config set-manifest e2e \
--target-path /tmp/e2e
@ -35,7 +30,6 @@ Flags:
--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
--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
--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

@ -11,7 +11,6 @@ airshipctl config set-manifest exampleManifest \
--url https://github.com/site \
--branch master \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the phase repo for manifest
@ -19,10 +18,6 @@ airshipctl config set-manifest e2e \
--repo exampleRepo \
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
--sub-path treasuremap/manifests/e2e
# Change the target-path for manifest
airshipctl config set-manifest e2e \
--target-path /tmp/e2e
@ -36,7 +31,6 @@ Flags:
--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
--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
--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

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

View File

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

View File

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

View File

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

View File

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

View File

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,13 +26,6 @@ type Manifest struct {
Repositories map[string]*Repository `json:"repositories,omitempty"`
// TargetPath Local Target path for working or home directory for all Manifest Cloned/Returned/Generated
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 string `json:"metadataPath"`
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ export KUSTOMIZE_PLUGIN_HOME
export KUBECONFIG
# 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
function generate_airshipconf {
cluster=$1