Refactor set

- Implement inline setters as OpenAPI extensions
- Naming cleanup substitute -> set
- Documentation cleanup
- Simplify implementation
This commit is contained in:
Phillip Wittrock
2020-01-01 22:06:18 -08:00
parent 3bef339186
commit b37abbf057
28 changed files with 934 additions and 1265 deletions

44
kyaml/setters/dokio.go Normal file
View File

@@ -0,0 +1,44 @@
// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package setters
import (
"sigs.k8s.io/kustomize/kyaml/kio"
"sigs.k8s.io/kustomize/kyaml/yaml"
)
var _ kio.Filter = &PerformSetters{}
// PerformSetters sets field values
type PerformSetters struct {
// Name is the name of the setter to perform
Name string
// Value is the value to set
Value string
// Description, if set will annotate the field with a description.
Description string
// SetBy, if set will annotate the field with who set it.
SetBy string
// Count is set by Filter and is the number of fields modified.
Count int
}
func (s *PerformSetters) Filter(input []*yaml.RNode) ([]*yaml.RNode, error) {
for i := range input {
p := &partialFieldSetter{
Name: s.Name,
Value: s.Value,
Description: s.Description,
}
if err := input[i].PipeE(p); err != nil {
return nil, err
}
s.Count += p.Count
}
return input, nil
}