Skip to content

Commit

Permalink
Merge pull request #1189 from 99designs/fix-pointer-ref
Browse files Browse the repository at this point in the history
Remove reference to pointer
  • Loading branch information
mtibben committed Mar 16, 2023
2 parents b15cc22 + fd0462c commit a782d74
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5
github.com/google/go-cmp v0.5.9
github.com/mattn/go-isatty v0.0.17
github.com/mattn/go-tty v0.0.4
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
golang.org/x/term v0.5.0
gopkg.in/ini.v1 v1.67.0
Expand All @@ -32,7 +33,6 @@ require (
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
github.com/mattn/go-tty v0.0.4 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/xhit/go-str2duration v1.2.0 // indirect
golang.org/x/sys v0.5.0 // indirect
Expand Down
6 changes: 3 additions & 3 deletions vault/assumeroleprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type AssumeRoleProvider struct {
Tags map[string]string
TransitiveTagKeys []string
SourceIdentity string
*Mfa
Mfa
}

// Retrieve generates a new set of temporary credentials using STS AssumeRole
Expand Down Expand Up @@ -62,8 +62,8 @@ func (p *AssumeRoleProvider) assumeRole(ctx context.Context) (*ststypes.Credenti
input.ExternalId = aws.String(p.ExternalID)
}

if p.GetMfaSerial() != "" {
input.SerialNumber = aws.String(p.GetMfaSerial())
if p.MfaSerial != "" {
input.SerialNumber = aws.String(p.MfaSerial)
input.TokenCode, err = p.GetMfaToken()
if err != nil {
return nil, err
Expand Down
17 changes: 6 additions & 11 deletions vault/mfa.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,23 @@ import (

// Mfa contains options for an MFA device
type Mfa struct {
mfaSerial string
MfaSerial string
mfaPromptFunc prompt.Func
}

// GetMfaToken returns the MFA token
func (m *Mfa) GetMfaToken() (*string, error) {
func (m Mfa) GetMfaToken() (*string, error) {
if m.mfaPromptFunc != nil {
token, err := m.mfaPromptFunc(m.mfaSerial)
token, err := m.mfaPromptFunc(m.MfaSerial)
return aws.String(token), err
}

return nil, errors.New("No prompt found")
}

// GetMfaSerial returns the MFA serial
func (m *Mfa) GetMfaSerial() string {
return m.mfaSerial
}

func NewMfa(config *ProfileConfig) *Mfa {
func NewMfa(config *ProfileConfig) Mfa {
m := Mfa{
mfaSerial: config.MfaSerial,
MfaSerial: config.MfaSerial,
}
if config.MfaToken != "" {
m.mfaPromptFunc = func(_ string) (string, error) { return config.MfaToken, nil }
Expand All @@ -48,7 +43,7 @@ func NewMfa(config *ProfileConfig) *Mfa {
m.mfaPromptFunc = prompt.Method(config.MfaPromptMethod)
}

return &m
return m
}

func ProcessMfaProvider(processCmd string) (string, error) {
Expand Down
6 changes: 3 additions & 3 deletions vault/sessiontokenprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
type SessionTokenProvider struct {
StsClient *sts.Client
Duration time.Duration
*Mfa
Mfa
}

// Retrieve generates a new set of temporary credentials using STS GetSessionToken
Expand All @@ -41,8 +41,8 @@ func (p *SessionTokenProvider) GetSessionToken(ctx context.Context) (*ststypes.C
DurationSeconds: aws.Int32(int32(p.Duration.Seconds())),
}

if p.GetMfaSerial() != "" {
input.SerialNumber = aws.String(p.GetMfaSerial())
if p.MfaSerial != "" {
input.SerialNumber = aws.String(p.MfaSerial)
input.TokenCode, err = p.GetMfaToken()
if err != nil {
return nil, err
Expand Down

0 comments on commit a782d74

Please sign in to comment.