From f69bdf5fd0b0ea4900003ccf4bb9a90d4a5eae7f Mon Sep 17 00:00:00 2001 From: Zhen Wang Date: Wed, 30 May 2018 11:16:54 -0700 Subject: [PATCH] add basic validate cluster command (#203) --- clusterctl/cmd/validate.go | 31 ++++++++++++++++++ clusterctl/cmd/validate_cluster.go | 42 +++++++++++++++++++++++++ clusterctl/cmd/validate_cluster_test.go | 30 ++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 clusterctl/cmd/validate.go create mode 100644 clusterctl/cmd/validate_cluster.go create mode 100644 clusterctl/cmd/validate_cluster_test.go diff --git a/clusterctl/cmd/validate.go b/clusterctl/cmd/validate.go new file mode 100644 index 000000000000..279c4c74f876 --- /dev/null +++ b/clusterctl/cmd/validate.go @@ -0,0 +1,31 @@ +/* +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" +) + +var validateCmd = &cobra.Command{ + Use: "validate", + Short: "Validate an API resource created by cluster API.", + Long: `Validate an API resource created by cluster API. See subcommands for supported API resources.`, +} + +func init() { + RootCmd.AddCommand(validateCmd) +} diff --git a/clusterctl/cmd/validate_cluster.go b/clusterctl/cmd/validate_cluster.go new file mode 100644 index 000000000000..0289ef2ce8f1 --- /dev/null +++ b/clusterctl/cmd/validate_cluster.go @@ -0,0 +1,42 @@ +/* +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" + "sigs.k8s.io/cluster-api/errors" +) + +var validateClusterCmd = &cobra.Command{ + Use: "cluster", + Short: "Validate a cluster created by cluster API.", + Long: `Validate a cluster created by cluster API.`, + Run: func(cmd *cobra.Command, args []string) { + if err := RunValidateCluster(); err != nil { + glog.Exit(err) + } + }, +} + +func init() { + validateCmd.AddCommand(validateClusterCmd) +} + +func RunValidateCluster() error { + return errors.NotImplementedError +} diff --git a/clusterctl/cmd/validate_cluster_test.go b/clusterctl/cmd/validate_cluster_test.go new file mode 100644 index 000000000000..df07966c07c0 --- /dev/null +++ b/clusterctl/cmd/validate_cluster_test.go @@ -0,0 +1,30 @@ +/* +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 ( + "testing" + + "sigs.k8s.io/cluster-api/errors" +) + +func TestRunValidateCluster(t *testing.T) { + err := RunValidateCluster() + if (err != errors.NotImplementedError) { + t.Fatalf("Unexpected returned error. Got: %v, Want Err: %v", err, errors.NotImplementedError) + } +}