github.com/jenkins-x/jx/v2@v2.1.155/pkg/cmd/compliance/compliance_delete.go (about) 1 package compliance 2 3 import ( 4 "github.com/heptio/sonobuoy/pkg/client" 5 "github.com/jenkins-x/jx/v2/pkg/cmd/helper" 6 "github.com/jenkins-x/jx/v2/pkg/cmd/opts" 7 "github.com/jenkins-x/jx/v2/pkg/cmd/templates" 8 "github.com/pkg/errors" 9 "github.com/spf13/cobra" 10 ) 11 12 var ( 13 complianceDeleteLong = templates.LongDesc(` 14 Deletes the Kubernetes resources allocated by the compliance tests 15 `) 16 17 complianceDeleteExample = templates.Examples(` 18 # Delete the Kubernetes resources allocated by the compliance test 19 jx compliance delete 20 `) 21 ) 22 23 // ComplianceDeleteOptions options for "compliance delete" command 24 type ComplianceDeleteOptions struct { 25 *opts.CommonOptions 26 } 27 28 // NewCmdComplianceDeletecreates a command object for the "compliance delete" action, which 29 // delete the Kubernetes resources allocated by the compliance tests 30 func NewCmdComplianceDelete(commonOpts *opts.CommonOptions) *cobra.Command { 31 options := &ComplianceDeleteOptions{ 32 CommonOptions: commonOpts, 33 } 34 35 cmd := &cobra.Command{ 36 Use: "delete", 37 Short: "Deletes the Kubernetes resources allocated by the compliance tests", 38 Long: complianceDeleteLong, 39 Example: complianceDeleteExample, 40 Run: func(cmd *cobra.Command, args []string) { 41 options.Cmd = cmd 42 options.Args = args 43 err := options.Run() 44 helper.CheckErr(err) 45 }, 46 } 47 48 return cmd 49 } 50 51 // Run implements the "compliance delete" command 52 func (o *ComplianceDeleteOptions) Run() error { 53 cc, err := o.ComplianceClient() 54 if err != nil { 55 return errors.Wrap(err, "could not create the compliance client") 56 } 57 deleteOpts := &client.DeleteConfig{ 58 Namespace: complianceNamespace, 59 EnableRBAC: false, 60 DeleteAll: true, 61 } 62 return cc.Delete(deleteOpts) 63 }