Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Check for errors when trying to create the auth token file (kubernete…
Browse files Browse the repository at this point in the history
…s-retired#447)

* Check for errors when trying to create the auth token file
* Close the file right away, instead of closing with `defer`

The file is not being used after it's created/opened, so there's no
reason to defer the closing.
  • Loading branch information
danielfm authored and mumoshu committed Mar 24, 2017
1 parent 737f551 commit 9698561
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion core/controlplane/config/token_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ func ReadOrEncryptAuthTokens(dirname string, encryptor CachedEncryptor) (*Encryp

// Auto-creates the auth token file, useful for those coming from previous versions of kube-aws
if _, err := os.Stat(authTokenPath); os.IsNotExist(err) {
os.OpenFile(authTokenPath, os.O_RDONLY|os.O_CREATE, 0600)
file, err := os.OpenFile(authTokenPath, os.O_RDONLY|os.O_CREATE, 0600)
if err != nil {
return nil, err
}
file.Close()
}

if _, err := ReadRawAuthTokens(dirname); err != nil {
Expand Down

0 comments on commit 9698561

Please sign in to comment.