Skip to content

Commit

Permalink
add basic validate cluster command (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangzhen127 authored and k8s-ci-robot committed May 30, 2018
1 parent e4be6af commit f69bdf5
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
31 changes: 31 additions & 0 deletions clusterctl/cmd/validate.go
Original file line number Diff line number Diff line change
@@ -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)
}
42 changes: 42 additions & 0 deletions clusterctl/cmd/validate_cluster.go
Original file line number Diff line number Diff line change
@@ -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
}
30 changes: 30 additions & 0 deletions clusterctl/cmd/validate_cluster_test.go
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit f69bdf5

Please sign in to comment.