github.com/mkimuram/operator-sdk@v0.7.1-0.20190410172100-52ad33a4bda0/cmd/operator-sdk/scorecard/cmd.go (about) 1 // Copyright 2019 The Operator-SDK Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package scorecard 16 17 import ( 18 "fmt" 19 "strings" 20 21 "github.com/operator-framework/operator-sdk/internal/pkg/scaffold" 22 "github.com/operator-framework/operator-sdk/internal/pkg/scorecard" 23 "github.com/operator-framework/operator-sdk/version" 24 25 log "github.com/sirupsen/logrus" 26 "github.com/spf13/cobra" 27 "github.com/spf13/viper" 28 ) 29 30 func NewCmd() *cobra.Command { 31 scorecardCmd := &cobra.Command{ 32 Use: "scorecard", 33 Short: "Run scorecard tests", 34 Long: `Runs blackbox scorecard tests on an operator 35 `, 36 RunE: scorecard.ScorecardTests, 37 } 38 39 scorecardCmd.Flags().String(scorecard.ConfigOpt, "", "config file (default is <project_dir>/.osdk-yaml)") 40 scorecardCmd.Flags().String(scorecard.NamespaceOpt, "", "Namespace of custom resource created in cluster") 41 scorecardCmd.Flags().String(scorecard.KubeconfigOpt, "", "Path to kubeconfig of custom resource created in cluster") 42 scorecardCmd.Flags().Int(scorecard.InitTimeoutOpt, 10, "Timeout for status block on CR to be created in seconds") 43 scorecardCmd.Flags().Bool(scorecard.OlmDeployedOpt, false, "The OLM has deployed the operator. Use only the CSV for test data") 44 scorecardCmd.Flags().String(scorecard.CSVPathOpt, "", "Path to CSV being tested") 45 scorecardCmd.Flags().Bool(scorecard.BasicTestsOpt, true, "Enable basic operator checks") 46 scorecardCmd.Flags().Bool(scorecard.OLMTestsOpt, true, "Enable OLM integration checks") 47 scorecardCmd.Flags().Bool(scorecard.TenantTestsOpt, false, "Enable good tenant checks") 48 scorecardCmd.Flags().String(scorecard.NamespacedManifestOpt, "", "Path to manifest for namespaced resources (e.g. RBAC and Operator manifest)") 49 scorecardCmd.Flags().String(scorecard.GlobalManifestOpt, "", "Path to manifest for Global resources (e.g. CRD manifests)") 50 scorecardCmd.Flags().String(scorecard.CRManifestOpt, "", "Path to manifest for Custom Resource (required)") 51 scorecardCmd.Flags().String(scorecard.ProxyImageOpt, fmt.Sprintf("quay.io/operator-framework/scorecard-proxy:%s", strings.TrimSuffix(version.Version, "+git")), "Image name for scorecard proxy") 52 scorecardCmd.Flags().String(scorecard.ProxyPullPolicyOpt, "Always", "Pull policy for scorecard proxy image") 53 scorecardCmd.Flags().String(scorecard.CRDsDirOpt, scaffold.CRDsDir, "Directory containing CRDs (all CRD manifest filenames must have the suffix 'crd.yaml')") 54 scorecardCmd.Flags().Bool(scorecard.VerboseOpt, false, "Enable verbose logging") 55 56 if err := viper.BindPFlags(scorecardCmd.Flags()); err != nil { 57 log.Fatalf("Failed to bind scorecard flags to viper: %v", err) 58 } 59 60 return scorecardCmd 61 }