-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8e2a339
commit c8820ac
Showing
8 changed files
with
251 additions
and
4 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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
.idea | ||
/rosa-support | ||
rosa-support | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
Copyright (c) 2024 Red Hat, Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package delete | ||
|
||
import ( | ||
"github.com/openshift-online/rosa-support/cmd/rosa-support/delete/tag" | ||
"github.com/openshift-online/rosa-support/cmd/rosa-support/delete/vpc" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var Cmd = &cobra.Command{ | ||
Use: "delete", | ||
Aliases: []string{"del"}, | ||
Short: "Delete a resource from stdin", | ||
Long: "Delete a resource from stdin", | ||
} | ||
|
||
func init() { | ||
Cmd.AddCommand(vpc.Cmd) | ||
Cmd.AddCommand(tag.Cmd) | ||
} |
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,91 @@ | ||
package tag | ||
|
||
import ( | ||
"os" | ||
|
||
awsClient "github.com/openshift-online/ocm-common/pkg/aws/aws_client" | ||
logger "github.com/openshift-online/ocm-common/pkg/log" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var args struct { | ||
region string | ||
resourceID string | ||
tagKey string | ||
tagValue string | ||
profileName string | ||
} | ||
var Cmd = &cobra.Command{ | ||
Use: "tag", | ||
Short: "Delete tag", | ||
Long: "Delete tag.", | ||
Example: ` # Delete a tag from the resource | ||
rosa-support delete tag --resource-id <vpc id> --region us-east-2 --tag-key key`, | ||
|
||
Run: run, | ||
} | ||
|
||
func init() { | ||
flags := Cmd.Flags() | ||
flags.SortFlags = false | ||
flags.StringVarP( | ||
&args.region, | ||
"region", | ||
"", | ||
"", | ||
"Region of the resource (required)", | ||
) | ||
flags.StringVarP( | ||
&args.profileName, | ||
"profile-name", | ||
"", | ||
"", | ||
"profile name to pass into aws client", | ||
) | ||
flags.StringVarP( | ||
&args.resourceID, | ||
"resource-id", | ||
"", | ||
"", | ||
"id of the resource (required)", | ||
) | ||
flags.StringVarP( | ||
&args.tagKey, | ||
"tag-key", | ||
"", | ||
"", | ||
"tag key of the resource (required)", | ||
) | ||
flags.StringVarP( | ||
&args.tagValue, | ||
"tag-value", | ||
"", | ||
"", | ||
"tag value of the resource", | ||
) | ||
|
||
err := Cmd.MarkFlagRequired("resource-id") | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = Cmd.MarkFlagRequired("region") | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = Cmd.MarkFlagRequired("tag-key") | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
func run(_ *cobra.Command, _ []string) { | ||
client, err := awsClient.CreateAWSClient(args.profileName, args.region) | ||
if err != nil { | ||
logger.LogError(err.Error()) | ||
os.Exit(1) | ||
} | ||
_, err = client.RemoveResourceTag(args.resourceID, args.tagKey, args.tagValue) | ||
if err != nil { | ||
logger.LogError(err.Error()) | ||
os.Exit(1) | ||
} | ||
} |
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,71 @@ | ||
package vpc | ||
|
||
import ( | ||
"os" | ||
|
||
logger "github.com/openshift-online/ocm-common/pkg/log" | ||
vpcClient "github.com/openshift-online/ocm-common/pkg/test/vpc_client" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
var args struct { | ||
region string | ||
totalClean bool | ||
vpcID string | ||
} | ||
var Cmd = &cobra.Command{ | ||
Use: "vpc", | ||
Short: "Delete vpc", | ||
Long: "Delete vpc.", | ||
Example: ` # Delete a vpc with vpc ID | ||
ocmqe delete vpc --vpc-id <vpc id> --region us-east-2`, | ||
|
||
Run: run, | ||
} | ||
|
||
func init() { | ||
flags := Cmd.Flags() | ||
flags.SortFlags = false | ||
flags.StringVarP( | ||
&args.region, | ||
"region", | ||
"", | ||
"", | ||
"Region of the vpc (required)", | ||
) | ||
flags.StringVarP( | ||
&args.vpcID, | ||
"vpc-id", | ||
"", | ||
"", | ||
"id of the vpc (required)", | ||
) | ||
flags.BoolVarP( | ||
&args.totalClean, | ||
"total-clean", | ||
"", | ||
false, | ||
"find the vpc with same name", | ||
) | ||
err := Cmd.MarkFlagRequired("vpc-id") | ||
if err != nil { | ||
panic(err) | ||
} | ||
err = Cmd.MarkFlagRequired("region") | ||
if err != nil { | ||
panic(err) | ||
} | ||
} | ||
func run(cmd *cobra.Command, _ []string) { | ||
vpc, err := vpcClient.GenerateVPCByID(args.vpcID, args.region) | ||
if err != nil { | ||
logger.LogError(err.Error()) | ||
os.Exit(1) | ||
} | ||
err = vpc.DeleteVPCChain(args.totalClean) | ||
if err != nil { | ||
logger.LogError(err.Error()) | ||
os.Exit(1) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/openshift-online/rosa-support/cmd/rosa-support" | ||
cli "github.com/openshift-online/rosa-support/cmd/rosa-support" | ||
) | ||
|
||
func main() { | ||
rosa_support.Execute() | ||
cli.Execute() | ||
} |