Skip to content

Commit

Permalink
add basic validate cluster command
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzhen127 committed May 23, 2018
1 parent f6f3bd2 commit c12b072
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
33 changes: 33 additions & 0 deletions clusterctl/cmd/validate.go
Original file line number Diff line number Diff line change
@@ -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)
}
50 changes: 50 additions & 0 deletions clusterctl/cmd/validate_cluster.go
Original file line number Diff line number Diff line change
@@ -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")
}

0 comments on commit c12b072

Please sign in to comment.