Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Set default behavior to automatically normalize line endings
* text=auto

# Force bash scripts to always use LF line endings
*.sh text eol=lf

# Force batch scripts to always use CRLF line endings
*.bat text eol=crlf
*.cmd text eol=crlf
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
fnConfig: ../config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
fnConfig: ../../config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --git a/resources.yaml b/resources.yaml
index 9d1f786..f2eec52 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -1,26 +1,26 @@
-# Copyright 2021 The kpt Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: nginx-deployment
-spec:
- replicas: 3
----
-apiVersion: custom.io/v1
-kind: Custom
-metadata:
- name: custom
-spec:
- image: nginx:1.2.3
+# Copyright 2021 The kpt Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nginx-deployment
+spec:
+ replicas: 3
+---
+apiVersion: custom.io/v1
+kind: Custom
+metadata:
+ name: custom
+spec:
+ image: nginx:1.2.3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
fnConfig: ../../config.yaml
exitCode: 1
stdErr: "resource must have `metadata.name`"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

runCount: 2
testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
includeMetaResources: true
exitCode: 1
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

runCount: 2
testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
includeMetaResources: true
exitCode: 1
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

runCount: 2
testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
includeMetaResources: true
exitCode: 1
args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@

testType: eval
exitCode: 1
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
fnConfig: ../../config.yaml
stdErr: "wrong node kind: expected MappingNode but got ScalarNode: node contents:\nI am not a valid config file\n"
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@

testType: eval
exitCode: 1
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
stdErr: "failed to configure function: input namespace cannot be empty"
57 changes: 57 additions & 0 deletions e2e/testdata/fn-eval/missing-fn-config/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
diff --git a/resources.yaml b/resources.yaml
index 9d1f786..f2eec52 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -1,26 +1,26 @@
-# Copyright 2021 The kpt Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: nginx-deployment
-spec:
- replicas: 3
----
-apiVersion: custom.io/v1
-kind: Custom
-metadata:
- name: custom
-spec:
- image: nginx:1.2.3
+# Copyright 2021 The kpt Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: nginx-deployment
+spec:
+ replicas: 3
+---
+apiVersion: custom.io/v1
+kind: Custom
+metadata:
+ name: custom
+spec:
+ image: nginx:1.2.3
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
fnConfig: ../../config.yaml
exitCode: 1
stdErr: "must not contain more than one config, got 2"
169 changes: 169 additions & 0 deletions e2e/testdata/fn-eval/no-op/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
diff --git a/resources.yaml b/resources.yaml
index c0974f0..60f96f2 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -1,82 +1,82 @@
-# Copyright 2021 The kpt Authors
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: my-nginx
- namespace: my-space
- labels:
- env: dev
- foo: bar
-spec:
- # comment 1
- replicas: 3
- selector:
- # comment 2
- matchLabels: # comment 3
- # comment 4
- app: nginx # comment 5
- template:
- metadata:
- labels:
- app: nginx
- spec:
- # comment 6
- containers:
- # comment 7
- - name: nginx
- image: 'nginx:1.14.2' # comment 8
- ports:
- # comment 9
- - containerPort: 80 # comment 10
----
-apiVersion: v1
-kind: Service
-metadata:
- name: my-service
-spec:
- ports:
- # comment 1
- - name: etcd-server-ssl
- port: 2380
- # comment 2
- - name: etcd-client-ssl
- port: 2379
----
-apiVersion: constraints.gatekeeper.sh/v1beta1
-kind: EnforceFoo
-metadata:
- name: enforce-foo
-spec:
- parameters:
- naming_rules:
- - kind: Folder
- patterns:
- # comment 1
- - ^(dev|prod|staging|qa|shared)$
----
-apiVersion: v1
-kind: ConfigMap
-metadata:
- name: setters-config
-data:
- # This should be the name of your Config Controller instance
- cluster-name: cluster-name
- # This should be the project where you deployed Config Controller
- project-id: project-id
- project-number: '1234567890123'
- # You can leave these defaults
- namespace: config-control
- deployment-repo: deployment-repo
- source-repo: source-repo
+# Copyright 2021 The kpt Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: my-nginx
+ namespace: my-space
+ labels:
+ env: dev
+ foo: bar
+spec:
+ # comment 1
+ replicas: 3
+ selector:
+ # comment 2
+ matchLabels: # comment 3
+ # comment 4
+ app: nginx # comment 5
+ template:
+ metadata:
+ labels:
+ app: nginx
+ spec:
+ # comment 6
+ containers:
+ # comment 7
+ - name: nginx
+ image: 'nginx:1.14.2' # comment 8
+ ports:
+ # comment 9
+ - containerPort: 80 # comment 10
+---
+apiVersion: v1
+kind: Service
+metadata:
+ name: my-service
+spec:
+ ports:
+ # comment 1
+ - name: etcd-server-ssl
+ port: 2380
+ # comment 2
+ - name: etcd-client-ssl
+ port: 2379
+---
+apiVersion: constraints.gatekeeper.sh/v1beta1
+kind: EnforceFoo
+metadata:
+ name: enforce-foo
+spec:
+ parameters:
+ naming_rules:
+ - kind: Folder
+ patterns:
+ # comment 1
+ - ^(dev|prod|staging|qa|shared)$
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: setters-config
+data:
+ # This should be the name of your Config Controller instance
+ cluster-name: cluster-name
+ # This should be the project where you deployed Config Controller
+ project-id: project-id
+ project-number: '1234567890123'
+ # You can leave these defaults
+ namespace: config-control
+ deployment-repo: deployment-repo
+ source-repo: source-repo
4 changes: 2 additions & 2 deletions e2e/testdata/fn-eval/non-krm-resource/.expected/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
# limitations under the License.

testType: eval
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0
image: ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest
args:
namespace: staging
exitCode: 1
stdErr: |
[FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s
[FAIL] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s
error: input resource list must contain only KRM resources: nonkrm.yaml: resource must have `apiVersion`
4 changes: 2 additions & 2 deletions e2e/testdata/fn-eval/out-of-place-dir/.expected/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

stdErr: |
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:v0.2.0" in 0s
[RUNNING] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest"
[PASS] "ghcr.io/kptdev/krm-functions-catalog/set-namespace:latest" in 0s
Loading
Loading