Skip to content

Commit 2a9f413

Browse files
Implement function target selectors, set infrastructure and handle pruning (#2447)
* Implement function selectors with basicpipeline test * Copy generator test * generator test: only select generated resource * Unit tests for merging resources * fix lint errors * Unit tests for isMatch method * Validator test * Select by PackagePath * Add comment to annotation, optimize presentIn calls * Address suggested changes * Imperative filtering * Out of place fn chain test * Update flag descriptions * Optimize calls * Suggested changes
1 parent 31c20e6 commit 2a9f413

File tree

36 files changed

+1142
-23
lines changed

36 files changed

+1142
-23
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 7a494c9..9d82bd6 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -15,6 +15,7 @@ apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: nginx-deployment
9+
+ namespace: staging
10+
spec:
11+
replicas: 3
12+
---
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#! /bin/bash
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -eo pipefail
17+
18+
kpt fn eval -i set-namespace:v0.1.3 --name nginx-deployment --kind Deployment -- namespace=staging
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.expected
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
apiVersion: apps/v1
15+
kind: Deployment
16+
metadata:
17+
name: nginx-deployment
18+
spec:
19+
replicas: 3
20+
---
21+
apiVersion: custom.io/v1
22+
kind: Custom
23+
metadata:
24+
name: custom
25+
spec:
26+
image: nginx:1.2.3
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Copyright 2021 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
stdErr: |
16+
[RUNNING] "gcr.io/kpt-fn/set-namespace:v0.1.3"
17+
[PASS] "gcr.io/kpt-fn/set-namespace:v0.1.3" in 0s
18+
[RUNNING] "gcr.io/kpt-fn/set-annotations:v0.1.3"
19+
[PASS] "gcr.io/kpt-fn/set-annotations:v0.1.3" in 0s
20+
[RUNNING] "gcr.io/kpt-fn/set-labels:v0.1.3"
21+
[PASS] "gcr.io/kpt-fn/set-labels:v0.1.3" in 0s
22+
stdOut: |
23+
apiVersion: apps/v1
24+
kind: Deployment
25+
metadata:
26+
name: nginx-deployment
27+
namespace: staging
28+
labels:
29+
tier: backend
30+
spec:
31+
replicas: 3
32+
selector:
33+
matchLabels:
34+
tier: backend
35+
template:
36+
metadata:
37+
labels:
38+
tier: backend
39+
---
40+
apiVersion: custom.io/v1
41+
kind: Custom
42+
metadata:
43+
name: custom
44+
annotations:
45+
foo: bar
46+
labels:
47+
tier: backend
48+
spec:
49+
image: nginx:1.2.3
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#! /bin/bash
2+
# Copyright 2021 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
17+
set -eo pipefail
18+
19+
kpt fn source \
20+
| kpt fn eval - --image gcr.io/kpt-fn/set-namespace:v0.1.3 --kind Deployment -o stdout -- namespace=staging \
21+
| kpt fn eval - --image gcr.io/kpt-fn/set-annotations:v0.1.3 --name custom -- foo=bar \
22+
| kpt fn eval - --image gcr.io/kpt-fn/set-labels:v0.1.3 -o unwrap -- tier=backend
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.expected
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: nginx-deployment
5+
spec:
6+
replicas: 3
7+
---
8+
apiVersion: custom.io/v1
9+
kind: Custom
10+
metadata:
11+
name: custom
12+
spec:
13+
image: nginx:1.2.3
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
diff --git a/resources.yaml b/resources.yaml
2+
index 7a494c9..1d36135 100644
3+
--- a/resources.yaml
4+
+++ b/resources.yaml
5+
@@ -15,12 +15,24 @@ apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: nginx-deployment
9+
+ namespace: staging
10+
+ labels:
11+
+ tier: backend
12+
spec:
13+
replicas: 3
14+
+ selector:
15+
+ matchLabels:
16+
+ tier: backend
17+
+ template:
18+
+ metadata:
19+
+ labels:
20+
+ tier: backend
21+
---
22+
apiVersion: custom.io/v1
23+
kind: Custom
24+
metadata:
25+
name: custom
26+
+ labels:
27+
+ tier: backend
28+
spec:
29+
image: nginx:1.2.3
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.expected

0 commit comments

Comments
 (0)