Skip to content

Commit

Permalink
remove unused consts & address linting issues
Browse files Browse the repository at this point in the history
Signed-off-by: Erhan Cagirici <[email protected]>
  • Loading branch information
erhancagirici committed Mar 12, 2024
1 parent 53599ef commit 22ae56a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 24 deletions.
26 changes: 5 additions & 21 deletions internal/clients/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ package clients

import (
"context"
"fmt"
"reflect"
"unsafe"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
"github.com/crossplane/crossplane-runtime/pkg/resource"
Expand All @@ -15,31 +17,13 @@ import (
"github.com/hashicorp/terraform-provider-aws/xpprovider"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/types"
"reflect"
"sigs.k8s.io/controller-runtime/pkg/client"
"unsafe"

"github.com/upbound/provider-aws/apis/v1beta1"
)

const (
// Terraform provider configuration keys for AWS credentials.
keyRegion = "region"
keyAccountId = "account_id"
keySessionToken = "token"
keyAccessKeyID = "access_key"
keySecretAccessKey = "secret_key"
keyAssumeRoleWithWebIdentity = "assume_role_with_web_identity"
keyRoleArn = "role_arn"
keySessionName = "session_name"
keyWebIdentityTokenFile = "web_identity_token_file"
keyWebIdentityToken = "web_identity_token"
keySkipCredsValidation = "skip_credentials_validation"
keyS3UsePathStyle = "s3_use_path_style"
keySkipMetadataApiCheck = "skip_metadata_api_check"
keySkipRegionValidation = "skip_region_validation"
keySkipReqAccountId = "skip_requesting_account_id"
keyEndpoints = "endpoints"
keyAccountId = "account_id"
)

type SetupConfig struct {
Expand Down Expand Up @@ -155,7 +139,7 @@ func configureNoForkAWSClient(ctx context.Context, ps *terraform.Setup, config *
ServicePackages: (*xpprovider.AWSClient)(unsafe.Pointer(reflect.ValueOf(p).Pointer())).ServicePackages,
})
if diags.HasError() {
return fmt.Errorf("cannot construct TF AWS Client from TF AWS Config, %v", diags)
return errors.Errorf("cannot construct TF AWS Client from TF AWS Config, %v", diags)
}
// accountID is already calculated/retrieved from Caller ID cache while
// obtaining AWS config. The terraform config is explicitly constructed
Expand Down
6 changes: 3 additions & 3 deletions internal/clients/provider_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const (
authKeyWebIdentity = "WebIdentity"
authKeyUpbound = "Upbound"
// authKeySAML = "SAML"
authKeySecret = "Secret"
// authKeySecret = "Secret"

envWebIdentityTokenFile = "AWS_WEB_IDENTITY_TOKEN_FILE"
envWebIdentityRoleARN = "AWS_ROLE_ARN"
Expand Down Expand Up @@ -86,8 +86,8 @@ func getRegion(obj runtime.Object) (string, error) {
}

// GetAWSConfigViaProviderConfig produces an AWS config from the specified
// v1beta1.ProviderConfig that can be used to authenticate to AWS,
func GetAWSConfigViaProviderConfig(ctx context.Context, c client.Client, mg resource.Managed, pc *v1beta1.ProviderConfig) (*aws.Config, error) {
// v1beta1.ProviderConfig that can be used to authenticate to AWS
func GetAWSConfigViaProviderConfig(ctx context.Context, c client.Client, mg resource.Managed, pc *v1beta1.ProviderConfig) (*aws.Config, error) { // nolint:gocyclo
region, err := getRegion(mg)
if err != nil {
return nil, errors.Wrap(err, "cannot get region")
Expand Down

0 comments on commit 22ae56a

Please sign in to comment.