Skip to content

Commit

Permalink
updates docs and example
Browse files Browse the repository at this point in the history
  • Loading branch information
benammann committed Jun 14, 2022
1 parent f398da9 commit a73ec5b
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 12 deletions.
38 changes: 37 additions & 1 deletion docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
![Docker Image Version](https://img.shields.io/docker/v/benammann/git-secrets?label=docker%20image%20tag)
![Release Badge](https://github.com/benammann/git-secrets/actions/workflows/brew-release.yml/badge.svg)
![Test Badge](https://github.com/benammann/git-secrets/actions/workflows/docker-release.yml/badge.svg)
![License](https://img.shields.io/github/license/benammann/git-secrets)
![License](https://img.shields.io/github/license/benammann/git-secrets?123)

Git Secrets encrypts your passwords and configurations for multiple environments and allows you to check them into a git repository. Using the GoLang templating engine, you can then decrypt them and write them to env files or Kubernetes deployment files.

Expand Down Expand Up @@ -125,11 +125,47 @@ git secrets add file .env.dist .env -t env
# targetName: env
git secrets render env

# prints all available variables
git secrets render env --debug

# prints the rendered files to the console without actually writing the file
git secrets render env --dry-run

# renders the files using the prod context
git secrets render env -c prod
````


### Custom Template Functions

Git Secrets extends the GoLang Templating engine by some useful functions

#### Base64Encode

The Base64Encode function takes the first argument and encodes it as Base64. This allows you to render Kubernetes Secrets

````yaml
# Created by git-secrets
apiVersion: v1
data:
apiPassword: "{{ Base64Encode .Secrets.applicationAPassword }}"
kind: Secret
metadata:
name: api-application-a
namespace: {{.Configs.namespace}}
type: Opaque
````

#### GitConfig

GitConfig allows you to resolve git config values. For example if you want to render files individually to the developer

````text
GIT_NAME={{GitConfig "user.name"}}
GIT_EMAIL={{GitConfig "user.email"}}
````


### Using Docker

There is also a Docker Image available: `benammann/git-secrets`.
Expand Down
10 changes: 1 addition & 9 deletions examples/render-kubernetes-secret/.git-secrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,7 @@
}
},
"renderFiles": {
"default": {
"files": [
{
"fileIn": "k8s-template/api-secrets.template.yaml",
"fileOut": "k8s-out/api-secrets.yaml"
}
]
},
"prod": {
"k8s": {
"files": [
{
"fileIn": "k8s-template/api-secrets.template.yaml",
Expand Down
2 changes: 1 addition & 1 deletion examples/render-kubernetes-secret/readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
This example demonstrates how to render kubernetes secrets using the `Base64Encode` template function

`git-secrets render`
`git-secrets render k8s`
2 changes: 1 addition & 1 deletion examples/with-binary-example/.env.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ DATABASE_PORT={{.Configs.databasePort}}
DATABASE_NAME={{.Configs.databaseName}}
DATABASE_PASSWORD={{.Secrets.databasePassword}}

GIT_USERNAME={{GitConfig "user.name123"}}
GIT_USERNAME={{GitConfig "user.name"}}
GIT_MAIL={{GitConfig "user.email"}}
36 changes: 36 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,47 @@ git secrets add file .env.dist .env -t env
# targetName: env
git secrets render env

# prints all available variables
git secrets render env --debug

# prints the rendered files to the console without actually writing the file
git secrets render env --dry-run

# renders the files using the prod context
git secrets render env -c prod
````


### Custom Template Functions

Git Secrets extends the GoLang Templating engine by some useful functions

#### Base64Encode

The Base64Encode function takes the first argument and encodes it as Base64. This allows you to render Kubernetes Secrets

````yaml
# Created by git-secrets
apiVersion: v1
data:
apiPassword: "{{ Base64Encode .Secrets.applicationAPassword }}"
kind: Secret
metadata:
name: api-application-a
namespace: {{.Configs.namespace}}
type: Opaque
````

#### GitConfig

GitConfig allows you to resolve git config values. For example if you want to render files individually to the developer

````text
GIT_NAME={{GitConfig "user.name"}}
GIT_EMAIL={{GitConfig "user.email"}}
````


### Using Docker

There is also a Docker Image available: `benammann/git-secrets`.
Expand Down

0 comments on commit a73ec5b

Please sign in to comment.