Skip to content

Commit

Permalink
fix: don't inject new name provisioners file if old name exists
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Meier <[email protected]>
  • Loading branch information
astromechza committed Jul 8, 2024
1 parent 9eac993 commit fbaa228
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/command/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ acts as a namespace when multiple score files and containers are used.

// create and write the default provisioners file if it doesn't already exist
dst := "zz-default" + loader.DefaultSuffix
if f, err := os.OpenFile(filepath.Join(sd.Path, dst), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644); err != nil {
if f, err := os.Stat(filepath.Join(sd.Path, "99-default"+loader.DefaultSuffix)); err == nil {
slog.Info(fmt.Sprintf("Default provisioners yaml file '%s' already exists, not overwriting it", f.Name()))
} else if f, err := os.OpenFile(filepath.Join(sd.Path, dst), os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0644); err != nil {
if !errors.Is(err, os.ErrExist) {
return fmt.Errorf("failed to open default provisioners for writing: %w", err)
}
Expand Down

0 comments on commit fbaa228

Please sign in to comment.