diff --git a/internal/cmd/kyma.go b/internal/cmd/kyma.go index 9444e4672..4793a1872 100644 --- a/internal/cmd/kyma.go +++ b/internal/cmd/kyma.go @@ -40,7 +40,7 @@ func NewKymaCMD() *cobra.Command { cmd.AddCommand(referenceinstance.NewReferenceInstanceCMD(config)) cmd.AddCommand(access.NewAccessCMD(config)) cmd.AddCommand(oidc.NewOIDCCMD(config)) - cmd.AddCommand(modules.NewModulesCMD()) + cmd.AddCommand(modules.NewModulesCMD(config)) return cmd } diff --git a/internal/cmd/modules/modules.go b/internal/cmd/modules/modules.go index f1b6bc181..2ab43fabe 100644 --- a/internal/cmd/modules/modules.go +++ b/internal/cmd/modules/modules.go @@ -3,6 +3,7 @@ package modules import ( "encoding/json" "fmt" + "github.com/kyma-project/cli.v3/internal/cmdcommon" "io" "net/http" @@ -11,19 +12,28 @@ import ( ) type modulesConfig struct { + *cmdcommon.KymaConfig + cmdcommon.KubeClientConfig + catalog bool managed bool installed bool } -func NewModulesCMD() *cobra.Command { +func NewModulesCMD(kymaConfig *cmdcommon.KymaConfig) *cobra.Command { - config := modulesConfig{} + config := modulesConfig{ + KymaConfig: kymaConfig, + KubeClientConfig: cmdcommon.KubeClientConfig{}, + } cmd := &cobra.Command{ Use: "modules", Short: "List modules.", Long: `List either installed, managed or available Kyma modules.`, + PreRun: func(_ *cobra.Command, args []string) { + clierror.Check(config.KubeClientConfig.Complete()) + }, Run: func(_ *cobra.Command, _ []string) { clierror.Check(runModules(&config)) }, @@ -55,10 +65,17 @@ func runModules(config *modulesConfig) clierror.Error { return nil } - if config.managed || config.installed { + if config.managed { + _, err := listManagedModules(config) + clierror.WrapE(err, clierror.New("not implemented yet, please use the catalog flag")) + return nil + } + + if config.installed { clierror.Wrap(err, clierror.New("not implemented yet, please use the catalog flag")) + return nil } - //TODO: installed and managed to implement + //TODO: installed to implement return clierror.Wrap(err, clierror.New("failed to get modules", "please use one of: catalog, managed or installed flags")) } @@ -89,3 +106,9 @@ func listAllModules() ([]string, clierror.Error) { } return out, nil } + +func listManagedModules(config *modulesConfig) ([]string, clierror.Error) { + trololo := config.KubeClient.Static().CoreV1().RESTClient().Get().AbsPath("kyma-project.io") + fmt.Println(trololo) + return nil, clierror.New("chleb") +}