Skip to content
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
Expand Up @@ -40,13 +40,13 @@ var (
}
)

// NewCreateSecretsCmd implements the "create-secrets" command for the credentials provisioning
func NewCreateSecretsCmd() *cobra.Command {
// NewCreateSharedSecretsCmd implements the "create-shared-secrets" command for the credentials provisioning
func NewCreateSharedSecretsCmd() *cobra.Command {
createSecretsCmd := &cobra.Command{
Use: "create-secrets",
Use: "create-shared-secrets",
Short: "Create credentials objects",
Long: "Creating objects related to cloud credentials",
RunE: createSecretsCmd,
Long: "Creating secrets from credentials requests using the API key in the IC_API_KEY environment variable",
RunE: createSharedSecretsCmd,
PersistentPreRun: initEnvForCreateCmd,
}

Expand All @@ -57,20 +57,20 @@ func NewCreateSecretsCmd() *cobra.Command {
return createSecretsCmd
}

func createSecretsCmd(cmd *cobra.Command, args []string) error {
func createSharedSecretsCmd(cmd *cobra.Command, args []string) error {
apiKey := os.Getenv(APIKeyEnvVar)
if apiKey == "" {
return fmt.Errorf("%s environment variable not set", APIKeyEnvVar)
}

err := createSecrets(CreateOpts.CredRequestDir, CreateOpts.TargetDir, apiKey)
err := createSharedSecrets(CreateOpts.CredRequestDir, CreateOpts.TargetDir, apiKey)
if err != nil {
return err
}
return nil
}

func createSecrets(credReqDir string, targetDir string, apiKey string) error {
func createSharedSecrets(credReqDir string, targetDir string, apiKey string) error {
credRequests, err := getListOfCredentialsRequests(credReqDir)
if err != nil {
return errors.Wrap(err, "Failed to process files containing CredentialsRequests")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestCreateSecretsCmd(t *testing.T) {
expectError: false,
},
{
name: "CreateSecretsCmd with unset API key environment variable should fail",
name: "CreateSharedSecretsCmd with unset API key environment variable should fail",
setup: func(t *testing.T) string {
os.Setenv(APIKeyEnvVar, "")
tempDirName, err := ioutil.TempDir(os.TempDir(), testDirPrefix)
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestCreateSecretsCmd(t *testing.T) {
}
CreateOpts.CredRequestDir = credReqDir
CreateOpts.TargetDir = targetDir
err = createSecretsCmd(&cobra.Command{}, args)
err = createSharedSecretsCmd(&cobra.Command{}, args)

if test.expectError {
require.Error(t, err, "Expected error returned")
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/provisioning/ibmcloud/ibmcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func NewIBMCloudCmd() *cobra.Command {
Long: "Creating/deleting cloud credentials objects for IBM Cloud",
}

createCmd.AddCommand(NewCreateSecretsCmd())
createCmd.AddCommand(NewCreateSharedSecretsCmd())

return createCmd
}