Skip to content

Commit

Permalink
Merge pull request #25 from and-fm/develop
Browse files Browse the repository at this point in the history
Added support for annotations
  • Loading branch information
npgy authored Nov 28, 2024
2 parents fb00f2d + fb26997 commit ab41da1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.5.0

- Added support for annotations

## 0.4.0

- You can now generate basic auth secrets!
Expand Down
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
FROM alpine/curl:latest

# Install kubectl
RUN curl -L "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" -o /bin/kubectl
RUN chmod +x /bin/kubectl

# Install yq
RUN curl -L "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64" -o /bin/yq
RUN chmod +x /bin/yq

COPY entrypoint.sh /entrypoint.sh
RUN chmod +x /entrypoint.sh

Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The following inputs can be used as `step.with` keys:
| `secrets` | List | | `false` | List of secrets to pass in to generate a secret |
| `basic_auth` | String | | `false` | A username and password to generate a basic auth secret. E.g. `bobby:iLikeTrains123` |
| `configmap_env` | List | | `false` | List of vars to pass in to generate a configmap (same format as secrets) |
| `annotations` | String | | `false` | Multi line list of valid k8s annotations |

## Outputs

Expand Down Expand Up @@ -58,6 +59,13 @@ jobs:
secrets: |-
SECRET_1:${{ secrets.SECRET_1 }}
SECRET_2:${{ secrets.SECRET_2 }}
#optional if you need annotations such as for reflection
annotations: |
sealedsecrets.bitnami.com/cluster-wide: "true"
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-allowed-namespaces: "*"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-namespaces: "*"
- name: get secrets
run: |
echo "${{ steps.gen.outputs.out_yaml }}"
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
configmap_env:
description: Env vars list in the same format as passing secrets but generates configmap
required: false
annotations:
description: K8s annotations to append to the resource
required: false
runs:
using: "docker"
image: "Dockerfile"
Expand All @@ -28,3 +31,4 @@ runs:
- ${{ inputs.secrets }}
- ${{ inputs.basic_auth }}
- ${{ inputs.configmap_env }}
- ${{ inputs.annotations }}
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ fi

chmod +x kubecmd.sh

# add any annotations passed in
if [ -z $6 ]; then
./kubecmd.sh >> finalresource.yml
else
./kubecmd.sh >> resource.yml
echo "$6" > annotations.yml

yq '.metadata.annotations = load("annotations.yml")' resource.yml > finalresource.yml
fi

echo 'out_yaml<<EOF' >> $GITHUB_OUTPUT
./kubecmd.sh >> $GITHUB_OUTPUT
cat finalresource.yml >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

0 comments on commit ab41da1

Please sign in to comment.