Skip to content

Commit

Permalink
Create config with user only permission & fix bug in key.go
Browse files Browse the repository at this point in the history
Signed-off-by: Pritesh Bandi <pritesb@amazon.com>
  • Loading branch information
Pritesh Bandi committed Feb 8, 2023
1 parent 5e5cba1 commit e1d18fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion config/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ func save(filePath string, cfg interface{}) error {
if err := os.MkdirAll(dir, 0700); err != nil {
return err
}
file, err := os.Create(filePath)

file, err := os.OpenFile(filePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600)
if err != nil {
return err
}
defer file.Close()

encoder := json.NewEncoder(file)
encoder.SetIndent("", " ")
return encoder.Encode(cfg)
Expand Down
2 changes: 1 addition & 1 deletion config/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func (s *SigningKeys) Remove(keyName ...string) ([]string, error) {
}
s.Keys = slices.Delete(s.Keys, idx)
deletedNames = append(deletedNames, name)
if *s.Default == name {
if s.Default !=nil && *s.Default == name {
s.Default = nil
}
}
Expand Down

0 comments on commit e1d18fa

Please sign in to comment.