Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Refactor Enable And Disable Module Commands #1918

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package enable
package add

import (
"github.com/kyma-project/cli/cmd/kyma/alpha/enable/module"
"github.com/kyma-project/cli/cmd/kyma/alpha/add/module"
"github.com/kyma-project/cli/internal/cli"
"github.com/spf13/cobra"
)

func NewCmd(o *cli.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "enable",
Short: "Enables a resource in the Kyma cluster.",
Use: "add",
Aliases: []string{"enable"},
Short: "Adds a resource to the Kyma cluster.",
Long: `Use this command to enable a resource in the Kyma cluster.
`,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func NewCmd(o *Options) *cobra.Command {

cmd := &cobra.Command{
Use: "module [name] [flags]",
Short: "Enables a module in the cluster or in the given Kyma resource.",
Long: `Use this command to enable Kyma modules available in the cluster.
Short: "Adds a module in the cluster or in the given Kyma resource.",
Long: `Use this command to add Kyma modules available in the cluster.

### Detailed description

Expand All @@ -43,8 +43,8 @@ A module is available when it is released with a ModuleTemplate. The ModuleTempl
`,

Example: `
Enable "my-module" from "alpha" channel in "default-kyma" in "kyma-system" Namespace
kyma alpha enable module my-module -c alpha -n kyma-system -k default-kyma
Add "my-module" from "alpha" channel to "default-kyma" in "kyma-system" Namespace
kyma alpha add module my-module -c alpha -n kyma-system -k default-kyma
`,
RunE: func(cmd *cobra.Command, args []string) error { return c.Run(cmd.Context(), args) },
Aliases: []string{"mod", "mods", "modules"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/kyma-project/lifecycle-manager/api/v1beta2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/kyma-project/cli/cmd/kyma/alpha/enable/module/mock"
"github.com/kyma-project/cli/cmd/kyma/alpha/add/module/mock"
"github.com/kyma-project/cli/internal/cli/alpha/module"
)

Expand Down
8 changes: 4 additions & 4 deletions cmd/kyma/alpha/alpha.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package alpha

import (
"github.com/kyma-project/cli/cmd/kyma/alpha/add"
"github.com/kyma-project/cli/cmd/kyma/alpha/create"
"github.com/kyma-project/cli/cmd/kyma/alpha/delete"
"github.com/kyma-project/cli/cmd/kyma/alpha/deploy"
"github.com/kyma-project/cli/cmd/kyma/alpha/disable"
"github.com/kyma-project/cli/cmd/kyma/alpha/enable"
"github.com/kyma-project/cli/cmd/kyma/alpha/list"
"github.com/kyma-project/cli/cmd/kyma/alpha/sign"
"github.com/kyma-project/cli/cmd/kyma/alpha/verify"
Expand All @@ -23,8 +23,8 @@ func NewCmd(o *cli.Options) *cobra.Command {

cmd.AddCommand(create.NewCmd(o))
cmd.AddCommand(list.NewCmd(o))
cmd.AddCommand(enable.NewCmd(o))
cmd.AddCommand(disable.NewCmd(o))
cmd.AddCommand(add.NewCmd(o))
cmd.AddCommand(delete.NewCmd(o))
cmd.AddCommand(deploy.NewCmd(deploy.NewOptions(o)))
cmd.AddCommand(sign.NewCmd(o))
cmd.AddCommand(verify.NewCmd(o))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package disable
package delete

import (
"github.com/kyma-project/cli/cmd/kyma/alpha/disable/module"
"github.com/kyma-project/cli/cmd/kyma/alpha/delete/module"
"github.com/kyma-project/cli/internal/cli"
"github.com/spf13/cobra"
)

func NewCmd(o *cli.Options) *cobra.Command {
cmd := &cobra.Command{
Use: "disable",
Short: "Disables a resource in the Kyma cluster.",
Use: "delete",
Aliases: []string{"disable"},
Short: "Deletes a resource from the Kyma cluster.",
Long: `Use this command to disable a resource in the Kyma cluster.
`,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func NewCmd(o *Options) *cobra.Command {

cmd := &cobra.Command{
Use: "module [name] [flags]",
Short: "Disables a module in the cluster or in the given Kyma resource.",
Long: `Use this command to disable active Kyma modules in the cluster.
Short: "Deletes a module from the cluster or the given Kyma resource.",
Long: `Use this command to delete Kyma modules from the cluster.

### Detailed description

Expand All @@ -40,8 +40,8 @@ This command disables an active module in the cluster.
`,

Example: `
Disable "my-module" from the "alpha" channel in "default-kyma" in "kyma-system" Namespace
kyma alpha disable module my-module -c alpha -n kyma-system -k default-kyma
Delete "my-module" from the "alpha" channel from "default-kyma" in "kyma-system" Namespace
kyma alpha delete module my-module -c alpha -n kyma-system -k default-kyma
`,
RunE: func(cmd *cobra.Command, args []string) error { return c.Run(cmd.Context(), args) },
Aliases: []string{"mod", "mods", "modules"},
Expand Down
4 changes: 2 additions & 2 deletions docs/gen-docs/kyma_alpha.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ Alpha commands are experimental, unreleased features that should only be used by
## See also

* [kyma](kyma.md) - Controls a Kyma cluster.
* [kyma alpha add](kyma_alpha_add.md) - Adds a resource to the Kyma cluster.
* [kyma alpha create](kyma_alpha_create.md) - Creates resources on the Kyma cluster.
* [kyma alpha delete](kyma_alpha_delete.md) - Deletes a resource from the Kyma cluster.
* [kyma alpha deploy](kyma_alpha_deploy.md) - Deploys Kyma on a running Kubernetes cluster.
* [kyma alpha disable](kyma_alpha_disable.md) - Disables a resource in the Kyma cluster.
* [kyma alpha enable](kyma_alpha_enable.md) - Enables a resource in the Kyma cluster.
* [kyma alpha list](kyma_alpha_list.md) - Lists resources on the Kyma cluster.
* [kyma alpha sign](kyma_alpha_sign.md) - Signs all module resources from an unsigned module component descriptor that's hosted in a remote OCI registry
* [kyma alpha verify](kyma_alpha_verify.md) - Verifies all module resources from a signed module component descriptor that's hosted in a remote OCI registry
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: kyma alpha enable
title: kyma alpha add
---

Enables a resource in the Kyma cluster.
Adds a resource to the Kyma cluster.

## Synopsis

Expand All @@ -22,5 +22,5 @@ Use this command to enable a resource in the Kyma cluster.
## See also

* [kyma alpha](kyma_alpha.md) - Experimental commands
* [kyma alpha enable module](kyma_alpha_enable_module.md) - Enables a module in the cluster or in the given Kyma resource.
* [kyma alpha add module](kyma_alpha_add_module.md) - Adds a module in the cluster or in the given Kyma resource.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: kyma alpha enable module
title: kyma alpha add module
---

Enables a module in the cluster or in the given Kyma resource.
Adds a module in the cluster or in the given Kyma resource.

## Synopsis

Use this command to enable Kyma modules available in the cluster.
Use this command to add Kyma modules available in the cluster.

### Detailed description

Expand All @@ -17,15 +17,15 @@ A module is available when it is released with a ModuleTemplate. The ModuleTempl


```bash
kyma alpha enable module [name] [flags]
kyma alpha add module [name] [flags]
```

## Examples

```bash

Enable "my-module" from "alpha" channel in "default-kyma" in "kyma-system" Namespace
kyma alpha enable module my-module -c alpha -n kyma-system -k default-kyma
Add "my-module" from "alpha" channel to "default-kyma" in "kyma-system" Namespace
kyma alpha add module my-module -c alpha -n kyma-system -k default-kyma

```

Expand Down Expand Up @@ -53,5 +53,5 @@ Enable "my-module" from "alpha" channel in "default-kyma" in "kyma-system" Names

## See also

* [kyma alpha enable](kyma_alpha_enable.md) - Enables a resource in the Kyma cluster.
* [kyma alpha add](kyma_alpha_add.md) - Adds a resource to the Kyma cluster.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
title: kyma alpha disable
title: kyma alpha delete
---

Disables a resource in the Kyma cluster.
Deletes a resource from the Kyma cluster.

## Synopsis

Expand All @@ -22,5 +22,5 @@ Use this command to disable a resource in the Kyma cluster.
## See also

* [kyma alpha](kyma_alpha.md) - Experimental commands
* [kyma alpha disable module](kyma_alpha_disable_module.md) - Disables a module in the cluster or in the given Kyma resource.
* [kyma alpha delete module](kyma_alpha_delete_module.md) - Deletes a module from the cluster or the given Kyma resource.

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: kyma alpha disable module
title: kyma alpha delete module
---

Disables a module in the cluster or in the given Kyma resource.
Deletes a module from the cluster or the given Kyma resource.

## Synopsis

Use this command to disable active Kyma modules in the cluster.
Use this command to delete Kyma modules from the cluster.

### Detailed description

Expand All @@ -16,15 +16,15 @@ This command disables an active module in the cluster.


```bash
kyma alpha disable module [name] [flags]
kyma alpha delete module [name] [flags]
```

## Examples

```bash

Disable "my-module" from the "alpha" channel in "default-kyma" in "kyma-system" Namespace
kyma alpha disable module my-module -c alpha -n kyma-system -k default-kyma
Delete "my-module" from the "alpha" channel from "default-kyma" in "kyma-system" Namespace
kyma alpha delete module my-module -c alpha -n kyma-system -k default-kyma

```

Expand All @@ -51,5 +51,5 @@ Disable "my-module" from the "alpha" channel in "default-kyma" in "kyma-system"

## See also

* [kyma alpha disable](kyma_alpha_disable.md) - Disables a resource in the Kyma cluster.
* [kyma alpha delete](kyma_alpha_delete.md) - Deletes a resource from the Kyma cluster.

2 changes: 1 addition & 1 deletion internal/net/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestDoGet(t *testing.T) {
require.Equal(t, 301, sc)

// Non existing URL
_, err = DoGet("http://fake-url.com")
_, err = DoGet("http://totally.fake.url")
require.Error(t, err)

// BAD URL
Expand Down