From e99e1a650f25ad200ff8cd390b18da783c03dd4f Mon Sep 17 00:00:00 2001 From: barnettZQG Date: Fri, 23 Sep 2022 16:53:52 +0800 Subject: [PATCH] Fix: deprecate the cue-packages command (#4762) --- references/cli/cli.go | 1 - references/cli/cue_packages.go | 69 ---------------------------------- 2 files changed, 70 deletions(-) delete mode 100644 references/cli/cue_packages.go diff --git a/references/cli/cli.go b/references/cli/cli.go index af1dcd8e7..a40bf5de3 100644 --- a/references/cli/cli.go +++ b/references/cli/cli.go @@ -120,7 +120,6 @@ func NewCommandWithIOStreams(ioStream util.IOStreams) *cobra.Command { NewInstallCommand(commandArgs, "1", ioStream), NewUnInstallCommand(commandArgs, "2", ioStream), NewExportCommand(commandArgs, ioStream), - NewCUEPackageCommand(commandArgs, ioStream), NewVersionCommand(ioStream), NewCompletionCommand(), NewSystemCommand(commandArgs), diff --git a/references/cli/cue_packages.go b/references/cli/cue_packages.go deleted file mode 100644 index 9c49a707a..000000000 --- a/references/cli/cue_packages.go +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright 2021. The KubeVela 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 cli - -import ( - "fmt" - "strings" - - "github.com/gosuri/uitable" - "github.com/spf13/cobra" - - "github.com/oam-dev/kubevela/pkg/utils/common" - cmdutil "github.com/oam-dev/kubevela/pkg/utils/util" -) - -// NewCUEPackageCommand creates `cue-package` command -func NewCUEPackageCommand(c common.Args, ioStreams cmdutil.IOStreams) *cobra.Command { - cmd := &cobra.Command{ - Use: "cue-packages", - DisableFlagsInUseLine: true, - Hidden: true, - Short: "List cue package", - Long: "List CUE packages available.", - Example: `vela cue-packages`, - Annotations: map[string]string{}, - RunE: func(cmd *cobra.Command, args []string) error { - return printCUEPackageList(c, ioStreams) - }, - } - cmd.SetOut(ioStreams.Out) - return cmd -} - -func printCUEPackageList(c common.Args, ioStreams cmdutil.IOStreams) error { - pd, err := c.GetPackageDiscover() - if err != nil { - return fmt.Errorf("get cue package discover: %w", err) - } - - table := uitable.New() - table.AddRow("DEFINITION-NAME", "IMPORT-PATH", " USAGE") - - packages := pd.ListPackageKinds() - for path, kinds := range packages { - if strings.HasPrefix(path, "kube/") { - continue - } - for _, kind := range kinds { - // TODO(yangsoon) support other kind object in future - table.AddRow(kind.DefinitionName, path, "Kube Object for "+kind.APIVersion+"."+kind.Kind) - } - } - ioStreams.Info(table.String()) - return nil -}