in file.go [210:242]
func (f *File) Update(ctx context.Context, scope Scope) error {
provider := f.provider(scope)
path := filepath.Join(provider.Prefix, f.Path)
if f.Absent {
return os.Remove(path)
}
if f.Force {
info, err := os.Stat(path)
if err == nil && info != nil && f.Directory != info.IsDir() {
err := os.RemoveAll(path)
if err != nil {
return err
}
}
return f.Create(ctx, scope)
}
if !f.KeepExistingContent {
err := f.writeContent(ctx, scope)
if err != nil {
return err
}
}
err := f.ensureMode(scope)
if err != nil {
return err
}
return nil
}