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

release -> main merge (20220808) #53

Merged
merged 8 commits into from
Aug 8, 2023
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
6 changes: 2 additions & 4 deletions internal/commands/appserve-show.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,14 @@ func printAppServeShow(d domain.AppServeApp, long bool) {
t.Style().Options.SeparateHeader = false
t.Style().Options.SeparateRows = false
if long {
t.AppendHeader(table.Row{"ID", "Version", "Status", "Available Rollback", "Strategy", "Revision",
"Image URL", "Profile", "CREATED_AT", "UPDATED_AT"})
t.AppendHeader(table.Row{"ID", "Version", "Status", "Available Rollback", "Strategy", "Revision", "Image URL", "Profile", "CREATED_AT", "UPDATED_AT"})
for _, i := range d.AppServeAppTasks {
tCreatedAt := helper.ParseTime(i.CreatedAt)
var tUpdatedAt string
if i.UpdatedAt != nil {
tUpdatedAt = helper.ParseTime(*i.UpdatedAt)
}
t.AppendRow(table.Row{i.ID, i.Version, i.Status, i.AvailableRollback, i.Strategy, strconv.Itoa(int(i.HelmRevision)),
i.ImageUrl, i.Profile, tCreatedAt, tUpdatedAt})
t.AppendRow(table.Row{i.ID, i.Version, i.Status, i.AvailableRollback, i.Strategy, strconv.Itoa(int(i.HelmRevision)), i.ImageUrl, i.Profile, tCreatedAt, tUpdatedAt})
}
} else {
fmt.Println("Not implemented yet.")
Expand Down
83 changes: 83 additions & 0 deletions internal/commands/cloud-account-create.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package commands

import (
"fmt"

_apiClient "github.com/openinfradev/tks-api/pkg/api-client"
"github.com/openinfradev/tks-api/pkg/domain"
"github.com/openinfradev/tks-client/internal/helper"
"github.com/spf13/cobra"
)

func NewCloudAccountCreateCommand(globalOpts *GlobalOptions) *cobra.Command {
var (
organizationId string
name string
description string
cloudService string
awsAccountId string
accessKeyId string
secretAccessKey string
)

var command = &cobra.Command{
Use: "create",
Short: "Create a cloud account.",
Long: `Create a cloud account.

Example:
tks cloud-account create <NAME> [--awsAccountId AWS_ACCOUNT_ID --accessKeyID ACCESS_KEY_ID --secretAccesssKey SECRET_ACCESS_KEY]`,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 1 {
name = args[0]
}

if name == "" {
helper.PanicWithError("You must specify name")
}

input := domain.CreateCloudAccountRequest{
Name: name,
Description: description,
CloudService: cloudService,
AwsAccountId: awsAccountId,
AccessKeyId: accessKeyId,
SecretAccessKey: secretAccessKey,
}

apiClient, err := _apiClient.New(globalOpts.ServerAddr, globalOpts.AuthToken)
helper.CheckError(err)

url := fmt.Sprintf("organizations/%v/cloud-accounts", organizationId)
body, err := apiClient.Post(url, input)
if err != nil {
return err
}

var out domain.CreateCloudAccountResponse
helper.Transcode(body, &out)

fmt.Println("cloudAccountId : ", out.ID)

return nil
},
}

command.Flags().StringVarP(&organizationId, "organization-id", "o", "", "the organizationId with cloud accounts")
helper.CheckError(command.MarkFlagRequired("organization-id"))

command.Flags().StringVarP(&name, "name", "n", "", "the name of cloud account")
command.Flags().StringVarP(&description, "description", "d", "", "the description of cloud account")
command.Flags().StringVar(&cloudService, "cloud-service", "AWS", "the type of cloud account")

command.Flags().StringVar(&awsAccountId, "aws-account-id", "", "The accountId of aws")
helper.CheckError(command.MarkFlagRequired("aws-account-id"))

command.Flags().StringVar(&accessKeyId, "access-key-id", "", "The accessKeyId of aws")
helper.CheckError(command.MarkFlagRequired("access-key-id"))

command.Flags().StringVar(&secretAccessKey, "secret-access-key", "", "The secret access key of accessKey Id")
helper.CheckError(command.MarkFlagRequired("secret-access-key"))

return command
}
1 change: 1 addition & 0 deletions internal/commands/cloud-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ func NewCloudAccountCommand(globalOpts *GlobalOptions) *cobra.Command {
},
}

command.AddCommand(NewCloudAccountCreateCommand(globalOpts))
command.AddCommand(NewCloudAccountListCommand(globalOpts))

return command
Expand Down