From 325d824503b63197e4b2faa4b509025404a31f4a Mon Sep 17 00:00:00 2001 From: Dmitry Ukov Date: Wed, 3 Jun 2020 19:35:17 +0400 Subject: [PATCH] Introduce phases and phase plan Airship API is extended with Phase and PhasePlan objects which implemet k8s runtime.Object interface. Phase plan command is added to airshipctl. Closes: #262 Closes: #261 Closes: #260 Change-Id: I4c299ec9078af4ace29ab46bd6440f47ae18a094 --- cmd/phase/phase.go | 1 + cmd/phase/plan.go | 61 +++++++++ cmd/phase/plan_test.go | 35 ++++++ .../phase-cmd-with-help.golden | 1 + .../phase-plan-cmd-with-help.golden | 9 ++ docs/source/cli/airshipctl_config.md | 1 + ...airshipctl_config_set-management-config.md | 33 +++++ docs/source/cli/airshipctl_phase.md | 1 + docs/source/cli/airshipctl_phase_plan.md | 33 +++++ pkg/api/v1alpha1/groupversion_info.go | 6 +- pkg/api/v1alpha1/phase_types.go | 36 ++++++ pkg/api/v1alpha1/phaseplan_types.go | 40 ++++++ pkg/api/v1alpha1/zz_generated.deepcopy.go | 116 +++++++++++++++++- pkg/phase/phase.go | 74 +++++++++++ pkg/phase/phase_test.go | 99 +++++++++++++++ pkg/phase/testdata/airshipconfig.yaml | 44 +++++++ pkg/phase/testdata/kubeconfig.yaml | 19 +++ .../no_plan_site/phases/kustomization.yaml | 0 .../valid_site/phases/kustomization.yaml | 2 + .../testdata/valid_site/phases/phaseplan.yaml | 10 ++ 20 files changed, 619 insertions(+), 2 deletions(-) create mode 100644 cmd/phase/plan.go create mode 100644 cmd/phase/plan_test.go create mode 100644 cmd/phase/testdata/TestNewPlanCommandGoldenOutput/phase-plan-cmd-with-help.golden create mode 100644 docs/source/cli/airshipctl_config_set-management-config.md create mode 100644 docs/source/cli/airshipctl_phase_plan.md create mode 100644 pkg/api/v1alpha1/phase_types.go create mode 100644 pkg/api/v1alpha1/phaseplan_types.go create mode 100644 pkg/phase/phase.go create mode 100644 pkg/phase/phase_test.go create mode 100644 pkg/phase/testdata/airshipconfig.yaml create mode 100644 pkg/phase/testdata/kubeconfig.yaml create mode 100644 pkg/phase/testdata/no_plan_site/phases/kustomization.yaml create mode 100644 pkg/phase/testdata/valid_site/phases/kustomization.yaml create mode 100644 pkg/phase/testdata/valid_site/phases/phaseplan.yaml diff --git a/cmd/phase/phase.go b/cmd/phase/phase.go index c04627e1d..d130caed7 100644 --- a/cmd/phase/phase.go +++ b/cmd/phase/phase.go @@ -45,6 +45,7 @@ func NewPhaseCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Comman phaseRootCmd.AddCommand(NewApplyCommand(rootSettings, client.DefaultClient)) phaseRootCmd.AddCommand(NewRenderCommand(rootSettings)) + phaseRootCmd.AddCommand(NewPlanCommand(rootSettings)) return phaseRootCmd } diff --git a/cmd/phase/plan.go b/cmd/phase/plan.go new file mode 100644 index 000000000..b743b8334 --- /dev/null +++ b/cmd/phase/plan.go @@ -0,0 +1,61 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package phase + +import ( + "fmt" + + "github.com/spf13/cobra" + + "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/pkg/phase" + "opendev.org/airship/airshipctl/pkg/util" +) + +const ( + cmdLong = ` +List life-cycle phases which were defined in document model by group. +Phases within a group are executed sequentially. Multiple phase groups +are executed in parallel. +` +) + +// NewPlanCommand creates a command which prints available phases +func NewPlanCommand(rootSettings *environment.AirshipCTLSettings) *cobra.Command { + p := &phase.Cmd{AirshipCTLSettings: rootSettings} + + planCmd := &cobra.Command{ + Use: "plan", + Short: "List phases", + Long: cmdLong[1:], + RunE: func(cmd *cobra.Command, args []string) error { + phases, err := p.Plan() + if err != nil { + return err + } + tw := util.NewTabWriter(cmd.OutOrStdout()) + defer tw.Flush() + fmt.Fprintf(tw, "GROUP\tPHASE\n") + for group, phaseList := range phases { + fmt.Fprintf(tw, "%s\t\n", group) + for _, phase := range phaseList { + fmt.Fprintf(tw, "\t%s\n", phase) + } + } + return nil + }, + } + return planCmd +} diff --git a/cmd/phase/plan_test.go b/cmd/phase/plan_test.go new file mode 100644 index 000000000..a0e8aae6f --- /dev/null +++ b/cmd/phase/plan_test.go @@ -0,0 +1,35 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package phase_test + +import ( + "testing" + + "opendev.org/airship/airshipctl/cmd/phase" + "opendev.org/airship/airshipctl/testutil" +) + +func TestNewPlanCommand(t *testing.T) { + tests := []*testutil.CmdTest{ + { + Name: "phase-plan-cmd-with-help", + CmdLine: "--help", + Cmd: phase.NewPlanCommand(nil), + }, + } + for _, testcase := range tests { + testutil.RunTest(t, testcase) + } +} diff --git a/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden b/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden index a5c86e471..48c9523b5 100644 --- a/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden +++ b/cmd/phase/testdata/TestNewPhaseCommandGoldenOutput/phase-cmd-with-help.golden @@ -7,6 +7,7 @@ Usage: Available Commands: apply Apply phase to a cluster help Help about any command + plan List phases render Render phase documents from model Flags: diff --git a/cmd/phase/testdata/TestNewPlanCommandGoldenOutput/phase-plan-cmd-with-help.golden b/cmd/phase/testdata/TestNewPlanCommandGoldenOutput/phase-plan-cmd-with-help.golden new file mode 100644 index 000000000..09fb8b73b --- /dev/null +++ b/cmd/phase/testdata/TestNewPlanCommandGoldenOutput/phase-plan-cmd-with-help.golden @@ -0,0 +1,9 @@ +List life-cycle phases which were defined in document model by group. +Phases within a group are executed sequentially. Multiple phase groups +are executed in parallel. + +Usage: + plan [flags] + +Flags: + -h, --help help for plan diff --git a/docs/source/cli/airshipctl_config.md b/docs/source/cli/airshipctl_config.md index 195034dab..4836b5bd7 100644 --- a/docs/source/cli/airshipctl_config.md +++ b/docs/source/cli/airshipctl_config.md @@ -31,5 +31,6 @@ Manage the airshipctl config file * [airshipctl config set-cluster](airshipctl_config_set-cluster.md) - Manage clusters * [airshipctl config set-context](airshipctl_config_set-context.md) - Manage contexts * [airshipctl config set-credentials](airshipctl_config_set-credentials.md) - Manage user credentials +* [airshipctl config set-management-config](airshipctl_config_set-management-config.md) - Modify an out-of-band management configuration * [airshipctl config use-context](airshipctl_config_use-context.md) - Switch to a different context diff --git a/docs/source/cli/airshipctl_config_set-management-config.md b/docs/source/cli/airshipctl_config_set-management-config.md new file mode 100644 index 000000000..ec57367bf --- /dev/null +++ b/docs/source/cli/airshipctl_config_set-management-config.md @@ -0,0 +1,33 @@ +## airshipctl config set-management-config + +Modify an out-of-band management configuration + +### Synopsis + +Modify an out-of-band management configuration + +``` +airshipctl config set-management-config NAME [flags] +``` + +### Options + +``` + -h, --help help for set-management-config + --insecure Ignore SSL certificate verification on out-of-band management requests + --management-type string Set the out-of-band management type (default "redfish") + --use-proxy Use the proxy configuration specified in the local environment (default true) +``` + +### Options inherited from parent commands + +``` + --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") + --debug enable verbose output + --kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig") +``` + +### SEE ALSO + +* [airshipctl config](airshipctl_config.md) - Manage the airshipctl config file + diff --git a/docs/source/cli/airshipctl_phase.md b/docs/source/cli/airshipctl_phase.md index 593dea90d..02a81c087 100644 --- a/docs/source/cli/airshipctl_phase.md +++ b/docs/source/cli/airshipctl_phase.md @@ -26,5 +26,6 @@ such as getting list and applying specific one. * [airshipctl](airshipctl.md) - A unified entrypoint to various airship components * [airshipctl phase apply](airshipctl_phase_apply.md) - Apply phase to a cluster +* [airshipctl phase plan](airshipctl_phase_plan.md) - List phases * [airshipctl phase render](airshipctl_phase_render.md) - Render phase documents from model diff --git a/docs/source/cli/airshipctl_phase_plan.md b/docs/source/cli/airshipctl_phase_plan.md new file mode 100644 index 000000000..3704123e8 --- /dev/null +++ b/docs/source/cli/airshipctl_phase_plan.md @@ -0,0 +1,33 @@ +## airshipctl phase plan + +List phases + +### Synopsis + +List life-cycle phases which were defined in document model by group. +Phases within a group are executed sequentially. Multiple phase groups +are executed in parallel. + + +``` +airshipctl phase plan [flags] +``` + +### Options + +``` + -h, --help help for plan +``` + +### Options inherited from parent commands + +``` + --airshipconf string Path to file for airshipctl configuration. (default "$HOME/.airship/config") + --debug enable verbose output + --kubeconfig string Path to kubeconfig associated with airshipctl configuration. (default "$HOME/.airship/kubeconfig") +``` + +### SEE ALSO + +* [airshipctl phase](airshipctl_phase.md) - Manage phases + diff --git a/pkg/api/v1alpha1/groupversion_info.go b/pkg/api/v1alpha1/groupversion_info.go index 60c9f9501..15b902d47 100644 --- a/pkg/api/v1alpha1/groupversion_info.go +++ b/pkg/api/v1alpha1/groupversion_info.go @@ -40,6 +40,10 @@ var ( func init() { Scheme = runtime.NewScheme() // NOTE add all api objects to scheme here - SchemeBuilder.Register(&Clusterctl{}) + SchemeBuilder.Register( + &Clusterctl{}, + &Phase{}, + &PhasePlan{}, + ) _ = AddToScheme(Scheme) //nolint:errcheck } diff --git a/pkg/api/v1alpha1/phase_types.go b/pkg/api/v1alpha1/phase_types.go new file mode 100644 index 000000000..c3f285d15 --- /dev/null +++ b/pkg/api/v1alpha1/phase_types.go @@ -0,0 +1,36 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1alpha1 + +import ( + corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +kubebuilder:object:root=true + +// Phase object to control deployment steps +type Phase struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Config PhaseConfig `json:"config,omitempty"` +} + +// PhaseConfig represents configuration for a particular phase. It contins a reference to +// phase runner object which should contain runner configuration +type PhaseConfig struct { + ExecutorRef *corev1.ObjectReference `json:"executorRef"` + DocumentEntryPoint string `json:"documentEntryPoint"` +} diff --git a/pkg/api/v1alpha1/phaseplan_types.go b/pkg/api/v1alpha1/phaseplan_types.go new file mode 100644 index 000000000..864a13b14 --- /dev/null +++ b/pkg/api/v1alpha1/phaseplan_types.go @@ -0,0 +1,40 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +kubebuilder:object:root=true + +// PhasePlan object represents phase execution sequence +type PhasePlan struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + PhaseGroups []PhaseGroup `json:"phaseGroups,omitempty"` +} + +// PhaseGroup represents set of phases (i.e. steps) executed sequentially. +// Phase groups are executed simultaneously +type PhaseGroup struct { + Name string `json:"name,omitempty"` + Phases []PhaseGroupStep `json:"phases,omitempty"` +} + +// PhaseGroupStep represents phase (or step) within phase group +type PhaseGroupStep struct { + Name string `json:"name,omitempty"` +} diff --git a/pkg/api/v1alpha1/zz_generated.deepcopy.go b/pkg/api/v1alpha1/zz_generated.deepcopy.go index c1d21a2a6..aed7daeb1 100644 --- a/pkg/api/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/api/v1alpha1/zz_generated.deepcopy.go @@ -5,7 +5,8 @@ package v1alpha1 import ( - runtime "k8s.io/apimachinery/pkg/runtime" + "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -99,6 +100,119 @@ func (in *MoveOptions) DeepCopy() *MoveOptions { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Phase) DeepCopyInto(out *Phase) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Config.DeepCopyInto(&out.Config) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Phase. +func (in *Phase) DeepCopy() *Phase { + if in == nil { + return nil + } + out := new(Phase) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Phase) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PhaseConfig) DeepCopyInto(out *PhaseConfig) { + *out = *in + if in.ExecutorRef != nil { + in, out := &in.ExecutorRef, &out.ExecutorRef + *out = new(v1.ObjectReference) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PhaseConfig. +func (in *PhaseConfig) DeepCopy() *PhaseConfig { + if in == nil { + return nil + } + out := new(PhaseConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PhaseGroup) DeepCopyInto(out *PhaseGroup) { + *out = *in + if in.Phases != nil { + in, out := &in.Phases, &out.Phases + *out = make([]PhaseGroupStep, len(*in)) + copy(*out, *in) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PhaseGroup. +func (in *PhaseGroup) DeepCopy() *PhaseGroup { + if in == nil { + return nil + } + out := new(PhaseGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PhaseGroupStep) DeepCopyInto(out *PhaseGroupStep) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PhaseGroupStep. +func (in *PhaseGroupStep) DeepCopy() *PhaseGroupStep { + if in == nil { + return nil + } + out := new(PhaseGroupStep) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PhasePlan) DeepCopyInto(out *PhasePlan) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.PhaseGroups != nil { + in, out := &in.PhaseGroups, &out.PhaseGroups + *out = make([]PhaseGroup, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PhasePlan. +func (in *PhasePlan) DeepCopy() *PhasePlan { + if in == nil { + return nil + } + out := new(PhasePlan) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *PhasePlan) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Provider) DeepCopyInto(out *Provider) { *out = *in diff --git a/pkg/phase/phase.go b/pkg/phase/phase.go new file mode 100644 index 000000000..70cf35e5e --- /dev/null +++ b/pkg/phase/phase.go @@ -0,0 +1,74 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package phase + +import ( + "path/filepath" + + airshipv1 "opendev.org/airship/airshipctl/pkg/api/v1alpha1" + "opendev.org/airship/airshipctl/pkg/document" + "opendev.org/airship/airshipctl/pkg/environment" +) + +const ( + // PhaseDirName directory for bundle with phases + // TODO (dukov) Remove this once repository metadata is ready + PhaseDirName = "phases" +) + +// Cmd object to work with phase api +type Cmd struct { + *environment.AirshipCTLSettings + DryRun bool +} + +func (p *Cmd) getBundle() (document.Bundle, error) { + ccm, err := p.Config.CurrentContextManifest() + if err != nil { + return nil, err + } + return document.NewBundleByPath(filepath.Join(ccm.TargetPath, ccm.SubPath, PhaseDirName)) +} + +// Plan shows available phase names +func (p *Cmd) Plan() (map[string][]string, error) { + bundle, err := p.getBundle() + if err != nil { + return nil, err + } + plan := &airshipv1.PhasePlan{} + selector, err := document.NewSelector().ByObject(plan, airshipv1.Scheme) + if err != nil { + return nil, err + } + doc, err := bundle.SelectOne(selector) + if err != nil { + return nil, err + } + + if err := doc.ToAPIObject(plan, airshipv1.Scheme); err != nil { + return nil, err + } + + result := make(map[string][]string) + for _, phaseGroup := range plan.PhaseGroups { + phases := make([]string, len(phaseGroup.Phases)) + for i, phase := range phaseGroup.Phases { + phases[i] = phase.Name + } + result[phaseGroup.Name] = phases + } + return result, nil +} diff --git a/pkg/phase/phase_test.go b/pkg/phase/phase_test.go new file mode 100644 index 000000000..a59ea9dc8 --- /dev/null +++ b/pkg/phase/phase_test.go @@ -0,0 +1,99 @@ +/* + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package phase_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "sigs.k8s.io/kustomize/api/resid" + "sigs.k8s.io/kustomize/api/types" + + "opendev.org/airship/airshipctl/pkg/config" + "opendev.org/airship/airshipctl/pkg/document" + "opendev.org/airship/airshipctl/pkg/environment" + "opendev.org/airship/airshipctl/pkg/phase" +) + +func TestPhasePlan(t *testing.T) { + testCases := []struct { + name string + settings func() *environment.AirshipCTLSettings + expectedPlan map[string][]string + expectedErr error + }{ + { + name: "No context", + settings: func() *environment.AirshipCTLSettings { + s := makeDefaultSettings() + s.Config.CurrentContext = "badCtx" + return s + }, + expectedErr: config.ErrMissingConfig{What: "Context with name 'badCtx'"}, + }, + { + name: "Valid Phase Plan", + settings: makeDefaultSettings, + expectedPlan: map[string][]string{ + "group1": { + "isogen", + "remotedirect", + "initinfra", + }, + }, + }, + { + name: "No Phase Plan", + settings: func() *environment.AirshipCTLSettings { + s := makeDefaultSettings() + m, err := s.Config.CurrentContextManifest() + require.NoError(t, err) + m.SubPath = "no_plan_site" + return s + }, + expectedErr: document.ErrDocNotFound{ + Selector: document.Selector{ + Selector: types.Selector{ + Gvk: resid.Gvk{ + Group: "airshipit.org", + Version: "v1alpha1", + Kind: "PhasePlan", + }, + }, + }, + }, + }, + } + + for _, test := range testCases { + tt := test + t.Run(tt.name, func(t *testing.T) { + cmd := phase.Cmd{AirshipCTLSettings: tt.settings()} + actualPlan, actualErr := cmd.Plan() + assert.Equal(t, tt.expectedErr, actualErr) + assert.Equal(t, tt.expectedPlan, actualPlan) + }) + } +} + +func makeDefaultSettings() *environment.AirshipCTLSettings { + testSettings := &environment.AirshipCTLSettings{ + AirshipConfigPath: "testdata/airshipconfig.yaml", + KubeConfigPath: "testdata/kubeconfig.yaml", + } + testSettings.InitConfig() + return testSettings +} diff --git a/pkg/phase/testdata/airshipconfig.yaml b/pkg/phase/testdata/airshipconfig.yaml new file mode 100644 index 000000000..52a357ea7 --- /dev/null +++ b/pkg/phase/testdata/airshipconfig.yaml @@ -0,0 +1,44 @@ +apiVersion: airshipit.org/v1alpha1 +bootstrapInfo: + dummy_bootstrap_config: + container: + volume: /tmp/airship:/config + image: quay.io/airshipit/isogen:latest-debian_stable + containerRuntime: docker + builder: + userDataFileName: user-data + networkConfigFileName: network-config + outputMetadataFileName: output-metadata.yaml + remoteDirect: + isoUrl: http://localhost:8099/debian-custom.iso + remoteType: redfish +clusters: + dummycluster: + clusterType: + ephemeral: + bootstrapInfo: dummy_bootstrap_config + clusterKubeconf: dummycluster_ephemeral +contexts: + dummy_cluster: + contextKubeconf: dummy_cluster + manifest: dummy_manifest +currentContext: dummy_cluster +kind: Config +manifests: + dummy_manifest: + primaryRepositoryName: primary + repositories: + primary: + auth: + sshKey: testdata/test-key.pem + type: ssh-key + checkout: + branch: "" + force: false + remoteRef: "" + tag: v1.0.1 + url: http://dummy.url.com/primary.git + subPath: valid_site + targetPath: testdata +users: + dummy_user: {} \ No newline at end of file diff --git a/pkg/phase/testdata/kubeconfig.yaml b/pkg/phase/testdata/kubeconfig.yaml new file mode 100644 index 000000000..b0d205918 --- /dev/null +++ b/pkg/phase/testdata/kubeconfig.yaml @@ -0,0 +1,19 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRFNU1Ea3lPVEUzTURNd09Wb1hEVEk1TURreU5qRTNNRE13T1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGd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WT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= + server: https://127.0.0.1:6443 + name: dummycluster_ephemeral +contexts: +- context: + cluster: dummycluster_ephemeral + user: kubernetes-admin + name: dummy_cluster +current-context: dummy_cluster +kind: Config +preferences: {} +users: +- name: kubernetes-admin + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJQXhEdzk2RUY4SXN3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB4T1RBNU1qa3hOekF6TURsYUZ3MHlNREE1TWpneE56QXpNVEphTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQXV6R0pZdlBaNkRvaTQyMUQKSzhXSmFaQ25OQWQycXo1cC8wNDJvRnpRUGJyQWd6RTJxWVZrek9MOHhBVmVSN1NONXdXb1RXRXlGOEVWN3JyLwo0K0hoSEdpcTVQbXF1SUZ5enpuNi9JWmM4alU5eEVmenZpa2NpckxmVTR2UlhKUXdWd2dBU05sMkFXQUloMmRECmRUcmpCQ2ZpS1dNSHlqMFJiSGFsc0J6T3BnVC9IVHYzR1F6blVRekZLdjJkajVWMU5rUy9ESGp5UlJKK0VMNlEKQlltR3NlZzVQNE5iQzllYnVpcG1NVEFxL0p1bU9vb2QrRmpMMm5acUw2Zkk2ZkJ0RjVPR2xwQ0IxWUo4ZnpDdApHUVFaN0hUSWJkYjJ0cDQzRlZPaHlRYlZjSHFUQTA0UEoxNSswV0F5bVVKVXo4WEE1NDRyL2J2NzRKY0pVUkZoCmFyWmlRd0lEQVFBQm95Y3dKVEFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwb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xZ1orcmtRc1I1S0lNWEw4cllBTElUNUpHKzFuendyN3BkaEFXZmFWdVV2SDRhamdYT0h6MUs5aQpFODNSVTNGMG9ldUg0V01PY1RwU0prWm0xZUlXcWRiaEVCb1FGdUlWTXRib1BsV0d4ZUhFRHJoOEtreGp4aThSCmdEcUQyajRwY1IzQ0g5QjJ5a0lqQjVFQ2dZRUExc0xXLys2enE1c1lNSm14K1JXZThhTXJmL3pjQnVTSU1LQWgKY0dNK0wwMG9RSHdDaUU4TVNqcVN1ajV3R214YUFuanhMb3ZwSFlRV1VmUEVaUW95UE1YQ2VhRVBLOU4xbk8xMwp0V2lHRytIZkIxaU5PazFCc0lhNFNDbndOM1FRVTFzeXBaeEgxT3hueS9LYmkvYmEvWEZ5VzNqMGFUK2YvVWxrCmJGV1ZVdWtDZ1lFQTBaMmRTTFlmTjV5eFNtYk5xMWVqZXdWd1BjRzQxR2hQclNUZEJxdHFac1doWGE3aDdLTWEKeHdvamh5SXpnTXNyK2tXODdlajhDQ2h0d21sQ1p5QU92QmdOZytncnJ1cEZLM3FOSkpKeU9YREdHckdpbzZmTQp5aXB3Q2tZVGVxRThpZ1J6UkI5QkdFUGY4eVpjMUtwdmZhUDVhM0lRZmxiV0czbGpUemNNZVZjPQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= diff --git a/pkg/phase/testdata/no_plan_site/phases/kustomization.yaml b/pkg/phase/testdata/no_plan_site/phases/kustomization.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/pkg/phase/testdata/valid_site/phases/kustomization.yaml b/pkg/phase/testdata/valid_site/phases/kustomization.yaml new file mode 100644 index 000000000..af85fe23b --- /dev/null +++ b/pkg/phase/testdata/valid_site/phases/kustomization.yaml @@ -0,0 +1,2 @@ +resources: + - phaseplan.yaml diff --git a/pkg/phase/testdata/valid_site/phases/phaseplan.yaml b/pkg/phase/testdata/valid_site/phases/phaseplan.yaml new file mode 100644 index 000000000..2848cb2ce --- /dev/null +++ b/pkg/phase/testdata/valid_site/phases/phaseplan.yaml @@ -0,0 +1,10 @@ +apiVersion: airshipit.org/v1alpha1 +kind: PhasePlan +metadata: + name: phasePlan +phaseGroups: + - name: group1 + phases: + - name: isogen + - name: remotedirect + - name: initinfra