From c12b072ab2a8b7ce5706f9d3f97a38661682afc3 Mon Sep 17 00:00:00 2001 From: Zhen Wang Date: Wed, 23 May 2018 11:11:41 -0700 Subject: [PATCH] add basic validate cluster command --- clusterctl/cmd/validate.go | 33 ++++++++++++++++++++ clusterctl/cmd/validate_cluster.go | 50 ++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 clusterctl/cmd/validate.go create mode 100644 clusterctl/cmd/validate_cluster.go diff --git a/clusterctl/cmd/validate.go b/clusterctl/cmd/validate.go new file mode 100644 index 000000000000..b3a7a39376e4 --- /dev/null +++ b/clusterctl/cmd/validate.go @@ -0,0 +1,33 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cmd + +import ( + "github.com/spf13/cobra" + "k8s.io/kubernetes/pkg/kubectl/util/i18n" +) + +var validateCmd = &cobra.Command{ + Use: "validate", + Short: i18n.T("Validate an API resource created by cluster API."), + Long: i18n.T("Validate an API resource created by cluster API."), +} + +func init() { + validateCmd.AddCommand(validateClusterCmd) + RootCmd.AddCommand(validateCmd) +} diff --git a/clusterctl/cmd/validate_cluster.go b/clusterctl/cmd/validate_cluster.go new file mode 100644 index 000000000000..6ad0d14f9572 --- /dev/null +++ b/clusterctl/cmd/validate_cluster.go @@ -0,0 +1,50 @@ +/* +Copyright 2018 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package cmd + +import ( + "github.com/golang/glog" + "github.com/spf13/cobra" + "k8s.io/kubernetes/pkg/kubectl/util/i18n" + "sigs.k8s.io/cluster-api/errors" +) + +type ValidateClusterOptions struct { + Name string +} + +var vco = &ValidateClusterOptions{} + +var validateClusterCmd = &cobra.Command{ + Use: "cluster", + Short: i18n.T("Validate a cluster created by cluster API."), + Long: i18n.T("Validate a cluster created by cluster API."), + Run: func(cmd *cobra.Command, args []string) { + if err := RunValidateCluster(vco); err != nil { + glog.Exit(err) + } + }, +} + +func RunValidateCluster(vco *ValidateClusterOptions) error { + return errors.NotImplementedError +} + +func init() { + validateClusterCmd.Flags().StringVarP(&vco.Name, "name", "n", "", "Cluster name") + validateClusterCmd.MarkFlagRequired("name") +}