Skip to content

Commit

Permalink
edit noobaa cli short of creation of aws-sts in bs and ns
Browse files Browse the repository at this point in the history
1. edit noobaa cli short of creation of noobaa backingstore create aws-sts.
2. add validation of the aws-sts-arn that passed.
3. add the above changes to noobaa namespacestore create aws-sts.

Signed-off-by: shirady <[email protected]>
  • Loading branch information
shirady committed Nov 9, 2023
1 parent c5aa88b commit 51297a5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions pkg/backingstore/backingstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/noobaa/noobaa-operator/v5/pkg/util"
"github.com/noobaa/noobaa-operator/v5/pkg/validations"

"github.com/aws/aws-sdk-go/aws/arn"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
storagev1 "k8s.io/api/storage/v1"
Expand Down Expand Up @@ -72,7 +73,7 @@ func CmdCreate() *cobra.Command {
func CmdCreateAWSSTSS3() *cobra.Command {
cmd := &cobra.Command{
Use: "aws-sts-s3 <backing-store-name>",
Short: "Create aws-sts-s3 backing store",
Short: "Create aws-s3 backing store (using STS, short-lived credentials)",
Run: RunCreateAWSSTSS3,
}
cmd.Flags().String(
Expand All @@ -94,7 +95,7 @@ func CmdCreateAWSSTSS3() *cobra.Command {
func CmdCreateAWSS3() *cobra.Command {
cmd := &cobra.Command{
Use: "aws-s3 <backing-store-name>",
Short: "Create aws-s3 backing store",
Short: "Create aws-s3 backing store (using long-lived credentials)",
Run: RunCreateAWSS3,
}
cmd.Flags().String(
Expand Down Expand Up @@ -481,6 +482,9 @@ func RunCreateAWSSTSS3(cmd *cobra.Command, args []string) {
log.Fatalf(`❌ BackingStore %q already exists in namespace %q`, backStore.Name, backStore.Namespace)
}
awsSTSARN := util.GetFlagStringOrPrompt(cmd, "aws-sts-arn")
if !arn.IsARN(awsSTSARN) {
log.Fatalf(`❌ aws-sts-arn %q is invalid`, awsSTSARN)
}
targetBucket := util.GetFlagStringOrPrompt(cmd, "target-bucket")
region, _ := cmd.Flags().GetString("region")
backStore.Spec.AWSS3 = &nbv1.AWSS3Spec{
Expand Down
8 changes: 6 additions & 2 deletions pkg/namespacestore/namespacestore.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/noobaa/noobaa-operator/v5/pkg/util"
"github.com/noobaa/noobaa-operator/v5/pkg/validations"

"github.com/aws/aws-sdk-go/aws/arn"
"github.com/spf13/cobra"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -69,7 +70,7 @@ func CmdCreate() *cobra.Command {
func CmdCreateAWSS3() *cobra.Command {
cmd := &cobra.Command{
Use: "aws-s3 <namespace-store-name>",
Short: "Create aws-s3 namespace store",
Short: "Create aws-s3 namespace store (using long-lived credentials)",
Run: RunCreateAWSS3,
}
cmd.Flags().String(
Expand Down Expand Up @@ -103,7 +104,7 @@ func CmdCreateAWSS3() *cobra.Command {
func CmdCreateAWSSTSS3() *cobra.Command {
cmd := &cobra.Command{
Use: "aws-sts-s3 <namespace-store-name>",
Short: "Create aws-sts-s3 namespace store",
Short: "Create aws-s3 namespace store (using STS, short-lived credentials)",
Run: RunCreateAWSSTSS3,
}
cmd.Flags().String(
Expand Down Expand Up @@ -491,6 +492,9 @@ func RunCreateAWSSTSS3(cmd *cobra.Command, args []string) {
log.Fatalf(`❌ NamespaceStore %q already exists in namespace %q`, namespaceStore.Name, namespaceStore.Namespace)
}
awsSTSARN := util.GetFlagStringOrPrompt(cmd, "aws-sts-arn")
if !arn.IsARN(awsSTSARN) {
log.Fatalf(`❌ aws-sts-arn %q is invalid`, awsSTSARN)
}
targetBucket := util.GetFlagStringOrPrompt(cmd, "target-bucket")
region, _ := cmd.Flags().GetString("region")
namespaceStore.Spec.AWSS3 = &nbv1.AWSS3Spec{
Expand Down

0 comments on commit 51297a5

Please sign in to comment.