Skip to content

Commit

Permalink
Provide full list of environment overrides (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
streamer45 authored Jan 21, 2025
1 parent 11b18d5 commit 73d50a2
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@ go-fmt: ## to perform formatting
$(AT)$(GO) fmt ./... || ${FAIL}
@$(OK) App code formatting...

.PHONY: go-doc
go-doc: ## to generate documentation
@$(INFO) Generating Documentation...
$(AT)$(GO) run ./scripts/env_config.go ./docs/env_config.md || ${FAIL}
@$(OK) Generating Documentation

.PHONY: github-release
github-release: ## to publish a release and relevant artifacts to GitHub
@$(INFO) Generating github-release http://github.com/$(GITHUB_ORG)/$(GITHUB_REPO)/releases/tag/$(APP_VERSION) ...
Expand Down
45 changes: 45 additions & 0 deletions docs/env_config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
### Config Environment Overrides

```
KEY TYPE
API_HTTP_LISTENADDRESS String
API_HTTP_TLS_ENABLE True or False
API_HTTP_TLS_CERTFILE String
API_HTTP_TLS_CERTKEY String
API_SECURITY_ENABLEADMIN True or False
API_SECURITY_ADMINSECRETKEY String
API_SECURITY_ALLOWSELFREGISTRATION True or False
API_SECURITY_SESSIONCACHE_EXPIRATIONMINUTES Integer
STORE_DATASOURCE String
JOBS_APITYPE JobAPIType
JOBS_MAXCONCURRENTJOBS Integer
JOBS_IMAGEREGISTRY String
JOBS_KUBERNETES_MAXCONCURRENTJOBS Integer
JOBS_KUBERNETES_FAILEDJOBSRETENTIONTIME Duration
JOBS_KUBERNETES_IMAGEREGISTRY String
JOBS_KUBERNETES_JOBSRESOURCEREQUIREMENTS Comma-separated list of Type: pairs
JOBS_KUBERNETES_PERSISTENTVOLUMECLAIMNAME String
JOBS_KUBERNETES_NODESYSCTLS String
JOBS_DOCKER_MAXCONCURRENTJOBS Integer
JOBS_DOCKER_FAILEDJOBSRETENTIONTIME Duration
JOBS_DOCKER_IMAGEREGISTRY String
LOGGER_ENABLECONSOLE True or False
LOGGER_CONSOLEJSON True or False
LOGGER_CONSOLELEVEL String
LOGGER_ENABLEFILE True or False
LOGGER_FILEJSON True or False
LOGGER_FILELEVEL String
LOGGER_FILELOCATION String
LOGGER_ENABLECOLOR True or False
```

### Custom Environment Overrides

```
KEY TYPE
K8S_NAMESPACE String
The Kubernetes namespace in which jobs will be created.
K8S_JOB_POD_TOLERATIONS String (JSON)
The Kubernetes tolerations to apply to the job pods.
Example: [{"key":"utilities","operator":"Equal","value":"true","effect":"NoSchedule"}]
```
51 changes: 51 additions & 0 deletions scripts/env_config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright (c) 2025-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

package main

import (
"log"
"os"
"text/tabwriter"

"github.com/mattermost/calls-offloader/service"

"github.com/kelseyhightower/envconfig"
)

const customEnv = `
KEY TYPE
K8S_NAMESPACE String
The Kubernetes namespace in which jobs will be created.
K8S_JOB_POD_TOLERATIONS String (JSON)
The Kubernetes tolerations to apply to the job pods.
Example: [{"key":"utilities","operator":"Equal","value":"true","effect":"NoSchedule"}]
`

func main() {
if len(os.Args) < 2 {
log.Fatalf("unexpected number of arguments, need 1")
}

outFile, err := os.OpenFile(os.Args[1], os.O_RDWR|os.O_CREATE, 0644)
if err != nil {
log.Fatalf("failed to write file: %s", err.Error())
}
defer outFile.Close()
if err := outFile.Truncate(0); err != nil {
log.Fatalf("failed to truncate file: %s", err.Error())
}
if _, err := outFile.Seek(0, 0); err != nil {
log.Fatalf("failed to seek file: %s", err.Error())
}
fmt := "### Config Environment Overrides\n\n```\nKEY TYPE\n{{range .}}{{usage_key .}} {{usage_type .}}\n{{end}}```\n"
tabs := tabwriter.NewWriter(outFile, 1, 0, 4, ' ', 0)
_ = envconfig.Usagef("", &service.Config{}, tabs, fmt)
tabs.Flush()

// Custom configs
_, err = outFile.WriteString("\n### Custom Environment Overrides\n\n```" + customEnv + "```\n")
if err != nil {
log.Fatalf("failed to write file: %s", err.Error())
}
}

0 comments on commit 73d50a2

Please sign in to comment.