Skip to content

Commit

Permalink
added the --profile option to the link subcommand too
Browse files Browse the repository at this point in the history
  • Loading branch information
YashdalfTheGray committed Oct 30, 2024
1 parent c97feae commit 823717a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_binary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Build binary
on: [push, pull_request]

env:
GOLANG_VERSION: '1.20.x'
GOLANG_VERSION: '1.23'

jobs:
make_build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/draft_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- completed

env:
GOLANG_VERSION: '1.20.x'
GOLANG_VERSION: '1.23'

jobs:
functional_tests:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/functional_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
- completed

env:
GOLANG_VERSION: '1.20.x'
GOLANG_VERSION: '1.23'

jobs:
functional_tests:
Expand Down
2 changes: 1 addition & 1 deletion constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package constants

// These are some constants for the application
const (
Version = "2.3.1"
Version = "2.4.0"
EnvAWSAccessKeyID = "AWS_ACCESS_KEY_ID"
EnvAWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
EnvAWSSessionToken = "AWS_SESSION_TOKEN"
Expand Down
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/YashdalfTheGray/federator

go 1.20
go 1.21

toolchain go1.23.2

require (
github.com/aws/aws-sdk-go-v2 v1.30.4
Expand Down
22 changes: 17 additions & 5 deletions subcommands/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
"github.com/YashdalfTheGray/federator/constants"
"github.com/YashdalfTheGray/federator/helpers"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
)

// LinkSubcommandParsedArgs holds all the bits of data that are
// needed for the link subcommand to work properly.
type LinkSubcommandParsedArgs struct {
RoleArn, ExternalID, Region, IssuerURL, DestinationURL string
OutputJSON bool
RoleArn, ExternalID, Region, IssuerURL, DestinationURL, Profile string
OutputJSON bool
}

// LinkSubcommand holds the parsed args, when populated as well as internal
Expand Down Expand Up @@ -71,6 +72,12 @@ func (cmd *LinkSubcommand) Setup() {
constants.DefaultDestination,
"the link that the user will be redirected to after login",
)
cmd.subcommand.StringVar(
&cmd.Parsed.Profile,
"profile",
"",
"the aws credentials profile to use when making the assume role call",
)
cmd.subcommand.BoolVar(
&cmd.Parsed.OutputJSON,
"json",
Expand All @@ -93,11 +100,16 @@ func (cmd LinkSubcommand) Validate() {
// GetAWSConfig gets the right AWS config based on whether the
// region is passed in or read from the CLI configuration
func (cmd LinkSubcommand) GetAWSConfig() aws.Config {
if cmd.Parsed.Region == "" {
return helpers.GetAWSConfig()
opts := []func(*config.LoadOptions) error{}

if cmd.Parsed.Region != "" {
opts = append(opts, config.WithRegion(cmd.Parsed.Region))
}
if cmd.Parsed.Profile != "" {
opts = append(opts, config.WithSharedConfigProfile(cmd.Parsed.Profile))
}

return helpers.GetAWSConfigForRegion(cmd.Parsed.Region)
return helpers.GetAWSConfigOpts(opts...)
}

// Parse will parse the flags, according to the arguments setup in .Setup
Expand Down

0 comments on commit 823717a

Please sign in to comment.