Skip to content

Commit 62b011a

Browse files
authored
kustomizations: update replacements fields (SchemaStore#5057)
1 parent de8ae80 commit 62b011a

File tree

2 files changed

+165
-155
lines changed

2 files changed

+165
-155
lines changed

src/schemas/json/kustomization.json

Lines changed: 146 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -656,33 +656,6 @@
656656
"additionalProperties": false,
657657
"type": "object"
658658
},
659-
"PatchTargetOptional": {
660-
"properties": {
661-
"group": {
662-
"type": "string"
663-
},
664-
"kind": {
665-
"type": "string"
666-
},
667-
"name": {
668-
"type": "string"
669-
},
670-
"namespace": {
671-
"type": "string"
672-
},
673-
"version": {
674-
"type": "string"
675-
},
676-
"labelSelector": {
677-
"type": "string"
678-
},
679-
"annotationSelector": {
680-
"type": "string"
681-
}
682-
},
683-
"additionalProperties": false,
684-
"type": "object"
685-
},
686659
"PatchesOptions": {
687660
"properties": {
688661
"allowNameChange": {
@@ -705,7 +678,7 @@
705678
"type": "string"
706679
},
707680
"target": {
708-
"$ref": "#/definitions/PatchTargetOptional",
681+
"$ref": "#/definitions/Selector",
709682
"description": "Refers to a Kubernetes object that the patch will be applied to. It must refer to a Kubernetes resource under the purview of this kustomization"
710683
}
711684
},
@@ -721,150 +694,50 @@
721694
"type": "string"
722695
},
723696
"target": {
724-
"$ref": "#/definitions/PatchTargetOptional",
697+
"$ref": "#/definitions/Selector",
725698
"description": "Refers to a Kubernetes object that the patch will be applied to. It must refer to a Kubernetes resource under the purview of this kustomization"
726699
}
727700
},
728701
"additionalProperties": false
729702
},
730703
"ReplacementsInline": {
731-
"required": ["source", "targets"],
732-
"type": "object",
733-
"additionalProperties": false,
734-
"properties": {
735-
"source": {
704+
"oneOf": [
705+
{
736706
"type": "object",
737-
"description": "The source of the value",
707+
"additionalProperties": false,
708+
"required": ["source", "targets"],
738709
"properties": {
739-
"group": {
740-
"type": "string",
741-
"description": "The group of the referent"
742-
},
743-
"version": {
744-
"type": "string",
745-
"description": "The version of the referent"
746-
},
747-
"kind": {
748-
"type": "string",
749-
"description": "The kind of the referent"
750-
},
751-
"name": {
752-
"type": "string",
753-
"description": "The name of the referent"
710+
"source": {
711+
"$ref": "#/definitions/ReplacementsSource"
754712
},
755-
"namespace": {
756-
"type": "string",
757-
"description": "The namespace of the referent"
758-
},
759-
"fieldPath": {
760-
"type": "string",
761-
"description": "The structured path to the source value"
762-
},
763-
"options": {
764-
"type": "object",
765-
"properties": {
766-
"delimiter": {
767-
"type": "string"
768-
},
769-
"index": {
770-
"type": "number"
771-
},
772-
"create": {
773-
"type": "boolean"
774-
}
713+
"targets": {
714+
"description": "The N fields to write the value to",
715+
"type": "array",
716+
"items": {
717+
"$ref": "#/definitions/ReplacementsTarget"
775718
}
776719
}
777720
}
778721
},
779-
"targets": {
780-
"description": "The N fields to write the value to",
781-
"type": "array",
782-
"items": {
783-
"required": ["select"],
784-
"type": "object",
785-
"properties": {
786-
"select": {
787-
"type": "object",
788-
"description": "Include objects that match this",
789-
"properties": {
790-
"group": {
791-
"type": "string",
792-
"description": "The group of the referent"
793-
},
794-
"version": {
795-
"type": "string",
796-
"description": "The version of the referent"
797-
},
798-
"kind": {
799-
"type": "string",
800-
"description": "The kind of the referent"
801-
},
802-
"name": {
803-
"type": "string",
804-
"description": "The name of the referent"
805-
},
806-
"namespace": {
807-
"type": "string",
808-
"description": "The namespace of the referent"
809-
}
810-
}
811-
},
812-
"reject": {
813-
"type": "array",
814-
"description": "Exclude objects that match this",
815-
"items": {
816-
"type": "object",
817-
"description": "Exclude objects that match this",
818-
"properties": {
819-
"group": {
820-
"type": "string",
821-
"description": "The group of the referent"
822-
},
823-
"version": {
824-
"type": "string",
825-
"description": "The version of the referent"
826-
},
827-
"kind": {
828-
"type": "string",
829-
"description": "The kind of the referent"
830-
},
831-
"name": {
832-
"type": "string",
833-
"description": "The name of the referent"
834-
},
835-
"namespace": {
836-
"type": "string",
837-
"description": "The namespace of the referent"
838-
}
839-
}
840-
}
841-
},
842-
"fieldPaths": {
843-
"type": "array",
844-
"description": "The structured path(s) to the target nodes",
845-
"items": {
846-
"type": "string",
847-
"description": "The structured path to the source value"
848-
}
849-
},
850-
"options": {
851-
"type": "object",
852-
"properties": {
853-
"delimiter": {
854-
"type": "string"
855-
},
856-
"index": {
857-
"type": "number"
858-
},
859-
"create": {
860-
"type": "boolean"
861-
}
862-
}
722+
{
723+
"type": "object",
724+
"additionalProperties": false,
725+
"required": ["sourceValue", "targets"],
726+
"properties": {
727+
"sourceValue": {
728+
"description": "A scalar value as source",
729+
"type": "string"
730+
},
731+
"targets": {
732+
"description": "The N fields to write the value to",
733+
"type": "array",
734+
"items": {
735+
"$ref": "#/definitions/ReplacementsTarget"
863736
}
864737
}
865738
}
866739
}
867-
}
740+
]
868741
},
869742
"ReplacementsPath": {
870743
"required": ["path"],
@@ -876,6 +749,89 @@
876749
}
877750
}
878751
},
752+
"ReplacementsSource": {
753+
"type": "object",
754+
"description": "The source of the value",
755+
"properties": {
756+
"group": {
757+
"type": "string",
758+
"description": "The group of the referent"
759+
},
760+
"version": {
761+
"type": "string",
762+
"description": "The version of the referent"
763+
},
764+
"kind": {
765+
"type": "string",
766+
"description": "The kind of the referent"
767+
},
768+
"name": {
769+
"type": "string",
770+
"description": "The name of the referent"
771+
},
772+
"namespace": {
773+
"type": "string",
774+
"description": "The namespace of the referent"
775+
},
776+
"fieldPath": {
777+
"type": "string",
778+
"description": "The structured path to the source value"
779+
},
780+
"options": {
781+
"type": "object",
782+
"properties": {
783+
"delimiter": {
784+
"type": "string"
785+
},
786+
"index": {
787+
"type": "number"
788+
},
789+
"create": {
790+
"type": "boolean"
791+
}
792+
}
793+
}
794+
}
795+
},
796+
"ReplacementsTarget": {
797+
"required": ["select"],
798+
"type": "object",
799+
"properties": {
800+
"select": {
801+
"$ref": "#/definitions/Selector",
802+
"description": "Include objects that match this"
803+
},
804+
"reject": {
805+
"type": "array",
806+
"description": "Exclude objects that match this",
807+
"items": {
808+
"$ref": "#/definitions/Selector"
809+
}
810+
},
811+
"fieldPaths": {
812+
"type": "array",
813+
"description": "The structured path(s) to the target nodes",
814+
"items": {
815+
"type": "string",
816+
"description": "The structured path to the source value"
817+
}
818+
},
819+
"options": {
820+
"type": "object",
821+
"properties": {
822+
"delimiter": {
823+
"type": "string"
824+
},
825+
"index": {
826+
"type": "number"
827+
},
828+
"create": {
829+
"type": "boolean"
830+
}
831+
}
832+
}
833+
}
834+
},
879835
"Replicas": {
880836
"properties": {
881837
"name": {
@@ -940,6 +896,41 @@
940896
"additionalProperties": false,
941897
"type": "object"
942898
},
899+
"Selector": {
900+
"description": "Selector specifies a set of resources.\nAny resource that matches intersection of all conditions is included in this set.",
901+
"properties": {
902+
"group": {
903+
"description": "The group of the referent",
904+
"type": "string"
905+
},
906+
"kind": {
907+
"description": "The kind of the referent",
908+
"type": "string"
909+
},
910+
"name": {
911+
"description": "The name of the referent",
912+
"type": "string"
913+
},
914+
"namespace": {
915+
"description": "The namespace of the referent",
916+
"type": "string"
917+
},
918+
"version": {
919+
"description": "The version of the referent",
920+
"type": "string"
921+
},
922+
"annotationSelector": {
923+
"description": "AnnotationSelector is a string that follows the label selection expression\nhttps://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api",
924+
"type": "string"
925+
},
926+
"labelSelector": {
927+
"description": "LabelSelector is a string that follows the label selection expression\nhttps://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#api",
928+
"type": "string"
929+
}
930+
},
931+
"additionalProperties": false,
932+
"type": "object"
933+
},
943934
"Target": {
944935
"required": ["name"],
945936
"properties": {

src/test/kustomization/replacements.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,29 @@
1717
],
1818
"reject": [
1919
{
20+
"annotationSelector": "config.kubernetes.io/local-config=true",
2021
"kind": "Job",
2122
"name": "bye"
2223
}
2324
],
25+
"select": {
26+
"kind": "Job",
27+
"labelSelector": "environment=production,tier in (frontend, backend)",
28+
"name": "hello"
29+
}
30+
}
31+
]
32+
},
33+
{
34+
"sourceValue": "my-secret-token-value",
35+
"targets": [
36+
{
37+
"fieldPaths": [
38+
"spec.template.spec.containers.[name=hello].env.[name=SECRET_TOKEN].value"
39+
],
40+
"options": {
41+
"create": true
42+
},
2443
"select": {
2544
"kind": "Job",
2645
"name": "hello"

0 commit comments

Comments
 (0)