Skip to content

Commit

Permalink
fix: errpr validation
Browse files Browse the repository at this point in the history
  • Loading branch information
jokestax committed Jan 16, 2025
1 parent 4f2b84e commit f29a6bf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/aws/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func convertLocalCredsToSession(ctx context.Context, stsClient stsClienter, iamC
output, err := stsClient.AssumeRole(ctx, &sts.AssumeRoleInput{
RoleArn: aws.String(roleArn),
RoleSessionName: aws.String(sessionName),
DurationSeconds: aws.Int32(sessionDuration),
// DurationSeconds: aws.Int32(sessionDuration),
})
if err != nil {
return nil, fmt.Errorf("failed to assume role %s: %w", roleArn, err)
Expand Down Expand Up @@ -304,15 +304,15 @@ func createKubernetesAdminRole(ctx context.Context, clusterName string, iamClien
// Check if the IAM policy exists
cp, err := iamClient.GetPolicy(ctx, &iam.GetPolicyInput{PolicyArn: aws.String(fmt.Sprintf("arn:aws:iam::%s:policy/%s", *callerIdentity.Account, policyName))})
if err != nil {
var newError awshttp.ResponseError
var newError *awshttp.ResponseError
if errors.As(err, &newError) && newError.HTTPStatusCode() == http.StatusNotFound {

Check failure on line 308 in cmd/aws/create.go

View workflow job for this annotation

GitHub Actions / build

empty-block: this block is empty, you can remove it (revive)
// Policy does not exist, continue
} else {
return "", fmt.Errorf("failed to get policy %q: %w", policyName, err)
}
}

if cp.Policy != nil {
if err == nil && cp.Policy != nil {
return "", fmt.Errorf("policy %q already exists: please delete the policy and try again", policyName)
}

Expand Down Expand Up @@ -353,15 +353,15 @@ func createKubernetesAdminRole(ctx context.Context, clusterName string, iamClien
// Check if a role with this name already exists
role, err := iamClient.GetRole(ctx, &iam.GetRoleInput{RoleName: aws.String(roleName)})
if err != nil {
var newError awshttp.ResponseError
var newError *awshttp.ResponseError
if errors.As(err, &newError) && newError.HTTPStatusCode() == http.StatusNotFound {

Check failure on line 357 in cmd/aws/create.go

View workflow job for this annotation

GitHub Actions / build

empty-block: this block is empty, you can remove it (revive)
// Role does not exist, continue
} else {
return "", fmt.Errorf("failed to get role %q: %w", roleName, err)
}
}

if role.Role != nil {
if err == nil && role.Role != nil {
return "", fmt.Errorf("role %q already exists: please delete the role and try again", roleName)
}

Expand Down

0 comments on commit f29a6bf

Please # to comment.