Skip to content

Commit

Permalink
Merge branch 'master' into sopsV3.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
aodinokov committed May 9, 2021
2 parents 228a86c + 2239e2e commit 9a82abc
Show file tree
Hide file tree
Showing 64 changed files with 1,341 additions and 159 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/checkSite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2021 Google LLC
#
# 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.

name: CheckSite
on:
pull_request:
paths:
- "functions/**"
- "examples/**"
- "site/**"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/checkout@v2
with:
repository: etefera/href-checker
ref: docsify
path: href-checker
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Install Site Checker
run: yarn install
working-directory: href-checker
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run Site Checker
run: make site-check
27 changes: 27 additions & 0 deletions .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This file was initially auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools

name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- master
- "*/v[0-9]+.[0-9]+"
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Generate Site
run: make site-generate
- uses: FirebaseExtended/action-hosting-deploy@276388dd6c2cde23455b30293105cc866c22282d # v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_KPT_DEV }}'
channelId: live
projectId: kpt-dev
entryPoint: site
env:
FIREBASE_CLI_PREVIEWS: hostingchannels
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ push: ## Push images to registry. WARN: This operation should only be done in CI
cd functions/contrib/ts && $(MAKE) push

site-generate: ## Collect function branches and generate a catalog of their examples and documentation using kpt next.
rm -rf ./examples/*/
rm -rf ./site/*/
# GO111MODULE=on go get -v github.com/GoogleContainerTools/kpt@next
(cd scripts/generate_catalog/ && go run . ../.. ../../examples)
(cd scripts/generate_catalog/ && go run . ../.. ../../site)

site-run: ## Run the site locally.
make site-generate
./scripts/run-site.sh

site-check: ## Test site for broken catalog links.
make site-run
./scripts/check-site.sh
10 changes: 5 additions & 5 deletions examples/_template/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# some-image-foo: Example Title

## Overview
### Overview

1. Explain what this particular example demonstrates.
2. Include a link to the function reference (help doc) on first mention of the function.
Expand All @@ -9,15 +9,15 @@
1. Explain what this function config does.
Focus on explaining this particular example, not repeating the function reference.

## Function invocation
### Function invocation

4. Show exact `kpt` commands to get the example package and run the function.

## Expected result
### Expected result

5. Describe the expected outcome of running the instructions above. This needs to be specific enough
so that the user is confident the function works as expected (Don't just provide the command to `cat` a file).

## Function Reference
### Function Reference

6. Provide a link to the function help doc for reference.
6. Provide a link to the function help doc for reference.
4 changes: 2 additions & 2 deletions examples/apply-setters/simple/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ environments: # kpt-set: ${env}
- stage
```

## Function invocation
### Function invocation

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

Expand All @@ -69,7 +69,7 @@ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/ex
kpt fn run simple
```

## Expected result
### 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]`.
Expand Down
4 changes: 2 additions & 2 deletions examples/contrib/analyze-istio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Istio configuration and outputs structured results detailing any errors found
during analysis. This example invokes the `analyze-istio` function using
declarative configuration.

## Function Invocation
### Function Invocation

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

Expand All @@ -14,7 +14,7 @@ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/ex
kpt fn run analyze-istio
```

## Expected Results
### Expected Results

This should give the following output:

Expand Down
4 changes: 2 additions & 2 deletions examples/contrib/inflate-helm-chart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The `inflate-helm-chart` KRM config function generates a new kpt package from a
local Helm chart. This example invokes the `inflate-helm-chart` function using
declarative configuration.

## Function invocation
### Function invocation

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

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

## Expected result
### Expected result

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

Expand Down
10 changes: 5 additions & 5 deletions examples/enforce-gatekeeper/invalid-configmap/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# enforce-gatekeeper: invalid configmap
# enforce-gatekeeper: Invalid Configmap

## Overview
### Overview

This example demonstrates how to validate ConfigMaps using a constraint.

There are 3 resources: a ConstraintTemplate, a K8sBannedConfigMapKeysV1 and a
ConfigMap.
The constraint disallows using `private_key` as a key in the ConfigMap.

## Function invocation
### Function invocation

Get the package:

Expand All @@ -30,7 +30,7 @@ Run the function:
$ kpt fn run --results-dir=results .
```

## Expected result
### Expected result

You should see the following output:

Expand Down Expand Up @@ -69,7 +69,7 @@ To pass validation, let's replace the key `private_key` in the ConfigMap in
`resources.yaml` with something else e.g. `public_key`.
Rerun the command. It will succeed (no output).

## Function Reference Doc
### Function Reference Doc

TODO: replace the following with the link to the reference doc when our site is live.
https://github.com/GoogleContainerTools/kpt-functions-catalog/blob/master/functions/go/enforce-gatekeeper/README.md
10 changes: 5 additions & 5 deletions examples/enforce-gatekeeper/warning-only/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# enforce-gatekeeper: warning only
# enforce-gatekeeper: Warning Only

## Overview
### Overview

This example is very similar to the invalid configmap example. The major
difference is that the violations are warnings instead of errors.

In the constraint, we use `enforcementAction: warn` instead of
`enforcementAction: deny`.

## Function invocation
### Function invocation

Get the package:

Expand All @@ -30,7 +30,7 @@ Run the function:
$ kpt fn run --results-dir=results .
```

## Expected result
### Expected result

You won't any failure. But if you look at the structured output, you can find a
warning about the constraint violation.
Expand Down Expand Up @@ -63,7 +63,7 @@ To pass validation, let's replace the key `private_key` in the ConfigMap in
`resources.yaml` with something else e.g. `public_key`.
Rerun the command. It will no longer have the warning.

## Function Reference Doc
### Function Reference Doc

TODO: replace the following with the link to the reference doc when our site is live.
https://github.com/GoogleContainerTools/kpt-functions-catalog/blob/master/functions/go/enforce-gatekeeper/README.md
4 changes: 2 additions & 2 deletions examples/ensure-name-substring/advanced/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fieldSpecs:
The function will not only update field `.metadata.name` but also field
`.spec.name` in `MyResource`.

## Function invocation
### Function invocation

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

Expand All @@ -37,7 +37,7 @@ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/ex
kpt fn run advanced
```

## Expected result
### Expected result

Check all resources have `prod-` in their names and the field `.spec.name` in
`MyResource` also got updated.
Expand Down
4 changes: 2 additions & 2 deletions examples/ensure-name-substring/prefix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data:
prepend: prod-
```
## Function invocation
### Function invocation
Get the config example and try it out by running the following commands:
Expand All @@ -29,7 +29,7 @@ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/ex
kpt fn run prefix
```

## Expected result
### Expected result

Check all resources have `prod-` in their names:

Expand Down
4 changes: 2 additions & 2 deletions examples/ensure-name-substring/suffix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ data:
append: -prod
```
## Function invocation
### Function invocation
Get the config example and try it out by running the following commands:
Expand All @@ -29,7 +29,7 @@ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/ex
kpt fn run suffix
```

## Expected result
### Expected result

Check all resources have `-prod` in their names:

Expand Down
1 change: 1 addition & 0 deletions examples/format/simple/.expected/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
runCount: 2
35 changes: 35 additions & 0 deletions examples/format/simple/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
diff --git a/resources.yaml b/resources.yaml
index 968a0f4..8cc1c72 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -1,22 +1,22 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- labels:
- foo: bar
- env: dev
name: my-nginx
namespace: my-space
+ labels:
+ env: dev
+ foo: bar
spec:
+ replicas: 3
selector:
- matchLabels:
- app: nginx
spec:
containers:
- - image: nginx:1.14.2
- name: nginx
+ - name: nginx
+ image: nginx:1.14.2
ports:
- containerPort: 80
- replicas: 3
+ matchLabels:
+ app: nginx
template:
metadata:
labels:
1 change: 1 addition & 0 deletions examples/format/simple/.krmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.expected
26 changes: 26 additions & 0 deletions examples/format/simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# format: Simple Example

The `format` function formats the field ordering in YAML configuration files. This example depicts the functionality of
`format` function by formatting a `Deployment` resource.

## Function invocation

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/format/simple .
kpt fn run simple
```

## Expected result

The fields should be ordered as per OpenAPI schema definition of `Deployment` resource. For e.g. `metadata.name` field
is placed before `metadata.labels` field. The keys in `metadata.labels` field are sorted alphabetically.

Verify that the changes are as described:

<!-- @getAndRunPkg @test -->
```sh
$ kpt cfg cat simple/
```
8 changes: 8 additions & 0 deletions examples/format/simple/fn-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: format-fn-config
annotations:
config.k8s.io/function: |
container:
image: gcr.io/kpt-fn/format:unstable
23 changes: 23 additions & 0 deletions examples/format/simple/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
foo: bar
env: dev
name: my-nginx
namespace: my-space
spec:
selector:
matchLabels:
app: nginx
spec:
containers:
- image: nginx:1.14.2
name: nginx
ports:
- containerPort: 80
replicas: 3
template:
metadata:
labels:
app: nginx
Loading

0 comments on commit 9a82abc

Please sign in to comment.