mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
Refactor set
- Implement inline setters as OpenAPI extensions - Naming cleanup substitute -> set - Documentation cleanup - Simplify implementation
This commit is contained in:
44
kyaml/setters/dokio.go
Normal file
44
kyaml/setters/dokio.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user