Skip to content

Commit

Permalink
Support setting helm namespace in Bookfile
Browse files Browse the repository at this point in the history
fixes #171

Signed-off-by: Samuel Suter <[email protected]>
  • Loading branch information
moensch committed Sep 27, 2023
1 parent aacc5f3 commit dc7726c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions internal/helm/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type Config struct {
// `--values` flag in the `helm template` command. By convention, if left
// unspecified, one path will be assumed: <branch name>/values.yaml.
ValuesPaths []string `json:"valuesPaths,omitempty"`
// Namespace is the Kubernetes namespace in which the Helm chart will be
// rendered. This is used as an argument in the `helm template` command. By
// convention, if left unspecified, the value `default` is assumed.
Namespace string `json:"namespace,omitempty"`
}

// Expand expands all file/directory paths referenced by this configuration
Expand Down
2 changes: 2 additions & 0 deletions internal/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
func Render(
ctx context.Context,
releaseName string,
namespace string,
chartPath string,
valuesPaths []string,
) ([]byte, error) {
Expand All @@ -31,6 +32,7 @@ func Render(
"", // Repo root
"", // Revision
&apiclient.ManifestRequest{
Namespace: namespace,
// Both of these fields need to be non-nil
Repo: &argoappv1.Repository{},
ApplicationSource: &argoappv1.ApplicationSource{
Expand Down
2 changes: 2 additions & 0 deletions rendering.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func (s *service) preRender(
appLogger = appLogger.WithFields(log.Fields{
"configManagement": "helm",
"releaseName": appConfig.ConfigManagement.Helm.ReleaseName,
"namespace": appConfig.ConfigManagement.Helm.Namespace,
"chartPath": chartPath,
"valuesPaths": valuesPaths,
})
Expand All @@ -56,6 +57,7 @@ func (s *service) preRender(
manifests[appName], err = s.helmRenderFn(
ctx,
appConfig.ConfigManagement.Helm.ReleaseName,
appConfig.ConfigManagement.Helm.Namespace,
chartPath,
absValuesPaths,
)
Expand Down
2 changes: 2 additions & 0 deletions rendering_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestPreRender(t *testing.T) {
context.Context,
string,
string,
string,
[]string,
) ([]byte, error) {
return nil, errors.New("something went wrong")
Expand Down Expand Up @@ -72,6 +73,7 @@ func TestPreRender(t *testing.T) {
context.Context,
string,
string,
string,
[]string,
) ([]byte, error) {
return fakeManifest, nil
Expand Down
4 changes: 4 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
"type": "string",
"pattern": "^\\w[\\w-]*\\w$"
},
"namespace": {
"type": "string",
"pattern": "^\\w[\\w-]*\\w$"
},
"chartPath": {
"$ref": "#/definitions/relativePath"
},
Expand Down
1 change: 1 addition & 0 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type service struct {
helmRenderFn func(
ctx context.Context,
releaseName string,
namespace string,
chartPath string,
valuesPaths []string,
) ([]byte, error)
Expand Down

0 comments on commit dc7726c

Please sign in to comment.