-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- issue: #2682
- Loading branch information
Bharath Joginapally
authored and
Bharath Joginapally
committed
Jun 24, 2022
1 parent
1c248a7
commit db50968
Showing
4 changed files
with
76 additions
and
0 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,57 @@ | ||
// ------------------------------------------------------------ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
// ------------------------------------------------------------ | ||
|
||
package cmd | ||
|
||
import ( | ||
"errors" | ||
|
||
"github.com/project-radius/radius/pkg/cli" | ||
"github.com/project-radius/radius/pkg/cli/environments" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// resourceDeleteCmd command to show details of a resource | ||
var resourceDeleteCmd = &cobra.Command{ | ||
Use: "delete", | ||
Short: "Delete a RAD resource", | ||
Long: "Deletes a RAD resource with the given name", | ||
RunE: deleteResource, | ||
} | ||
|
||
func init() { | ||
resourceCmd.AddCommand(resourceDeleteCmd) | ||
} | ||
|
||
func deleteResource(cmd *cobra.Command, args []string) error { | ||
config := ConfigFromContext(cmd.Context()) | ||
env, err := cli.RequireEnvironment(cmd, config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
isUCPEnabled := false | ||
if env.GetKind() == environments.KindKubernetes { | ||
isUCPEnabled = env.(*environments.KubernetesEnvironment).GetEnableUCP() | ||
} | ||
|
||
if !isUCPEnabled { | ||
return errors.New("Delete is not enabled") | ||
} | ||
|
||
client, err := environments.CreateApplicationsManagementClient(cmd.Context(), env) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
resourceType, resourceName, err := cli.RequireResourceTypeAndName(args) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
deleteResponse, err := client.DeleteResource(cmd.Context(), resourceType, resourceName) | ||
|
||
return printOutput(cmd, deleteResponse, false) | ||
} |
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