mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-25 17:34:17 +00:00
@@ -21,7 +21,7 @@ const (
|
||||
ResourceModifierSupportedVersionV1 = "v1"
|
||||
)
|
||||
|
||||
type JsonPatch struct {
|
||||
type JSONPatch struct {
|
||||
Operation string `yaml:"operation"`
|
||||
Path string `yaml:"path"`
|
||||
Value string `yaml:"value,omitempty"`
|
||||
@@ -35,7 +35,7 @@ type Conditions struct {
|
||||
|
||||
type ResourceModifierRule struct {
|
||||
Conditions Conditions `yaml:"conditions"`
|
||||
Patches []JsonPatch `yaml:"patches"`
|
||||
Patches []JSONPatch `yaml:"patches"`
|
||||
}
|
||||
|
||||
type ResourceModifiers struct {
|
||||
@@ -111,7 +111,7 @@ func (r *ResourceModifierRule) PatchArrayToByteArray() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf(`[%s]`, patchesStr)), nil
|
||||
}
|
||||
|
||||
func (p *JsonPatch) ToString() string {
|
||||
func (p *JSONPatch) ToString() string {
|
||||
return fmt.Sprintf(`{"op": "%s", "path": "%s", "value": "%s"}`, p.Operation, p.Path, p.Value)
|
||||
}
|
||||
|
||||
@@ -122,7 +122,7 @@ func ApplyPatch(patch []byte, obj *unstructured.Unstructured, log logrus.FieldLo
|
||||
}
|
||||
objBytes, err := obj.MarshalJSON()
|
||||
if err != nil {
|
||||
return fmt.Errorf("error in marshalling object %s", err.Error())
|
||||
return fmt.Errorf("error in marshaling object %s", err.Error())
|
||||
}
|
||||
modifiedObjBytes, err := jsonPatch.Apply(objBytes)
|
||||
if err != nil {
|
||||
|
||||
@@ -40,7 +40,7 @@ func TestGetResourceModifiersFromConfig(t *testing.T) {
|
||||
ResourceNameRegex: ".*",
|
||||
Namespaces: []string{"bar", "foo"},
|
||||
},
|
||||
Patches: []JsonPatch{
|
||||
Patches: []JSONPatch{
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/spec/storageClassName",
|
||||
@@ -114,7 +114,7 @@ func TestResourceModifiers_ApplyResourceModifierRules(t *testing.T) {
|
||||
ResourceNameRegex: ".*",
|
||||
Namespaces: []string{"foo"},
|
||||
},
|
||||
Patches: []JsonPatch{
|
||||
Patches: []JSONPatch{
|
||||
{
|
||||
Operation: "test",
|
||||
Path: "/spec/storageClassName",
|
||||
|
||||
@@ -36,7 +36,7 @@ func (p *ResourceModifiers) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *JsonPatch) Validate() error {
|
||||
func (p *JSONPatch) Validate() error {
|
||||
// TODO validate allowed operation
|
||||
if p.Operation == "" {
|
||||
return fmt.Errorf("operation cannot be empty")
|
||||
|
||||
@@ -25,7 +25,7 @@ func TestResourceModifiers_Validate(t *testing.T) {
|
||||
ResourceNameRegex: ".*",
|
||||
Namespaces: []string{"bar", "foo"},
|
||||
},
|
||||
Patches: []JsonPatch{
|
||||
Patches: []JSONPatch{
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/spec/storageClassName",
|
||||
@@ -48,7 +48,7 @@ func TestResourceModifiers_Validate(t *testing.T) {
|
||||
ResourceNameRegex: ".*",
|
||||
Namespaces: []string{"bar", "foo"},
|
||||
},
|
||||
Patches: []JsonPatch{
|
||||
Patches: []JSONPatch{
|
||||
{
|
||||
Operation: "replace",
|
||||
Path: "/spec/storageClassName",
|
||||
@@ -124,7 +124,7 @@ func TestJsonPatch_Validate(t *testing.T) {
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
p := &JsonPatch{
|
||||
p := &JSONPatch{
|
||||
Operation: tt.fields.Operation,
|
||||
Path: tt.fields.Path,
|
||||
Value: tt.fields.Value,
|
||||
|
||||
Reference in New Issue
Block a user