Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: set-namespace without kyaml/rnode dependencies #769

Merged
merged 3 commits into from
Mar 23, 2022
Merged
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
38 changes: 0 additions & 38 deletions examples/set-namespace-advanced/.expected/diff.patch

This file was deleted.

1 change: 0 additions & 1 deletion examples/set-namespace-advanced/.krmignore

This file was deleted.

8 changes: 0 additions & 8 deletions examples/set-namespace-advanced/Kptfile

This file was deleted.

70 changes: 0 additions & 70 deletions examples/set-namespace-advanced/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions examples/set-namespace-advanced/fn-config.yaml

This file was deleted.

34 changes: 0 additions & 34 deletions examples/set-namespace-advanced/resources.yaml

This file was deleted.

16 changes: 4 additions & 12 deletions examples/set-namespace-imperative/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
diff --git a/app.yaml b/app.yaml
index 53c70b1..15a02f9 100644
index 1f8aeee..33e42da 100644
--- a/app.yaml
+++ b/app.yaml
@@ -2,6 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
+ namespace: example-ns
data:
some-key: some-value
---
@@ -9,7 +10,7 @@ apiVersion: v1
@@ -9,7 +9,7 @@ apiVersion: v1
kind: Service
metadata:
name: the-service
Expand All @@ -19,9 +11,9 @@ index 53c70b1..15a02f9 100644
spec:
ports:
- name: etcd-server-ssl
@@ -21,4 +22,4 @@ spec:
@@ -21,4 +21,4 @@ spec:
apiVersion: v1
kind: Namespace
metadata:
- name: old-name
- name: example
+ name: example-ns
2 changes: 1 addition & 1 deletion examples/set-namespace-imperative/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ spec:
apiVersion: v1
kind: Namespace
metadata:
name: old-name
name: example
48 changes: 32 additions & 16 deletions examples/set-namespace-simple/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
diff --git a/resources.yaml b/resources.yaml
index 468897a..8d5a446 100644
index 85885ac..f93e6a4 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -2,6 +2,7 @@ apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
+ namespace: example-ns
data:
some-key: some-value
---
@@ -9,7 +10,7 @@ apiVersion: v1
@@ -2,12 +2,12 @@ apiVersion: v1
kind: Service
metadata:
name: the-service
- namespace: the-namespace
- namespace: example
+ namespace: example-ns
spec:
ports:
- name: etcd-server-ssl
@@ -22,4 +23,4 @@ spec:
---
apiVersion: v1
kind: Namespace
metadata:
- name: old-name
- name: example
+ name: example-ns
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
@@ -20,7 +20,7 @@ spec:
clientConfig:
service:
name: crd-svc
- namespace: example
+ namespace: example-ns
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
@@ -29,7 +29,7 @@ metadata:
spec:
service:
name: api-svc
- namespace: example
+ namespace: example-ns
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
@@ -38,4 +38,4 @@ metadata:
subjects:
- kind: ServiceAccount
name: default
- namespace: example
+ namespace: example-ns
7 changes: 3 additions & 4 deletions examples/set-namespace-simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

### Overview

This example demonstrates how to declaratively run [`set-namespace`] function
to adds or replaces the `.metadata.namespace` field on all resources except for
those known to be cluster-scoped.
This example demonstrates how to run [`set-namespace`] function
to replace the `namespace` resource type in a variety of KRM resources.

### Fetch the example package

Expand Down Expand Up @@ -42,6 +41,6 @@ $ kpt fn render set-namespace-simple

### Expected result

Check all resources have `metadata.namespace` set to `example-ns`:
Check all resources have `metadata.namespace` set to `example-ns`

[`set-namespace`]: https://catalog.kpt.dev/set-namespace/v0.1/
yuwenma marked this conversation as resolved.
Show resolved Hide resolved
50 changes: 33 additions & 17 deletions examples/set-namespace-simple/resources.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,41 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
data:
some-key: some-value
---
apiVersion: v1
kind: Service
metadata:
name: the-service
namespace: the-namespace
spec:
ports:
- name: etcd-server-ssl
port: 2380
- name: etcd-client-ssl
port: 2379
clusterIP: None
publishNotReadyAddresses: true
namespace: example
---
apiVersion: v1
kind: Namespace
metadata:
name: old-name
name: example
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: the-crd
spec:
conversion:
strategy: Webhook
webhook:
clientConfig:
service:
name: crd-svc
namespace: example
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: the-api-service
spec:
service:
name: api-svc
namespace: example
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: crb1
subjects:
- kind: ServiceAccount
name: default
namespace: example
Loading