Skip to content

Commit

Permalink
fix: perm for keploy files (keploy#1781)
Browse files Browse the repository at this point in the history
Signed-off-by: charankamarapu <[email protected]>
  • Loading branch information
charankamarapu authored Apr 4, 2024
1 parent 48ec8ba commit c5042ce
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/platform/yaml/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,16 @@ func CreateYamlFile(ctx context.Context, Logger *zap.Logger, path string, fileNa
}
if _, err := os.Stat(yamlPath); err != nil {
if ctx.Err() == nil {
err = os.MkdirAll(filepath.Join(path), fs.ModePerm)
err = os.MkdirAll(filepath.Join(path), 0777)
if err != nil {
utils.LogError(Logger, err, "failed to create a directory for the yaml file", zap.String("path directory", path), zap.String("yaml", fileName))
return false, err
}
err = os.Chmod(path, 0777)
if err != nil {
utils.LogError(Logger, err, "failed to set permissions for the directory", zap.String("path directory", path))
return false, err
}
file, err := os.OpenFile(yamlPath, os.O_CREATE, 0777) // Set file permissions to 777
if err != nil {
utils.LogError(Logger, err, "failed to create a yaml file", zap.String("path directory", path), zap.String("yaml", fileName))
Expand All @@ -151,6 +156,11 @@ func CreateYamlFile(ctx context.Context, Logger *zap.Logger, path string, fileNa
utils.LogError(Logger, err, "failed to close the yaml file", zap.String("path directory", path), zap.String("yaml", fileName))
return false, err
}
err = os.Chmod(yamlPath, 0777)
if err != nil {
utils.LogError(Logger, err, "failed to set permissions for the directory", zap.String("path directory", path))
return false, err
}
return true, nil
}
return false, err
Expand Down

0 comments on commit c5042ce

Please sign in to comment.