Skip to content

Commit

Permalink
Add managed flag
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalKalke committed Jun 3, 2024
1 parent 4aac24c commit 2f8a12d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/cmd/kyma.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
31 changes: 27 additions & 4 deletions internal/cmd/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package modules
import (
"encoding/json"
"fmt"
"github.com/kyma-project/cli.v3/internal/cmdcommon"
"io"
"net/http"

Expand All @@ -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))
},
Expand Down Expand Up @@ -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"))
}
Expand Down Expand Up @@ -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")
}

0 comments on commit 2f8a12d

Please sign in to comment.