Merge "Replace PrimaryRepositoryName with PhaseRepositoryName"

This commit is contained in:
Zuul 2020-10-13 20:50:53 +00:00 committed by Gerrit Code Review
commit f92e8bd042
34 changed files with 94 additions and 94 deletions

View File

@ -69,8 +69,8 @@ func TestGetManifestConfigCmd(t *testing.T) {
func getTestManifest(name string) *config.Manifest {
manifests := &config.Manifest{
PrimaryRepositoryName: name + "_primary_repo",
TargetPath: name + "_target_path",
PhaseRepositoryName: name + "_phase_repo",
TargetPath: name + "_target_path",
}
return manifests
}

View File

@ -34,14 +34,14 @@ airshipctl config set-manifest exampleManifest \
--repo exampleRepo \
--url https://github.com/site \
--branch master \
--primary \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the primary repo for manifest
# Change the phase repo for manifest
airshipctl config set-manifest e2e \
--repo exampleRepo \
--primary
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
@ -130,10 +130,10 @@ func addSetManifestFlags(o *config.ManifestOptions, cmd *cobra.Command) {
"if set, enable force checkout in repository with this manifest")
flags.BoolVar(
&o.IsPrimary,
"primary",
&o.IsPhase,
"phase",
false,
"if set, enable this repository as primary 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,

View File

@ -93,7 +93,7 @@ func TestSetManifest(t *testing.T) {
"--repo " + mRepoName,
"--url " + mURL,
"--branch " + mBranch,
"--primary",
"--phase",
"--sub-path " + mSubPath,
"--target-path " + mTargetPath,
"--metadata-path " + mMetadataPath,

View File

@ -9,14 +9,14 @@ airshipctl config set-manifest exampleManifest \
--repo exampleRepo \
--url https://github.com/site \
--branch master \
--primary \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the primary repo for manifest
# Change the phase repo for manifest
airshipctl config set-manifest e2e \
--repo exampleRepo \
--primary
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
@ -33,7 +33,7 @@ Flags:
--force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest
--metadata-path string the metadata path to be set for this manifest
--primary if set, enable this repository as primary 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
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest

View File

@ -9,14 +9,14 @@ airshipctl config set-manifest exampleManifest \
--repo exampleRepo \
--url https://github.com/site \
--branch master \
--primary \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the primary repo for manifest
# Change the phase repo for manifest
airshipctl config set-manifest e2e \
--repo exampleRepo \
--primary
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
@ -33,7 +33,7 @@ Flags:
--force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest
--metadata-path string the metadata path to be set for this manifest
--primary if set, enable this repository as primary 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
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest

View File

@ -10,14 +10,14 @@ airshipctl config set-manifest exampleManifest \
--repo exampleRepo \
--url https://github.com/site \
--branch master \
--primary \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the primary repo for manifest
# Change the phase repo for manifest
airshipctl config set-manifest e2e \
--repo exampleRepo \
--primary
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
@ -34,7 +34,7 @@ Flags:
--force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest
--metadata-path string the metadata path to be set for this manifest
--primary if set, enable this repository as primary 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
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest

View File

@ -1,15 +1,15 @@
metadataPath: ""
primaryRepositoryName: bar_primary_repo
phaseRepositoryName: bar_phase_repo
subPath: ""
targetPath: bar_target_path
metadataPath: ""
primaryRepositoryName: baz_primary_repo
phaseRepositoryName: baz_phase_repo
subPath: ""
targetPath: baz_target_path
metadataPath: ""
primaryRepositoryName: foo_primary_repo
phaseRepositoryName: foo_phase_repo
subPath: ""
targetPath: foo_target_path

View File

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

View File

@ -20,14 +20,14 @@ airshipctl config set-manifest exampleManifest \
--repo exampleRepo \
--url https://github.com/site \
--branch master \
--primary \
--phase \
--sub-path exampleSubpath \
--target-path exampleTargetpath
# Change the primary repo for manifest
# Change the phase repo for manifest
airshipctl config set-manifest e2e \
--repo exampleRepo \
--primary
--phase
# Change the sub-path for manifest
airshipctl config set-manifest e2e \
@ -47,7 +47,7 @@ airshipctl config set-manifest e2e \
--force if set, enable force checkout in repository with this manifest
-h, --help help for set-manifest
--metadata-path string the metadata path to be set for this manifest
--primary if set, enable this repository as primary 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
--sub-path string the sub path to be set for this manifest
--tag string the tag to be associated with repository in this manifest

View File

@ -111,7 +111,7 @@ Run the below command to configure docker manifest, and add it to airship config
```
$ airshipctl config set-manifest docker_manifest --repo primary \
--url https://opendev.org/airship/airshipctl --branch master \
--primary --sub-path manifests/site/docker-test-site --target-path /tmp/airship
--phase --sub-path manifests/site/docker-test-site --target-path /tmp/airship
```
$ airshipctl config set-context kind-capi-docker --manifest docker_manifest

View File

@ -264,7 +264,7 @@ func TestGenerateBootstrapIso(t *testing.T) {
settings := func() (*config.Config, error) {
return cfg, nil
}
expectedErr := config.ErrMissingPrimaryRepo{}
expectedErr := config.ErrMissingPhaseRepo{}
actualErr := GenerateBootstrapIso(settings, false)
assert.Equal(t, expectedErr, actualErr)
})

View File

@ -19,7 +19,7 @@ managementConfiguration:
type: redfish
manifests:
default:
primaryRepositoryName: primary
phaseRepositoryName: primary
repositories:
primary:
checkout:

View File

@ -45,9 +45,9 @@ func TestNewCommand(t *testing.T) {
currentContext: validContext,
manifests: map[string]*config.Manifest{
manifestName: {
TargetPath: "testdata",
SubPath: "valid",
PrimaryRepositoryName: "primary",
TargetPath: "testdata",
SubPath: "valid",
PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{
"primary": {},
},
@ -60,9 +60,9 @@ func TestNewCommand(t *testing.T) {
expectErr: true,
manifests: map[string]*config.Manifest{
manifestName: {
TargetPath: "testdata",
SubPath: "invalid-path",
PrimaryRepositoryName: "primary",
TargetPath: "testdata",
SubPath: "invalid-path",
PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{
"primary": {},
},
@ -75,9 +75,9 @@ func TestNewCommand(t *testing.T) {
expectErr: true,
manifests: map[string]*config.Manifest{
manifestName: {
TargetPath: "testdata",
SubPath: "no-clusterctl",
PrimaryRepositoryName: "primary",
TargetPath: "testdata",
SubPath: "no-clusterctl",
PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{
"primary": {},
},
@ -85,7 +85,7 @@ func TestNewCommand(t *testing.T) {
},
},
{
name: "no primary repo",
name: "no phase repo",
expectErr: true,
manifests: map[string]*config.Manifest{
manifestName: {
@ -99,9 +99,9 @@ func TestNewCommand(t *testing.T) {
expectErr: true,
manifests: map[string]*config.Manifest{
manifestName: {
TargetPath: "testdata",
SubPath: "can't build bundle",
PrimaryRepositoryName: "primary",
TargetPath: "testdata",
SubPath: "can't build bundle",
PhaseRepositoryName: "primary",
Repositories: map[string]*config.Repository{
"primary": {},
},

View File

@ -7,7 +7,7 @@ currentContext: dummy_cluster
kind: Config
manifests:
dummy_manifest:
primaryRepositoryName: primary
phaseRepositoryName: primary
repositories:
primary:
auth:

View File

@ -338,9 +338,9 @@ func (c *Config) CurrentContextEntryPoint(phase string) (string, error) {
if err != nil {
return "", err
}
_, exists := ccm.Repositories[ccm.PrimaryRepositoryName]
_, exists := ccm.Repositories[ccm.PhaseRepositoryName]
if !exists {
return "", ErrMissingPrimaryRepo{}
return "", ErrMissingPhaseRepo{}
}
epp := path.Join(ccm.TargetPath, ccm.SubPath, clusterType, phase)
if _, err := os.Stat(epp); err != nil {
@ -404,8 +404,8 @@ func (c *Config) AddManifest(theManifest *ManifestOptions) *Manifest {
// ModifyManifest set actual values to manifests
func (c *Config) ModifyManifest(manifest *Manifest, theManifest *ManifestOptions) error {
if theManifest.IsPrimary {
manifest.PrimaryRepositoryName = theManifest.RepoName
if theManifest.IsPhase {
manifest.PhaseRepositoryName = theManifest.RepoName
}
if theManifest.SubPath != "" {
manifest.SubPath = theManifest.SubPath
@ -420,9 +420,9 @@ func (c *Config) ModifyManifest(manifest *Manifest, theManifest *ManifestOptions
if theManifest.RepoName == "" {
return nil
}
//when setting an existing repository as primary, verify whether the repository exists
//when setting an existing repository as phase, verify whether the repository exists
//and user is also not passing any repository URL
if theManifest.IsPrimary && theManifest.URL == "" && (manifest.Repositories[theManifest.RepoName] == nil) {
if theManifest.IsPhase && theManifest.URL == "" && (manifest.Repositories[theManifest.RepoName] == nil) {
return ErrRepositoryNotFound{theManifest.RepoName}
}
repository, exists := manifest.Repositories[theManifest.RepoName]

View File

@ -507,7 +507,7 @@ func TestGetManifests(t *testing.T) {
manifests := conf.GetManifests()
require.NotNil(t, manifests)
assert.EqualValues(t, manifests[0].PrimaryRepositoryName, "primary")
assert.EqualValues(t, manifests[0].PhaseRepositoryName, "primary")
}
func TestModifyManifests(t *testing.T) {

View File

@ -70,8 +70,8 @@ const (
// Default Value for manifest
const (
// DefaultTestPrimaryRepo holds default repo name
DefaultTestPrimaryRepo = "primary"
// DefaultTestPhaseRepo holds default repo name
DefaultTestPhaseRepo = "primary"
// DefaultTargetPath holds default target path
DefaultTargetPath = "/tmp/default"
// DefaultSubPath holds default sub path

View File

@ -90,7 +90,7 @@ func (e ErrMissingRepositoryName) Error() string {
}
// ErrMissingRepoURL is returned if repository is empty
// when using --primary in set-manifest
// when using --phase in set-manifest
type ErrMissingRepoURL struct {
}
@ -171,12 +171,12 @@ func (e ErrMissingManagementConfiguration) Error() string {
e.context.NameInKubeconf)
}
// ErrMissingPrimaryRepo returned when Primary Repository is not set in context manifest
type ErrMissingPrimaryRepo struct {
// ErrMissingPhaseRepo returned when Phase Repository is not set in context manifest
type ErrMissingPhaseRepo struct {
}
func (e ErrMissingPrimaryRepo) Error() string {
return "Current context manifest must have a primary repository set."
func (e ErrMissingPhaseRepo) Error() string {
return "Current context manifest must have a phase repository set."
}
// ErrMissingPhaseDocument returned when appropriate Phase document was not found in the filesystem

View File

@ -19,16 +19,16 @@ import "sigs.k8s.io/yaml"
// Manifest is a tuple of references to a Manifest (how do Identify, collect ,
// find the yaml manifests that airship uses to perform its operations)
type Manifest struct {
// PrimaryRepositoryName is a name of the repo, that contains site/<site-name> directory
// PhaseRepositoryName is a name of the repo, that contains site/<site-name> directory
// and is a starting point for building document bundle
PrimaryRepositoryName string `json:"primaryRepositoryName"`
PhaseRepositoryName string `json:"phaseRepositoryName"`
// ExtraRepositories is the map of extra repositories addressable by a name
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 PrimaryRepository is cloned and contains
// SubPath is a path relative to TargetPath + Path where PhaseRepository is cloned and contains
// directories with ClusterType and Phase bundles, example:
// Repositories[PrimaryRepositoryName].Url = 'https://github.com/airshipit/treasuremap'
// 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.

View File

@ -41,7 +41,7 @@ type ManifestOptions struct {
Tag string
RemoteRef string
Force bool
IsPrimary bool
IsPhase bool
SubPath string
TargetPath string
MetadataPath string
@ -90,7 +90,7 @@ func (o *ManifestOptions) Validate() error {
if o.RemoteRef != "" {
return errors.ErrNotImplemented{What: "repository checkout by RemoteRef"}
}
if o.IsPrimary && o.RepoName == "" {
if o.IsPhase && o.RepoName == "" {
return ErrMissingRepositoryName{}
}
possibleValues := [3]string{o.CommitHash, o.Branch, o.Tag}

View File

@ -18,7 +18,7 @@ managementConfiguration:
manifests:
dummy_manifest:
metadataPath: manifests/site/test-site/metadata.yaml
primaryRepositoryName: primary
phaseRepositoryName: primary
repositories:
primary:
auth:

View File

@ -1,5 +1,5 @@
metadataPath: manifests/site/test-site/metadata.yaml
primaryRepositoryName: primary
phaseRepositoryName: primary
repositories:
primary:
auth:

View File

@ -42,16 +42,16 @@ func NewConfig() *Config {
Manifests: map[string]*Manifest{
AirshipDefaultManifest: {
Repositories: map[string]*Repository{
DefaultTestPrimaryRepo: {
DefaultTestPhaseRepo: {
URLString: AirshipDefaultManifestRepoLocation,
CheckoutOptions: &RepoCheckout{
Branch: "master",
},
},
},
TargetPath: "/tmp/" + AirshipDefaultManifest,
PrimaryRepositoryName: DefaultTestPrimaryRepo,
SubPath: AirshipDefaultManifestRepo + "/manifests/site",
TargetPath: "/tmp/" + AirshipDefaultManifest,
PhaseRepositoryName: DefaultTestPhaseRepo,
SubPath: AirshipDefaultManifestRepo + "/manifests/site",
},
},
}
@ -88,11 +88,11 @@ func NewContext() *Context {
// object with non-nil maps
func NewManifest() *Manifest {
return &Manifest{
PrimaryRepositoryName: DefaultTestPrimaryRepo,
TargetPath: DefaultTargetPath,
SubPath: DefaultSubPath,
Repositories: map[string]*Repository{DefaultTestPrimaryRepo: NewRepository()},
MetadataPath: DefaultManifestMetadataFile,
PhaseRepositoryName: DefaultTestPhaseRepo,
TargetPath: DefaultTargetPath,
SubPath: DefaultSubPath,
Repositories: map[string]*Repository{DefaultTestPhaseRepo: NewRepository()},
MetadataPath: DefaultManifestMetadataFile,
}
}

View File

@ -38,7 +38,7 @@ func mockConfigFactory(t *testing.T, testGitDir string, chkOutOpts *config.RepoC
currentManifest, err := cfg.CurrentContextManifest()
require.NoError(t, err)
currentManifest.Repositories = map[string]*config.Repository{
currentManifest.PrimaryRepositoryName: {
currentManifest.PhaseRepositoryName: {
URLString: testGitDir,
CheckoutOptions: chkOutOpts,
Auth: &config.RepoAuth{
@ -51,7 +51,7 @@ func mockConfigFactory(t *testing.T, testGitDir string, chkOutOpts *config.RepoC
_, err = repo.NewRepository(
".",
currentManifest.Repositories[currentManifest.PrimaryRepositoryName],
currentManifest.Repositories[currentManifest.PhaseRepositoryName],
)
require.NoError(t, err)

View File

@ -446,7 +446,7 @@ currentContext: dummy_cluster
kind: Config
manifests:
dummy_manifest:
primaryRepositoryName: primary
phaseRepositoryName: primary
targetPath: testdata
metadataPath: valid_site/metadata.yaml
subPath: valid_site`

View File

@ -7,7 +7,7 @@ currentContext: dummy_cluster
kind: Config
manifests:
dummy_manifest:
primaryRepositoryName: primary
phaseRepositoryName: primary
targetPath: testdata
metadataPath: valid_site/metadata.yaml
repositories:

View File

@ -58,7 +58,7 @@
state: absent
when: remote_work_dir is defined
- name: clone document model
command: git clone -q {{ airship_config_primary_repo_url }} {{ remote_work_dir }}
command: git clone -q {{ airship_config_phase_repo_url }} {{ remote_work_dir }}
when: remote_work_dir is defined
- name: get VM config(MACs and bootMode) from BareMetalHost objects

View File

@ -12,7 +12,7 @@
airship_config_action: generate
airship_config_iso_gen_target_path: "{{ serve_dir }}"
airship_config_primary_repo_url: "https://review.opendev.org/airship/airshipctl"
airship_config_phase_repo_url: "https://review.opendev.org/airship/airshipctl"
airship_config_manifest_directory: "{{ remote_work_dir | default(zuul.project.src_dir) | default(local_src_dir) }}"
airship_config_ephemeral_ip: "{{ airship_gate_ipam.nat_network.ephemeral_ip }}"
airship_config_iso_builder_docker_image: "quay.io/airshipit/isogen:latest-ubuntu_focal"

View File

@ -19,5 +19,5 @@
vars:
default_zuul_dir: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
environment:
AIRSHIP_CONFIG_PRIMARY_REPO_URL: "{{ remote_work_dir | default(local_src_dir) | default(default_zuul_dir) }}"
AIRSHIP_CONFIG_PHASE_REPO_URL: "{{ remote_work_dir | default(local_src_dir) | default(default_zuul_dir) }}"
SITE_NAME: "{{ site | default('test-site') }}"

View File

@ -68,7 +68,7 @@ func DummyManifest() *config.Manifest {
m := config.NewManifest()
// Repositories is the map of repository addressable by a name
m.Repositories = map[string]*config.Repository{"primary": DummyRepository()}
m.PrimaryRepositoryName = "primary"
m.PhaseRepositoryName = "primary"
m.TargetPath = "/var/tmp/"
m.SubPath = "manifests/site/test-site"
return m
@ -175,7 +175,7 @@ func DummyManifestOptions() *config.ManifestOptions {
Name: "dummy_manifest",
SubPath: "manifests/dummy_site",
TargetPath: "/tmp/dummy_site",
IsPrimary: true,
IsPhase: true,
RepoName: "dummy_repo",
URL: "https://github.com/treasuremap/dummy_site",
Branch: "master",

View File

@ -33,10 +33,10 @@ export AIRSHIP_CONFIG_ISO_NAME=${ISO_NAME:-"ubuntu-focal.iso"}
export AIRSHIP_CONFIG_METADATA_PATH=${AIRSHIP_CONFIG_METADATA_PATH:-"airshipctl/manifests/metadata.yaml"}
export SYSTEM_ACTION_RETRIES=30
export SYSTEM_REBOOT_DELAY=30
export AIRSHIP_CONFIG_PRIMARY_REPO_BRANCH=${BRANCH:-"master"}
export AIRSHIP_CONFIG_PHASE_REPO_BRANCH=${BRANCH:-"master"}
# the git repo url or local file system path to a cloned repo, e.g., /home/stack/airshipctl
export AIRSHIP_CONFIG_PRIMARY_REPO_URL=${AIRSHIP_CONFIG_PRIMARY_REPO_URL:-"https://review.opendev.org/airship/airshipctl"}
export AIRSHIP_CONFIG_PRIMARY_REPO_NAME=${AIRSHIP_CONFIG_PRIMARY_REPO_NAME:-"airshipctl"}
export AIRSHIP_CONFIG_PHASE_REPO_URL=${AIRSHIP_CONFIG_PHASE_REPO_URL:-"https://review.opendev.org/airship/airshipctl"}
export AIRSHIP_CONFIG_PHASE_REPO_NAME=${AIRSHIP_CONFIG_PHASE_REPO_NAME:-"airshipctl"}
export AIRSHIP_CONFIG_MANIFEST_DIRECTORY=${AIRSHIP_CONFIG_MANIFEST_DIRECTORY:-"/tmp/airship"}
export EPHEMERAL_CONFIG_CA_DATA=$(cat tools/deployment/certificates/ephemeral_config_ca_data| base64 -w0)
export EPHEMERAL_IP=${EPHEMERAL_IP:-"10.23.25.101"}

View File

@ -19,14 +19,14 @@ currentContext: ephemeral-cluster
kind: Config
manifests:
dummy_manifest:
primaryRepositoryName: primary
phaseRepositoryName: primary
repositories:
primary:
checkout:
branch: ${AIRSHIP_CONFIG_PRIMARY_REPO_BRANCH}
branch: ${AIRSHIP_CONFIG_PHASE_REPO_BRANCH}
force: false
remoteRef: ""
tag: ""
url: ${AIRSHIP_CONFIG_PRIMARY_REPO_URL}
url: ${AIRSHIP_CONFIG_PHASE_REPO_URL}
metadataPath: ${AIRSHIP_CONFIG_METADATA_PATH}
targetPath: ${AIRSHIP_CONFIG_MANIFEST_DIRECTORY}

View File

@ -68,7 +68,7 @@ managementConfiguration:
type: redfish
manifests:
${CONTEXT}_${cluster}:
primaryRepositoryName: primary
phaseRepositoryName: primary
repositories:
primary:
checkout:

View File

@ -23,7 +23,7 @@ TMP_DIR=${TMP_DIR:-"$(dirname $(mktemp -u))"}
ANSIBLE_HOSTS=${ANSIBLE_HOSTS:-"${TMP_DIR}/ansible_hosts"}
PLAYBOOK_CONFIG=${PLAYBOOK_CONFIG:-"${TMP_DIR}/config.yaml"}
export AIRSHIPCTL_WS=${AIRSHIPCTL_WS:-$PWD}
export AIRSHIP_CONFIG_PRIMARY_REPO_URL=${AIRSHIP_CONFIG_PRIMARY_REPO_URL:-$PWD}
export AIRSHIP_CONFIG_PHASE_REPO_URL=${AIRSHIP_CONFIG_PHASE_REPO_URL:-$PWD}
sudo --preserve-env=AIRSHIPCTL_WS ansible-playbook -i "$ANSIBLE_HOSTS" \
playbooks/airshipctl-gate-runner.yaml \