-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
List modules based on ModuleTemplates (#2261)
- Loading branch information
Showing
9 changed files
with
710 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package modules | ||
|
||
import ( | ||
"github.com/kyma-project/cli.v3/internal/clierror" | ||
"github.com/kyma-project/cli.v3/internal/cmdcommon" | ||
"github.com/kyma-project/cli.v3/internal/modules" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
type modulesConfig struct { | ||
*cmdcommon.KymaConfig | ||
} | ||
|
||
func NewListCMD(kymaConfig *cmdcommon.KymaConfig) *cobra.Command { | ||
cfg := modulesConfig{ | ||
KymaConfig: kymaConfig, | ||
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "List modules.", | ||
Long: `List either installed, managed or available Kyma modules.`, | ||
Run: func(_ *cobra.Command, _ []string) { | ||
clierror.Check(listModules(&cfg)) | ||
}, | ||
} | ||
|
||
return cmd | ||
} | ||
|
||
// listModules collects all the methods responsible for the command and its flags | ||
func listModules(cfg *modulesConfig) clierror.Error { | ||
client, clierr := cfg.GetKubeClientWithClierr() | ||
if clierr != nil { | ||
return clierr | ||
} | ||
|
||
modulesList, err := modules.List(cfg.Ctx, client.Kyma()) | ||
if err != nil { | ||
return clierror.Wrap(err, clierror.New("failed to list available modules from the cluster")) | ||
} | ||
|
||
modules.Render(modulesList, modules.ModulesTableInfo) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.