Skip to content

Commit

Permalink
fix(aws):fix an error caused by switching version
Browse files Browse the repository at this point in the history
  • Loading branch information
404tk committed Dec 10, 2022
1 parent 3f4d015 commit 5f0dec1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
6 changes: 0 additions & 6 deletions pkg/providers/aws/ec2/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"log"
"strings"

"github.com/404tk/cloudtoolkit/pkg/schema"
"github.com/aws/aws-sdk-go/aws"
Expand Down Expand Up @@ -32,14 +31,9 @@ func (d *InstanceProvider) GetResource(ctx context.Context) ([]*schema.Host, err
req := &ec2.DescribeInstancesInput{
MaxResults: aws.Int64(1000),
}
endpointBuilder := &strings.Builder{}
endpointBuilder.WriteString("https://ec2.")
endpointBuilder.WriteString(region)
endpointBuilder.WriteString(".amazonaws.com")

ec2Client := ec2.New(
d.Session,
aws.NewConfig().WithEndpoint(endpointBuilder.String()),
aws.NewConfig().WithRegion(region),
)
for {
Expand Down
4 changes: 2 additions & 2 deletions pkg/providers/aws/iam/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ func (d *IAMProvider) GetIAMUser(ctx context.Context) ([]*schema.User, error) {
_user := &schema.User{
UserName: *user.UserName,
UserId: *user.UserId,
LastLogin: user.PasswordLastUsed.Format(time.RFC3339),
CreateTime: user.CreateDate.Format(time.RFC3339),
}
if _user.LastLogin != "" {
if user.PasswordLastUsed != nil {
_user.LastLogin = user.PasswordLastUsed.Format(time.RFC3339)
_user.EnableLogin = true
}
list = append(list, _user)
Expand Down
7 changes: 7 additions & 0 deletions runner/console/completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,13 @@ func actionCompleter(d prompt.Document) []prompt.Suggest {
}()
return prompt.FilterContains(getPayloads, d.GetWordBeforeCursor(), true)
}
if len(args) == 3 && args[1] == utils.Version {
var versions = []prompt.Suggest{
{Text: "Global", Description: "International Edition"},
{Text: "China", Description: "Chinese Edition"},
}
return prompt.FilterContains(versions, d.GetWordBeforeCursor(), true)
}
}
return []prompt.Suggest{}
}
2 changes: 1 addition & 1 deletion runner/console/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func loadConfig1() map[string]string {
utils.SecurityToken: "",
utils.Region: "all", // Default enumerate all
utils.Payload: "cloudlist", // Default use cloudlist
utils.Version: "",
utils.Version: "Global", // Default select International Edition
}
}

Expand Down

0 comments on commit 5f0dec1

Please sign in to comment.