From 66ff5b975ae290692ff104be872a551bbf18bdf3 Mon Sep 17 00:00:00 2001 From: Dominique Vernier Date: Thu, 20 May 2021 13:06:55 -0400 Subject: [PATCH] first commit Signed-off-by: Dominique Vernier --- Makefile | 6 +- OWNERS | 10 +- README.md | 22 +- build/run-functional-tests.sh | 86 +- cmd/{cm.go => clusteradm.go} | 36 +- docs/cluster.md | 85 -- go.mod | 9 +- go.sum | 3 +- .../applierscenarioreader_test.go | 4 +- .../detach/hub/managed_cluster_cr.yaml | 15 - .../embed_test/detach/values-template.yaml | 6 - .../embed_test}/namespace.yaml | 0 .../embed_test}/values-template.yaml | 2 +- pkg/cmd/attach/cluster/cmd.go | 66 - pkg/cmd/attach/cluster/exec.go | 236 ---- pkg/cmd/attach/cluster/exec_test.go | 416 ------ pkg/cmd/attach/cluster/options.go | 25 - pkg/cmd/attach/cluster/options_test.go | 38 - .../hub/klusterlet_addon_config_cr.yaml | 24 - .../attach/hub/managed_cluster_cr.yaml | 15 - .../attach/hub/managed_cluster_secret.yaml | 21 - .../attach/managedcluster/import.yaml | 4 - .../scenario/attach/values-default.yaml | 16 - .../scenario/attach/values-template.yaml | 28 - pkg/cmd/attach/cluster/scenario/resources.go | 15 - .../cluster/test/unit/fake-kubeconfig.yaml | 20 - pkg/cmd/attach/cluster/test/unit/import.yaml | 5 - .../cluster/test/unit/import_result.yaml | 5 - .../cluster/test/unit/values-empty.yaml | 1 - .../cluster/test/unit/values-with-data.yaml | 24 - pkg/cmd/create/cluster/cmd.go | 62 - pkg/cmd/create/cluster/exec.go | 158 --- pkg/cmd/create/cluster/exec_test.go | 320 ----- pkg/cmd/create/cluster/options.go | 21 - pkg/cmd/create/cluster/options_test.go | 38 - .../create/hub/aws/install_config.yaml | 67 - .../create/hub/azure/install_config.yaml | 45 - .../scenario/create/hub/common/_helpers.tpl | 8 - .../hub/common/cluster_deployment_cr.yaml | 70 - .../create/hub/common/clusterimageset_cr.yaml | 10 - .../create/hub/common/creds_secret_cr.yaml | 30 - .../hub/common/install_config_secret_cr.yaml | 11 - .../common/klusterlet_addon_config_cr.yaml | 23 - .../create/hub/common/machinepool_cr.yaml | 24 - .../create/hub/common/managed_cluster_cr.yaml | 13 - .../scenario/create/hub/common/namespace.yaml | 6 - .../create/hub/common/pull_secret_cr.yaml | 11 - .../hub/common/ssh_private_key_secret_cr.yaml | 11 - .../hub/common/vsphere_ca_cert_secret_cr.yaml | 14 - .../create/hub/gcp/install_config.yaml | 35 - .../create/hub/openstack/install_config.yaml | 38 - .../create/hub/vsphere/install_config.yaml | 42 - .../scenario/create/values-template.yaml | 89 -- pkg/cmd/create/cluster/scenario/resources.go | 15 - .../cluster/test/unit/values-empty.yaml | 1 - .../cluster/test/unit/values-fake-aws.yaml | 29 - .../cluster/test/unit/values-fake-azure.yaml | 32 - .../cluster/test/unit/values-fake-gcp.yaml | 32 - .../test/unit/values-fake-openstack.yaml | 46 - .../test/unit/values-fake-vsphere.yaml | 39 - pkg/cmd/delete/cluster/cmd.go | 62 - pkg/cmd/delete/cluster/exec.go | 103 -- pkg/cmd/delete/cluster/exec_test.go | 280 ---- pkg/cmd/delete/cluster/options.go | 20 - pkg/cmd/delete/cluster/options_test.go | 38 - .../scenario/delete/hub/common/_helpers.tpl | 8 - .../hub/common/cluster_deployment_cr.yaml | 7 - .../delete/hub/common/managed_cluster_cr.yaml | 6 - .../scenario/delete/values-template.yaml | 4 - pkg/cmd/delete/cluster/scenario/resources.go | 15 - .../cluster/test/unit/values-empty.yaml | 1 - .../delete/cluster/test/unit/values-fake.yaml | 4 - .../cluster/test/unit/values-with-data.yaml | 4 - pkg/cmd/detach/cluster/cmd.go | 61 - pkg/cmd/detach/cluster/exec.go | 102 -- pkg/cmd/detach/cluster/exec_test.go | 216 --- pkg/cmd/detach/cluster/options.go | 20 - pkg/cmd/detach/cluster/options_test.go | 38 - .../detach/hub/managed_cluster_cr.yaml | 15 - pkg/cmd/detach/cluster/scenario/resources.go | 15 - .../cluster/test/unit/values-empty.yaml | 1 - .../detach/cluster/test/unit/values-fake.yaml | 4 - .../cluster/test/unit/values-with-data.yaml | 4 - pkg/cmd/get/clusters/cmd.go | 67 - pkg/cmd/verbs/verbs.go | 99 +- .../attach/cluster/fake-kubeconfig.yaml | 20 - .../cluster/kubeconfig_no_values_result.yaml | 71 - .../attach/cluster/kubeconfig_result.yaml | 51 - .../attach/cluster/kubeconfig_values.yaml | 20 - .../cluster/manual_no_values_result.yaml | 41 - .../attach/cluster/manual_result.yaml | 41 - .../attach/cluster/manual_values.yaml | 20 - .../attach/cluster/token_result.yaml | 52 - .../attach/cluster/token_values.yaml | 20 - .../functional/create/cluster/aws_result.yaml | 136 -- .../functional/create/cluster/aws_values.yaml | 30 - .../create/cluster/azure_result.yaml | 139 -- .../create/cluster/azure_values.yaml | 33 - .../functional/create/cluster/gcp_result.yaml | 131 -- .../functional/create/cluster/gcp_values.yaml | 31 - .../create/cluster/openstack_result.yaml | 144 -- .../create/cluster/openstack_values.yaml | 47 - .../create/cluster/vsphere_result.yaml | 151 --- .../create/cluster/vsphere_values.yaml | 40 - .../resources/clustermanager_cr.yaml | 11 - .../resources/clustermanager_crd.yaml | 146 --- .../hive_v1_clusterdeployment_crd.yaml | 1154 ----------------- .../resources/multiclusterhubs_cr.yaml | 11 - .../resources/multiclusterhubs_crd.yaml | 226 ---- .../resources/open-cluster-management-ns.yaml | 6 - .../resources/openshift-config-ns.yaml | 6 - test/functional/resources/pull_secret_cr.yaml | 10 - 112 files changed, 44 insertions(+), 6521 deletions(-) rename cmd/{cm.go => clusteradm.go} (58%) delete mode 100644 docs/cluster.md delete mode 100644 pkg/cmd/applierscenarios/embed_test/detach/hub/managed_cluster_cr.yaml delete mode 100644 pkg/cmd/applierscenarios/embed_test/detach/values-template.yaml rename pkg/cmd/{attach/cluster/scenario/attach/hub => applierscenarios/embed_test}/namespace.yaml (100%) rename pkg/cmd/{detach/cluster/scenario/detach => applierscenarios/embed_test}/values-template.yaml (89%) delete mode 100644 pkg/cmd/attach/cluster/cmd.go delete mode 100644 pkg/cmd/attach/cluster/exec.go delete mode 100644 pkg/cmd/attach/cluster/exec_test.go delete mode 100644 pkg/cmd/attach/cluster/options.go delete mode 100644 pkg/cmd/attach/cluster/options_test.go delete mode 100644 pkg/cmd/attach/cluster/scenario/attach/hub/klusterlet_addon_config_cr.yaml delete mode 100644 pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_cr.yaml delete mode 100644 pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_secret.yaml delete mode 100644 pkg/cmd/attach/cluster/scenario/attach/managedcluster/import.yaml delete mode 100644 pkg/cmd/attach/cluster/scenario/attach/values-default.yaml delete mode 100644 pkg/cmd/attach/cluster/scenario/attach/values-template.yaml delete mode 100644 pkg/cmd/attach/cluster/scenario/resources.go delete mode 100644 pkg/cmd/attach/cluster/test/unit/fake-kubeconfig.yaml delete mode 100644 pkg/cmd/attach/cluster/test/unit/import.yaml delete mode 100644 pkg/cmd/attach/cluster/test/unit/import_result.yaml delete mode 100644 pkg/cmd/attach/cluster/test/unit/values-empty.yaml delete mode 100644 pkg/cmd/attach/cluster/test/unit/values-with-data.yaml delete mode 100644 pkg/cmd/create/cluster/cmd.go delete mode 100644 pkg/cmd/create/cluster/exec.go delete mode 100644 pkg/cmd/create/cluster/exec_test.go delete mode 100644 pkg/cmd/create/cluster/options.go delete mode 100644 pkg/cmd/create/cluster/options_test.go delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/aws/install_config.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/azure/install_config.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/_helpers.tpl delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/cluster_deployment_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/clusterimageset_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/creds_secret_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/install_config_secret_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/klusterlet_addon_config_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/machinepool_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/managed_cluster_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/namespace.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/pull_secret_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/ssh_private_key_secret_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/common/vsphere_ca_cert_secret_cr.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/gcp/install_config.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/openstack/install_config.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/hub/vsphere/install_config.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/create/values-template.yaml delete mode 100644 pkg/cmd/create/cluster/scenario/resources.go delete mode 100644 pkg/cmd/create/cluster/test/unit/values-empty.yaml delete mode 100644 pkg/cmd/create/cluster/test/unit/values-fake-aws.yaml delete mode 100644 pkg/cmd/create/cluster/test/unit/values-fake-azure.yaml delete mode 100644 pkg/cmd/create/cluster/test/unit/values-fake-gcp.yaml delete mode 100644 pkg/cmd/create/cluster/test/unit/values-fake-openstack.yaml delete mode 100644 pkg/cmd/create/cluster/test/unit/values-fake-vsphere.yaml delete mode 100644 pkg/cmd/delete/cluster/cmd.go delete mode 100644 pkg/cmd/delete/cluster/exec.go delete mode 100644 pkg/cmd/delete/cluster/exec_test.go delete mode 100644 pkg/cmd/delete/cluster/options.go delete mode 100644 pkg/cmd/delete/cluster/options_test.go delete mode 100644 pkg/cmd/delete/cluster/scenario/delete/hub/common/_helpers.tpl delete mode 100644 pkg/cmd/delete/cluster/scenario/delete/hub/common/cluster_deployment_cr.yaml delete mode 100644 pkg/cmd/delete/cluster/scenario/delete/hub/common/managed_cluster_cr.yaml delete mode 100644 pkg/cmd/delete/cluster/scenario/delete/values-template.yaml delete mode 100644 pkg/cmd/delete/cluster/scenario/resources.go delete mode 100644 pkg/cmd/delete/cluster/test/unit/values-empty.yaml delete mode 100644 pkg/cmd/delete/cluster/test/unit/values-fake.yaml delete mode 100644 pkg/cmd/delete/cluster/test/unit/values-with-data.yaml delete mode 100644 pkg/cmd/detach/cluster/cmd.go delete mode 100644 pkg/cmd/detach/cluster/exec.go delete mode 100644 pkg/cmd/detach/cluster/exec_test.go delete mode 100644 pkg/cmd/detach/cluster/options.go delete mode 100644 pkg/cmd/detach/cluster/options_test.go delete mode 100644 pkg/cmd/detach/cluster/scenario/detach/hub/managed_cluster_cr.yaml delete mode 100644 pkg/cmd/detach/cluster/scenario/resources.go delete mode 100644 pkg/cmd/detach/cluster/test/unit/values-empty.yaml delete mode 100644 pkg/cmd/detach/cluster/test/unit/values-fake.yaml delete mode 100644 pkg/cmd/detach/cluster/test/unit/values-with-data.yaml delete mode 100644 pkg/cmd/get/clusters/cmd.go delete mode 100644 test/functional/attach/cluster/fake-kubeconfig.yaml delete mode 100644 test/functional/attach/cluster/kubeconfig_no_values_result.yaml delete mode 100644 test/functional/attach/cluster/kubeconfig_result.yaml delete mode 100755 test/functional/attach/cluster/kubeconfig_values.yaml delete mode 100644 test/functional/attach/cluster/manual_no_values_result.yaml delete mode 100644 test/functional/attach/cluster/manual_result.yaml delete mode 100755 test/functional/attach/cluster/manual_values.yaml delete mode 100644 test/functional/attach/cluster/token_result.yaml delete mode 100755 test/functional/attach/cluster/token_values.yaml delete mode 100644 test/functional/create/cluster/aws_result.yaml delete mode 100755 test/functional/create/cluster/aws_values.yaml delete mode 100644 test/functional/create/cluster/azure_result.yaml delete mode 100755 test/functional/create/cluster/azure_values.yaml delete mode 100644 test/functional/create/cluster/gcp_result.yaml delete mode 100755 test/functional/create/cluster/gcp_values.yaml delete mode 100644 test/functional/create/cluster/openstack_result.yaml delete mode 100644 test/functional/create/cluster/openstack_values.yaml delete mode 100644 test/functional/create/cluster/vsphere_result.yaml delete mode 100755 test/functional/create/cluster/vsphere_values.yaml delete mode 100644 test/functional/resources/clustermanager_cr.yaml delete mode 100644 test/functional/resources/clustermanager_crd.yaml delete mode 100644 test/functional/resources/hive_v1_clusterdeployment_crd.yaml delete mode 100644 test/functional/resources/multiclusterhubs_cr.yaml delete mode 100644 test/functional/resources/multiclusterhubs_crd.yaml delete mode 100644 test/functional/resources/open-cluster-management-ns.yaml delete mode 100644 test/functional/resources/openshift-config-ns.yaml delete mode 100644 test/functional/resources/pull_secret_cr.yaml diff --git a/Makefile b/Makefile index 9ea7c83e3..a9ec1570b 100644 --- a/Makefile +++ b/Makefile @@ -24,15 +24,15 @@ deps: .PHONY: build build: - go install ./cmd/cm.go + go install ./cmd/clusteradm.go .PHONY: install install: build .PHONY: plugin plugin: build - cp ${GOPATH}/bin/cm ${GOPATH}/bin/oc-cm - cp ${GOPATH}/bin/cm ${GOPATH}/bin/kubectl-cm + cp ${GOPATH}/bin/clusteradm ${GOPATH}/bin/oc-clusteradm + cp ${GOPATH}/bin/clusteradm${GOPATH}/bin/kubectl-clusteradm .PHONY: check ## Runs a set of required checks diff --git a/OWNERS b/OWNERS index 97baa2ce5..5d3d5f5aa 100644 --- a/OWNERS +++ b/OWNERS @@ -1,11 +1,7 @@ approvers: -- gurnben -- dhaiducek -- KevinFCormier - itdove +- qiujian16 reviewers: -- gurnben -- dhaiducek -- KevinFCormier -- itdove \ No newline at end of file +- itdove +- qiujian16 \ No newline at end of file diff --git a/README.md b/README.md index 519656559..4262fdcb2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [comment]: # ( Copyright Contributors to the Open Cluster Management project ) -# Open Cluster Management CLI & CLI Plugin +# clusteeradm CLI & CLI Plugin A CLI and kubernetes CLI plugin that allows you to interact with OCM/ACM to provision and managed your Hybrid Cloud presence from the command-line. @@ -13,25 +13,25 @@ The binary will be installed in GOPATH/bin ### CLI ```bash -git clone https://github.com/open-cluster-management/cm-cli.git -cd cm-cli +git clone https://github.com/open-cluster-management-io/clusteradm.git +cd clusteradmin make build cm ``` ### Plugin -This will create a binary `oc-cm` and `kubectl-cm` in the `$GOPATH/go/bin` allowing you to call `oc cm` or `kubectl cm` +This will create a binary `oc-clusteradm` and `kubectl-clusteradm` in the `$GOPATH/go/bin` allowing you to call `oc clusteradm` or `kubectl clusteradm` ```bash -git clone https://github.com/open-cluster-management/cm-cli.git -cd cm-cli +git clone https://github.com/open-cluster-management-io/clusteradm.git +cd clusteradm make plugin -kubectl cm -oc cm +kubectl clusteradm +oc clusteradm ``` ## Disclaimer -This CLI (and plugin) is still in development, but aims to expose OCM/ACM's functional through a useful and lightweight CLI and kubectl/oc CLI plugin. Some features may not be present, fully implemented, and it might be buggy! +This CLI (and plugin) is still in development, but aims to expose CNCF's functional through a useful and lightweight CLI and kubectl/oc CLI plugin. Some features may not be present, fully implemented, and it might be buggy! ## Contributing @@ -43,6 +43,4 @@ The commands are composed of a verb and a noun and then a number of parameters. ## Cluster commands -[applier](docs/applier.md) - -[cluster](docs/cluster.md) +[applier](docs/applier.md) \ No newline at end of file diff --git a/build/run-functional-tests.sh b/build/run-functional-tests.sh index 04f77f09f..8f215c404 100755 --- a/build/run-functional-tests.sh +++ b/build/run-functional-tests.sh @@ -13,90 +13,14 @@ rm -rf $TEST_RESULT_DIR mkdir -p $TEST_RESULT_DIR kind create cluster --name ${CLUSTER_NAME} -kind get kubeconfig --name ${CLUSTER_NAME} > ${TEST_DIR}/tmp/kind.yaml +#Wait for cluster to setup +sleep 10 -# Configure the kind cluster -cm applier -d $TEST_DIR/resources - -echo "Test cm create cluster AWS" -cm create cluster --values $TEST_DIR/create/cluster/aws_values.yaml -o $TEST_RESULT_DIR/aws_result.yaml -diff -u $TEST_DIR/create/cluster/aws_result.yaml $TEST_RESULT_DIR/aws_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"create/cluster/deploy.sh AWS failed\n" -fi - -echo "Test cm create cluster Azure" -cm create cluster --values $TEST_DIR/create/cluster/azure_values.yaml -o $TEST_RESULT_DIR/azure_result.yaml -diff -u $TEST_DIR/create/cluster/azure_result.yaml $TEST_RESULT_DIR/azure_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm create cluster Azure failed\n" -fi - -echo "Test cm create cluster GCP" -cm create cluster --values $TEST_DIR/create/cluster/gcp_values.yaml -o $TEST_RESULT_DIR/gcp_result.yaml -diff -u $TEST_DIR/create/cluster/gcp_result.yaml $TEST_RESULT_DIR/gcp_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm create cluster GCP failed\n" -fi - -echo "Test cm create cluster OpenStack" -cm create cluster --values $TEST_DIR/create/cluster/openstack_values.yaml -o $TEST_RESULT_DIR/openstack_result.yaml -diff -u $TEST_DIR/create/cluster/openstack_result.yaml $TEST_RESULT_DIR/openstack_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm create cluster OpenStack failed\n" -fi - -echo "Test cm create cluster vSphere" -cm create cluster --values $TEST_DIR/create/cluster/vsphere_values.yaml -o $TEST_RESULT_DIR/vsphere_result.yaml -diff -u $TEST_DIR/create/cluster/vsphere_result.yaml $TEST_RESULT_DIR/vsphere_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm create cluster vSphere failed\n" -fi - -echo "Test cm attach cluster manual" -cm attach cluster --values $TEST_DIR/attach/cluster/manual_values.yaml -o $TEST_RESULT_DIR/manual_result.yaml -diff -u $TEST_DIR/attach/cluster/manual_result.yaml $TEST_RESULT_DIR/manual_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm attach cluster manual failed\n" -fi - -echo "Test cm attach cluster no values.yaml" -cm attach cluster --name mycluster -o $TEST_RESULT_DIR/manual_no_values_result.yaml -diff -u $TEST_DIR/attach/cluster/manual_no_values_result.yaml $TEST_RESULT_DIR/manual_no_values_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm attach cluster manual failed without values.yaml\n" -fi - - -echo "Test cm attach cluster kubeconfig" -cm attach cluster --values $TEST_DIR/attach/cluster/kubeconfig_values.yaml -o $TEST_RESULT_DIR/kubeconfig_result.yaml -diff -u $TEST_DIR/attach/cluster/kubeconfig_result.yaml $TEST_RESULT_DIR/kubeconfig_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm attach cluster kubeconfig failed\n" -fi - -echo "Test cm attach cluster kubeconfig no values.yaml with kubeconfig" -cm attach cluster --name mycluster --cluster-kubeconfig $TEST_DIR/attach/cluster/fake-kubeconfig.yaml -o $TEST_RESULT_DIR/kubeconfig_no_values_result.yaml -diff -u $TEST_DIR/attach/cluster/kubeconfig_no_values_result.yaml $TEST_RESULT_DIR/kubeconfig_no_values_result.yaml -if [ $? != 0 ] -then - ERROR_REPORT=$ERROR_REPORT+"cm attach cluster kubeconfig failed without values.yaml\n" -fi - -echo "Test cm attach cluster token" -cm attach cluster --values $TEST_DIR/attach/cluster/token_values.yaml -o $TEST_RESULT_DIR/token_result.yaml -diff -u $TEST_DIR/attach/cluster/token_result.yaml $TEST_RESULT_DIR/token_result.yaml +echo "Test clusteradm get secret" +clusteradm get secret -n default if [ $? != 0 ] then - ERROR_REPORT=$ERROR_REPORT+"cm attach cluster token failed\n" + ERROR_REPORT=$ERROR_REPORT+"clusteradm get secret -n default failed\n" fi if [ -z "$ERROR_REPORT" ] diff --git a/cmd/cm.go b/cmd/clusteradm.go similarity index 58% rename from cmd/cm.go rename to cmd/clusteradm.go index ca75657f1..fc8e3946a 100644 --- a/cmd/cm.go +++ b/cmd/clusteradm.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" - "github.com/open-cluster-management/cm-cli/pkg/cmd/verbs" + "github.com/open-cluster-management-io/clusteradm/pkg/cmd/verbs" "k8s.io/cli-runtime/pkg/genericclioptions" "k8s.io/client-go/tools/clientcmd" cliflag "k8s.io/component-base/cli/flag" @@ -18,51 +18,39 @@ import ( func main() { streams := genericclioptions.IOStreams{In: os.Stdin, Out: os.Stdout, ErrOut: os.Stderr} + root := NewRootCMD("clusteradm", streams) + if err := root.Execute(); err != nil { + os.Exit(1) + } +} - // flags := pflag.NewFlagSet("cm", pflag.ExitOnError) - // pflag.CommandLine = flags +func NewRootCMD(parent string, streams genericclioptions.IOStreams) *cobra.Command { configFlags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag() matchVersionKubeConfigFlags := cmdutil.NewMatchVersionFlags(configFlags) f := cmdutil.NewFactory(matchVersionKubeConfigFlags) - root := newCmdCMVerbs(f, streams) + root := newCmdCMVerbs(parent, f, streams) flags := root.PersistentFlags() matchVersionKubeConfigFlags.AddFlags(flags) flags.SetNormalizeFunc(cliflag.WarnWordSepNormalizeFunc) // Warn for "_" flags - // Normalize all flags that are coming from other packages or pre-configurations - // a.k.a. change all "_" to "-". e.g. glog package flags.SetNormalizeFunc(cliflag.WordSepNormalizeFunc) // From this point and forward we get warnings on flags that contain "_" separators root.SetGlobalNormalizationFunc(cliflag.WarnWordSepNormalizeFunc) configFlags.AddFlags(flags) root.AddCommand(cmdconfig.NewCmdConfig(f, clientcmd.NewDefaultPathOptions(), streams)) - // root.AddCommand(plugin.NewCmdPlugin(f, streams)) - // root.AddCommand(version.NewCmdVersion(f, streams)) - // root.AddCommand(apiresources.NewCmdAPIVersions(f, streams)) - // root.AddCommand(apiresources.NewCmdAPIResources(f, streams)) root.AddCommand(options.NewCmdOptions(streams.Out)) - - if err := root.Execute(); err != nil { - os.Exit(1) - } + return root } // NewCmdNamespace provides a cobra command wrapping NamespaceOptions -func newCmdCMVerbs(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{Use: "cm"} +func newCmdCMVerbs(parent string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { + cmd := &cobra.Command{Use: parent} cmd.AddCommand( - verbs.NewVerb("create", f, streams), - verbs.NewVerb("get", f, streams), - // verbs.NewVerb("update", streams), - verbs.NewVerb("delete", f, streams), - // verbs.NewVerb("list", streams), - verbs.NewVerb("applier", f, streams), - verbs.NewVerb("attach", f, streams), - verbs.NewVerb("detach", f, streams), + verbs.NewVerb(parent, "get", f, streams), ) return cmd diff --git a/docs/cluster.md b/docs/cluster.md deleted file mode 100644 index e5e4b9227..000000000 --- a/docs/cluster.md +++ /dev/null @@ -1,85 +0,0 @@ -[comment]: # ( Copyright Contributors to the Open Cluster Management project ) - -# Cluster noun - -The CLI has commands to manage clusters. -Behind the scene it uses the [applier](https://github.com/open-cluster-management/applier) with predefined templates. One template per verb. - -```bash -cm cluster -``` - -## Brief common options - -- `--outfile | -o`: Outputs the resources yaml in a file rather than to apply them in the cluster. Later, `oc|kubectl apply -f` can be used to effectively apply it. -- `--out-templates-dir`: Extracts the templates used for a given verb and the values.yaml sample. -- `--values`: Provides to the CLI the values that will used to parse the templates. The values can also be provided as a input pipe like -```bash -cat values.yaml | cm cluster -``` - -The values.yaml have the same format and so if one is used for `create` it can be used for `attach`, `delete`, `detach`. - -## Help - -```bash -cm cluster -h -``` - -## Verbs - -### Attach Cluster - -``` -cm attach cluster --values -``` -or -``` -cm attach cluster --name [--cluster-kubeconfig ] -``` - -The `attach` verb provides the capability to attach a cluster to a hub. -The `attach` can be done on different ways. -1. Manually, meaning once you ran the `attach` you still have to run an `cm apply` command (provided by the execution of the `attach` command) to install the agent on the managed cluster. - -2. Automatically: - a) By providing the kubeconfig in the [values.yaml](../pkg/cmd/attach/cluster/scenario/attach/values-template.yaml), then a secret will be created on the hub cluster and the system will use it to install the agent. The secret is deleled if the `attach` failed or succeed and so the credentials are not kept on the hub. - b) By providing the pair server/token in the [values.yaml](../pkg/cmd/attach/cluster/scenario/attach/values-template.yaml) and again a secret will be created on the hub and the system will use it to install the agent. The secret is deleled if the `attach` failed or succeed and so the credentials are not kept on the hub. - c) When the cluster was provisionned with hive. If the cluster was provisionned with hive, a clusterdeployemnt custom resource exists which contain a secret to access the remote cluster and thus if you `attach` a hive cluster, you don't have to provide any credential to access the cluster. The system will find out the credentials and attach the cluster. - - The `attach` command also takes `--name` and `--cluster-kubeconfig` instead of the `--values`, in that case the default [values.yaml](../pkg/attach/cluster/scenario/attach/values-default.yaml) will be used. - -5. Attaching the hub: by default the hub is attached but if you detached it and want to reattach it you just have to provide a [values.yaml](../pkg/cmd/attach/cluster/scenario/attach/values-template.yaml) with a cluster name `local-cluster`. The system will recognized that name and use the cluster credentials to do the attach. - -### Detach Cluster - -``` -cm detach cluster --values -``` -or -``` -cm detach cluster --name -``` - -The `detach` verb will detach from the hub an already managed cluster. - -### Create Cluster - -``` -cm create cluster --values -``` - -The `create` will create a new managed cluster and attach it to the hub. Cloud provider credentials must be given in the values.yaml. - -### Delete Cluster - - -``` -cm delete cluster --values -``` -or -``` -cm delete cluster --name -``` - -The `delete` detaches and deletes an existing managed cluster. \ No newline at end of file diff --git a/go.mod b/go.mod index 2767869cb..29a9ffb43 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/open-cluster-management/cm-cli +module github.com/open-cluster-management-io/clusteradm go 1.16 @@ -9,15 +9,12 @@ replace ( require ( github.com/ghodss/yaml v1.0.0 - github.com/huandu/xstrings v1.3.2 // indirect github.com/open-cluster-management/applier v0.0.0-20210422205113-6c10f923726b github.com/spf13/cobra v1.1.3 github.com/spf13/pflag v1.0.5 - k8s.io/api v0.20.5 - k8s.io/apimachinery v0.20.5 k8s.io/cli-runtime v0.20.5 - k8s.io/client-go v1.5.2 // indirect - k8s.io/component-base v0.20.1 // indirect + k8s.io/client-go v1.5.2 + k8s.io/component-base v0.20.1 k8s.io/kubectl v0.20.1 sigs.k8s.io/controller-runtime v0.6.2 ) diff --git a/go.sum b/go.sum index d50b3d273..e3b86c8b4 100644 --- a/go.sum +++ b/go.sum @@ -295,9 +295,8 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs= github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= -github.com/huandu/xstrings v1.3.2 h1:L18LIDzqlW6xN2rEkpdV8+oL/IXWJ1APd+vsdYy4Wdw= -github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/imdario/mergo v0.3.5/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/imdario/mergo v0.3.9/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= diff --git a/pkg/cmd/applierscenarios/applierscenarioreader_test.go b/pkg/cmd/applierscenarios/applierscenarioreader_test.go index 4025d6f41..9a29690d3 100644 --- a/pkg/cmd/applierscenarios/applierscenarioreader_test.go +++ b/pkg/cmd/applierscenarios/applierscenarioreader_test.go @@ -18,7 +18,7 @@ var testDir = filepath.Join("..", "..", "..", "test", "unit") var testDirTmp = filepath.Join(testDir, "tmp") func TestResources_Asset(t *testing.T) { - asset := "embed_test/detach/hub/managed_cluster_cr.yaml" + asset := "embed_test/namespace.yaml" basset, errFile := ioutil.ReadFile(asset) if errFile != nil { t.Error(errFile) @@ -37,7 +37,7 @@ func TestResources_Asset(t *testing.T) { name: "Existing asset", b: NewApplierScenarioResourcesReader(&files), args: args{ - name: "embed_test/detach/hub/managed_cluster_cr.yaml", + name: "embed_test/namespace.yaml", }, want: basset, wantErr: false, diff --git a/pkg/cmd/applierscenarios/embed_test/detach/hub/managed_cluster_cr.yaml b/pkg/cmd/applierscenarios/embed_test/detach/hub/managed_cluster_cr.yaml deleted file mode 100644 index 05d802550..000000000 --- a/pkg/cmd/applierscenarios/embed_test/detach/hub/managed_cluster_cr.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - {{ if eq .managedCluster.name "local-cluster" }} - local-cluster: "true" - {{ end }} - name: "{{ .managedCluster.name }}" -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 diff --git a/pkg/cmd/applierscenarios/embed_test/detach/values-template.yaml b/pkg/cmd/applierscenarios/embed_test/detach/values-template.yaml deleted file mode 100644 index b0a94bdf8..000000000 --- a/pkg/cmd/applierscenarios/embed_test/detach/values-template.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: # , this value is overwritten by the --name parameter - - diff --git a/pkg/cmd/attach/cluster/scenario/attach/hub/namespace.yaml b/pkg/cmd/applierscenarios/embed_test/namespace.yaml similarity index 100% rename from pkg/cmd/attach/cluster/scenario/attach/hub/namespace.yaml rename to pkg/cmd/applierscenarios/embed_test/namespace.yaml diff --git a/pkg/cmd/detach/cluster/scenario/detach/values-template.yaml b/pkg/cmd/applierscenarios/embed_test/values-template.yaml similarity index 89% rename from pkg/cmd/detach/cluster/scenario/detach/values-template.yaml rename to pkg/cmd/applierscenarios/embed_test/values-template.yaml index b0a94bdf8..d203edf60 100644 --- a/pkg/cmd/detach/cluster/scenario/detach/values-template.yaml +++ b/pkg/cmd/applierscenarios/embed_test/values-template.yaml @@ -1,6 +1,6 @@ # Copyright Contributors to the Open Cluster Management project -managedCluster: +cluster: name: # , this value is overwritten by the --name parameter diff --git a/pkg/cmd/attach/cluster/cmd.go b/pkg/cmd/attach/cluster/cmd.go deleted file mode 100644 index 289e4c1ab..000000000 --- a/pkg/cmd/attach/cluster/cmd.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "fmt" - "path/filepath" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/open-cluster-management/cm-cli/pkg/cmd/attach/cluster/scenario" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - "github.com/spf13/cobra" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -var example = ` -# Attach a cluster -%[1]s attach cluster --values values.yaml - -# Attach a cluster with overwritting the cluster name -%[1]s attach cluster --values values.yaml --name mycluster -` - -const ( - scenarioDirectory = "attach" -) - -var valuesTemplatePath = filepath.Join(scenarioDirectory, "values-template.yaml") -var valuesDefaultPath = filepath.Join(scenarioDirectory, "values-default.yaml") - -// NewCmd provides a cobra command wrapping NewCmdImportCluster -func NewCmd(streams genericclioptions.IOStreams) *cobra.Command { - o := newOptions(streams) - - cmd := &cobra.Command{ - Use: "cluster", - Short: "Import a cluster", - Example: fmt.Sprintf(example, helpers.GetExampleHeader()), - SilenceUsage: true, - RunE: func(c *cobra.Command, args []string) error { - if err := o.complete(c, args); err != nil { - return err - } - if err := o.validate(); err != nil { - return err - } - if err := o.run(); err != nil { - return err - } - - return nil - }, - } - - cmd.SetUsageTemplate(applierscenarios.UsageTempate(cmd, scenario.GetApplierScenarioResourcesReader(), valuesTemplatePath)) - cmd.Flags().StringVar(&o.clusterName, "name", "", "Name of the cluster to import") - cmd.Flags().StringVar(&o.clusterServer, "cluster-server", "", "cluster server url of the cluster to import") - cmd.Flags().StringVar(&o.clusterToken, "cluster-token", "", "token to access the cluster to import") - cmd.Flags().StringVar(&o.clusterKubeConfig, "cluster-kubeconfig", "", "path to the kubeconfig the cluster to import") - cmd.Flags().StringVar(&o.importFile, "import-file", "", "the file which will contain the import secret for manual import") - - o.applierScenariosOptions.AddFlags(cmd.Flags()) - o.applierScenariosOptions.ConfigFlags.AddFlags(cmd.Flags()) - - return cmd -} diff --git a/pkg/cmd/attach/cluster/exec.go b/pkg/cmd/attach/cluster/exec.go deleted file mode 100644 index 5eaa66994..000000000 --- a/pkg/cmd/attach/cluster/exec.go +++ /dev/null @@ -1,236 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "context" - "fmt" - "io/ioutil" - "path/filepath" - "time" - - "github.com/ghodss/yaml" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/types" - - crclient "sigs.k8s.io/controller-runtime/pkg/client" - - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/cm-cli/pkg/cmd/attach/cluster/scenario" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - "github.com/spf13/cobra" -) - -func (o *Options) complete(cmd *cobra.Command, args []string) (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - - //Check if default values must be used - if o.applierScenariosOptions.ValuesPath == "" { - if o.clusterName != "" { - reader := scenario.GetApplierScenarioResourcesReader() - b, err := reader.Asset(valuesDefaultPath) - if err != nil { - return err - } - err = yaml.Unmarshal(b, &o.values) - if err != nil { - return err - } - mc := o.values["managedCluster"].(map[string]interface{}) - mc["name"] = o.clusterName - } else { - return fmt.Errorf("values or name are missing") - } - } else { - //Read values - o.values, err = appliercmd.ConvertValuesFileToValuesMap(o.applierScenariosOptions.ValuesPath, "") - if err != nil { - return err - } - } - - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - return fmt.Errorf("managedCluster is missing") - } - mc := imc.(map[string]interface{}) - - if o.clusterKubeConfig == "" { - if ikubeConfig, ok := mc["kubeConfig"]; ok { - o.clusterKubeConfig = ikubeConfig.(string) - } - } else { - b, err := ioutil.ReadFile(o.clusterKubeConfig) - if err != nil { - return err - } - o.clusterKubeConfig = string(b) - } - - mc["kubeConfig"] = o.clusterKubeConfig - - if o.clusterServer == "" { - if iclusterServer, ok := mc["server"]; ok { - o.clusterServer = iclusterServer.(string) - } - } - mc["server"] = o.clusterServer - - if o.clusterToken == "" { - if iclusterToken, ok := mc["token"]; ok { - o.clusterToken = iclusterToken.(string) - } - } - mc["token"] = o.clusterToken - - return nil -} - -func (o *Options) validate() error { - client, err := helpers.GetControllerRuntimeClientFromFlags(o.applierScenariosOptions.ConfigFlags) - if err != nil { - return err - } - return o.validateWithClient(client) -} - -func (o *Options) validateWithClient(client crclient.Client) error { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - return fmt.Errorf("managedCluster is missing") - } - mc := imc.(map[string]interface{}) - - if o.clusterName == "" { - iname, ok := mc["name"] - if !ok || iname == nil { - return fmt.Errorf("cluster name is missing") - } - o.clusterName = iname.(string) - if len(o.clusterName) == 0 { - return fmt.Errorf("managedCluster.name not specified") - } - } - - mc["name"] = o.clusterName - - if o.clusterName != "local-cluster" { - if o.clusterKubeConfig != "" && (o.clusterToken != "" || o.clusterServer != "") { - return fmt.Errorf("server/token and kubeConfig are mutually exclusif") - } - - if (o.clusterToken == "" && o.clusterServer != "") || - (o.clusterToken != "" && o.clusterServer == "") { - return fmt.Errorf("server or token is missing or should be removed") - } - - cd := unstructured.Unstructured{} - cd.SetKind("ClusterDeployment") - cd.SetAPIVersion("hive.openshift.io/v1") - err := client.Get(context.TODO(), - crclient.ObjectKey{ - Name: o.clusterName, - Namespace: o.clusterName, - }, &cd) - - if err != nil { - if !errors.IsNotFound(err) { - return err - } - } else { - o.hiveScenario = true - } - - if o.applierScenariosOptions.OutFile == "" && - o.clusterKubeConfig == "" && - o.clusterToken == "" && - o.clusterServer == "" && - o.importFile == "" && - !o.hiveScenario { - return fmt.Errorf("either kubeConfig or token/server or import-file must be provided") - } - } - - return nil -} - -func (o *Options) run() (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - reader := scenario.GetApplierScenarioResourcesReader() - return reader.ExtractAssets(scenarioDirectory, o.applierScenariosOptions.OutTemplatesDir) - } - client, err := helpers.GetControllerRuntimeClientFromFlags(o.applierScenariosOptions.ConfigFlags) - if err != nil { - return err - } - return o.runWithClient(client) -} - -func (o *Options) runWithClient(client crclient.Client) (err error) { - reader := scenario.GetApplierScenarioResourcesReader() - - applyOptions := &appliercmd.Options{ - OutFile: o.applierScenariosOptions.OutFile, - ConfigFlags: o.applierScenariosOptions.ConfigFlags, - - Timeout: o.applierScenariosOptions.Timeout, - Force: o.applierScenariosOptions.Force, - Silent: o.applierScenariosOptions.Silent, - IOStreams: o.applierScenariosOptions.IOStreams, - } - - err = applyOptions.ApplyWithValues(client, reader, - filepath.Join(scenarioDirectory, "hub"), - o.values) - if err != nil { - return err - } - - if !o.hiveScenario && - o.importFile != "" && - o.applierScenariosOptions.OutFile == "" && - o.clusterName != "local-cluster" { - time.Sleep(10 * time.Second) - importSecret := &corev1.Secret{} - err = client.Get(context.TODO(), - types.NamespacedName{Name: fmt.Sprintf("%s-import", o.clusterName), - Namespace: o.clusterName}, importSecret) - if err != nil { - return err - } - - ys, err := yaml.Marshal(importSecret) - if err != nil { - return err - } - - valueys := make(map[string]interface{}) - err = yaml.Unmarshal(ys, &valueys) - if err != nil { - return err - } - - applyOptions.Silent = true - applyOptions.OutFile = o.importFile - err = applyOptions.ApplyWithValues(client, reader, - filepath.Join(scenarioDirectory, "managedcluster"), - valueys) - if err != nil { - return err - } - if !o.applierScenariosOptions.Silent { - fmt.Printf("Execute this command on the managed cluster\n%s applier -d %s\n", helpers.GetExampleHeader(), o.importFile) - return nil - } - } - return nil -} diff --git a/pkg/cmd/attach/cluster/exec_test.go b/pkg/cmd/attach/cluster/exec_test.go deleted file mode 100644 index 852bc4c04..000000000 --- a/pkg/cmd/attach/cluster/exec_test.go +++ /dev/null @@ -1,416 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "bytes" - "context" - "io/ioutil" - "os" - "path/filepath" - "testing" - - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/spf13/cobra" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - crclientfake "sigs.k8s.io/controller-runtime/pkg/client/fake" -) - -var testDir = filepath.Join("test", "unit") - -func TestOptions_complete(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - values map[string]interface{} - clusterName string - clusterServer string - clusterToken string - clusterKubeConfig string - importFile string - } - type args struct { - cmd *cobra.Command - args []string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Failed, bad valuesPath", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: "bad-values-path.yaml", - }, - }, - wantErr: true, - }, - { - name: "Failed, empty values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-empty.yaml"), - }, - }, - wantErr: true, - }, - { - name: "Failed, no values.yaml, no name", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - }, - wantErr: true, - }, - { - name: "Success, not replacing values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-with-data.yaml"), - }, - }, - wantErr: false, - }, - { - name: "Success, no values.yaml", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - clusterName: "mycluster", - clusterKubeConfig: filepath.Join(testDir, "fake-kubeconfig.yaml"), - }, - wantErr: false, - }, - { - name: "Success, replacing values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-with-data.yaml"), - }, - clusterServer: "overwriteServer", - clusterToken: "overwriteToken", - clusterKubeConfig: filepath.Join(testDir, "fake-kubeconfig.yaml"), - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - values: tt.fields.values, - clusterName: tt.fields.clusterName, - clusterServer: tt.fields.clusterServer, - clusterToken: tt.fields.clusterToken, - clusterKubeConfig: tt.fields.clusterKubeConfig, - importFile: tt.fields.importFile, - } - if err := o.complete(tt.args.cmd, tt.args.args); (err != nil) != tt.wantErr { - t.Errorf("Options.complete() error = %v, wantErr %v", err, tt.wantErr) - } - if !tt.wantErr { - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - t.Errorf("missing managedCluster") - } - mc := imc.(map[string]interface{}) - - if tt.name == "Success, no values.yaml" { - if mc["name"] != o.clusterName { - t.Errorf("Expect %s got %s", o.clusterName, mc["name"]) - } - if mc["kubeConfig"] != o.clusterKubeConfig { - t.Errorf("Expect %s got %s", o.clusterKubeConfig, mc["kubeConfig"]) - } - } - if tt.name == "Success, replacing values" { - if mc["kubeConfig"] != o.clusterKubeConfig { - t.Errorf("Expect %s got %s", o.clusterKubeConfig, mc["kubeConfig"]) - } - if mc["server"] != o.clusterServer { - t.Errorf("Expect %s got %s", o.clusterServer, mc["server"]) - } - if mc["token"] != o.clusterToken { - t.Errorf("Expect %s got %s", o.clusterToken, mc["token"]) - } - } - if tt.name == "Success, not replacing values" { - if mc["kubeConfig"] != "myKubeConfig" { - t.Errorf("Expect %s got %s", "myKubeConfig", mc["kubeConfig"]) - } - if mc["server"] != "myServer" { - t.Errorf("Expect %s got %s", "myServer", mc["server"]) - } - if mc["token"] != "myToken" { - t.Errorf("Expect %s got %s", "myToken", mc["token"]) - } - } - } - }) - } -} - -func TestAttachClusterOptions_ValidateWithClient(t *testing.T) { - client := crclientfake.NewFakeClient() - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - values map[string]interface{} - clusterName string - clusterServer string - clusterToken string - clusterKubeConfig string - importFile string - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - { - name: "Success local-cluster, all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "local-cluster", - }, - }, - }, - wantErr: false, - }, - { - name: "Failed local-cluster, cluster name empty", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "", - }, - }, - }, - wantErr: true, - }, - { - name: "Failed local-cluster, cluster name missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{}, - }, - wantErr: true, - }, - { - name: "Success non-local-cluster, overrite cluster-name with local-cluster", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test-cluster", - }, - }, - - clusterName: "local-cluster", - }, - wantErr: false, - }, - { - name: "Failed non-local-cluster, missing kubeconfig or token/server", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "cluster-test", - }, - }, - }, - wantErr: true, - }, - { - name: "Success non-local-cluster, with kubeconfig", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "cluster-test", - }, - }, - - clusterKubeConfig: "fake-config", - }, - wantErr: false, - }, - { - name: "Success non-local-cluster, with token/server", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "cluster-test", - }, - }, - - clusterToken: "fake-token", - clusterServer: "fake-server", - }, - wantErr: false, - }, - { - name: "Failed non-local-cluster, with token no server", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "cluster-test", - }, - }, - clusterToken: "fake-token", - }, - wantErr: true, - }, - { - name: "Failed non-local-cluster, with server no token", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "cluster-test", - }, - }, - clusterServer: "fake-server", - }, - wantErr: true, - }, - { - name: "Failed non-local-cluster, with kubeconfig and token/server", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "cluster-test", - }, - }, - clusterKubeConfig: "fake-config", - clusterToken: "fake-token", - clusterServer: "fake-server", - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - values: tt.fields.values, - clusterName: tt.fields.clusterName, - clusterServer: tt.fields.clusterServer, - clusterToken: tt.fields.clusterToken, - clusterKubeConfig: tt.fields.clusterKubeConfig, - importFile: tt.fields.importFile, - } - if err := o.validateWithClient(client); (err != nil) != tt.wantErr { - t.Errorf("AttachClusterOptions.Validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOptions_runWithClient(t *testing.T) { - dir, err := ioutil.TempDir(testDir, "tmp") - if err != nil { - t.Error(err) - } - defer os.RemoveAll(dir) - generatedImportFileName := filepath.Join(dir, "import.yaml") - resultImportFileName := filepath.Join(testDir, "import_result.yaml") - os.Remove(generatedImportFileName) - importSecret := corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "test-import", - Namespace: "test", - }, - Data: map[string][]byte{ - "crds.yaml": []byte("crds: mycrds"), - "import.yaml": []byte("import: myimport"), - }, - } - client := crclientfake.NewFakeClient(&importSecret) - values, err := appliercmd.ConvertValuesFileToValuesMap(filepath.Join(testDir, "values-with-data.yaml"), "") - if err != nil { - t.Fatal(err) - } - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - values map[string]interface{} - clusterName string - clusterServer string - clusterToken string - clusterKubeConfig string - importFile string - } - type args struct { - client crclient.Client - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Success", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - //Had to set to 1 sec otherwise test timeout is reached (30s) - Timeout: 1, - }, - values: values, - importFile: generatedImportFileName, - clusterName: "test", - }, - args: args{ - client: client, - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - values: tt.fields.values, - clusterName: tt.fields.clusterName, - clusterServer: tt.fields.clusterServer, - clusterToken: tt.fields.clusterToken, - clusterKubeConfig: tt.fields.clusterKubeConfig, - importFile: tt.fields.importFile, - } - if err := o.runWithClient(tt.args.client); (err != nil) != tt.wantErr { - t.Errorf("Options.runWithClient() error = %v, wantErr %v", err, tt.wantErr) - } else { - ns := &corev1.Namespace{} - err = client.Get(context.TODO(), - crclient.ObjectKey{ - Name: "test", - }, - ns) - if err != nil { - t.Error(err) - } - //TO DO add test on exists managedcluster - generatedImportFile, err := ioutil.ReadFile(generatedImportFileName) - if err != nil { - t.Error(err) - } - resultImportFile, err := ioutil.ReadFile(resultImportFileName) - if err != nil { - t.Error(err) - } - if !bytes.Equal(generatedImportFile, resultImportFile) { - t.Errorf("expected import file doesn't match expected got: \n%s\n expected:\n%s\n", - string(generatedImportFile), - string(resultImportFile)) - } - } - }) - } -} diff --git a/pkg/cmd/attach/cluster/options.go b/pkg/cmd/attach/cluster/options.go deleted file mode 100644 index 6d22d4db9..000000000 --- a/pkg/cmd/attach/cluster/options.go +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -type Options struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - values map[string]interface{} - clusterName string - clusterServer string - clusterToken string - clusterKubeConfig string - importFile string - hiveScenario bool -} - -func newOptions(streams genericclioptions.IOStreams) *Options { - return &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(streams), - } -} diff --git a/pkg/cmd/attach/cluster/options_test.go b/pkg/cmd/attach/cluster/options_test.go deleted file mode 100644 index 0b65c7115..000000000 --- a/pkg/cmd/attach/cluster/options_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "reflect" - "testing" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -func Test_newOptions(t *testing.T) { - type args struct { - streams genericclioptions.IOStreams - } - tests := []struct { - name string - args args - want *Options - }{ - { - name: "success", - args: args{ - streams: genericclioptions.IOStreams{}, - }, - want: &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(genericclioptions.IOStreams{}), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newOptions(tt.args.streams); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newOptions() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/cmd/attach/cluster/scenario/attach/hub/klusterlet_addon_config_cr.yaml b/pkg/cmd/attach/cluster/scenario/attach/hub/klusterlet_addon_config_cr.yaml deleted file mode 100644 index a9e789d15..000000000 --- a/pkg/cmd/attach/cluster/scenario/attach/hub/klusterlet_addon_config_cr.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: "{{ .managedCluster.name }}" - namespace: "{{ .managedCluster.name }}" -spec: - clusterName: "{{ .managedCluster.name }}" - clusterNamespace: "{{ .managedCluster.name }}" - clusterLabels: - cloud: auto-detect - vendor: auto-detect - applicationManager: - enabled: {{ .managedCluster.addons.applicationManager.enabled }} - argocdCluster: {{ .managedCluster.addons.applicationManager.argocdCluster }} - policyController: - enabled: {{ .managedCluster.addons.policyController.enabled }} - searchCollector: - enabled: {{ .managedCluster.addons.searchCollector.enabled }} - certPolicyController: - enabled: {{ .managedCluster.addons.certPolicyController.enabled }} - iamPolicyController: - enabled: {{ .managedCluster.addons.iamPolicyController.enabled }} diff --git a/pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_cr.yaml b/pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_cr.yaml deleted file mode 100644 index 05d802550..000000000 --- a/pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_cr.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - {{ if eq .managedCluster.name "local-cluster" }} - local-cluster: "true" - {{ end }} - name: "{{ .managedCluster.name }}" -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 diff --git a/pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_secret.yaml b/pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_secret.yaml deleted file mode 100644 index 12773aa78..000000000 --- a/pkg/cmd/attach/cluster/scenario/attach/hub/managed_cluster_secret.yaml +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -{{ $needed := (printf "%s%s" .managedCluster.kubeConfig .managedCluster.token) }} -{{ if not (eq $needed "" "%!s()" "%!s()%!s()" ) }} -apiVersion: v1 -kind: Secret -metadata: - name: auto-import-secret - namespace: "{{ .managedCluster.name }}" -stringData: - autoImportRetry: "{{ .managedCluster.autoImportRetry }}" -{{ if .managedCluster.kubeConfig }} - kubeconfig: |- -{{ .managedCluster.kubeConfig | indent 4 }} -{{ end }} -{{ if .managedCluster.token }} - token: {{ .managedCluster.token }} - server: {{ .managedCluster.server }} -{{ end }} -type: Opaque -{{ end }} diff --git a/pkg/cmd/attach/cluster/scenario/attach/managedcluster/import.yaml b/pkg/cmd/attach/cluster/scenario/attach/managedcluster/import.yaml deleted file mode 100644 index 6cefa0e83..000000000 --- a/pkg/cmd/attach/cluster/scenario/attach/managedcluster/import.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -{{ index .data "crds.yaml" | b64dec }} -{{ index .data "import.yaml" | b64dec }} diff --git a/pkg/cmd/attach/cluster/scenario/attach/values-default.yaml b/pkg/cmd/attach/cluster/scenario/attach/values-default.yaml deleted file mode 100644 index b7f584c3c..000000000 --- a/pkg/cmd/attach/cluster/scenario/attach/values-default.yaml +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - addons: - applicationManager: - enabled: true - argocdCluster: false - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - autoImportRetry: 5 diff --git a/pkg/cmd/attach/cluster/scenario/attach/values-template.yaml b/pkg/cmd/attach/cluster/scenario/attach/values-template.yaml deleted file mode 100644 index 386082a0c..000000000 --- a/pkg/cmd/attach/cluster/scenario/attach/values-template.yaml +++ /dev/null @@ -1,28 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: # , this value is overwritten by the --name parameter - addons: - applicationManager: - enabled: true - argocdCluster: false - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - # Define the number of time the import must be tentavelly executed. - autoImportRetry: 5 - # For automatically import the cluster, - # provide the kubeconfig or the server/token pair - # The cluster kubeconfig, token and server can also be passed as parameter - # The parameters override these values - kubeConfig: |- - - token: - server: - - diff --git a/pkg/cmd/attach/cluster/scenario/resources.go b/pkg/cmd/attach/cluster/scenario/resources.go deleted file mode 100644 index d84e74e88..000000000 --- a/pkg/cmd/attach/cluster/scenario/resources.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package scenario - -import ( - "embed" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" -) - -//go:embed attach -var files embed.FS - -func GetApplierScenarioResourcesReader() *applierscenarios.ApplierScenarioResourcesReader { - return applierscenarios.NewApplierScenarioResourcesReader(&files) -} diff --git a/pkg/cmd/attach/cluster/test/unit/fake-kubeconfig.yaml b/pkg/cmd/attach/cluster/test/unit/fake-kubeconfig.yaml deleted file mode 100644 index ccc3f3365..000000000 --- a/pkg/cmd/attach/cluster/test/unit/fake-kubeconfig.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -apiVersion: v1 -clusters: -- cluster: - certificate-authority-data: - server: https://127.0.0.1:55005 - name: kind-kind -contexts: -- context: - cluster: kind-kind - user: kind-kind - name: kind-kind -current-context: kind-kind -kind: Config -preferences: {} -users: -- name: kind-kind - user: - client-certificate-data: - client-key-data: \ No newline at end of file diff --git a/pkg/cmd/attach/cluster/test/unit/import.yaml b/pkg/cmd/attach/cluster/test/unit/import.yaml deleted file mode 100644 index c5d640ee5..000000000 --- a/pkg/cmd/attach/cluster/test/unit/import.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -crds: mycrds -import: myimport diff --git a/pkg/cmd/attach/cluster/test/unit/import_result.yaml b/pkg/cmd/attach/cluster/test/unit/import_result.yaml deleted file mode 100644 index c5d640ee5..000000000 --- a/pkg/cmd/attach/cluster/test/unit/import_result.yaml +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -crds: mycrds -import: myimport diff --git a/pkg/cmd/attach/cluster/test/unit/values-empty.yaml b/pkg/cmd/attach/cluster/test/unit/values-empty.yaml deleted file mode 100644 index 1b4a0b558..000000000 --- a/pkg/cmd/attach/cluster/test/unit/values-empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project \ No newline at end of file diff --git a/pkg/cmd/attach/cluster/test/unit/values-with-data.yaml b/pkg/cmd/attach/cluster/test/unit/values-with-data.yaml deleted file mode 100644 index 86f3961dd..000000000 --- a/pkg/cmd/attach/cluster/test/unit/values-with-data.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -managedCluster: - name: test # , this value is overwritten by the --name parameter - addons: - applicationManager: - enabled: true - argocdCluster: false - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - # Define the number of time the import must be tentavelly executed. - autoImportRetry: 5 - # For automatically import the cluster, - # provide the kubeconfig or the server/token pair - # The cluster kubeconfig, token and server can also be passed as parameter - # The parameters override these values - kubeConfig: myKubeConfig - token: myToken - server: myServer \ No newline at end of file diff --git a/pkg/cmd/create/cluster/cmd.go b/pkg/cmd/create/cluster/cmd.go deleted file mode 100644 index e9eeedebf..000000000 --- a/pkg/cmd/create/cluster/cmd.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "fmt" - "path/filepath" - - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/open-cluster-management/cm-cli/pkg/cmd/create/cluster/scenario" - - "github.com/spf13/cobra" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -const ( - scenarioDirectory = "create" -) - -var valuesTemplatePath = filepath.Join(scenarioDirectory, "values-template.yaml") - -var example = ` -# Create a cluster -%[1]s create cluster --values values.yaml - -# Create a cluster -%[1]s create cluster --values values.yaml -` - -// NewCmd ... -func NewCmd(streams genericclioptions.IOStreams) *cobra.Command { - o := newOptions(streams) - - cmd := &cobra.Command{ - Use: "cluster", - Short: "Create a cluster", - Example: fmt.Sprintf(example, helpers.GetExampleHeader()), - SilenceUsage: true, - RunE: func(c *cobra.Command, args []string) error { - if err := o.complete(c, args); err != nil { - return err - } - if err := o.validate(); err != nil { - return err - } - if err := o.run(); err != nil { - return err - } - - return nil - }, - } - - cmd.SetUsageTemplate(applierscenarios.UsageTempate(cmd, scenario.GetApplierScenarioResourcesReader(), valuesTemplatePath)) - cmd.Flags().StringVar(&o.clusterName, "name", "", "Name of the cluster to import") - - o.applierScenariosOptions.AddFlags(cmd.Flags()) - o.applierScenariosOptions.ConfigFlags.AddFlags(cmd.Flags()) - - return cmd -} diff --git a/pkg/cmd/create/cluster/exec.go b/pkg/cmd/create/cluster/exec.go deleted file mode 100644 index f3d21d6f4..000000000 --- a/pkg/cmd/create/cluster/exec.go +++ /dev/null @@ -1,158 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "context" - "fmt" - "path/filepath" - - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/cm-cli/pkg/cmd/create/cluster/scenario" - - "github.com/ghodss/yaml" - "github.com/open-cluster-management/applier/pkg/templateprocessor" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/types" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/spf13/cobra" -) - -const ( - AWS = "aws" - AZURE = "azure" - GCP = "gcp" - OPENSTACK = "openstack" - VSPHERE = "vsphere" -) - -func (o *Options) complete(cmd *cobra.Command, args []string) (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - o.values, err = appliercmd.ConvertValuesFileToValuesMap(o.applierScenariosOptions.ValuesPath, "") - if err != nil { - return err - } - - if len(o.values) == 0 { - return fmt.Errorf("values are missing") - } - - return nil -} - -func (o *Options) validate() (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - return fmt.Errorf("managedCluster is missing") - } - mc := imc.(map[string]interface{}) - icloud, ok := mc["cloud"] - if !ok || icloud == nil { - return fmt.Errorf("cloud type is missing") - } - cloud := icloud.(string) - if cloud != AWS && cloud != AZURE && cloud != GCP && cloud != OPENSTACK && cloud != VSPHERE { - return fmt.Errorf("supported cloud type are (%s, %s, %s, %s, %s) and got %s", AWS, AZURE, GCP, OPENSTACK, VSPHERE, cloud) - } - o.cloud = cloud - - if o.clusterName == "" { - iname, ok := mc["name"] - if !ok || iname == nil { - return fmt.Errorf("cluster name is missing") - } - o.clusterName = iname.(string) - if len(o.clusterName) == 0 { - return fmt.Errorf("managedCluster.name not specified") - } - } - - mc["name"] = o.clusterName - - return nil -} - -func (o *Options) run() error { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return scenario.GetApplierScenarioResourcesReader().ExtractAssets(scenarioDirectory, - o.applierScenariosOptions.OutTemplatesDir) - } - client, err := helpers.GetControllerRuntimeClientFromFlags(o.applierScenariosOptions.ConfigFlags) - if err != nil { - return err - } - return o.runWithClient(client) -} - -func (o *Options) runWithClient(client crclient.Client) error { - pullSecret := &corev1.Secret{} - err := client.Get( - context.TODO(), - types.NamespacedName{ - Name: "pull-secret", - Namespace: "openshift-config", - }, - pullSecret) - if err != nil { - return err - } - - ps, err := yaml.Marshal(pullSecret) - if err != nil { - return err - } - - valueps := make(map[string]interface{}) - err = yaml.Unmarshal(ps, &valueps) - if err != nil { - return err - } - - o.values["pullSecret"] = valueps - - reader := scenario.GetApplierScenarioResourcesReader() - tp, err := templateprocessor.NewTemplateProcessor( - reader, - &templateprocessor.Options{}, - ) - if err != nil { - return err - } - - installConfig, err := tp.TemplateResource( - filepath.Join(scenarioDirectory, "hub", o.cloud, "install_config.yaml"), - o.values) - if err != nil { - return err - } - - valueic := make(map[string]interface{}) - err = yaml.Unmarshal(installConfig, &valueic) - if err != nil { - return err - } - - o.values["installConfig"] = valueic - - applyOptions := &appliercmd.Options{ - OutFile: o.applierScenariosOptions.OutFile, - ConfigFlags: o.applierScenariosOptions.ConfigFlags, - - Delete: false, - Timeout: o.applierScenariosOptions.Timeout, - Force: o.applierScenariosOptions.Force, - Silent: o.applierScenariosOptions.Silent, - IOStreams: o.applierScenariosOptions.IOStreams, - } - - return applyOptions.ApplyWithValues(client, reader, - filepath.Join(scenarioDirectory, "hub", "common"), - o.values) -} diff --git a/pkg/cmd/create/cluster/exec_test.go b/pkg/cmd/create/cluster/exec_test.go deleted file mode 100644 index 324a6dc63..000000000 --- a/pkg/cmd/create/cluster/exec_test.go +++ /dev/null @@ -1,320 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "path/filepath" - "testing" - - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/spf13/cobra" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - crclientfake "sigs.k8s.io/controller-runtime/pkg/client/fake" -) - -var testDir = filepath.Join("test", "unit") - -func TestOptions_complete(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - cloud string - values map[string]interface{} - } - type args struct { - cmd *cobra.Command - args []string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Failed, empty values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-empty.yaml"), - }, - }, - wantErr: true, - }, - { - name: "Sucess, with values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-fake-aws.yaml"), - }, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - cloud: tt.fields.cloud, - values: tt.fields.values, - } - if err := o.complete(tt.args.cmd, tt.args.args); (err != nil) != tt.wantErr { - t.Errorf("Options.complete() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOptions_validate(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - cloud string - values map[string]interface{} - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - { - name: "Success AWS all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "aws", - }, - }, - }, - wantErr: false, - }, - { - name: "Success Azure all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "azure", - }, - }, - }, - wantErr: false, - }, - { - name: "Success GCP all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "gcp", - }, - }, - }, - wantErr: false, - }, - { - name: "Success VSphere all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "vsphere", - }, - }, - }, - wantErr: false, - }, - { - name: "Failed, bad valuesPath", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: "bad-values-path.yaml", - }, - }, - wantErr: true, - }, - { - name: "Failed managedCluster missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{}, - }, - wantErr: true, - }, - { - name: "Failed name missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "cloud": "vsphere", - }, - }, - }, - wantErr: true, - }, - { - name: "Failed name empty", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "", - "cloud": "vsphere", - }, - }, - }, - wantErr: true, - }, - { - name: "Failed cloud missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - }, - }, - }, - wantErr: true, - }, - { - name: "Failed cloud enpty", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "", - }, - }, - }, - wantErr: true, - }, - { - name: "Success replace clusterName", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "aws", - }, - }, - clusterName: "test2", - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - cloud: tt.fields.cloud, - values: tt.fields.values, - } - if err := o.validate(); (err != nil) != tt.wantErr { - t.Errorf("Options.validate() error = %v, wantErr %v", err, tt.wantErr) - } - if tt.name == "Success replace clusterName" { - if imc, ok := o.values["managedCluster"]; ok { - mc := imc.(map[string]interface{}) - if icn, ok := mc["name"]; ok { - cm := icn.(string) - if cm != "test2" { - t.Errorf("got %s and expected %s", tt.fields.clusterName, cm) - } - } else { - t.Error("name not found") - } - } else { - t.Error("managedCluster not found") - } - } - }) - } -} - -func TestOptions_runWithClient(t *testing.T) { - pullSecret := corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "pull-secret", - Namespace: "openshift-config", - }, - Data: map[string][]byte{ - ".dockerconfigjson": []byte("crds: mycrds"), - }, - } - client := crclientfake.NewFakeClient(&pullSecret) - valuesAWS, err := appliercmd.ConvertValuesFileToValuesMap(filepath.Join(testDir, "values-fake-aws.yaml"), "") - if err != nil { - t.Fatal(err) - } - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - cloud string - values map[string]interface{} - } - type args struct { - client crclient.Client - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Success", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - //Had to set to 1 sec otherwise test timeout is reached (30s) - Timeout: 1, - }, - values: valuesAWS, - cloud: "aws", - }, - args: args{ - client: client, - }, - wantErr: false, - }, - { - name: "Failed no pullSecret", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - //Had to set to 1 sec otherwise test timeout is reached (30s) - Timeout: 1, - }, - values: valuesAWS, - cloud: "aws", - }, - args: args{ - client: crclientfake.NewFakeClient(), - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - cloud: tt.fields.cloud, - values: tt.fields.values, - } - if err := o.runWithClient(tt.args.client); (err != nil) != tt.wantErr { - t.Errorf("Options.runWithClient() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/pkg/cmd/create/cluster/options.go b/pkg/cmd/create/cluster/options.go deleted file mode 100644 index d87ce55cf..000000000 --- a/pkg/cmd/create/cluster/options.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -type Options struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - cloud string - values map[string]interface{} -} - -func newOptions(streams genericclioptions.IOStreams) *Options { - return &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(streams), - } -} diff --git a/pkg/cmd/create/cluster/options_test.go b/pkg/cmd/create/cluster/options_test.go deleted file mode 100644 index 0b65c7115..000000000 --- a/pkg/cmd/create/cluster/options_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "reflect" - "testing" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -func Test_newOptions(t *testing.T) { - type args struct { - streams genericclioptions.IOStreams - } - tests := []struct { - name string - args args - want *Options - }{ - { - name: "success", - args: args{ - streams: genericclioptions.IOStreams{}, - }, - want: &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(genericclioptions.IOStreams{}), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newOptions(tt.args.streams); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newOptions() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/aws/install_config.yaml b/pkg/cmd/create/cluster/scenario/create/hub/aws/install_config.yaml deleted file mode 100644 index 514917cca..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/aws/install_config.yaml +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -metadata: - name: "{{ .managedCluster.name }}" -baseDomain: {{ .managedCluster.aws.baseDnsDomain }} -controlPlane: - hyperthreading: Enabled - name: master - replicas: {{ if .managedCluster.master }}{{ .managedCluster.master.replicas }}{{ else }}3{{end}} - platform: - aws: -{{ if .managedCluster.aws.master }} -{{ if .managedCluster.aws.master.rootVolume }} - rootVolume: -{{ toYaml .managedCluster.aws.master.rootVolume | indent 8}} -{{ else }} - rootVolume: # see below the default values - iops: 4000 - size: 100 - type: gp2 -{{ end }} -{{ else }} - rootVolume: # see below the default values - iops: 4000 - size: 100 - type: gp2 -{{end}} - type: {{ if .managedCluster.aws.master }}{{ default "m5.xlarge" .managedCluster.aws.master.type }}{{ else }}m5.xlarge{{end}} -compute: -- hyperthreading: Enabled - name: worker - replicas: {{ if .managedCluster.worker }}{{ .managedCluster.worker.replicas }}{{ else }}3{{end}} - platform: - aws: -{{ if .managedCluster.aws.worker }} -{{ if .managedCluster.aws.worker.rootVolume }} - rootVolume: -{{ toYaml .managedCluster.aws.worker.rootVolume | indent 8}} -{{ else }} - rootVolume: # see below the default values - iops: 2000 - size: 100 - type: gp2 -{{ end }} -{{ else }} - rootVolume: # see below the default values - iops: 2000 - size: 100 - type: gp2 -{{ end }} - type: {{ if .managedCluster.aws.worker }}{{ default "m5.xlarge" .managedCluster.aws.worker.type }}{{ else }}m5.xlarge{{end}} -networking: - clusterNetwork: - - cidr: 10.128.0.0/14 - hostPrefix: 23 - machineNetwork: - - cidr: 10.0.0.0/16 - networkType: OpenShiftSDN - serviceNetwork: - - 172.30.0.0/16 -platform: - aws: - region: {{ .managedCluster.aws.region }} -pullSecret: "" # skip, hive will inject based on it's secrets -sshKey: |- -{{ .managedCluster.sshPublicKey | indent 4 }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/azure/install_config.yaml b/pkg/cmd/create/cluster/scenario/create/hub/azure/install_config.yaml deleted file mode 100644 index e8d7f7ae3..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/azure/install_config.yaml +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -metadata: - name: "{{ .managedCluster.name }}" -baseDomain: {{ .managedCluster.azure.baseDnsDomain }} -controlPlane: - hyperthreading: Enabled - name: master - replicas: {{ if .managedCluster.master }}{{ .managedCluster.master.replicas }}{{ else }}3{{end}} - platform: - azure: - osDisk: - diskSizeGB: 128 - type: Standard_D4s_v3 -compute: -- hyperthreading: Enabled - name: worker - replicas: {{ if .managedCluster.worker }}{{ .managedCluster.worker.replicas }}{{ else }}3{{end}} - platform: - azure: - type: Standard_D2s_v3 - osDisk: - diskSizeGB: 128 - zones: - - "1" - - "2" - - "3" -networking: - clusterNetwork: - - cidr: 10.128.0.0/14 - hostPrefix: 23 - machineNetwork: - - cidr: 10.0.0.0/16 - networkType: OpenShiftSDN - serviceNetwork: - - 172.30.0.0/16 -platform: - azure: - baseDomainResourceGroupName: {{ .managedCluster.azure.baseDomainRGN }} - region: {{ .managedCluster.azure.region }} -pullSecret: "" # skip, hive will inject based on it's secrets -sshKey: |- -{{ .managedCluster.sshPublicKey | indent 4 }} - \ No newline at end of file diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/_helpers.tpl b/pkg/cmd/create/cluster/scenario/create/hub/common/_helpers.tpl deleted file mode 100644 index 735c591dc..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/_helpers.tpl +++ /dev/null @@ -1,8 +0,0 @@ -{{- define "ocpImage" }} - {{ $release := splitList ":" .managedCluster.ocpImage }} - {{ if gt (len $release) 1 }} - {{ $release = index $release 1 | replace "_" "-" | lower }} - {{ $release = (print $release "-" .managedCluster.name ) }} -{{ $release }} - {{ end }} -{{- end }} \ No newline at end of file diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/cluster_deployment_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/cluster_deployment_cr.yaml deleted file mode 100644 index 9d5b15f4a..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/cluster_deployment_cr.yaml +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - name: "{{ .managedCluster.name }}" - namespace: "{{ .managedCluster.name }}" - labels: - cloud: {{ .managedCluster.cloud }} - vendor: {{ .managedCluster.vendor }} -spec: -{{ if (eq .managedCluster.cloud "aws") }} - baseDomain: {{ .managedCluster.aws.baseDnsDomain }} -{{ end }} -{{ if (eq .managedCluster.cloud "azure") }} - baseDomain: {{ .managedCluster.azure.baseDnsDomain }} -{{ end }} -{{ if (eq .managedCluster.cloud "gcp") }} - baseDomain: {{ .managedCluster.gcp.baseDnsDomain }} -{{ end }} -{{ if (eq .managedCluster.cloud "openstack") }} - baseDomain: {{ .managedCluster.openstack.baseDnsDomain }} -{{ end }} -{{ if (eq .managedCluster.cloud "vsphere") }} - baseDomain: {{ .managedCluster.vsphere.baseDnsDomain }} -{{ end }} - clusterName: "{{ .managedCluster.name }}" - controlPlaneConfig: - servingCertificates: {} - installAttemptsLimit: {{ default 1 .managedCluster.installAttemptsLimit}} - installed: false - platform: -{{ if (eq .managedCluster.cloud "aws") }} - aws: - region: {{ .managedCluster.aws.region }} -{{ end }} -{{ if (eq .managedCluster.cloud "azure") }} - azure: - baseDomainResourceGroupName: {{ .managedCluster.azure.baseDomainRGN }} - region: {{ .managedCluster.azure.region }} -{{ end }} -{{ if (eq .managedCluster.cloud "gcp") }} - gcp: - region: {{ .managedCluster.gcp.region }} -{{ end }} -{{ if (eq .managedCluster.cloud "openstack") }} - openstack: - cloud: {{ .managedCluster.openstack.cloud }} -{{ end }} -{{ if (eq .managedCluster.cloud "vsphere") }} - vsphere: - cluster: {{ .managedCluster.vsphere.cluster }} - certificatesSecretRef: - name: {{ .managedCluster.name }}-vsphere-certs - vCenter: {{ .managedCluster.vsphere.vcenter }} - datacenter: {{ .managedCluster.vsphere.datacenter }} - defaultDatastore: {{ .managedCluster.vsphere.datastore }} - network: {{ .managedCluster.vsphere.network }} -{{ end }} - credentialsSecretRef: - name: "{{ .managedCluster.name }}-creds" - provisioning: - installConfigSecretRef: - name: {{ .managedCluster.name }}-install-config - sshPrivateKeySecretRef: - name: {{ .managedCluster.name }}-ssh-private-key - imageSetRef: - name: {{ include "ocpImage" . | indent 8 }} - pullSecretRef: - name: {{ .managedCluster.name }}-pull-secret diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/clusterimageset_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/clusterimageset_cr.yaml deleted file mode 100644 index 0ff20c60a..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/clusterimageset_cr.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -{{ if .managedCluster.ocpImage }} -apiVersion: hive.openshift.io/v1 -kind: ClusterImageSet -metadata: - name: {{ include "ocpImage" . | indent 6 }} -spec: - releaseImage: {{ .managedCluster.ocpImage }} -{{ end }} \ No newline at end of file diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/creds_secret_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/creds_secret_cr.yaml deleted file mode 100644 index bcb4ebbbe..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/creds_secret_cr.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Secret -type: Opaque -metadata: - name: {{ .managedCluster.name }}-creds - namespace: "{{ .managedCluster.name }}" -stringData: -{{ if (eq .managedCluster.cloud "aws") }} - aws_access_key_id: {{ .managedCluster.aws.awsAccessKeyID }} - aws_secret_access_key: {{ .managedCluster.aws.awsSecretAccessKeyID }} -{{ end }} -{{ if (eq .managedCluster.cloud "azure") }} - osServicePrincipal.json: |- - {"clientId": "{{ .managedCluster.azure.clientID }}", "clientSecret": "{{ .managedCluster.azure.clientSecret }}", "tenantId": "{{ .managedCluster.azure.tenantID }}", "subscriptionId": "{{ .managedCluster.azure.subscriptionID }}"} -{{ end }} -{{ if (eq .managedCluster.cloud "gcp") }} - osServiceAccount.json: |- -{{ .managedCluster.gcp.osServiceAccountJson | indent 4 }} -{{ end }} -{{ if (eq .managedCluster.cloud "openstack") }} - cloud: {{ .managedCluster.openstack.cloud }} - clouds.yaml: |- -{{ .managedCluster.openstack.cloudsYaml | indent 4 }} -{{ end }} -{{ if (eq .managedCluster.cloud "vsphere") }} - username: {{ .managedCluster.vsphere.username }} - password: {{ .managedCluster.vsphere.password }} -{{ end }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/install_config_secret_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/install_config_secret_cr.yaml deleted file mode 100644 index 7769cae45..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/install_config_secret_cr.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Secret -metadata: - name: {{ .managedCluster.name }}-install-config - namespace: "{{ .managedCluster.name }}" -type: Opaque -data: - # Base64 encoding of install-config yaml - install-config.yaml: {{ toYaml .installConfig | b64enc }} \ No newline at end of file diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/klusterlet_addon_config_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/klusterlet_addon_config_cr.yaml deleted file mode 100644 index c262d9a4a..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/klusterlet_addon_config_cr.yaml +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: "{{ .managedCluster.name }}" - namespace: "{{ .managedCluster.name }}" -spec: - clusterName: "{{ .managedCluster.name }}" - clusterNamespace: "{{ .managedCluster.name }}" - clusterLabels: - cloud: {{ .managedCluster.cloud }} - vendor: {{ .managedCluster.vendor }} - applicationManager: - enabled: {{ .managedCluster.addons.applicationManager.enabled }} - policyController: - enabled: {{ .managedCluster.addons.policyController.enabled }} - searchCollector: - enabled: {{ .managedCluster.addons.searchCollector.enabled }} - certPolicyController: - enabled: {{ .managedCluster.addons.certPolicyController.enabled }} - iamPolicyController: - enabled: {{ .managedCluster.addons.iamPolicyController.enabled }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/machinepool_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/machinepool_cr.yaml deleted file mode 100644 index 5e5ac9aea..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/machinepool_cr.yaml +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: hive.openshift.io/v1 -kind: MachinePool -metadata: - name: {{ .managedCluster.name }}-worker - namespace: "{{ .managedCluster.name }}" -spec: - clusterDeploymentRef: - name: "{{ .managedCluster.name }}" - name: worker - platform: -{{ if (eq .managedCluster.cloud "openstack") }} - openstack: - flavor: {{ if .managedCluster.openstack.workerFlavor }}{{ .managedCluster.openstack.workerFlavor }}{{ else }}m1.xlarge{{end}} - -{{ else }} -{{ block "platform" . }} -{{ $p := index .installConfig.compute 0 "platform" }} -{{ toYaml $p | indent 4 }} -{{ end }} -{{ end }} - - replicas: {{ index .installConfig.compute 0 "replicas" }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/managed_cluster_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/managed_cluster_cr.yaml deleted file mode 100644 index 6d7523c3e..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/managed_cluster_cr.yaml +++ /dev/null @@ -1,13 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: {{ .managedCluster.cloud }} - name: "{{ .managedCluster.name }}" - vendor: {{ .managedCluster.vendor }} - name: "{{ .managedCluster.name }}" -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 \ No newline at end of file diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/namespace.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/namespace.yaml deleted file mode 100644 index cc7fc5719..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/namespace.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Namespace -metadata: - name: "{{ .managedCluster.name }}" diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/pull_secret_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/pull_secret_cr.yaml deleted file mode 100644 index dd5475694..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/pull_secret_cr.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Secret -metadata: - name: {{ .managedCluster.name }}-pull-secret - namespace: "{{ .managedCluster.name }}" -data: - .dockerconfigjson: |- -{{ index .pullSecret.data ".dockerconfigjson" | indent 4 }} -type: kubernetes.io/dockerconfigjson \ No newline at end of file diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/ssh_private_key_secret_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/ssh_private_key_secret_cr.yaml deleted file mode 100644 index 51b376210..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/ssh_private_key_secret_cr.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Secret -metadata: - name: {{ .managedCluster.name }}-ssh-private-key - namespace: "{{ .managedCluster.name }}" -stringData: - ssh-privatekey: |- -{{ .managedCluster.sshPrivateKey | indent 4}} -type: Opaque diff --git a/pkg/cmd/create/cluster/scenario/create/hub/common/vsphere_ca_cert_secret_cr.yaml b/pkg/cmd/create/cluster/scenario/create/hub/common/vsphere_ca_cert_secret_cr.yaml deleted file mode 100644 index 8bcba3ad3..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/common/vsphere_ca_cert_secret_cr.yaml +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -{{ if (eq .managedCluster.cloud "vsphere") }} - -apiVersion: v1 -kind: Secret -metadata: - name: {{ .managedCluster.name }}-vsphere-certs - namespace: "{{ .managedCluster.name }}" -data: - .cacert: {{ .managedCluster.vsphere.cacertificate | b64enc }} -type: Opaque - -{{ end }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/gcp/install_config.yaml b/pkg/cmd/create/cluster/scenario/create/hub/gcp/install_config.yaml deleted file mode 100644 index a1e108390..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/gcp/install_config.yaml +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -metadata: - name: "{{ .managedCluster.name }}" -baseDomain: {{ .managedCluster.gcp.baseDnsDomain }} -controlPlane: - hyperthreading: Enabled - name: master - replicas: {{ if .managedCluster.master }}{{ .managedCluster.master.replicas }}{{ else }}3{{end}} - platform: - gcp: - type: n1-standard-4 -compute: -- hyperthreading: Enabled - replicas: {{ if .managedCluster.worker }}{{ .managedCluster.worker.replicas }}{{ else }}3{{end}} - platform: - gcp: - type: n1-standard-4 -networking: - clusterNetwork: - - cidr: 10.128.0.0/14 - hostPrefix: 23 - machineNetwork: - - cidr: 10.0.0.0/16 - networkType: OpenShiftSDN - serviceNetwork: - - 172.30.0.0/16 -platform: - gcp: - projectID: {{ .managedCluster.gcp.projectID }} - region: {{ .managedCluster.gcp.region }} -pullSecret: "" # skip, hive will inject based on it's secrets -sshKey: |- - {{ .managedCluster.sshPublicKey | indent 4 }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/openstack/install_config.yaml b/pkg/cmd/create/cluster/scenario/create/hub/openstack/install_config.yaml deleted file mode 100644 index 87ba94642..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/openstack/install_config.yaml +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -metadata: - name: "{{ .managedCluster.name }}" -baseDomain: {{ .managedCluster.openstack.baseDnsDomain }} -controlPlane: - hyperthreading: Enabled - name: master - replicas: {{ if .managedCluster.master }}{{ .managedCluster.master.replicas }}{{ else }}3{{end}} - platform: - openstack: - type: {{ if .managedCluster.openstack.masterFlavor }}{{ .managedCluster.openstack.masterFlavor }}{{ else }}m1.xlarge{{end}} -compute: -- hyperthreading: Enabled - name: worker - replicas: {{ if .managedCluster.worker }}{{ .managedCluster.worker.replicas }}{{ else }}3{{end}} - platform: - openstack: - type: {{ if .managedCluster.openstack.workerFlavor }}{{ .managedCluster.openstack.workerFlavor }}{{ else }}m1.xlarge{{end}} -networking: - clusterNetwork: - - cidr: 10.128.0.0/14 - hostPrefix: 23 - machineNetwork: - - cidr: {{ .managedCluster.openstack.machineNetworkCIDR }} - networkType: OpenShiftSDN - serviceNetwork: - - 172.30.0.0/16 -platform: - openstack: - cloud: {{ .managedCluster.openstack.cloud }} - externalNetwork: {{ .managedCluster.openstack.externalNetwork }} - lbFloatingIP: {{ .managedCluster.openstack.apiFloatingIP }} - ingressFloatingIP: {{ .managedCluster.openstack.ingressFloatingIP }} -pullSecret: "" # skip, hive will inject based on it's secrets -sshKey: |- -{{ .managedCluster.sshPublicKey | indent 4 }} diff --git a/pkg/cmd/create/cluster/scenario/create/hub/vsphere/install_config.yaml b/pkg/cmd/create/cluster/scenario/create/hub/vsphere/install_config.yaml deleted file mode 100644 index 312957cd9..000000000 --- a/pkg/cmd/create/cluster/scenario/create/hub/vsphere/install_config.yaml +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -metadata: - name: "{{ .managedCluster.name }}" -baseDomain: {{ .managedCluster.vsphere.baseDnsDomain }} -controlPlane: - hyperthreading: Enabled - name: master - replicas: {{ if .managedCluster.master }}{{ .managedCluster.master.replicas }}{{ else }}3{{end}} - platform: - vsphere: - cpus: 4 - coresPerSocket: 2 - memoryMB: 16384 - osDisk: - diskSizeGB: 120 -compute: -- hyperthreading: Enabled - name: worker - replicas: {{ if .managedCluster.worker }}{{ .managedCluster.worker.replicas }}{{ else }}3{{end}} - platform: - vsphere: - cpus: 4 - coresPerSocket: 2 - memoryMB: 16384 - osDisk: - diskSizeGB: 120 -platform: - vsphere: - vCenter: {{ .managedCluster.vsphere.vcenter }} - username: {{ .managedCluster.vsphere.username }} - password: {{ .managedCluster.vsphere.password }} - datacenter: {{ .managedCluster.vsphere.datacenter }} - defaultDatastore: {{ .managedCluster.vsphere.datastore }} - cluster: {{ .managedCluster.vsphere.cluster }} - apiVIP: {{ .managedCluster.vsphere.apiVIP }} - ingressVIP: {{ .managedCluster.vsphere.ingressVIP }} - network: {{ .managedCluster.vsphere.network }} -pullSecret: "" # skip, hive will inject based on it's secrets -sshKey: |- -{{ .managedCluster.sshPublicKey | indent 4 }} diff --git a/pkg/cmd/create/cluster/scenario/create/values-template.yaml b/pkg/cmd/create/cluster/scenario/create/values-template.yaml deleted file mode 100644 index 9d4f883c9..000000000 --- a/pkg/cmd/create/cluster/scenario/create/values-template.yaml +++ /dev/null @@ -1,89 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - master: - replicas: 3 #Number of master node, default 3 - worker: - replicas: 3 #Number of worker node, default 3 - name: #, this value is overwritten by the --name parameter - cloud: vsphere # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: # ocp image (ie: quay.io/openshift-release-dev/ocp-release:4.3.40-x86_64) - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - sshPublicKey: |- - Public key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - private key - -----END RSA PRIVATE KEY----- - aws: - baseDnsDomain: # baseDomain of your cluster (ie: mycompany.com) - awsAccessKeyID: - awsSecretAccessKeyID: - region: # Region (ie: us-east-1) - master: - type: m5.xlarge - rootVolume: # see below the default values - iops: 4000 - size: 100 - type: gp2 - worker: - type: m5.xlarge - rootVolume: # see below the default values - iops: 2000 - size: 100 - type: gp2 - azure: - baseDnsDomain: # baseDomain of your cluster (ie: mycompany.com) - baseDomainRGN: - clientID: - clientSecret: - tenantID: - subscriptionID: - region: - gcp: - osServiceAccountJson: |- - { - your authentication - } - projectID: - baseDnsDomain: - region: - vsphere: - username: - password: - vcenter: - cacertificate: |- - -----BEGIN CERTIFICATE----- - vSphere certificate - -----END CERTIFICATE----- - cluster: - datacenter: - datastore: - network: - baseDnsDomain: # baseDomain of your cluster (ie: mycompany.com) - apiVIP: - ingressVIP: - openstack: - baseDnsDomain: # baseDomain of your cluster (ie: mycompany.com) - cloudsYaml: |- - clouds: - openstack: - auth: - cloud: - externalNetwork: - apiFloatingIP: - ingressFloatingIP: - masterFlavor: - workerFlavor: - machineNetworkCIDR: diff --git a/pkg/cmd/create/cluster/scenario/resources.go b/pkg/cmd/create/cluster/scenario/resources.go deleted file mode 100644 index b5b3d59fa..000000000 --- a/pkg/cmd/create/cluster/scenario/resources.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package scenario - -import ( - "embed" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" -) - -//go:embed create create/*/*/_helpers.tpl -var files embed.FS - -func GetApplierScenarioResourcesReader() *applierscenarios.ApplierScenarioResourcesReader { - return applierscenarios.NewApplierScenarioResourcesReader(&files) -} diff --git a/pkg/cmd/create/cluster/test/unit/values-empty.yaml b/pkg/cmd/create/cluster/test/unit/values-empty.yaml deleted file mode 100644 index 1b4a0b558..000000000 --- a/pkg/cmd/create/cluster/test/unit/values-empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project \ No newline at end of file diff --git a/pkg/cmd/create/cluster/test/unit/values-fake-aws.yaml b/pkg/cmd/create/cluster/test/unit/values-fake-aws.yaml deleted file mode 100644 index 289d6acb9..000000000 --- a/pkg/cmd/create/cluster/test/unit/values-fake-aws.yaml +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter - cloud: aws # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - sshPublicKey: |- - Public key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - private key - -----END RSA PRIVATE KEY----- - aws: - baseDnsDomain: myBaseDnsDomain # baseDomain of your cluster (ie: mycompany.com) - awsAccessKeyID: myAccessKeyID - awsSecretAccessKeyID: mySecretAccessKeyID - region: myRegion # Region (ie: us-east-1) diff --git a/pkg/cmd/create/cluster/test/unit/values-fake-azure.yaml b/pkg/cmd/create/cluster/test/unit/values-fake-azure.yaml deleted file mode 100644 index c88fd5502..000000000 --- a/pkg/cmd/create/cluster/test/unit/values-fake-azure.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter - cloud: azure # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - sshPublicKey: |- - Public key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - private key - -----END RSA PRIVATE KEY----- - azure: - baseDnsDomain: myBaseDnsDomain - baseDomainRGN: baseDomainRGN - clientID: myclientID - clientSecret: myclientSecret - tenantID: mytenantID - subscriptionID: mySubscriptionID - region: myRegion diff --git a/pkg/cmd/create/cluster/test/unit/values-fake-gcp.yaml b/pkg/cmd/create/cluster/test/unit/values-fake-gcp.yaml deleted file mode 100644 index 2cf43cbce..000000000 --- a/pkg/cmd/create/cluster/test/unit/values-fake-gcp.yaml +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter - cloud: gcp # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - sshPublicKey: |- - Public key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - private key - -----END RSA PRIVATE KEY----- - gcp: - osServiceAccountJson: |- - { - your authentication - } - projectID: myProjectID - baseDnsDomain: myBaseDnsDomain - region: myRegion diff --git a/pkg/cmd/create/cluster/test/unit/values-fake-openstack.yaml b/pkg/cmd/create/cluster/test/unit/values-fake-openstack.yaml deleted file mode 100644 index 7b4a2b464..000000000 --- a/pkg/cmd/create/cluster/test/unit/values-fake-openstack.yaml +++ /dev/null @@ -1,46 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter - cloud: openstack # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - sshPublicKey: |- - Public key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - private key - -----END RSA PRIVATE KEY----- - openstack: - baseDnsDomain: # baseDomain of your cluster (ie: mycompany.com) - cloudsYaml: |- - clouds: - openstack: - auth: - auth_url: https://abcd - username: "fakeuser" - password: "fakepwd" - project_id: 12345678 - project_name: "fakeproject" - user_domain_name: "redhat.com" - region_name: "regionOne" - interface: "public" - identity_api_version: 3 - cloud: openstack - externalNetwork: external - apiFloatingIP: "1.1.1.1" - ingressFloatingIP: "2.2.2.2" - masterFlavor: m1.xlarge - workerFlavor: m1.2xlarge - machineNetworkCIDR: "10.0.0.0/16" diff --git a/pkg/cmd/create/cluster/test/unit/values-fake-vsphere.yaml b/pkg/cmd/create/cluster/test/unit/values-fake-vsphere.yaml deleted file mode 100644 index e316938ec..000000000 --- a/pkg/cmd/create/cluster/test/unit/values-fake-vsphere.yaml +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter - cloud: vsphere # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - sshPublicKey: |- - Public key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - private key - -----END RSA PRIVATE KEY----- - vsphere: - username: myUser - password: myPassword - vcenter: myVcenter - cacertificate: |- - -----BEGIN CERTIFICATE----- - vSphere certificate - -----END CERTIFICATE----- - cluster: myCluster - datacenter: myDataCenter - datastore: myDatastore - network: myNetwork - baseDnsDomain: myBaseDnsDomain # baseDomain of your cluster (ie: mycompany.com) - apiVIP: myAPIVIP - ingressVIP: myIngressVIP diff --git a/pkg/cmd/delete/cluster/cmd.go b/pkg/cmd/delete/cluster/cmd.go deleted file mode 100644 index a1c93689f..000000000 --- a/pkg/cmd/delete/cluster/cmd.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "fmt" - "path/filepath" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/delete/cluster/scenario" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - - "github.com/spf13/cobra" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -var example = ` -# Delete a cluster -%[1]s delete cluster --values values.yaml - -# Delete a cluster with overwritting the cluster name -%[1]s delete cluster --values values.yaml --name mycluster -` - -const ( - scenarioDirectory = "delete" -) - -var valuesTemplatePath = filepath.Join(scenarioDirectory, "values-template.yaml") - -// NewCmd ... -func NewCmd(streams genericclioptions.IOStreams) *cobra.Command { - o := newOptions(streams) - - cmd := &cobra.Command{ - Use: "cluster", - Short: "Delete a cluster", - Example: fmt.Sprintf(example, helpers.GetExampleHeader()), - SilenceUsage: true, - RunE: func(c *cobra.Command, args []string) error { - if err := o.complete(c, args); err != nil { - return err - } - if err := o.validate(); err != nil { - return err - } - if err := o.run(); err != nil { - return err - } - - return nil - }, - } - - cmd.SetUsageTemplate(applierscenarios.UsageTempate(cmd, scenario.GetApplierScenarioResourcesReader(), valuesTemplatePath)) - cmd.Flags().StringVar(&o.clusterName, "name", "", "Name of the cluster to import") - - o.applierScenariosOptions.AddFlags(cmd.Flags()) - o.applierScenariosOptions.ConfigFlags.AddFlags(cmd.Flags()) - - return cmd -} diff --git a/pkg/cmd/delete/cluster/exec.go b/pkg/cmd/delete/cluster/exec.go deleted file mode 100644 index 3ead19fb5..000000000 --- a/pkg/cmd/delete/cluster/exec.go +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "fmt" - "path/filepath" - - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/delete/cluster/scenario" - - crclient "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/spf13/cobra" -) - -func (o *Options) complete(cmd *cobra.Command, args []string) (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - //Check if default values must be used - if o.applierScenariosOptions.ValuesPath == "" { - if o.clusterName != "" { - o.values = make(map[string]interface{}) - mc := make(map[string]interface{}) - mc["name"] = o.clusterName - o.values["managedCluster"] = mc - } else { - return fmt.Errorf("values or name are missing") - } - } else { - //Read values - o.values, err = appliercmd.ConvertValuesFileToValuesMap(o.applierScenariosOptions.ValuesPath, "") - if err != nil { - return err - } - } - - if len(o.values) == 0 { - return fmt.Errorf("values are missing") - } - - return nil -} - -func (o *Options) validate() (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - return fmt.Errorf("managedCluster is missing") - } - mc := imc.(map[string]interface{}) - - if o.clusterName == "" { - iname, ok := mc["name"] - if !ok || iname == nil { - return fmt.Errorf("cluster name is missing") - } - o.clusterName = iname.(string) - if len(o.clusterName) == 0 { - return fmt.Errorf("managedCluster.name not specified") - } - } - - mc["name"] = o.clusterName - - return nil -} - -func (o *Options) run() error { - if o.applierScenariosOptions.OutTemplatesDir != "" { - reader := scenario.GetApplierScenarioResourcesReader() - return reader.ExtractAssets(scenarioDirectory, o.applierScenariosOptions.OutTemplatesDir) - } - client, err := helpers.GetControllerRuntimeClientFromFlags(o.applierScenariosOptions.ConfigFlags) - if err != nil { - return err - } - return o.runWithClient(client) -} - -func (o *Options) runWithClient(client crclient.Client) error { - - reader := scenario.GetApplierScenarioResourcesReader() - - applyOptions := &appliercmd.Options{ - OutFile: o.applierScenariosOptions.OutFile, - ConfigFlags: o.applierScenariosOptions.ConfigFlags, - - Delete: true, - Timeout: o.applierScenariosOptions.Timeout, - Force: o.applierScenariosOptions.Force, - Silent: o.applierScenariosOptions.Silent, - IOStreams: o.applierScenariosOptions.IOStreams, - } - - return applyOptions.ApplyWithValues(client, reader, - filepath.Join(scenarioDirectory, "hub", "common"), - o.values) -} diff --git a/pkg/cmd/delete/cluster/exec_test.go b/pkg/cmd/delete/cluster/exec_test.go deleted file mode 100644 index 0b3078acc..000000000 --- a/pkg/cmd/delete/cluster/exec_test.go +++ /dev/null @@ -1,280 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "context" - "path/filepath" - "testing" - - "github.com/open-cluster-management/applier/pkg/applier" - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/applier/pkg/templateprocessor" - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/spf13/cobra" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - crclientfake "sigs.k8s.io/controller-runtime/pkg/client/fake" -) - -var testDir = filepath.Join("test", "unit") - -func TestOptions_complete(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} - } - type args struct { - cmd *cobra.Command - args []string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Failed, bad valuesPath", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: "bad-values-path.yaml", - }, - }, - wantErr: true, - }, - { - name: "Failed, empty values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-empty.yaml"), - }, - }, - wantErr: true, - }, - { - name: "Success, no values.yaml, no name", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - }, - wantErr: true, - }, - { - name: "Success, no values.yaml", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - clusterName: "myCluster", - }, - wantErr: false, - }, - { - name: "Success, with values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-fake.yaml"), - }, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - values: tt.fields.values, - } - if err := o.complete(tt.args.cmd, tt.args.args); (err != nil) != tt.wantErr { - t.Errorf("Options.complete() error = %v, wantErr %v", err, tt.wantErr) - } - if !tt.wantErr { - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - t.Errorf("missing managedCluster") - } - mc := imc.(map[string]interface{}) - if tt.name == "Success, no values.yaml" { - if mc["name"] != o.clusterName { - t.Errorf("Expect %s got %s", o.clusterName, mc["name"]) - } - } - } - }) - } -} - -func TestOptions_validate(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - { - name: "Success AWS all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - }, - }, - }, - wantErr: false, - }, - { - name: "Failed name missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{}, - }, - }, - wantErr: true, - }, - { - name: "Failed name empty", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "", - }, - }, - }, - wantErr: true, - }, - { - name: "Failed managedCluster missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{}, - }, - wantErr: true, - }, - { - name: "Success replace clusterName", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - "cloud": "aws", - }, - }, - clusterName: "test2", - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - values: tt.fields.values, - } - if err := o.validate(); (err != nil) != tt.wantErr { - t.Errorf("Options.validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOptions_runWithClient(t *testing.T) { - existingMC := `apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: "run-with-client" -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - name: "run-with-client" - namespace: "run-with-client" - -` - client := crclientfake.NewFakeClient() - values, err := appliercmd.ConvertValuesFileToValuesMap(filepath.Join(testDir, "values-with-data.yaml"), "") - if err != nil { - t.Error(err) - } - - reader := templateprocessor.NewYamlStringReader(existingMC, templateprocessor.KubernetesYamlsDelimiter) - a, err := applier.NewApplier(reader, &templateprocessor.Options{}, client, nil, nil, &applier.Options{}) - if err != nil { - t.Error(err) - } - err = a.CreateResources([]string{"0"}, values) - if err != nil { - t.Error(err) - } - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} - } - type args struct { - client crclient.Client - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Success", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - //Had to set to 1 sec otherwise test timeout is reached (30s) - Timeout: 1, - }, - values: values, - clusterName: "test", - }, - args: args{ - client: client, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - // clusterName: tt.fields.clusterName, - values: tt.fields.values, - } - if err := o.runWithClient(tt.args.client); (err != nil) != tt.wantErr { - t.Errorf("Options.runWithClient() error = %v, wantErr %v", err, tt.wantErr) - } else { - obj := unstructured.Unstructured{} - obj.SetKind("ManagedCluster") - obj.SetAPIVersion("cluster.open-cluster-management.io/v1") - err := tt.args.client.Get(context.TODO(), crclient.ObjectKey{Name: tt.fields.clusterName}, &obj) - if err != nil && !errors.IsNotFound(err) { - t.Error(err) - } - obj = unstructured.Unstructured{} - obj.SetKind("ClusterDeployment") - obj.SetAPIVersion("hive.openshift.io/v1") - err = tt.args.client.Get(context.TODO(), crclient.ObjectKey{Name: tt.fields.clusterName}, &obj) - if err != nil && !errors.IsNotFound(err) { - t.Error(err) - } - } - }) - } -} diff --git a/pkg/cmd/delete/cluster/options.go b/pkg/cmd/delete/cluster/options.go deleted file mode 100644 index 3595739dc..000000000 --- a/pkg/cmd/delete/cluster/options.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -type Options struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} -} - -func newOptions(streams genericclioptions.IOStreams) *Options { - return &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(streams), - } -} diff --git a/pkg/cmd/delete/cluster/options_test.go b/pkg/cmd/delete/cluster/options_test.go deleted file mode 100644 index 0b65c7115..000000000 --- a/pkg/cmd/delete/cluster/options_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "reflect" - "testing" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -func Test_newOptions(t *testing.T) { - type args struct { - streams genericclioptions.IOStreams - } - tests := []struct { - name string - args args - want *Options - }{ - { - name: "success", - args: args{ - streams: genericclioptions.IOStreams{}, - }, - want: &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(genericclioptions.IOStreams{}), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newOptions(tt.args.streams); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newOptions() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/cmd/delete/cluster/scenario/delete/hub/common/_helpers.tpl b/pkg/cmd/delete/cluster/scenario/delete/hub/common/_helpers.tpl deleted file mode 100644 index 8bae3d802..000000000 --- a/pkg/cmd/delete/cluster/scenario/delete/hub/common/_helpers.tpl +++ /dev/null @@ -1,8 +0,0 @@ -{{- define "ocpImage" }} - {{ $release := splitList ":" .managedCluster.ocpImage }} - {{ if index $release 1 }} - {{ $release = index $release 1 | replace "_" "-" | lower }} - {{ $release = (print $release "-" .managedCluster.name ) }} -{{ $release }} - {{ end }} -{{- end }} \ No newline at end of file diff --git a/pkg/cmd/delete/cluster/scenario/delete/hub/common/cluster_deployment_cr.yaml b/pkg/cmd/delete/cluster/scenario/delete/hub/common/cluster_deployment_cr.yaml deleted file mode 100644 index e665a7865..000000000 --- a/pkg/cmd/delete/cluster/scenario/delete/hub/common/cluster_deployment_cr.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - name: "{{ .managedCluster.name }}" - namespace: "{{ .managedCluster.name }}" diff --git a/pkg/cmd/delete/cluster/scenario/delete/hub/common/managed_cluster_cr.yaml b/pkg/cmd/delete/cluster/scenario/delete/hub/common/managed_cluster_cr.yaml deleted file mode 100644 index da6a5deb2..000000000 --- a/pkg/cmd/delete/cluster/scenario/delete/hub/common/managed_cluster_cr.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - name: "{{ .managedCluster.name }}" diff --git a/pkg/cmd/delete/cluster/scenario/delete/values-template.yaml b/pkg/cmd/delete/cluster/scenario/delete/values-template.yaml deleted file mode 100644 index 86d655d0e..000000000 --- a/pkg/cmd/delete/cluster/scenario/delete/values-template.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: #, this value is overwritten by the --name parameter diff --git a/pkg/cmd/delete/cluster/scenario/resources.go b/pkg/cmd/delete/cluster/scenario/resources.go deleted file mode 100644 index 124b2335e..000000000 --- a/pkg/cmd/delete/cluster/scenario/resources.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package scenario - -import ( - "embed" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" -) - -//go:embed delete delete/*/*/_helpers.tpl -var files embed.FS - -func GetApplierScenarioResourcesReader() *applierscenarios.ApplierScenarioResourcesReader { - return applierscenarios.NewApplierScenarioResourcesReader(&files) -} diff --git a/pkg/cmd/delete/cluster/test/unit/values-empty.yaml b/pkg/cmd/delete/cluster/test/unit/values-empty.yaml deleted file mode 100644 index 1b4a0b558..000000000 --- a/pkg/cmd/delete/cluster/test/unit/values-empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project \ No newline at end of file diff --git a/pkg/cmd/delete/cluster/test/unit/values-fake.yaml b/pkg/cmd/delete/cluster/test/unit/values-fake.yaml deleted file mode 100644 index e2819c6bc..000000000 --- a/pkg/cmd/delete/cluster/test/unit/values-fake.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter diff --git a/pkg/cmd/delete/cluster/test/unit/values-with-data.yaml b/pkg/cmd/delete/cluster/test/unit/values-with-data.yaml deleted file mode 100644 index 1003f2012..000000000 --- a/pkg/cmd/delete/cluster/test/unit/values-with-data.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: run-with-client #, this value is overwritten by the --name parameter diff --git a/pkg/cmd/detach/cluster/cmd.go b/pkg/cmd/detach/cluster/cmd.go deleted file mode 100644 index eb582028b..000000000 --- a/pkg/cmd/detach/cluster/cmd.go +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "fmt" - "path/filepath" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/open-cluster-management/cm-cli/pkg/cmd/detach/cluster/scenario" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - "github.com/spf13/cobra" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -var example = ` -# Detach a cluster -%[1]s detach cluster --values values.yaml - -# Detach a cluster with overwritting the cluster name -%[1]s detach cluster --values values.yaml --name mycluster -` - -const ( - scenarioDirectory = "detach" -) - -var valuesTemplatePath = filepath.Join(scenarioDirectory, "values-template.yaml") - -// NewCmd ... -func NewCmd(streams genericclioptions.IOStreams) *cobra.Command { - o := newOptions(streams) - - cmd := &cobra.Command{ - Use: "cluster", - Short: "detach a cluster", - Example: fmt.Sprintf(example, helpers.GetExampleHeader()), - SilenceUsage: true, - RunE: func(c *cobra.Command, args []string) error { - if err := o.complete(c, args); err != nil { - return err - } - if err := o.validate(); err != nil { - return err - } - if err := o.run(); err != nil { - return err - } - - return nil - }, - } - - cmd.SetUsageTemplate(applierscenarios.UsageTempate(cmd, scenario.GetApplierScenarioResourcesReader(), valuesTemplatePath)) - cmd.Flags().StringVar(&o.clusterName, "name", "", "Name of the cluster to import") - - o.applierScenariosOptions.AddFlags(cmd.Flags()) - o.applierScenariosOptions.ConfigFlags.AddFlags(cmd.Flags()) - - return cmd -} diff --git a/pkg/cmd/detach/cluster/exec.go b/pkg/cmd/detach/cluster/exec.go deleted file mode 100644 index d8ec58841..000000000 --- a/pkg/cmd/detach/cluster/exec.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "fmt" - "path/filepath" - - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/cm-cli/pkg/cmd/detach/cluster/scenario" - "github.com/open-cluster-management/cm-cli/pkg/helpers" - - crclient "sigs.k8s.io/controller-runtime/pkg/client" - - "github.com/spf13/cobra" -) - -func (o *Options) complete(cmd *cobra.Command, args []string) (err error) { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - //Check if default values must be used - if o.applierScenariosOptions.ValuesPath == "" { - if o.clusterName != "" { - o.values = make(map[string]interface{}) - mc := make(map[string]interface{}) - mc["name"] = o.clusterName - o.values["managedCluster"] = mc - } else { - return fmt.Errorf("values or name are missing") - } - } else { - //Read values - o.values, err = appliercmd.ConvertValuesFileToValuesMap(o.applierScenariosOptions.ValuesPath, "") - if err != nil { - return err - } - } - - if len(o.values) == 0 { - return fmt.Errorf("values are missing") - } - - return nil -} - -func (o *Options) validate() error { - if o.applierScenariosOptions.OutTemplatesDir != "" { - return nil - } - imc, ok := o.values["managedCluster"] - if !ok || imc == nil { - return fmt.Errorf("managedCluster is missing") - } - mc := imc.(map[string]interface{}) - - if o.clusterName == "" { - iname, ok := mc["name"] - if !ok || iname == nil { - return fmt.Errorf("cluster name is missing") - } - o.clusterName = iname.(string) - if len(o.clusterName) == 0 { - return fmt.Errorf("managedCluster.name not specified") - } - } - - mc["name"] = o.clusterName - - return nil -} - -func (o *Options) run() error { - if o.applierScenariosOptions.OutTemplatesDir != "" { - reader := scenario.GetApplierScenarioResourcesReader() - return reader.ExtractAssets(scenarioDirectory, o.applierScenariosOptions.OutTemplatesDir) - } - client, err := helpers.GetControllerRuntimeClientFromFlags(o.applierScenariosOptions.ConfigFlags) - if err != nil { - return err - } - return o.runWithClient(client) -} - -func (o *Options) runWithClient(client crclient.Client) error { - reader := scenario.GetApplierScenarioResourcesReader() - - applyOptions := &appliercmd.Options{ - OutFile: o.applierScenariosOptions.OutFile, - ConfigFlags: o.applierScenariosOptions.ConfigFlags, - - Delete: true, - Timeout: o.applierScenariosOptions.Timeout, - Force: o.applierScenariosOptions.Force, - Silent: o.applierScenariosOptions.Silent, - IOStreams: o.applierScenariosOptions.IOStreams, - } - - return applyOptions.ApplyWithValues(client, reader, - filepath.Join(scenarioDirectory, "hub"), - o.values) - -} diff --git a/pkg/cmd/detach/cluster/exec_test.go b/pkg/cmd/detach/cluster/exec_test.go deleted file mode 100644 index a43f38851..000000000 --- a/pkg/cmd/detach/cluster/exec_test.go +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "context" - "path/filepath" - "testing" - - "github.com/open-cluster-management/applier/pkg/applier" - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - "github.com/open-cluster-management/applier/pkg/templateprocessor" - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "github.com/spf13/cobra" - crclient "sigs.k8s.io/controller-runtime/pkg/client" - crclientfake "sigs.k8s.io/controller-runtime/pkg/client/fake" -) - -var testDir = filepath.Join("test", "unit") - -func TestOptions_complete(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} - } - type args struct { - cmd *cobra.Command - args []string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Failed, bad valuesPath", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: "bad-values-path.yaml", - }, - }, - wantErr: true, - }, - { - name: "Failed, empty values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-empty.yaml"), - }, - }, - wantErr: true, - }, - { - name: "Sucess, with values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - ValuesPath: filepath.Join(testDir, "values-fake.yaml"), - }, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - values: tt.fields.values, - } - if err := o.complete(tt.args.cmd, tt.args.args); (err != nil) != tt.wantErr { - t.Errorf("Options.complete() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOptions_validate(t *testing.T) { - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} - } - tests := []struct { - name string - fields fields - wantErr bool - }{ - { - name: "Success all info in values", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "test", - }, - }, - }, - wantErr: false, - }, - { - name: "Failed name missing", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{}, - }, - wantErr: true, - }, - { - name: "Failed name empty", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{}, - values: map[string]interface{}{ - "managedCluster": map[string]interface{}{ - "name": "", - }, - }, - }, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - clusterName: tt.fields.clusterName, - values: tt.fields.values, - } - if err := o.validate(); (err != nil) != tt.wantErr { - t.Errorf("Options.validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestOptions_runWithClient(t *testing.T) { - existingMC := `apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: "run-with-client" -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 -` - client := crclientfake.NewFakeClient() - values, err := appliercmd.ConvertValuesFileToValuesMap(filepath.Join(testDir, "values-with-data.yaml"), "") - if err != nil { - t.Error(err) - } - - reader := templateprocessor.NewYamlStringReader(existingMC, templateprocessor.KubernetesYamlsDelimiter) - a, err := applier.NewApplier(reader, &templateprocessor.Options{}, client, nil, nil, &applier.Options{}) - if err != nil { - t.Error(err) - } - err = a.CreateResources([]string{"0"}, values) - if err != nil { - t.Error(err) - } - type fields struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} - } - type args struct { - client crclient.Client - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Success", - fields: fields{ - applierScenariosOptions: &applierscenarios.ApplierScenariosOptions{ - //Had to set to 1 sec otherwise test timeout is reached (30s) - Timeout: 1, - }, - values: values, - clusterName: "test", - }, - args: args{ - client: client, - }, - wantErr: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - o := &Options{ - applierScenariosOptions: tt.fields.applierScenariosOptions, - // clusterName: tt.fields.clusterName, - values: tt.fields.values, - } - if err := o.runWithClient(tt.args.client); (err != nil) != tt.wantErr { - t.Errorf("Options.runWithClient() error = %v, wantErr %v", err, tt.wantErr) - } else { - obj := unstructured.Unstructured{} - obj.SetKind("ManagedCluster") - obj.SetAPIVersion("cluster.open-cluster-management.io/v1") - err := tt.args.client.Get(context.TODO(), crclient.ObjectKey{Name: tt.fields.clusterName}, &obj) - if err != nil && !errors.IsNotFound(err) { - t.Error(err) - } - } - }) - } -} diff --git a/pkg/cmd/detach/cluster/options.go b/pkg/cmd/detach/cluster/options.go deleted file mode 100644 index 3595739dc..000000000 --- a/pkg/cmd/detach/cluster/options.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -type Options struct { - applierScenariosOptions *applierscenarios.ApplierScenariosOptions - clusterName string - values map[string]interface{} -} - -func newOptions(streams genericclioptions.IOStreams) *Options { - return &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(streams), - } -} diff --git a/pkg/cmd/detach/cluster/options_test.go b/pkg/cmd/detach/cluster/options_test.go deleted file mode 100644 index 0b65c7115..000000000 --- a/pkg/cmd/detach/cluster/options_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package cluster - -import ( - "reflect" - "testing" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -func Test_newOptions(t *testing.T) { - type args struct { - streams genericclioptions.IOStreams - } - tests := []struct { - name string - args args - want *Options - }{ - { - name: "success", - args: args{ - streams: genericclioptions.IOStreams{}, - }, - want: &Options{ - applierScenariosOptions: applierscenarios.NewApplierScenariosOptions(genericclioptions.IOStreams{}), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := newOptions(tt.args.streams); !reflect.DeepEqual(got, tt.want) { - t.Errorf("newOptions() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/pkg/cmd/detach/cluster/scenario/detach/hub/managed_cluster_cr.yaml b/pkg/cmd/detach/cluster/scenario/detach/hub/managed_cluster_cr.yaml deleted file mode 100644 index 05d802550..000000000 --- a/pkg/cmd/detach/cluster/scenario/detach/hub/managed_cluster_cr.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - {{ if eq .managedCluster.name "local-cluster" }} - local-cluster: "true" - {{ end }} - name: "{{ .managedCluster.name }}" -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 diff --git a/pkg/cmd/detach/cluster/scenario/resources.go b/pkg/cmd/detach/cluster/scenario/resources.go deleted file mode 100644 index 9bd7104ca..000000000 --- a/pkg/cmd/detach/cluster/scenario/resources.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package scenario - -import ( - "embed" - - "github.com/open-cluster-management/cm-cli/pkg/cmd/applierscenarios" -) - -//go:embed detach -var files embed.FS - -func GetApplierScenarioResourcesReader() *applierscenarios.ApplierScenarioResourcesReader { - return applierscenarios.NewApplierScenarioResourcesReader(&files) -} diff --git a/pkg/cmd/detach/cluster/test/unit/values-empty.yaml b/pkg/cmd/detach/cluster/test/unit/values-empty.yaml deleted file mode 100644 index 1b4a0b558..000000000 --- a/pkg/cmd/detach/cluster/test/unit/values-empty.yaml +++ /dev/null @@ -1 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project \ No newline at end of file diff --git a/pkg/cmd/detach/cluster/test/unit/values-fake.yaml b/pkg/cmd/detach/cluster/test/unit/values-fake.yaml deleted file mode 100644 index e2819c6bc..000000000 --- a/pkg/cmd/detach/cluster/test/unit/values-fake.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: fake #, this value is overwritten by the --name parameter diff --git a/pkg/cmd/detach/cluster/test/unit/values-with-data.yaml b/pkg/cmd/detach/cluster/test/unit/values-with-data.yaml deleted file mode 100644 index 1003f2012..000000000 --- a/pkg/cmd/detach/cluster/test/unit/values-with-data.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: run-with-client #, this value is overwritten by the --name parameter diff --git a/pkg/cmd/get/clusters/cmd.go b/pkg/cmd/get/clusters/cmd.go deleted file mode 100644 index 0477645bd..000000000 --- a/pkg/cmd/get/clusters/cmd.go +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright Contributors to the Open Cluster Management project -package clusters - -import ( - "fmt" - - "k8s.io/kubectl/pkg/cmd/get" - cmdutil "k8s.io/kubectl/pkg/cmd/util" - - "github.com/open-cluster-management/cm-cli/pkg/helpers" - "github.com/spf13/cobra" - "k8s.io/cli-runtime/pkg/genericclioptions" -) - -const ( - example = ` - # get a cluster - %[1]s clusters -oyaml` -) - -// NewCmd ... -func NewCmd(f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - o := get.NewGetOptions("cm", streams) - cmd := &cobra.Command{ - Use: "clusters [(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...] (TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags]", - Aliases: []string{"cluster"}, - DisableFlagsInUseLine: true, - Short: "Display one or many resources", - Example: fmt.Sprintf(example, helpers.GetExampleHeader()), - Run: func(cmd *cobra.Command, args []string) { - args = append([]string{"managedcluster"}, args...) - cmdutil.CheckErr(o.Complete(f, cmd, args)) - cmdutil.CheckErr(o.Validate(cmd)) - cmdutil.CheckErr(o.Run(f, cmd, args)) - }, - SuggestFor: []string{"list", "ps"}, - } - - o.PrintFlags.AddFlags(cmd) - - cmd.Flags().BoolVarP(&o.Watch, "watch", "w", o.Watch, "After listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided.") - cmd.Flags().BoolVar(&o.WatchOnly, "watch-only", o.WatchOnly, "Watch for changes to the requested object(s), without listing/getting first.") - cmd.Flags().BoolVar(&o.OutputWatchEvents, "output-watch-events", o.OutputWatchEvents, "Output watch event objects when --watch or --watch-only is used. Existing objects are output as initial ADDED events.") - cmd.Flags().Int64Var(&o.ChunkSize, "chunk-size", o.ChunkSize, "Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future.") - cmd.Flags().BoolVar(&o.IgnoreNotFound, "ignore-not-found", o.IgnoreNotFound, "If the requested object does not exist the command will return exit code 0.") - cmd.Flags().StringVarP(&o.LabelSelector, "selector", "l", o.LabelSelector, "Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)") - cmd.Flags().StringVar(&o.FieldSelector, "field-selector", o.FieldSelector, "Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.") - cmd.Flags().BoolVarP(&o.AllNamespaces, "all-namespaces", "A", o.AllNamespaces, "If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.") - addOpenAPIPrintColumnFlags(cmd, o) - addServerPrintColumnFlags(cmd, o) - cmdutil.AddFilenameOptionFlags(cmd, &o.FilenameOptions, "identifying the resource to get from a server.") - return cmd -} - -const ( - useOpenAPIPrintColumnFlagLabel = "use-openapi-print-columns" - useServerPrintColumns = "server-print" -) - -func addOpenAPIPrintColumnFlags(cmd *cobra.Command, opt *get.GetOptions) { - cmd.Flags().BoolVar(&opt.PrintWithOpenAPICols, useOpenAPIPrintColumnFlagLabel, opt.PrintWithOpenAPICols, "If true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource.") - cmd.Flags().MarkDeprecated(useOpenAPIPrintColumnFlagLabel, "deprecated in favor of server-side printing") -} - -func addServerPrintColumnFlags(cmd *cobra.Command, opt *get.GetOptions) { - cmd.Flags().BoolVar(&opt.ServerPrint, useServerPrintColumns, opt.ServerPrint, "If true, have the server return the appropriate table output. Supports extension APIs and CRDs.") -} diff --git a/pkg/cmd/verbs/verbs.go b/pkg/cmd/verbs/verbs.go index 8cfbd3cf6..cea72d1f5 100644 --- a/pkg/cmd/verbs/verbs.go +++ b/pkg/cmd/verbs/verbs.go @@ -4,12 +4,6 @@ package verbs import ( "fmt" - appliercmd "github.com/open-cluster-management/applier/pkg/applier/cmd" - attachcluster "github.com/open-cluster-management/cm-cli/pkg/cmd/attach/cluster" - createcluster "github.com/open-cluster-management/cm-cli/pkg/cmd/create/cluster" - deletecluster "github.com/open-cluster-management/cm-cli/pkg/cmd/delete/cluster" - detachcluster "github.com/open-cluster-management/cm-cli/pkg/cmd/detach/cluster" - getclusters "github.com/open-cluster-management/cm-cli/pkg/cmd/get/clusters" "github.com/spf13/cobra" "k8s.io/cli-runtime/pkg/genericclioptions" @@ -19,100 +13,15 @@ import ( ) //NewVerb creates a new verb -func NewVerb(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { +func NewVerb(parent string, verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { switch verb { - case "create": - return newVerbCreate(verb, f, streams) case "get": - return newVerbGet(verb, f, streams) - case "update": - return newVerbUpdate(verb, f, streams) - case "delete": - return newVerbDelete(verb, f, streams) - case "list": - return newVerbList(verb, f, streams) - case "attach": - return newVerbAttach(verb, f, streams) - case "applier": - return newVerbApplier(verb, f, streams) - case "detach": - return newVerbDetach(verb, f, streams) + return newVerbGet(parent, verb, f, streams) } panic(fmt.Sprintf("Unknow verb: %s", verb)) } -func newVerbCreate(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: verb, - } - cmd.AddCommand( - createcluster.NewCmd(streams), - ) - - return cmd -} - -func newVerbGet(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := get.NewCmdGet("cm", f, streams) - cmd.AddCommand( - getclusters.NewCmd(f, streams), - ) - return cmd -} - -func newVerbUpdate(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: verb, - Short: "Not yet implemented", - } - - return cmd -} - -func newVerbDelete(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: verb, - } - cmd.AddCommand( - deletecluster.NewCmd(streams), - ) - - return cmd -} - -func newVerbList(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: verb, - Short: "Not yet implemented", - } - - return cmd -} - -func newVerbApplier(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := appliercmd.NewCmd(streams) - - return cmd -} - -func newVerbAttach(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: verb, - Short: "Attach cluster to hub", - } - - cmd.AddCommand(attachcluster.NewCmd(streams)) - - return cmd -} - -func newVerbDetach(verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: verb, - Short: "Detatch a cluster from the hub", - } - - cmd.AddCommand(detachcluster.NewCmd(streams)) - +func newVerbGet(parent string, verb string, f cmdutil.Factory, streams genericclioptions.IOStreams) *cobra.Command { + cmd := get.NewCmdGet(parent, f, streams) return cmd } diff --git a/test/functional/attach/cluster/fake-kubeconfig.yaml b/test/functional/attach/cluster/fake-kubeconfig.yaml deleted file mode 100644 index ccc3f3365..000000000 --- a/test/functional/attach/cluster/fake-kubeconfig.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -apiVersion: v1 -clusters: -- cluster: - certificate-authority-data: - server: https://127.0.0.1:55005 - name: kind-kind -contexts: -- context: - cluster: kind-kind - user: kind-kind - name: kind-kind -current-context: kind-kind -kind: Config -preferences: {} -users: -- name: kind-kind - user: - client-certificate-data: - client-key-data: \ No newline at end of file diff --git a/test/functional/attach/cluster/kubeconfig_no_values_result.yaml b/test/functional/attach/cluster/kubeconfig_no_values_result.yaml deleted file mode 100644 index e04d0e57c..000000000 --- a/test/functional/attach/cluster/kubeconfig_no_values_result.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: auto-import-secret - namespace: mycluster -stringData: - autoImportRetry: "5" - kubeconfig: |- - # Copyright Contributors to the Open Cluster Management project - apiVersion: v1 - clusters: - - cluster: - certificate-authority-data: - server: https://127.0.0.1:55005 - name: kind-kind - contexts: - - context: - cluster: kind-kind - user: kind-kind - name: kind-kind - current-context: kind-kind - kind: Config - preferences: {} - users: - - name: kind-kind - user: - client-certificate-data: - client-key-data: -type: Opaque ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - argocdCluster: false - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: auto-detect - vendor: auto-detect - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true diff --git a/test/functional/attach/cluster/kubeconfig_result.yaml b/test/functional/attach/cluster/kubeconfig_result.yaml deleted file mode 100644 index 5a0168719..000000000 --- a/test/functional/attach/cluster/kubeconfig_result.yaml +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: auto-import-secret - namespace: mycluster -stringData: - autoImportRetry: "5" - kubeconfig: 'kubeconfig: fakeVAlue' -type: Opaque ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - argocdCluster: false - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: auto-detect - vendor: auto-detect - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true diff --git a/test/functional/attach/cluster/kubeconfig_values.yaml b/test/functional/attach/cluster/kubeconfig_values.yaml deleted file mode 100755 index 2cc527559..000000000 --- a/test/functional/attach/cluster/kubeconfig_values.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - addons: - applicationManager: - argocdCluster: false - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.3.0 - autoImportRetry: 5 - kubeConfig: |- - kubeconfig: fakeVAlue \ No newline at end of file diff --git a/test/functional/attach/cluster/manual_no_values_result.yaml b/test/functional/attach/cluster/manual_no_values_result.yaml deleted file mode 100644 index 8701410d5..000000000 --- a/test/functional/attach/cluster/manual_no_values_result.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - argocdCluster: false - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: auto-detect - vendor: auto-detect - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true diff --git a/test/functional/attach/cluster/manual_result.yaml b/test/functional/attach/cluster/manual_result.yaml deleted file mode 100644 index 8701410d5..000000000 --- a/test/functional/attach/cluster/manual_result.yaml +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - argocdCluster: false - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: auto-detect - vendor: auto-detect - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true diff --git a/test/functional/attach/cluster/manual_values.yaml b/test/functional/attach/cluster/manual_values.yaml deleted file mode 100755 index fa79fdce2..000000000 --- a/test/functional/attach/cluster/manual_values.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - addons: - applicationManager: - argocdCluster: false - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - token: "" - # kubeConfig: "" - diff --git a/test/functional/attach/cluster/token_result.yaml b/test/functional/attach/cluster/token_result.yaml deleted file mode 100644 index f61e57e45..000000000 --- a/test/functional/attach/cluster/token_result.yaml +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: auto-import-secret - namespace: mycluster -stringData: - autoImportRetry: "5" - server: https://fakeurl - token: fakeToken -type: Opaque ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: auto-detect - vendor: auto-detect - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - argocdCluster: false - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: auto-detect - vendor: auto-detect - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true diff --git a/test/functional/attach/cluster/token_values.yaml b/test/functional/attach/cluster/token_values.yaml deleted file mode 100755 index eede74141..000000000 --- a/test/functional/attach/cluster/token_values.yaml +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - addons: - applicationManager: - argocdCluster: false - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - autoImportRetry: 5 - token: fakeToken - server: https://fakeurl \ No newline at end of file diff --git a/test/functional/create/cluster/aws_result.yaml b/test/functional/create/cluster/aws_result.yaml deleted file mode 100644 index cfd15fb15..000000000 --- a/test/functional/create/cluster/aws_result.yaml +++ /dev/null @@ -1,136 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-creds - namespace: mycluster -stringData: - aws_access_key_id: awsAccessKeyIDValue - aws_secret_access_key: awsSecretAccessKeyIDValue -type: Opaque ---- -apiVersion: v1 -data: - install-config.yaml: YXBpVmVyc2lvbjogdjEKYmFzZURvbWFpbjogYmFzZURuc0RvbWFpblZhbHVlCmNvbXB1dGU6Ci0gaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBuYW1lOiB3b3JrZXIKICBwbGF0Zm9ybToKICAgIGF3czoKICAgICAgcm9vdFZvbHVtZToKICAgICAgICBpb3BzOiAyMDAwCiAgICAgICAgc2l6ZTogMTAwCiAgICAgICAgdHlwZTogZ3AyCiAgICAgIHR5cGU6IG01LnhsYXJnZQogIHJlcGxpY2FzOiAzCmNvbnRyb2xQbGFuZToKICBoeXBlcnRocmVhZGluZzogRW5hYmxlZAogIG5hbWU6IG1hc3RlcgogIHBsYXRmb3JtOgogICAgYXdzOgogICAgICByb290Vm9sdW1lOgogICAgICAgIGlvcHM6IDQwMDAKICAgICAgICBzaXplOiAxMDAKICAgICAgICB0eXBlOiBncDIKICAgICAgdHlwZTogbTUueGxhcmdlCiAgcmVwbGljYXM6IDMKbWV0YWRhdGE6CiAgbmFtZTogbXljbHVzdGVyCm5ldHdvcmtpbmc6CiAgY2x1c3Rlck5ldHdvcms6CiAgLSBjaWRyOiAxMC4xMjguMC4wLzE0CiAgICBob3N0UHJlZml4OiAyMwogIG1hY2hpbmVOZXR3b3JrOgogIC0gY2lkcjogMTAuMC4wLjAvMTYKICBuZXR3b3JrVHlwZTogT3BlblNoaWZ0U0ROCiAgc2VydmljZU5ldHdvcms6CiAgLSAxNzIuMzAuMC4wLzE2CnBsYXRmb3JtOgogIGF3czoKICAgIHJlZ2lvbjogcmVnaW9uVmFsdWUKcHVsbFNlY3JldDogIiIKc3NoS2V5OiBzc2gtcnNhIGZha2Uga2V5Cg== -kind: Secret -metadata: - name: mycluster-install-config - namespace: mycluster -type: Opaque ---- -apiVersion: v1 -data: - .dockerconfigjson: eyJmYWtlX3B1bGxfc2VjcmV0IjoiZmFrZV9wdWxsX3NlY3JldCJ9Cg== -kind: Secret -metadata: - name: mycluster-pull-secret - namespace: mycluster -type: kubernetes.io/dockerconfigjson ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-ssh-private-key - namespace: mycluster -stringData: - ssh-privatekey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- -type: Opaque ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterImageSet -metadata: - name: 4.6.17-x86-64-mycluster -spec: - releaseImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: aws - name: mycluster - vendor: OpenShift - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: aws - vendor: OpenShift - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - labels: - cloud: aws - vendor: OpenShift - name: mycluster - namespace: mycluster -spec: - baseDomain: baseDnsDomainValue - clusterName: mycluster - controlPlaneConfig: - servingCertificates: {} - installAttemptsLimit: 1 - installed: false - platform: - aws: - credentialsSecretRef: - name: mycluster-creds - region: regionValue - provisioning: - imageSetRef: - name: 4.6.17-x86-64-mycluster - installConfigSecretRef: - name: mycluster-install-config - sshPrivateKeySecretRef: - name: mycluster-ssh-private-key - pullSecretRef: - name: mycluster-pull-secret ---- -apiVersion: hive.openshift.io/v1 -kind: MachinePool -metadata: - name: mycluster-worker - namespace: mycluster -spec: - clusterDeploymentRef: - name: mycluster - name: worker - platform: - aws: - rootVolume: - iops: 2000 - size: 100 - type: gp2 - type: m5.xlarge - replicas: 3 diff --git a/test/functional/create/cluster/aws_values.yaml b/test/functional/create/cluster/aws_values.yaml deleted file mode 100755 index 38e9cbe5b..000000000 --- a/test/functional/create/cluster/aws_values.yaml +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - cloud: aws # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - sshPublicKey: |- - ssh-rsa fake key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- - aws: - awsAccessKeyID: awsAccessKeyIDValue - awsSecretAccessKeyID: awsSecretAccessKeyIDValue - baseDnsDomain: baseDnsDomainValue - region: regionValue diff --git a/test/functional/create/cluster/azure_result.yaml b/test/functional/create/cluster/azure_result.yaml deleted file mode 100644 index 6ad45ef7f..000000000 --- a/test/functional/create/cluster/azure_result.yaml +++ /dev/null @@ -1,139 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-creds - namespace: mycluster -stringData: - osServicePrincipal.json: '{"clientId": "clientIDValue", "clientSecret": "clientSecretValue", - "tenantId": "tenantIDValue", "subscriptionId": "subscriptionIDValue"}' -type: Opaque ---- -apiVersion: v1 -data: - install-config.yaml: YXBpVmVyc2lvbjogdjEKYmFzZURvbWFpbjogYmFzZURuc0RvbWFpblZhbHVlCmNvbXB1dGU6Ci0gaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBuYW1lOiB3b3JrZXIKICBwbGF0Zm9ybToKICAgIGF6dXJlOgogICAgICBvc0Rpc2s6CiAgICAgICAgZGlza1NpemVHQjogMTI4CiAgICAgIHR5cGU6IFN0YW5kYXJkX0Qyc192MwogICAgICB6b25lczoKICAgICAgLSAiMSIKICAgICAgLSAiMiIKICAgICAgLSAiMyIKICByZXBsaWNhczogMwpjb250cm9sUGxhbmU6CiAgaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBuYW1lOiBtYXN0ZXIKICBwbGF0Zm9ybToKICAgIGF6dXJlOgogICAgICBvc0Rpc2s6CiAgICAgICAgZGlza1NpemVHQjogMTI4CiAgICAgIHR5cGU6IFN0YW5kYXJkX0Q0c192MwogIHJlcGxpY2FzOiAzCm1ldGFkYXRhOgogIG5hbWU6IG15Y2x1c3RlcgpuZXR3b3JraW5nOgogIGNsdXN0ZXJOZXR3b3JrOgogIC0gY2lkcjogMTAuMTI4LjAuMC8xNAogICAgaG9zdFByZWZpeDogMjMKICBtYWNoaW5lTmV0d29yazoKICAtIGNpZHI6IDEwLjAuMC4wLzE2CiAgbmV0d29ya1R5cGU6IE9wZW5TaGlmdFNETgogIHNlcnZpY2VOZXR3b3JrOgogIC0gMTcyLjMwLjAuMC8xNgpwbGF0Zm9ybToKICBhenVyZToKICAgIGJhc2VEb21haW5SZXNvdXJjZUdyb3VwTmFtZTogYmFzZURvbWFpblJHTlZhbHVlCiAgICByZWdpb246IHJlZ2lvblZhbHVlCnB1bGxTZWNyZXQ6ICIiCnNzaEtleTogc3NoLXJzYSBmYWtlIGtleQo= -kind: Secret -metadata: - name: mycluster-install-config - namespace: mycluster -type: Opaque ---- -apiVersion: v1 -data: - .dockerconfigjson: eyJmYWtlX3B1bGxfc2VjcmV0IjoiZmFrZV9wdWxsX3NlY3JldCJ9Cg== -kind: Secret -metadata: - name: mycluster-pull-secret - namespace: mycluster -type: kubernetes.io/dockerconfigjson ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-ssh-private-key - namespace: mycluster -stringData: - ssh-privatekey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- -type: Opaque ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterImageSet -metadata: - name: 4.6.17-x86-64-mycluster -spec: - releaseImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: azure - name: mycluster - vendor: OpenShift - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: azure - vendor: OpenShift - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - labels: - cloud: azure - vendor: OpenShift - name: mycluster - namespace: mycluster -spec: - baseDomain: baseDnsDomainValue - clusterName: mycluster - controlPlaneConfig: - servingCertificates: {} - installAttemptsLimit: 1 - installed: false - platform: - azure: - baseDomainResourceGroupName: baseDomainRGNValue - credentialsSecretRef: - name: mycluster-creds - region: regionValue - provisioning: - imageSetRef: - name: 4.6.17-x86-64-mycluster - installConfigSecretRef: - name: mycluster-install-config - sshPrivateKeySecretRef: - name: mycluster-ssh-private-key - pullSecretRef: - name: mycluster-pull-secret ---- -apiVersion: hive.openshift.io/v1 -kind: MachinePool -metadata: - name: mycluster-worker - namespace: mycluster -spec: - clusterDeploymentRef: - name: mycluster - name: worker - platform: - azure: - osDisk: - diskSizeGB: 128 - type: Standard_D2s_v3 - zones: - - "1" - - "2" - - "3" - replicas: 3 diff --git a/test/functional/create/cluster/azure_values.yaml b/test/functional/create/cluster/azure_values.yaml deleted file mode 100755 index 35cf1a414..000000000 --- a/test/functional/create/cluster/azure_values.yaml +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - cloud: azure # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - sshPublicKey: |- - ssh-rsa fake key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- - azure: - clientID: clientIDValue - clientSecret: clientSecretValue - tenantID: tenantIDValue - subscriptionID: subscriptionIDValue - baseDomainRGN: baseDomainRGNValue - baseDnsDomain: baseDnsDomainValue - region: regionValue diff --git a/test/functional/create/cluster/gcp_result.yaml b/test/functional/create/cluster/gcp_result.yaml deleted file mode 100644 index 86d7be941..000000000 --- a/test/functional/create/cluster/gcp_result.yaml +++ /dev/null @@ -1,131 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-creds - namespace: mycluster -stringData: - osServiceAccount.json: '{"fakeJson":"fakeJsonValue"}' -type: Opaque ---- -apiVersion: v1 -data: - install-config.yaml: YXBpVmVyc2lvbjogdjEKYmFzZURvbWFpbjogYmFzZURuc0RvbWFpblZhbHVlCmNvbXB1dGU6Ci0gaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBwbGF0Zm9ybToKICAgIGdjcDoKICAgICAgdHlwZTogbjEtc3RhbmRhcmQtNAogIHJlcGxpY2FzOiAzCmNvbnRyb2xQbGFuZToKICBoeXBlcnRocmVhZGluZzogRW5hYmxlZAogIG5hbWU6IG1hc3RlcgogIHBsYXRmb3JtOgogICAgZ2NwOgogICAgICB0eXBlOiBuMS1zdGFuZGFyZC00CiAgcmVwbGljYXM6IDMKbWV0YWRhdGE6CiAgbmFtZTogbXljbHVzdGVyCm5ldHdvcmtpbmc6CiAgY2x1c3Rlck5ldHdvcms6CiAgLSBjaWRyOiAxMC4xMjguMC4wLzE0CiAgICBob3N0UHJlZml4OiAyMwogIG1hY2hpbmVOZXR3b3JrOgogIC0gY2lkcjogMTAuMC4wLjAvMTYKICBuZXR3b3JrVHlwZTogT3BlblNoaWZ0U0ROCiAgc2VydmljZU5ldHdvcms6CiAgLSAxNzIuMzAuMC4wLzE2CnBsYXRmb3JtOgogIGdjcDoKICAgIHByb2plY3RJRDogbXlwcm9qZWN0SUQKICAgIHJlZ2lvbjogcmVnaW9uVmFsdWUKcHVsbFNlY3JldDogIiIKc3NoS2V5OiBzc2gtcnNhIGZha2Uga2V5Cg== -kind: Secret -metadata: - name: mycluster-install-config - namespace: mycluster -type: Opaque ---- -apiVersion: v1 -data: - .dockerconfigjson: eyJmYWtlX3B1bGxfc2VjcmV0IjoiZmFrZV9wdWxsX3NlY3JldCJ9Cg== -kind: Secret -metadata: - name: mycluster-pull-secret - namespace: mycluster -type: kubernetes.io/dockerconfigjson ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-ssh-private-key - namespace: mycluster -stringData: - ssh-privatekey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- -type: Opaque ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterImageSet -metadata: - name: 4.6.17-x86-64-mycluster -spec: - releaseImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: gcp - name: mycluster - vendor: OpenShift - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: gcp - vendor: OpenShift - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - labels: - cloud: gcp - vendor: OpenShift - name: mycluster - namespace: mycluster -spec: - baseDomain: baseDnsDomainValue - clusterName: mycluster - controlPlaneConfig: - servingCertificates: {} - installAttemptsLimit: 1 - installed: false - platform: - gcp: - credentialsSecretRef: - name: mycluster-creds - region: regionValue - provisioning: - imageSetRef: - name: 4.6.17-x86-64-mycluster - installConfigSecretRef: - name: mycluster-install-config - sshPrivateKeySecretRef: - name: mycluster-ssh-private-key - pullSecretRef: - name: mycluster-pull-secret ---- -apiVersion: hive.openshift.io/v1 -kind: MachinePool -metadata: - name: mycluster-worker - namespace: mycluster -spec: - clusterDeploymentRef: - name: mycluster - name: worker - platform: - gcp: - type: n1-standard-4 - replicas: 3 diff --git a/test/functional/create/cluster/gcp_values.yaml b/test/functional/create/cluster/gcp_values.yaml deleted file mode 100755 index a8a4bc855..000000000 --- a/test/functional/create/cluster/gcp_values.yaml +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - cloud: gcp # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - sshPublicKey: |- - ssh-rsa fake key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- - gcp: - baseDnsDomain: baseDnsDomainValue - region: regionValue - projectID: myprojectID - osServiceAccountJson: |- - {"fakeJson":"fakeJsonValue"} diff --git a/test/functional/create/cluster/openstack_result.yaml b/test/functional/create/cluster/openstack_result.yaml deleted file mode 100644 index 875b79d89..000000000 --- a/test/functional/create/cluster/openstack_result.yaml +++ /dev/null @@ -1,144 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-creds - namespace: mycluster -stringData: - cloud: openstack - clouds.yaml: |- - clouds: - openstack: - auth: - auth_url: https://abcd - username: "fakeuser" - password: "fakepwd" - project_id: 12345678 - project_name: "fakeproject" - user_domain_name: "redhat.com" - region_name: "regionOne" - interface: "public" - identity_api_version: 3 -type: Opaque ---- -apiVersion: v1 -data: - install-config.yaml: YXBpVmVyc2lvbjogdjEKYmFzZURvbWFpbjogYmFzZS5kbnMuZG9tYWluLnZhbHVlCmNvbXB1dGU6Ci0gaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBuYW1lOiB3b3JrZXIKICBwbGF0Zm9ybToKICAgIG9wZW5zdGFjazoKICAgICAgdHlwZTogbTEuMnhsYXJnZQogIHJlcGxpY2FzOiAzCmNvbnRyb2xQbGFuZToKICBoeXBlcnRocmVhZGluZzogRW5hYmxlZAogIG5hbWU6IG1hc3RlcgogIHBsYXRmb3JtOgogICAgb3BlbnN0YWNrOgogICAgICB0eXBlOiBtMS54bGFyZ2UKICByZXBsaWNhczogMwptZXRhZGF0YToKICBuYW1lOiBteWNsdXN0ZXIKbmV0d29ya2luZzoKICBjbHVzdGVyTmV0d29yazoKICAtIGNpZHI6IDEwLjEyOC4wLjAvMTQKICAgIGhvc3RQcmVmaXg6IDIzCiAgbWFjaGluZU5ldHdvcms6CiAgLSBjaWRyOiAxMC4wLjAuMC8xNgogIG5ldHdvcmtUeXBlOiBPcGVuU2hpZnRTRE4KICBzZXJ2aWNlTmV0d29yazoKICAtIDE3Mi4zMC4wLjAvMTYKcGxhdGZvcm06CiAgb3BlbnN0YWNrOgogICAgY2xvdWQ6IG9wZW5zdGFjawogICAgZXh0ZXJuYWxOZXR3b3JrOiBleHRlcm5hbAogICAgaW5ncmVzc0Zsb2F0aW5nSVA6IDIuMi4yLjIKICAgIGxiRmxvYXRpbmdJUDogMS4xLjEuMQpwdWxsU2VjcmV0OiAiIgpzc2hLZXk6IHNzaC1yc2EgZmFrZSBrZXkK -kind: Secret -metadata: - name: mycluster-install-config - namespace: mycluster -type: Opaque ---- -apiVersion: v1 -data: - .dockerconfigjson: eyJmYWtlX3B1bGxfc2VjcmV0IjoiZmFrZV9wdWxsX3NlY3JldCJ9Cg== -kind: Secret -metadata: - name: mycluster-pull-secret - namespace: mycluster -type: kubernetes.io/dockerconfigjson ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-ssh-private-key - namespace: mycluster -stringData: - ssh-privatekey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- -type: Opaque ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterImageSet -metadata: - name: 4.6.17-x86-64-mycluster -spec: - releaseImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: openstack - name: mycluster - vendor: OpenShift - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: openstack - vendor: OpenShift - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - labels: - cloud: openstack - vendor: OpenShift - name: mycluster - namespace: mycluster -spec: - baseDomain: base.dns.domain.value - clusterName: mycluster - controlPlaneConfig: - servingCertificates: {} - installAttemptsLimit: 1 - installed: false - platform: - openstack: - cloud: openstack - credentialsSecretRef: - name: mycluster-creds - provisioning: - imageSetRef: - name: 4.6.17-x86-64-mycluster - installConfigSecretRef: - name: mycluster-install-config - sshPrivateKeySecretRef: - name: mycluster-ssh-private-key - pullSecretRef: - name: mycluster-pull-secret ---- -apiVersion: hive.openshift.io/v1 -kind: MachinePool -metadata: - name: mycluster-worker - namespace: mycluster -spec: - clusterDeploymentRef: - name: mycluster - name: worker - platform: - openstack: - flavor: m1.2xlarge - replicas: 3 diff --git a/test/functional/create/cluster/openstack_values.yaml b/test/functional/create/cluster/openstack_values.yaml deleted file mode 100644 index 754262e13..000000000 --- a/test/functional/create/cluster/openstack_values.yaml +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - cloud: openstack # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - sshPublicKey: |- - ssh-rsa fake key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- - openstack: - baseDnsDomain: base.dns.domain.value - cloudsYaml: |- - clouds: - openstack: - auth: - auth_url: https://abcd - username: "fakeuser" - password: "fakepwd" - project_id: 12345678 - project_name: "fakeproject" - user_domain_name: "redhat.com" - region_name: "regionOne" - interface: "public" - identity_api_version: 3 - cloud: openstack - externalNetwork: external - apiFloatingIP: "1.1.1.1" - ingressFloatingIP: "2.2.2.2" - masterFlavor: m1.xlarge - workerFlavor: m1.2xlarge - machineNetworkCIDR: "10.0.0.0/16" diff --git a/test/functional/create/cluster/vsphere_result.yaml b/test/functional/create/cluster/vsphere_result.yaml deleted file mode 100644 index 352390344..000000000 --- a/test/functional/create/cluster/vsphere_result.yaml +++ /dev/null @@ -1,151 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -# Generated by github.com/open-cluster-management/applier/pkg/templateprocessor - -apiVersion: v1 -kind: Namespace -metadata: - name: mycluster ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-creds - namespace: mycluster -stringData: - password: passwordValue - username: usernameValue -type: Opaque ---- -apiVersion: v1 -data: - install-config.yaml: YXBpVmVyc2lvbjogdjEKYmFzZURvbWFpbjogYmFzZURuc0RvbWFpblZhbHVlCmNvbXB1dGU6Ci0gaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBuYW1lOiB3b3JrZXIKICBwbGF0Zm9ybToKICAgIHZzcGhlcmU6CiAgICAgIGNvcmVzUGVyU29ja2V0OiAyCiAgICAgIGNwdXM6IDQKICAgICAgbWVtb3J5TUI6IDE2Mzg0CiAgICAgIG9zRGlzazoKICAgICAgICBkaXNrU2l6ZUdCOiAxMjAKICByZXBsaWNhczogMwpjb250cm9sUGxhbmU6CiAgaHlwZXJ0aHJlYWRpbmc6IEVuYWJsZWQKICBuYW1lOiBtYXN0ZXIKICBwbGF0Zm9ybToKICAgIHZzcGhlcmU6CiAgICAgIGNvcmVzUGVyU29ja2V0OiAyCiAgICAgIGNwdXM6IDQKICAgICAgbWVtb3J5TUI6IDE2Mzg0CiAgICAgIG9zRGlzazoKICAgICAgICBkaXNrU2l6ZUdCOiAxMjAKICByZXBsaWNhczogMwptZXRhZGF0YToKICBuYW1lOiBteWNsdXN0ZXIKcGxhdGZvcm06CiAgdnNwaGVyZToKICAgIGFwaVZJUDogYXBpVklQVmFsdWUKICAgIGNsdXN0ZXI6IGNsdXN0ZXJWYWx1ZQogICAgZGF0YWNlbnRlcjogZGF0YWNlbnRlclZhbHVlCiAgICBkZWZhdWx0RGF0YXN0b3JlOiBkYXRhc3RvcmVWYWx1ZQogICAgaW5ncmVzc1ZJUDogaW5ncmVzc1ZJUFZhbHVlCiAgICBuZXR3b3JrOiBuZXR3b3JrVmFsdWUKICAgIHBhc3N3b3JkOiBwYXNzd29yZFZhbHVlCiAgICB1c2VybmFtZTogdXNlcm5hbWVWYWx1ZQogICAgdkNlbnRlcjogdmNlbnRlclZhbHVlCnB1bGxTZWNyZXQ6ICIiCnNzaEtleTogc3NoLXJzYSBmYWtlIGtleQo= -kind: Secret -metadata: - name: mycluster-install-config - namespace: mycluster -type: Opaque ---- -apiVersion: v1 -data: - .dockerconfigjson: eyJmYWtlX3B1bGxfc2VjcmV0IjoiZmFrZV9wdWxsX3NlY3JldCJ9Cg== -kind: Secret -metadata: - name: mycluster-pull-secret - namespace: mycluster -type: kubernetes.io/dockerconfigjson ---- -apiVersion: v1 -kind: Secret -metadata: - name: mycluster-ssh-private-key - namespace: mycluster -stringData: - ssh-privatekey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- -type: Opaque ---- -apiVersion: v1 -data: - .cacert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCkZha2UgQ2VydGlmaWNhdGUKLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQ== -kind: Secret -metadata: - name: mycluster-vsphere-certs - namespace: mycluster -type: Opaque ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterImageSet -metadata: - name: 4.6.17-x86-64-mycluster -spec: - releaseImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 ---- -apiVersion: cluster.open-cluster-management.io/v1 -kind: ManagedCluster -metadata: - labels: - cloud: vsphere - name: mycluster - vendor: OpenShift - name: mycluster -spec: - hubAcceptsClient: true - leaseDurationSeconds: 60 ---- -apiVersion: hive.openshift.io/v1 -kind: ClusterDeployment -metadata: - labels: - cloud: vsphere - vendor: OpenShift - name: mycluster - namespace: mycluster -spec: - baseDomain: baseDnsDomainValue - clusterName: mycluster - controlPlaneConfig: - servingCertificates: {} - installAttemptsLimit: 1 - installed: false - platform: - vsphere: - certificatesSecretRef: - name: mycluster-vsphere-certs - cluster: clusterValue - credentialsSecretRef: - name: mycluster-creds - datacenter: datacenterValue - defaultDatastore: datastoreValue - network: networkValue - vCenter: vcenterValue - provisioning: - imageSetRef: - name: 4.6.17-x86-64-mycluster - installConfigSecretRef: - name: mycluster-install-config - sshPrivateKeySecretRef: - name: mycluster-ssh-private-key - pullSecretRef: - name: mycluster-pull-secret ---- -apiVersion: agent.open-cluster-management.io/v1 -kind: KlusterletAddonConfig -metadata: - name: mycluster - namespace: mycluster -spec: - applicationManager: - enabled: true - certPolicyController: - enabled: true - clusterLabels: - cloud: vsphere - vendor: OpenShift - clusterName: mycluster - clusterNamespace: mycluster - iamPolicyController: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true ---- -apiVersion: hive.openshift.io/v1 -kind: MachinePool -metadata: - name: mycluster-worker - namespace: mycluster -spec: - clusterDeploymentRef: - name: mycluster - name: worker - platform: - vsphere: - coresPerSocket: 2 - cpus: 4 - memoryMB: 16384 - osDisk: - diskSizeGB: 120 - replicas: 3 diff --git a/test/functional/create/cluster/vsphere_values.yaml b/test/functional/create/cluster/vsphere_values.yaml deleted file mode 100755 index b3f6e5be2..000000000 --- a/test/functional/create/cluster/vsphere_values.yaml +++ /dev/null @@ -1,40 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -managedCluster: - name: mycluster - cloud: vsphere # clouds values can be aws, azure, gcp, openstack, vsphere - vendor: OpenShift - ocpImage: quay.io/openshift-release-dev/ocp-release:4.6.17-x86_64 - addons: - applicationManager: - enabled: true - policyController: - enabled: true - searchCollector: - enabled: true - certPolicyController: - enabled: true - iamPolicyController: - enabled: true - version: 2.2.0 - sshPublicKey: |- - ssh-rsa fake key - sshPrivateKey: |- - -----BEGIN RSA PRIVATE KEY----- - Fake key - -----END RSA PRIVATE KEY----- - vsphere: - vcenter: vcenterValue - username: usernameValue - password: passwordValue - datacenter: datacenterValue - datastore: datastoreValue - cluster: clusterValue - apiVIP: apiVIPValue - ingressVIP: ingressVIPValue - network: networkValue - baseDnsDomain: baseDnsDomainValue - cacertificate: |- - -----BEGIN CERTIFICATE----- - Fake Certificate - -----END CERTIFICATE----- diff --git a/test/functional/resources/clustermanager_cr.yaml b/test/functional/resources/clustermanager_cr.yaml deleted file mode 100644 index 54a3656c5..000000000 --- a/test/functional/resources/clustermanager_cr.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -apiVersion: operator.open-cluster-management.io/v1 -kind: ClusterManager -metadata: - labels: - installer.name: multiclusterhub - installer.namespace: open-cluster-management - name: cluster-manager -spec: - registrationImagePullSpec: fake-registration-image - workImagePullSpec: fake-work-image diff --git a/test/functional/resources/clustermanager_crd.yaml b/test/functional/resources/clustermanager_crd.yaml deleted file mode 100644 index 29a8ea38a..000000000 --- a/test/functional/resources/clustermanager_crd.yaml +++ /dev/null @@ -1,146 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - labels: - operators.coreos.com/advanced-cluster-management.open-cluster-management: "" - name: clustermanagers.operator.open-cluster-management.io -spec: - conversion: - strategy: None - group: operator.open-cluster-management.io - names: - kind: ClusterManager - listKind: ClusterManagerList - plural: clustermanagers - singular: clustermanager - scope: Cluster - versions: - - name: v1 - schema: - openAPIV3Schema: - description: ClusterManager configures the controllers on the hub that govern registration and work distribution for attached Klusterlets. ClusterManager will be only deployed in open-cluster-management-hub namespace. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: Spec represents a desired deployment configuration of controllers that govern registration and work distribution for attached Klusterlets. - properties: - registrationImagePullSpec: - description: RegistrationImagePullSpec represents the desired image of registration controller/webhook installed on hub. - type: string - workImagePullSpec: - description: WorkImagePullSpec represents the desired image configuration of work controller/webhook installed on hub. - type: string - type: object - status: - description: Status represents the current status of controllers that govern the lifecycle of managed clusters. - properties: - conditions: - description: 'Conditions contain the different condition statuses for this ClusterManager. Valid condition types are: Applied: components in hub are applied. Available: components in hub are available and ready to serve. Progressing: components in hub are in a transitioning state. Degraded: components in hub do not match the desired configuration and only provide degraded service.' - items: - description: "Condition contains details for one aspect of the current state of this API Resource. --- This struct is intended for direct use as an array at the field path .status.conditions. For example, type FooStatus struct{ // Represents the observations of a foo's current state. // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge // +listType=map // +listMapKey=type Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. --- Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be useful (see .node.status.conditions), the ability to deconflict is important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - generations: - description: Generations are used to determine when an item needs to be reconciled or has changed in a way that needs a reaction. - items: - description: GenerationStatus keeps track of the generation for a given resource so that decisions about forced updates can be made. the definition matches the GenerationStatus defined in github.com/openshift/api/v1 - properties: - group: - description: group is the group of the thing you're tracking - type: string - lastGeneration: - description: lastGeneration is the last generation of the thing that controller applies - format: int64 - type: integer - name: - description: name is the name of the thing you're tracking - type: string - namespace: - description: namespace is where the thing you're tracking is - type: string - resource: - description: resource is the resource type of the thing you're tracking - type: string - version: - description: version is the version of the thing you're tracking - type: string - type: object - type: array - observedGeneration: - description: ObservedGeneration is the last generation change you've dealt with - format: int64 - type: integer - relatedResources: - description: RelatedResources are used to track the resources that are related to this ClusterManager - items: - description: RelatedResourceMeta represents the resource that is managed by an operator - properties: - group: - description: group is the group of the thing you're tracking - type: string - name: - description: name is the name of the thing you're tracking - type: string - namespace: - description: namespace is where the thing you're tracking is - type: string - resource: - description: resource is the resource type of the thing you're tracking - type: string - version: - description: version is the version of the thing you're tracking - type: string - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/test/functional/resources/hive_v1_clusterdeployment_crd.yaml b/test/functional/resources/hive_v1_clusterdeployment_crd.yaml deleted file mode 100644 index 4c63c46d8..000000000 --- a/test/functional/resources/hive_v1_clusterdeployment_crd.yaml +++ /dev/null @@ -1,1154 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1beta1 -kind: CustomResourceDefinition -metadata: - creationTimestamp: null - name: clusterdeployments.hive.openshift.io -spec: - additionalPrinterColumns: - - JSONPath: .metadata.labels.hive\.openshift\.io/cluster-platform - name: Platform - type: string - - JSONPath: .metadata.labels.hive\.openshift\.io/cluster-region - name: Region - type: string - - JSONPath: .metadata.labels.hive\.openshift\.io/cluster-type - name: ClusterType - type: string - - JSONPath: .spec.installed - name: Installed - type: boolean - - JSONPath: .spec.clusterMetadata.infraID - name: InfraID - type: string - - JSONPath: .metadata.labels.hive\.openshift\.io/version-major-minor-patch - name: Version - type: string - - JSONPath: .status.conditions[?(@.type=='Hibernating')].reason - name: PowerState - type: string - - JSONPath: .metadata.creationTimestamp - name: Age - type: date - group: hive.openshift.io - names: - kind: ClusterDeployment - listKind: ClusterDeploymentList - plural: clusterdeployments - shortNames: - - cd - singular: clusterdeployment - scope: Namespaced - subresources: - status: {} - validation: - openAPIV3Schema: - description: ClusterDeployment is the Schema for the clusterdeployments API - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: ClusterDeploymentSpec defines the desired state of ClusterDeployment - properties: - baseDomain: - description: BaseDomain is the base domain to which the cluster should - belong. - type: string - boundServiceAccountSigningKeySecretRef: - description: BoundServiceAccountSignkingKeySecretRef refers to a Secret - that contains a 'bound-service-account-signing-key.key' data key pointing - to the private key that will be used to sign ServiceAccount objects. - Primarily used to provision AWS clusters to use Amazon's Security - Token Service. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - certificateBundles: - description: CertificateBundles is a list of certificate bundles associated - with this cluster - items: - description: CertificateBundleSpec specifies a certificate bundle - associated with a cluster deployment - properties: - certificateSecretRef: - description: CertificateSecretRef is the reference to the secret - that contains the certificate bundle. If the certificate bundle - is to be generated, it will be generated with the name in this - reference. Otherwise, it is expected that the secret should - exist in the same namespace as the ClusterDeployment - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - generate: - description: Generate indicates whether this bundle should have - real certificates generated for it. - type: boolean - name: - description: Name is an identifier that must be unique within - the bundle and must be referenced by an ingress or by the control - plane serving certs - type: string - required: - - certificateSecretRef - - name - type: object - type: array - clusterMetadata: - description: ClusterMetadata contains metadata information about the - installed cluster. - properties: - adminKubeconfigSecretRef: - description: AdminKubeconfigSecretRef references the secret containing - the admin kubeconfig for this cluster. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - adminPasswordSecretRef: - description: AdminPasswordSecretRef references the secret containing - the admin username/password which can be used to login to this - cluster. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - clusterID: - description: ClusterID is a globally unique identifier for this - cluster generated during installation. Used for reporting metrics - among other places. - type: string - infraID: - description: InfraID is an identifier for this cluster generated - during installation and used for tagging/naming resources in cloud - providers. - type: string - required: - - adminKubeconfigSecretRef - - adminPasswordSecretRef - - clusterID - - infraID - type: object - clusterName: - description: ClusterName is the friendly name of the cluster. It is - used for subdomains, some resource tagging, and other instances where - a friendly name for the cluster is useful. - type: string - clusterPoolRef: - description: ClusterPoolRef is a reference to the ClusterPool that this - ClusterDeployment originated from. - properties: - claimName: - description: ClaimName is the name of the ClusterClaim that claimed - the cluster from the pool. - type: string - namespace: - description: Namespace is the namespace where the ClusterPool resides. - type: string - poolName: - description: PoolName is the name of the ClusterPool for which the - cluster was created. - type: string - required: - - namespace - - poolName - type: object - controlPlaneConfig: - description: ControlPlaneConfig contains additional configuration for - the target cluster's control plane - properties: - apiURLOverride: - description: APIURLOverride is the optional URL override to which - Hive will transition for communication with the API server of - the remote cluster. When a remote cluster is created, Hive will - initially communicate using the API URL established during installation. - If an API URL Override is specified, Hive will periodically attempt - to connect to the remote cluster using the override URL. Once - Hive has determined that the override URL is active, Hive will - use the override URL for further communications with the API server - of the remote cluster. - type: string - servingCertificates: - description: ServingCertificates specifies serving certificates - for the control plane - properties: - additional: - description: Additional is a list of additional domains and - certificates that are also associated with the control plane's - api endpoint. - items: - description: ControlPlaneAdditionalCertificate defines an - additional serving certificate for a control plane - properties: - domain: - description: Domain is the domain of the additional control - plane certificate - type: string - name: - description: Name references a CertificateBundle in the - ClusterDeployment.Spec that should be used for this - additional certificate. - type: string - required: - - domain - - name - type: object - type: array - default: - description: Default references the name of a CertificateBundle - in the ClusterDeployment that should be used for the control - plane's default endpoint. - type: string - type: object - type: object - hibernateAfter: - description: HibernateAfter will transition a cluster to hibernating - power state after it has been running for the given duration. The - time that a cluster has been running is the time since the cluster - was installed or the time since the cluster last came out of hibernation. - type: string - ingress: - description: Ingress allows defining desired clusteringress/shards to - be configured on the cluster. - items: - description: ClusterIngress contains the configurable pieces for any - ClusterIngress objects that should exist on the cluster. - properties: - domain: - description: Domain (sometimes referred to as shard) is the full - DNS suffix that the resulting IngressController object will - service (eg abcd.mycluster.mydomain.com). - type: string - name: - description: Name of the ClusterIngress object to create. - type: string - namespaceSelector: - description: NamespaceSelector allows filtering the list of namespaces - serviced by the ingress controller. - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: operator represents a key's relationship - to a set of values. Valid operators are In, NotIn, - Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If - the operator is In or NotIn, the values array must - be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced - during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A - single {key,value} in the matchLabels map is equivalent - to an element of matchExpressions, whose key field is "key", - the operator is "In", and the values array contains only - "value". The requirements are ANDed. - type: object - type: object - routeSelector: - description: RouteSelector allows filtering the set of Routes - serviced by the ingress controller - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: operator represents a key's relationship - to a set of values. Valid operators are In, NotIn, - Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If - the operator is In or NotIn, the values array must - be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced - during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A - single {key,value} in the matchLabels map is equivalent - to an element of matchExpressions, whose key field is "key", - the operator is "In", and the values array contains only - "value". The requirements are ANDed. - type: object - type: object - servingCertificate: - description: ServingCertificate references a CertificateBundle - in the ClusterDeployment.Spec that should be used for this Ingress - type: string - required: - - domain - - name - type: object - type: array - installAttemptsLimit: - description: InstallAttemptsLimit is the maximum number of times Hive - will attempt to install the cluster. - format: int32 - type: integer - installed: - description: Installed is true if the cluster has been installed - type: boolean - machineManagement: - description: MachineManagement contains machine management settings - including the strategy that will be used when provisioning worker - machines. - properties: - central: - description: Central contains settings for central machine management. - If set Central indicates that central machine management will - be used as opposed to management on the spoke cluster. - type: object - targetNamespace: - description: TargetNamespace is the namespace in which we will create - worker machineset resources. Resources required to create machines - will be copied to the TargetNamespace. TargetNamespace is created - for you and cannot be set during creation. TargetNamespace is - also immutable once set. - type: string - type: object - manageDNS: - description: ManageDNS specifies whether a DNSZone should be created - and managed automatically for this ClusterDeployment - type: boolean - platform: - description: Platform is the configuration for the specific platform - upon which to perform the installation. - properties: - agentBareMetal: - description: AgentBareMetal is the configuration used when performing - an Assisted Agent based installation to bare metal. Can only be - used with the Assisted InstallStrategy. - properties: - agentSelector: - description: AgentSelector is a label selector used for associating - relevant custom resources with this cluster. (Agent, BareMetalHost, - etc) - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: operator represents a key's relationship - to a set of values. Valid operators are In, NotIn, - Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. - If the operator is In or NotIn, the values array - must be non-empty. If the operator is Exists or - DoesNotExist, the values array must be empty. This - array is replaced during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. - A single {key,value} in the matchLabels map is equivalent - to an element of matchExpressions, whose key field is - "key", the operator is "In", and the values array contains - only "value". The requirements are ANDed. - type: object - type: object - apiVIP: - description: APIVIP is the virtual IP used to reach the OpenShift - cluster's API. - type: string - apiVIPDNSName: - description: APIVIPDNSName is the domain name used to reach - the OpenShift cluster API. - type: string - ingressVIP: - description: IngressVIP is the virtual IP used for cluster ingress - traffic. - type: string - required: - - agentSelector - type: object - aws: - description: AWS is the configuration used when installing on AWS. - properties: - credentialsAssumeRole: - description: CredentialsAssumeRole refers to the IAM role that - must be assumed to obtain AWS account access for the cluster - operations. - properties: - externalID: - description: 'ExternalID is random string generated by platform - so that assume role is protected from confused deputy - problem. more info: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html' - type: string - roleARN: - type: string - required: - - roleARN - type: object - credentialsSecretRef: - description: CredentialsSecretRef refers to a secret that contains - the AWS account access credentials. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - privateLink: - description: PrivateLink allows uses to enable access to the - cluster's API server using AWS PrivateLink. AWS PrivateLink - includes a pair of VPC Endpoint Service and VPC Endpoint accross - AWS accounts and allows clients to connect to services using - AWS's internal networking instead of the Internet. - properties: - enabled: - type: boolean - required: - - enabled - type: object - region: - description: Region specifies the AWS region where the cluster - will be created. - type: string - userTags: - additionalProperties: - type: string - description: UserTags specifies additional tags for AWS resources - created for the cluster. - type: object - required: - - region - type: object - azure: - description: Azure is the configuration used when installing on - Azure. - properties: - baseDomainResourceGroupName: - description: BaseDomainResourceGroupName specifies the resource - group where the azure DNS zone for the base domain is found - type: string - credentialsSecretRef: - description: CredentialsSecretRef refers to a secret that contains - the Azure account access credentials. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - region: - description: Region specifies the Azure region where the cluster - will be created. - type: string - required: - - credentialsSecretRef - - region - type: object - baremetal: - description: BareMetal is the configuration used when installing - on bare metal. - properties: - libvirtSSHPrivateKeySecretRef: - description: LibvirtSSHPrivateKeySecretRef is the reference - to the secret that contains the private SSH key to use for - access to the libvirt provisioning host. The SSH private key - is expected to be in the secret data under the "ssh-privatekey" - key. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - required: - - libvirtSSHPrivateKeySecretRef - type: object - gcp: - description: GCP is the configuration used when installing on Google - Cloud Platform. - properties: - credentialsSecretRef: - description: CredentialsSecretRef refers to a secret that contains - the GCP account access credentials. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - region: - description: Region specifies the GCP region where the cluster - will be created. - type: string - required: - - credentialsSecretRef - - region - type: object - openstack: - description: OpenStack is the configuration used when installing - on OpenStack - properties: - certificatesSecretRef: - description: "CertificatesSecretRef refers to a secret that - contains CA certificates necessary for communicating with - the OpenStack. There is additional configuration required - for the OpenShift cluster to trust the certificates provided - in this secret. The \"clouds.yaml\" file included in the credentialsSecretRef - Secret must also include a reference to the certificate bundle - file for the OpenShift cluster being created to trust the - OpenStack endpoints. The \"clouds.yaml\" file must set the - \"cacert\" field to either \"/etc/openstack-ca/\" or \"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem\". - \n For example, \"\"\"clouds.yaml clouds: shiftstack: auth: - ... cacert: \"/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem\" - \"\"\"" - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - cloud: - description: Cloud will be used to indicate the OS_CLOUD value - to use the right section from the clouds.yaml in the CredentialsSecretRef. - type: string - credentialsSecretRef: - description: CredentialsSecretRef refers to a secret that contains - the OpenStack account access credentials. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - trunkSupport: - description: TrunkSupport indicates whether or not to use trunk - ports in your OpenShift cluster. - type: boolean - required: - - cloud - - credentialsSecretRef - type: object - ovirt: - description: Ovirt is the configuration used when installing on - oVirt - properties: - certificatesSecretRef: - description: CertificatesSecretRef refers to a secret that contains - the oVirt CA certificates necessary for communicating with - oVirt. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - credentialsSecretRef: - description: 'CredentialsSecretRef refers to a secret that contains - the oVirt account access credentials with fields: ovirt_url, - ovirt_username, ovirt_password, ovirt_ca_bundle' - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - ovirt_cluster_id: - description: The target cluster under which all VMs will run - type: string - ovirt_network_name: - description: The target network of all the network interfaces - of the nodes. Omitting defaults to ovirtmgmt network which - is a default network for evert ovirt cluster. - type: string - storage_domain_id: - description: The target storage domain under which all VM disk - would be created. - type: string - required: - - certificatesSecretRef - - credentialsSecretRef - - ovirt_cluster_id - - storage_domain_id - type: object - vsphere: - description: VSphere is the configuration used when installing on - vSphere - properties: - certificatesSecretRef: - description: CertificatesSecretRef refers to a secret that contains - the vSphere CA certificates necessary for communicating with - the VCenter. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - cluster: - description: Cluster is the name of the cluster virtual machines - will be cloned into. - type: string - credentialsSecretRef: - description: 'CredentialsSecretRef refers to a secret that contains - the vSphere account access credentials: GOVC_USERNAME, GOVC_PASSWORD - fields.' - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - datacenter: - description: Datacenter is the name of the datacenter to use - in the vCenter. - type: string - defaultDatastore: - description: DefaultDatastore is the default datastore to use - for provisioning volumes. - type: string - folder: - description: Folder is the name of the folder that will be used - and/or created for virtual machines. - type: string - network: - description: Network specifies the name of the network to be - used by the cluster. - type: string - vCenter: - description: VCenter is the domain name or IP address of the - vCenter. - type: string - required: - - certificatesSecretRef - - credentialsSecretRef - - datacenter - - defaultDatastore - - vCenter - type: object - type: object - powerState: - description: PowerState indicates whether a cluster should be running - or hibernating. When omitted, PowerState defaults to the Running state. - enum: - - "" - - Running - - Hibernating - type: string - preserveOnDelete: - description: PreserveOnDelete allows the user to disconnect a cluster - from Hive without deprovisioning it - type: boolean - provisioning: - description: Provisioning contains settings used only for initial cluster - provisioning. May be unset in the case of adopted clusters. - properties: - imageSetRef: - description: ImageSetRef is a reference to a ClusterImageSet. If - a value is specified for ReleaseImage, that will take precedence - over the one from the ClusterImageSet. - properties: - name: - description: Name is the name of the ClusterImageSet that this - refers to - type: string - required: - - name - type: object - installConfigSecretRef: - description: InstallConfigSecretRef is the reference to a secret - that contains an openshift-install InstallConfig. This file will - be passed through directly to the installer. Any version of InstallConfig - can be used, provided it can be parsed by the openshift-install - version for the release you are provisioning. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - installStrategy: - description: InstallStrategy provides platform agnostic configuration - for the use of alternate install strategies. Defaults to openshift-install - if none specified. - properties: - agent: - description: Agent is the install strategy configuration for - provisioning a cluster with the Agent based assisted installer. - properties: - networking: - description: Networking is the configuration for the pod - network provider in the cluster. - properties: - clusterNetwork: - description: ClusterNetwork is the list of IP address - pools for pods. Default is 10.128.0.0/14 and a host - prefix of /23. - items: - description: ClusterNetworkEntry is a single IP address - block for pod IP blocks. IP blocks are allocated - with size 2^HostSubnetLength. - properties: - cidr: - description: CIDR is the IP block address pool. - type: string - hostPrefix: - description: HostPrefix is the prefix size to - allocate to each node from the CIDR. For example, - 24 would allocate 2^8=256 adresses to each node. - If this field is not used by the plugin, it - can be left unset. - format: int32 - type: integer - required: - - cidr - type: object - type: array - machineNetwork: - description: MachineNetwork is the list of IP address - pools for machines. - items: - description: MachineNetworkEntry is a single IP address - block for node IP blocks. - properties: - cidr: - description: CIDR is the IP block address pool - for machines within the cluster. - type: string - required: - - cidr - type: object - type: array - serviceNetwork: - description: 'ServiceNetwork is the list of IP address - pools for services. Default is 172.30.0.0/16. NOTE: - currently only one entry is supported.' - items: - type: string - maxItems: 1 - type: array - type: object - provisionRequirements: - description: ProvisionRequirements defines configuration - for when the installation is ready to be launched automatically. - properties: - controlPlaneAgents: - description: ControlPlaneAgents is the number of matching - approved and ready Agents with the control plane role - required to launch the install. Must be either 1 or - 3. - type: integer - workerAgents: - description: WorkerAgents is the minimum number of matching - approved and ready Agents with the worker role required - to launch the install. - minimum: 0 - type: integer - required: - - controlPlaneAgents - type: object - sshPublicKey: - description: SSHPublicKey will be added to all cluster hosts - for use in debugging. - type: string - required: - - networking - - provisionRequirements - type: object - type: object - installerEnv: - description: InstallerEnv are extra environment variables to pass - through to the installer. This may be used to enable additional - features of the installer. - items: - description: EnvVar represents an environment variable present - in a Container. - properties: - name: - description: Name of the environment variable. Must be a C_IDENTIFIER. - type: string - value: - description: 'Variable references $(VAR_NAME) are expanded - using the previous defined environment variables in the - container and any service environment variables. If a variable - cannot be resolved, the reference in the input string will - be unchanged. The $(VAR_NAME) syntax can be escaped with - a double $$, ie: $$(VAR_NAME). Escaped references will never - be expanded, regardless of whether the variable exists or - not. Defaults to "".' - type: string - valueFrom: - description: Source for the environment variable's value. - Cannot be used if value is not empty. - properties: - configMapKeyRef: - description: Selects a key of a ConfigMap. - properties: - key: - description: The key to select. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the ConfigMap or its - key must be defined - type: boolean - required: - - key - type: object - fieldRef: - description: 'Selects a field of the pod: supports metadata.name, - metadata.namespace, `metadata.labels['''']`, `metadata.annotations['''']`, - spec.nodeName, spec.serviceAccountName, status.hostIP, - status.podIP, status.podIPs.' - properties: - apiVersion: - description: Version of the schema the FieldPath is - written in terms of, defaults to "v1". - type: string - fieldPath: - description: Path of the field to select in the specified - API version. - type: string - required: - - fieldPath - type: object - resourceFieldRef: - description: 'Selects a resource of the container: only - resources limits and requests (limits.cpu, limits.memory, - limits.ephemeral-storage, requests.cpu, requests.memory - and requests.ephemeral-storage) are currently supported.' - properties: - containerName: - description: 'Container name: required for volumes, - optional for env vars' - type: string - divisor: - description: Specifies the output format of the exposed - resources, defaults to "1" - type: string - resource: - description: 'Required: resource to select' - type: string - required: - - resource - type: object - secretKeyRef: - description: Selects a key of a secret in the pod's namespace - properties: - key: - description: The key of the secret to select from. Must - be a valid secret key. - type: string - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, - uid?' - type: string - optional: - description: Specify whether the Secret or its key - must be defined - type: boolean - required: - - key - type: object - type: object - required: - - name - type: object - type: array - manifestsConfigMapRef: - description: ManifestsConfigMapRef is a reference to user-provided - manifests to add to or replace manifests that are generated by - the installer. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - releaseImage: - description: ReleaseImage is the image containing metadata for all - components that run in the cluster, and is the primary and best - way to specify what specific version of OpenShift you wish to - install. - type: string - sshKnownHosts: - description: SSHKnownHosts are known hosts to be configured in the - hive install manager pod to avoid ssh prompts. Use of ssh in the - install pod is somewhat limited today (failure log gathering from - cluster, some bare metal provisioning scenarios), so this setting - is often not needed. - items: - type: string - type: array - sshPrivateKeySecretRef: - description: SSHPrivateKeySecretRef is the reference to the secret - that contains the private SSH key to use for access to compute - instances. This private key should correspond to the public key - included in the InstallConfig. The private key is used by Hive - to gather logs on the target cluster if there are install failures. - The SSH private key is expected to be in the secret data under - the "ssh-privatekey" key. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - type: object - pullSecretRef: - description: PullSecretRef is the reference to the secret to use when - pulling images. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - required: - - baseDomain - - clusterName - - platform - type: object - status: - description: ClusterDeploymentStatus defines the observed state of ClusterDeployment - properties: - apiURL: - description: APIURL is the URL where the cluster's API can be accessed. - type: string - certificateBundles: - description: CertificateBundles contains of the status of the certificate - bundles associated with this cluster deployment. - items: - description: CertificateBundleStatus specifies whether a certificate - bundle was generated for this cluster deployment. - properties: - generated: - description: Generated indicates whether the certificate bundle - was generated - type: boolean - name: - description: Name of the certificate bundle - type: string - required: - - generated - - name - type: object - type: array - cliImage: - description: CLIImage is the name of the oc cli image to use when installing - the target cluster - type: string - conditions: - description: Conditions includes more detailed status for the cluster - deployment - items: - description: ClusterDeploymentCondition contains details for the current - condition of a cluster deployment - properties: - lastProbeTime: - description: LastProbeTime is the last time we probed the condition. - format: date-time - type: string - lastTransitionTime: - description: LastTransitionTime is the last time the condition - transitioned from one status to another. - format: date-time - type: string - message: - description: Message is a human-readable message indicating details - about last transition. - type: string - reason: - description: Reason is a unique, one-word, CamelCase reason for - the condition's last transition. - type: string - status: - description: Status is the status of the condition. - type: string - type: - description: Type is the type of the condition. - type: string - required: - - status - - type - type: object - type: array - installRestarts: - description: InstallRestarts is the total count of container restarts - on the clusters install job. - type: integer - installStartedTimestamp: - description: InstallStartedTimestamp is the time when all pre-requisites - were met and cluster installation was launched. - format: date-time - type: string - installStrategy: - description: InstallStrategy contains observed state from specific install - strategies. - properties: - agent: - description: Agent defines the observed state of the Agent install - strategy for this cluster. - properties: - connectivityMajorityGroups: - type: string - controlPlaneAgentsDiscovered: - description: ControlPlaneAgentsDiscovered is the number of Agents - currently linked to this ClusterDeployment. - type: integer - controlPlaneAgentsReady: - description: ControlPlaneAgentsDiscovered is the number of Agents - currently linked to this ClusterDeployment that are ready - for use. - type: integer - workerAgentsDiscovered: - description: WorkerAgentsDiscovered is the number of worker - Agents currently linked to this ClusterDeployment. - type: integer - workerAgentsReady: - description: WorkerAgentsDiscovered is the number of worker - Agents currently linked to this ClusterDeployment that are - ready for use. - type: integer - type: object - type: object - installVersion: - description: InstallVersion is the version of OpenShift as reported - by the release image resolved for the installation. - type: string - installedTimestamp: - description: InstalledTimestamp is the time we first detected that the - cluster has been successfully installed. - format: date-time - type: string - installerImage: - description: InstallerImage is the name of the installer image to use - when installing the target cluster - type: string - platformStatus: - description: Platform contains the observed state for the specific platform - upon which to perform the installation. - properties: - aws: - description: AWS is the observed state on AWS. - properties: - privateLink: - description: PrivateLinkAccessStatus contains the observed state - for PrivateLinkAccess resources. - properties: - hostedZoneID: - type: string - vpcEndpointID: - type: string - vpcEndpointService: - properties: - id: - type: string - name: - type: string - type: object - type: object - type: object - type: object - provisionRef: - description: ProvisionRef is a reference to the last ClusterProvision - created for the deployment - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names - TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - webConsoleURL: - description: WebConsoleURL is the URL for the cluster's web console - UI. - type: string - type: object - version: v1 - versions: - - name: v1 - served: true - storage: true -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] \ No newline at end of file diff --git a/test/functional/resources/multiclusterhubs_cr.yaml b/test/functional/resources/multiclusterhubs_cr.yaml deleted file mode 100644 index 5f6f05080..000000000 --- a/test/functional/resources/multiclusterhubs_cr.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: operator.open-cluster-management.io/v1 -kind: MultiClusterHub -metadata: - name: multiclusterhub - namespace: open-cluster-management -spec: - availabilityConfig: High -status: - currentVersion: 2.3.0 diff --git a/test/functional/resources/multiclusterhubs_crd.yaml b/test/functional/resources/multiclusterhubs_crd.yaml deleted file mode 100644 index 6ad8844d4..000000000 --- a/test/functional/resources/multiclusterhubs_crd.yaml +++ /dev/null @@ -1,226 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - labels: - operators.coreos.com/advanced-cluster-management.open-cluster-management: "" - name: multiclusterhubs.operator.open-cluster-management.io -spec: - conversion: - strategy: None - group: operator.open-cluster-management.io - names: - kind: MultiClusterHub - listKind: MultiClusterHubList - plural: multiclusterhubs - shortNames: - - mch - singular: multiclusterhub - scope: Namespaced - versions: - - additionalPrinterColumns: - - description: The overall status of the multiclusterhub - jsonPath: .status.phase - name: Status - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1 - schema: - openAPIV3Schema: - description: MultiClusterHub defines the configuration for an instance of the MultiCluster Hub - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: MultiClusterHubSpec defines the desired state of MultiClusterHub - properties: - availabilityConfig: - description: 'Specifies deployment replication for improved availability. Options are: Basic and High (default)' - type: string - customCAConfigmap: - description: Provide the customized OpenShift default ingress CA certificate to RHACM - type: string - disableHubSelfManagement: - description: Disable automatic import of the hub cluster as a managed cluster - type: boolean - disableUpdateClusterImageSets: - description: Disable automatic update of ClusterImageSets - type: boolean - hive: - description: (Deprecated) Overrides for the default HiveConfig spec - properties: - additionalCertificateAuthorities: - description: (Deprecated) AdditionalCertificateAuthorities is a list of references to secrets in the 'hive' namespace that contain an additional Certificate Authority to use when communicating with target clusters. These certificate authorities will be used in addition to any self-signed CA generated by each cluster on installation. - items: - description: LocalObjectReference contains enough information to let you locate the referenced object inside the same namespace. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - type: array - backup: - description: (Deprecated) Backup specifies configuration for backup integration. If absent, backup integration will be disabled. - properties: - minBackupPeriodSeconds: - description: (Deprecated) MinBackupPeriodSeconds specifies that a minimum of MinBackupPeriodSeconds will occur in between each backup. This is used to rate limit backups. This potentially batches together multiple changes into 1 backup. No backups will be lost as changes that happen during this interval are queued up and will result in a backup happening once the interval has been completed. - type: integer - velero: - description: (Deprecated) Velero specifies configuration for the Velero backup integration. - properties: - enabled: - description: (Deprecated) Enabled dictates if Velero backup integration is enabled. If not specified, the default is disabled. - type: boolean - type: object - type: object - externalDNS: - description: (Deprecated) ExternalDNS specifies configuration for external-dns if it is to be deployed by Hive. If absent, external-dns will not be deployed. - properties: - aws: - description: (Deprecated) AWS contains AWS-specific settings for external DNS - properties: - credentials: - description: (Deprecated) Credentials references a secret that will be used to authenticate with AWS Route53. It will need permission to manage entries in each of the managed domains for this cluster. Secret should have AWS keys named 'aws_access_key_id' and 'aws_secret_access_key'. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - type: object - gcp: - description: (Deprecated) GCP contains GCP-specific settings for external DNS - properties: - credentials: - description: (Deprecated) Credentials references a secret that will be used to authenticate with GCP DNS. It will need permission to manage entries in each of the managed domains for this cluster. Secret should have a key names 'osServiceAccount.json'. The credentials must specify the project to use. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - type: object - type: object - failedProvisionConfig: - description: (Deprecated) FailedProvisionConfig is used to configure settings related to handling provision failures. - properties: - skipGatherLogs: - description: (Deprecated) SkipGatherLogs disables functionality that attempts to gather full logs from the cluster if an installation fails for any reason. The logs will be stored in a persistent volume for up to 7 days. - type: boolean - type: object - globalPullSecret: - description: (Deprecated) GlobalPullSecret is used to specify a pull secret that will be used globally by all of the cluster deployments. For each cluster deployment, the contents of GlobalPullSecret will be merged with the specific pull secret for a cluster deployment(if specified), with precedence given to the contents of the pull secret for the cluster deployment. - properties: - name: - description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names TODO: Add other useful fields. apiVersion, kind, uid?' - type: string - type: object - maintenanceMode: - description: (Deprecated) MaintenanceMode can be set to true to disable the hive controllers in situations where we need to ensure nothing is running that will add or act upon finalizers on Hive types. This should rarely be needed. Sets replicas to 0 for the hive-controllers deployment to accomplish this. - type: boolean - required: - - failedProvisionConfig - type: object - imagePullSecret: - description: Override pull secret for accessing MultiClusterHub operand and endpoint images - type: string - ingress: - description: Configuration options for ingress management - properties: - sslCiphers: - description: List of SSL ciphers enabled for management ingress. Defaults to full list of supported ciphers - items: - type: string - type: array - type: object - nodeSelector: - additionalProperties: - type: string - description: Set the nodeselectors - type: object - overrides: - description: Developer Overrides - properties: - imagePullPolicy: - description: Pull policy of the MultiCluster hub images - type: string - type: object - separateCertificateManagement: - description: Install cert-manager into its own namespace - type: boolean - type: object - status: - description: MultiClusterHubStatus defines the observed state of MultiClusterHub - properties: - components: - additionalProperties: - description: StatusCondition contains condition information. - properties: - lastTransitionTime: - description: LastTransitionTime is the last time the condition changed from one status to another. - format: date-time - type: string - message: - description: Message is a human-readable message indicating details about the last status change. - type: string - reason: - description: Reason is a (brief) reason for the condition's last status change. - type: string - status: - description: Status is the status of the condition. One of True, False, Unknown. - type: string - type: - description: Type is the type of the cluster condition. - type: string - type: object - description: Components []ComponentCondition `json:"manifests,omitempty"` - type: object - conditions: - description: Conditions contains the different condition statuses for the MultiClusterHub - items: - description: StatusCondition contains condition information. - properties: - lastTransitionTime: - description: LastTransitionTime is the last time the condition changed from one status to another. - format: date-time - type: string - lastUpdateTime: - description: The last time this condition was updated. - format: date-time - type: string - message: - description: Message is a human-readable message indicating details about the last status change. - type: string - reason: - description: Reason is a (brief) reason for the condition's last status change. - type: string - status: - description: Status is the status of the condition. One of True, False, Unknown. - type: string - type: - description: Type is the type of the cluster condition. - type: string - type: object - type: array - currentVersion: - description: CurrentVersion indicates the current version - type: string - desiredVersion: - description: DesiredVersion indicates the desired version - type: string - phase: - description: Represents the running phase of the MultiClusterHub - type: string - type: object - type: object - served: true - storage: true - subresources: - status: {} diff --git a/test/functional/resources/open-cluster-management-ns.yaml b/test/functional/resources/open-cluster-management-ns.yaml deleted file mode 100644 index 1c410aa7c..000000000 --- a/test/functional/resources/open-cluster-management-ns.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Namespace -metadata: - name: open-cluster-management \ No newline at end of file diff --git a/test/functional/resources/openshift-config-ns.yaml b/test/functional/resources/openshift-config-ns.yaml deleted file mode 100644 index 6360a7f24..000000000 --- a/test/functional/resources/openshift-config-ns.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Namespace -metadata: - name: openshift-config \ No newline at end of file diff --git a/test/functional/resources/pull_secret_cr.yaml b/test/functional/resources/pull_secret_cr.yaml deleted file mode 100644 index 7fff8fcca..000000000 --- a/test/functional/resources/pull_secret_cr.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright Contributors to the Open Cluster Management project - -apiVersion: v1 -kind: Secret -metadata: - name: pull-secret - namespace: openshift-config -data: - .dockerconfigjson: eyJmYWtlX3B1bGxfc2VjcmV0IjoiZmFrZV9wdWxsX3NlY3JldCJ9Cg== -type: kubernetes.io/dockerconfigjson \ No newline at end of file