Skip to content

Commit a782d74

Browse files
authored
Merge pull request #1189 from 99designs/fix-pointer-ref
Remove reference to pointer
2 parents b15cc22 + fd0462c commit a782d74

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ require (
1414
github.com/aws/aws-sdk-go-v2/service/sts v1.18.5
1515
github.com/google/go-cmp v0.5.9
1616
github.com/mattn/go-isatty v0.0.17
17+
github.com/mattn/go-tty v0.0.4
1718
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
1819
golang.org/x/term v0.5.0
1920
gopkg.in/ini.v1 v1.67.0
@@ -32,7 +33,6 @@ require (
3233
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
3334
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
3435
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
35-
github.com/mattn/go-tty v0.0.4 // indirect
3636
github.com/mtibben/percent v0.2.1 // indirect
3737
github.com/xhit/go-str2duration v1.2.0 // indirect
3838
golang.org/x/sys v0.5.0 // indirect

vault/assumeroleprovider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type AssumeRoleProvider struct {
2121
Tags map[string]string
2222
TransitiveTagKeys []string
2323
SourceIdentity string
24-
*Mfa
24+
Mfa
2525
}
2626

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

65-
if p.GetMfaSerial() != "" {
66-
input.SerialNumber = aws.String(p.GetMfaSerial())
65+
if p.MfaSerial != "" {
66+
input.SerialNumber = aws.String(p.MfaSerial)
6767
input.TokenCode, err = p.GetMfaToken()
6868
if err != nil {
6969
return nil, err

vault/mfa.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,23 @@ import (
1414

1515
// Mfa contains options for an MFA device
1616
type Mfa struct {
17-
mfaSerial string
17+
MfaSerial string
1818
mfaPromptFunc prompt.Func
1919
}
2020

2121
// GetMfaToken returns the MFA token
22-
func (m *Mfa) GetMfaToken() (*string, error) {
22+
func (m Mfa) GetMfaToken() (*string, error) {
2323
if m.mfaPromptFunc != nil {
24-
token, err := m.mfaPromptFunc(m.mfaSerial)
24+
token, err := m.mfaPromptFunc(m.MfaSerial)
2525
return aws.String(token), err
2626
}
2727

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

31-
// GetMfaSerial returns the MFA serial
32-
func (m *Mfa) GetMfaSerial() string {
33-
return m.mfaSerial
34-
}
35-
36-
func NewMfa(config *ProfileConfig) *Mfa {
31+
func NewMfa(config *ProfileConfig) Mfa {
3732
m := Mfa{
38-
mfaSerial: config.MfaSerial,
33+
MfaSerial: config.MfaSerial,
3934
}
4035
if config.MfaToken != "" {
4136
m.mfaPromptFunc = func(_ string) (string, error) { return config.MfaToken, nil }
@@ -48,7 +43,7 @@ func NewMfa(config *ProfileConfig) *Mfa {
4843
m.mfaPromptFunc = prompt.Method(config.MfaPromptMethod)
4944
}
5045

51-
return &m
46+
return m
5247
}
5348

5449
func ProcessMfaProvider(processCmd string) (string, error) {

vault/sessiontokenprovider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
type SessionTokenProvider struct {
1515
StsClient *sts.Client
1616
Duration time.Duration
17-
*Mfa
17+
Mfa
1818
}
1919

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

44-
if p.GetMfaSerial() != "" {
45-
input.SerialNumber = aws.String(p.GetMfaSerial())
44+
if p.MfaSerial != "" {
45+
input.SerialNumber = aws.String(p.MfaSerial)
4646
input.TokenCode, err = p.GetMfaToken()
4747
if err != nil {
4848
return nil, err

0 commit comments

Comments
 (0)