-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.Denotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.
Description
What is missing
We want to skip missing files during scaffolding without failing.
Right now, if a file doesn’t exist (like a test file), Scaffold.Execute()
fails. But some files (like test/e2e/webhook_test.go
) are optional, and we want to ignore them safely.
What do we need
We need something like
type IfNotExistsAction int
const (
IgnoreFile IfNotExistsAction = iota
)
type File struct {
Path string
Contents string
IfExistsAction IfExistsAction
IfNotExistsAction IfNotExistsAction
}
type Inserter interface {
...
GetIfNotExistsAction() IfNotExistsAction
}
type IfNotExistsActionMixin struct {
IfNotExistsAction IfNotExistsAction
}
func (m IfNotExistsActionMixin) GetIfNotExistsAction() IfNotExistsAction {
return m.IfNotExistsAction
}
AND
m, err := s.loadPreviousModel(i, models)
if err != nil {
if i.GetIfNotExistsAction() == IgnoreFile && os.IsNotExist(err) {
log.Infof("Skipping missing file: %s", i.GetPath())
return nil
}
return fmt.Errorf("failed to load previous model for %s: %w", i.GetPath(), err)
}
So we can configure specific templates like:
type WebhookTestUpdater struct {
machinery.MarkerUpdaterMixin
machinery.IfNotExistsActionMixin
}
Such as we have:
if f.Force {
f.IfExistsAction = machinery.OverwriteFile
}
By default should fail unless we configure / write to IfNotExistAction ignore files
Metadata
Metadata
Assignees
Labels
good first issueDenotes an issue ready for a new contributor, according to the "help wanted" guidelines.Denotes an issue ready for a new contributor, according to the "help wanted" guidelines.help wantedDenotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.kind/featureCategorizes issue or PR as related to a new feature.Categorizes issue or PR as related to a new feature.