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

Update example packages to use new kpt #275

Merged
merged 10 commits into from
May 27, 2021
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: 11 additions & 27 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,50 +67,34 @@ jobs:
cd functions/go
make check-licenses
verify-ci:
runs-on: ubuntu-latest
env:
GOPATH: /home/runner/work/kpt-functions-catalog/functions/go
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up python 3
uses: actions/setup-python@v2
- name: Install libs
run: |
pip install pyyaml
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Install mdrip
run: |
go get github.com/russross/blackfriday/[email protected]
go get github.com/monopole/[email protected]
- name: Verify docs
run: |
make verify-docs
e2e-ci:
needs: [ts-unit-test-ci, go-unit-test-ci, verify-ci]
needs: [ts-unit-test-ci, go-unit-test-ci]
strategy:
matrix:
platform: [ubuntu-latest]
node-version: [12.x]
runs-on: ${{ matrix.platform }}
env:
GOPATH: /home/runner/work/kpt-functions-catalog/functions/go
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Install kpt
run: |
go get github.com/GoogleContainerTools/kpt@next
- name: Build node and Go docker images
if: matrix.platform == 'ubuntu-latest'
run: |
make build
- name: Run all tests
if: matrix.platform == 'ubuntu-latest'
run: |
sudo curl https://storage.googleapis.com/kpt-dev/latest/linux_amd64/kpt -o /usr/local/bin/kpt
sudo chmod +x /usr/local/bin/kpt
make e2e-test
32 changes: 32 additions & 0 deletions .github/workflows/verify-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: verify-docs

on:
pull_request:
branches:
- master
- '*/v[0-9]+.[0-9]+'

jobs:
verify-ci:
runs-on: ubuntu-latest
env:
GOPATH: /home/runner/work/kpt-functions-catalog/functions/go
GO111MODULE: on
steps:
- uses: actions/checkout@v2
- name: Set up python 3
uses: actions/setup-python@v2
- name: Install libs
run: |
pip install pyyaml
- name: Set up Go 1.15
uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Install mdrip
run: |
go get github.com/russross/blackfriday/[email protected]
go get github.com/monopole/[email protected]
- name: Verify docs
run: |
make verify-docs
1 change: 0 additions & 1 deletion examples/apply-setters/simple/.expected/config.yaml

This file was deleted.

8 changes: 4 additions & 4 deletions examples/apply-setters/simple/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/resources.yaml b/resources.yaml
index c0c871e..cd75f56 100644
index c79db4d..6dc582c 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -1,7 +1,7 @@
Expand All @@ -15,6 +15,6 @@ index c0c871e..cd75f56 100644
metadata:
name: ns
environments: # kpt-set: ${env}
-- dev
+- prod
- stage
- - dev
+ - prod
- stage
12 changes: 12 additions & 0 deletions examples/apply-setters/simple/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: example
pipeline:
mutators:
- image: gcr.io/kpt-fn/apply-setters:unstable
configMap:
env: |
- prod
- stage
name: my-new-map
15 changes: 6 additions & 9 deletions examples/apply-setters/simple/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# apply-setters: Simple Example

### Overview

Setters provide a solution for template-free setting of field values. The
`apply-setters` KRM config function applies setter values to resource fields
with setter references.
Expand All @@ -23,7 +25,7 @@ environments: # kpt-set: ${env}
- stage
```

We use ConfigMap to configure the `apply-setters` function. The desired
We use `ConfigMap` to configure the `apply-setters` function. The desired
setter values are provided as key-value pairs using `data` field where key is
the name of the setter(as seen in the reference comments) and value is the new
desired value for the tagged field.
Expand Down Expand Up @@ -63,21 +65,16 @@ environments: # kpt-set: ${env}

Get the config example and try it out by running the following commands:

<!-- @getAndRunPkg @test -->
```sh
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/apply-setters/simple .
kpt fn run simple
```shell
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/apply-setters/simple .
$ kpt fn render simple
```

### Expected result

Check the value of setter `name` is set to `my-new-map`.
Check the value of setter `env` is set to array value `[prod, stage]`.

```sh
$ kpt cfg cat simple/
```

#### Note:

Refer to the `create-setters` example in `search-replace` function examples for creating setters.
14 changes: 0 additions & 14 deletions examples/apply-setters/simple/fn-config.yaml

This file was deleted.

4 changes: 2 additions & 2 deletions examples/apply-setters/simple/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ kind: MyKind
metadata:
name: ns
environments: # kpt-set: ${env}
- dev
- stage
- dev
- stage
1 change: 0 additions & 1 deletion examples/contrib/analyze-istio/.expected/config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
exitCode: 1
runCount: 2
37 changes: 19 additions & 18 deletions examples/contrib/analyze-istio/.expected/results.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
- message: 'Istioctl analyze command results in error: function toString() { [native
code] }'
severity: error
file:
path: ''
- message: 'Schema validation error: gateway must have at least one server'
severity: error
tags:
documentation_url: 'https://istio.io/docs/reference/config/analysis/IST0106?ref=istioctl-analyze'
origin: Gateway httpbin-gateway.default
code: IST0106
resourceRef:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
namespace: ''
name: httpbin-gateway
file:
path: istio-config.yaml
apiVersion: kpt.dev/v1alpha2
kind: FunctionResultList
metadata:
name: fnresults
exitCode: 1
items:
- image: gcr.io/kpt-fn-contrib/analyze-istio:unstable
exitCode: 1
results:
- message: 'Istioctl analyze command results in error: function toString() { [native code] }'
severity: error
- message: 'Schema validation error: gateway must have at least one server'
severity: error
resourceRef:
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
name: httpbin-gateway
file:
path: istio-config.yaml
9 changes: 9 additions & 0 deletions examples/contrib/analyze-istio/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn-contrib/analyze-istio:unstable
configMap:
'--use-kube': 'false'
4 changes: 2 additions & 2 deletions examples/contrib/analyze-istio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declarative configuration.

Get this example and try it out by running the following commands:

```sh
```shell
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/analyze-istio .
kpt fn run analyze-istio
```
Expand All @@ -18,7 +18,7 @@ kpt fn run analyze-istio

This should give the following output:

```sh
```shell
[ERROR] Schema validation error: gateway must have at least one server in object 'networking.istio.io/v1alpha3/Gateway//httpbin-gateway' in file example-config.yaml
error: exit status 1
```
Expand Down
11 changes: 0 additions & 11 deletions examples/contrib/analyze-istio/fn-config.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions examples/contrib/inflate-helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ declarative configuration.

Get this example and try it out by running the following commands:

```sh
```shell
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/inflate-helm-chart .
kpt fn run --as-current-user inflate-helm-chart/local-configs --mount type=bind,src=$(pwd)/inflate-helm-chart/helloworld-chart,dst=/source
```
Expand All @@ -17,7 +17,7 @@ kpt fn run --as-current-user inflate-helm-chart/local-configs --mount type=bind,

Checking the contents of the `local-configs` directory with `kpt cfg tree inflate-helm-chart/local-configs/` should reveal the following new yaml files:

```sh
```shell
inflate-helm-chart/local-configs
├── [deployment_chart-helloworld-chart.yaml] Deployment chart-helloworld-chart
├── [fn-config.yaml] ConfigMap my-func-config
Expand All @@ -28,7 +28,7 @@ inflate-helm-chart/local-configs

To view changes without writing them into a file, a dry run can be performed as follows:

```sh
```shell
kpt fn run --as-current-user inflate-helm-chart/local-configs --mount type=bind,src=$(pwd)/inflate-helm-chart/helloworld-chart,dst=/source --dry-run
```

Expand Down
4 changes: 2 additions & 2 deletions examples/contrib/sops/age/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This example demonstrates invocation of `sops` for encryption the resouce called

Get this example and try it out by running the following commands:

```sh
```shell
# download this example
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/sops/age .

Expand All @@ -25,7 +25,7 @@ SOPS_IMPORT_AGE="$(cat age_keys.txt)" kpt fn run age

Verify the updated configuration:

```sh
```shell
kpt cfg cat age
```

Expand Down
4 changes: 2 additions & 2 deletions examples/contrib/sops/gpg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This example demonstrates invocation of `sops` for encryption the resouce called

Get this example and try it out by running the following commands:

```sh
```shell
# download this example
kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/examples/contrib/sops/gpg .

Expand All @@ -25,7 +25,7 @@ SOPS_IMPORT_PGP="$(cat gpg_keys.asc)" kpt fn run gpg

Verify the updated configuration:

```sh
```shell
kpt cfg cat gpg
```

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
exitCode: 1
runCount: 2
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
apiVersion: kpt.dev/v1alpha2
kind: FunctionResultList
metadata:
name: fnresults
exitCode: 1
items:
- message: |-
The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
severity: error
resourceRef:
apiVersion: v1
kind: ConfigMap
metadata:
name: super-secret
namespace: default
file:
path: resources.yaml
index: 2
- image: gcr.io/kpt-fn/enforce-gatekeeper:unstable
stderr: |-
The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
exitCode: 1
results:
- message: |-
The following banned keys are being used in the ConfigMap: {"private_key"}
violatedConstraint: no-secrets-in-configmap
severity: error
resourceRef:
apiVersion: v1
kind: ConfigMap
name: super-secret
namespace: default
file:
path: resources.yaml
index: 2
7 changes: 7 additions & 0 deletions examples/enforce-gatekeeper/invalid-configmap/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: kpt.dev/v1alpha2
kind: Kptfile
metadata:
name: example
pipeline:
validators:
- image: gcr.io/kpt-fn/enforce-gatekeeper:unstable
Loading