Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
Signed-off-by: Pierre-Emmanuel Jacquier <15922119+pierre-emmanuelJ@users.noreply.github.com>
  • Loading branch information
pierre-emmanuelJ committed Dec 22, 2023
1 parent 7c6115a commit 4d12fb8
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions v3/credentials/file.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,42 @@
package credentials

import "fmt"

type FileOpt func(*FileProvider)

// FileOptWithFilename returns a FileOpt overriding the default filename.
func FileOptWithFilename(filename string) FileOpt {
return func(f *FileProvider) {
f.filename = filename
}
}

// FileOptWithAccount returns a FileOpt overriding the default account.
func FileOptWithAccount(account string) FileOpt {
return func(f *FileProvider) {
f.account = account
}
}

type FileProvider struct {
filename string
account string
retrieved bool
}

func NewFileCredentials() *Credentials {
return NewCredentials(&FileProvider{})
func NewFileCredentials(opts ...FileOpt) *Credentials {
fp := &FileProvider{}
for _, opt := range opts {
opt(fp)
}
return NewCredentials(fp)
}

func (f *FileProvider) Retrieve() (Value, error) {
return Value{}, nil
return Value{}, fmt.Errorf("not implemented")
}

func (f *FileProvider) IsExpired() bool {
return false
// IsExpired returns if the shared credentials have expired.
func (p *FileProvider) IsExpired() bool {

Check failure on line 40 in v3/credentials/file.go

View workflow job for this annotation

GitHub Actions / CI

receiver-naming: receiver name p should be consistent with previous receiver name f for FileProvider (revive)
return !p.retrieved
}

0 comments on commit 4d12fb8

Please # to comment.