Skip to content

Commit

Permalink
Prepare release candidate fro apply-replacements/v0.1.1 (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuwenma authored May 7, 2022
1 parent a426838 commit 6ea2a08
Show file tree
Hide file tree
Showing 117 changed files with 2,618 additions and 654 deletions.
33 changes: 33 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,38 @@ kpt-functions-catalog repo.
1. Click `Publish release` button.
1. Send an announcement email in the [kpt users google group].

## Updating function docs

After creating a release, the docs for the function should be updated to reflect
the latest patch version. A script has been created to automate this process.
The `RELEASE_BRANCH` branch should already exist in the [repo] and a tag should
be created on the [releases pages]. `RELEASE_BRANCH` is in the form of
`${FUNCTION_NAME}/v${MAJOR_VERSION}.${MINOR_VERSION}`.
For example `set-namespace/v0.3`, `kubeval/v0.1`, etc.


1. Run the script:
```shell
# Fetch from upstream (assuming upstream is set to official repo)
git fetch upstream
# Make sure local release branch is up to date
# e.g. git checkout set-namespace/v0.3 && git reset --hard upstream/set-namespace/v0.3
git checkout <RELEASE_BRANCH> && git reset --hard upstream/<RELEASE_BRANCH>
# Check out latest version of the make target from master
git checkout upstream/master
# Run the make target
# e.g. RELEASE_BRANCH=set-namespace/v0.3 make update-function-docs
RELEASE_BRANCH=<RELEASE_BRANCH> make update-function-docs
```
1. The script will generate a new commit in your local repository which updates
the docs for the provided function release. Push this commit to your remote.
```shell
# Push the commit to your remote (branch name can be anything)
# e.g. git push origin HEAD:update-docs-set-namespace
git push origin HEAD:<remote-branch>
```
1. Create a pull request targeted at the release branch.

[repo]: https://github.com/GoogleContainerTools/kpt-functions-catalog
[releases pages]: https://github.com/GoogleContainerTools/kpt-functions-catalog/releases
[kpt users google group]: https://groups.google.com/g/kpt-users
13 changes: 13 additions & 0 deletions contrib/examples/delete-annotations-simple/.expected/diff.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/resources.yaml b/resources.yaml
index f8ec01d..bcc8f78 100644
--- a/resources.yaml
+++ b/resources.yaml
@@ -3,8 +3,6 @@ kind: ConfigMap
metadata:
name: the-map
namespace: the-namespace
- annotations:
- annotation-to-delete: "some_value"
data:
some-key: some-value
---
9 changes: 9 additions & 0 deletions contrib/examples/delete-annotations-simple/Kptfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kpt.dev/v1
kind: Kptfile
metadata:
name: delete-annotations-simple
pipeline:
mutators:
- image: gcr.io/kpt-fn-contrib/delete-annotations:unstable
configMap:
annotationKeys: annotation-to-delete
25 changes: 25 additions & 0 deletions contrib/examples/delete-annotations-simple/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# delete-annotations: Simple Example

### Overview

In this example, we will see how to delete annotations on a set of resources in a package/folder

### Fetch the example package

Get the example package by running the following commands:

```shell
$ kpt pkg get https://github.com/GoogleContainerTools/kpt-functions-catalog.git/contrib/examples/delete-annotations-simple
```

### Function invocation

Invoke the function by running the following command:

```shell
$ kpt fn render delete-annotations-simple
```

### Expected result

One of the two resources i.e. `ConfigMap` in `resources.yaml` should have been mutated with the annotation `annotation-to-delete` removed from `metadata.annotations` where as there shouldn't be any changes to the second resource i.e. `Namespace` as it didn't have the supplied annotation.
14 changes: 14 additions & 0 deletions contrib/examples/delete-annotations-simple/resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: the-map
namespace: the-namespace
annotations:
annotation-to-delete: "some_value"
data:
some-key: some-value
---
apiVersion: v1
kind: Namespace
metadata:
name: the-namespace

This file was deleted.

2 changes: 1 addition & 1 deletion contrib/functions/go/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GOBIN := $(shell go env GOPATH)/bin
# Edit this list to contain all go functions
FUNCTIONS := \
annotate-apply-time-mutations \
generate-kpt-pkg-docs
delete-annotations

# Targets for running all function tests
FUNCTION_TESTS := $(patsubst %,%-TEST,$(FUNCTIONS))
Expand Down
51 changes: 51 additions & 0 deletions contrib/functions/go/delete-annotations/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# delete-annotations

## Overview

<!--mdtogo:Short-->

Deletes the supplied annotation keys from the resource(s).

<!--mdtogo-->

One of the use cases for this function is to help users remove annotations that are
not necessary for deployment across a package. E.g. a user may add annotations to
resource(s) for local processing but those annotations may not be necessary for
deployment or for the functioning of the workload. This function can be used to
clean up such unnecessary annotations before resources are deployed.

<!--mdtogo:Long-->

## Usage

You can delete multiple annotations provided as a comma separated string as part of the function config.

To execute imperatively:
```shell
$ kpt fn eval -i gcr.io/kpt-fn-contrib/delete-annotations:unstable -- annotationKeys=annotation-to-delete,another-annotation-to-delete
```

To execute `delete-annotations` declaratively include the function in kpt package pipeline as follows:
```yaml
...
pipeline:
mutators:
- image: gcr.io/kpt-fn-contrib/delete-annotations:unstable
configMap:
annotationKeys: annotation-to-delete,another-annotation-to-delete
...
```

### FunctionConfig

This function takes the annotation key names as part of the function config parameter
`annotationKeys` where the key names can be provided as comma separated values as follows:

`annotationKeys=annotation-key-1,annotation-key-2`

In the previous example, the function will delete annotations `annotation-key-1` and `annotation-key-2`
in all resource(s) where those annotations are present.

The `annotationKeys` field is a required parameter.

<!--mdtogo-->
35 changes: 35 additions & 0 deletions contrib/functions/go/delete-annotations/generated/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions contrib/functions/go/delete-annotations/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module github.com/GoogleContainerTools/kpt-functions-catalog/contrib/functions/go/delete-annotations

go 1.17

require (
github.com/GoogleContainerTools/kpt-functions-sdk/go/fn v0.0.0-20220405020624-e5817d5d2014
github.com/stretchr/testify v1.7.0
)

require (
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/go-errors/errors v1.0.1 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.3 // indirect
github.com/go-openapi/swag v0.19.5 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/xlab/treeprint v0.0.0-20181112141820-a009c3971eca // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
sigs.k8s.io/kustomize/kyaml v0.13.3 // indirect
)
Loading

0 comments on commit 6ea2a08

Please sign in to comment.