Skip to content

Commit

Permalink
feat(helm): add support for helm capabilities (#48)
Browse files Browse the repository at this point in the history
Capabilities can be defined in env-data.ytt.yaml.
Capabilities are passed to helm template.

Fixes #31
  • Loading branch information
kbudde authored Aug 13, 2023
1 parent c9a67ab commit 1a13ee1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
18 changes: 11 additions & 7 deletions internal/myks/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package myks
import (
"errors"
"fmt"
"github.com/rs/zerolog/log"
yaml "gopkg.in/yaml.v3"
"io"
"os"
"path/filepath"

"github.com/rs/zerolog/log"
yaml "gopkg.in/yaml.v3"
)

const (
Expand Down Expand Up @@ -35,13 +36,16 @@ type Application struct {
}

type HelmConfig struct {
Namespace string `yaml:"namespace"`
KubeVersion string `yaml:"kubeVersion"`
IncludeCRDs bool `yaml:"includeCRDs"`
Namespace string `yaml:"namespace"`
KubeVersion string `yaml:"kubeVersion"`
IncludeCRDs bool `yaml:"includeCRDs"`
Capabilities []string `yaml:"capabilities"`
}

var ErrNoVendirConfig = errors.New("no vendir config found")
var ApplicationLogFormat = "\033[1m[%s > %s > %s]\033[0m %s"
var (
ErrNoVendirConfig = errors.New("no vendir config found")
ApplicationLogFormat = "\033[1m[%s > %s > %s]\033[0m %s"
)

func NewApplication(e *Environment, name string, prototypeName string) (*Application, error) {
if prototypeName == "" {
Expand Down
4 changes: 4 additions & 0 deletions internal/myks/assets/data-schema.ytt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ helm:
#! Used by myks.
#! If defined, passed as a value of `--namespace` for `helm template`.
namespace: ""
#! Used by myks.
#! If defined, passed as `--api-version` for `helm-template`.
capabilities:
- "" #! e.g. "monitoring.coreos.com/v1"
#! Myks configuration and runtime data.
myks:
applicationDataFileName: ""
Expand Down
3 changes: 3 additions & 0 deletions internal/myks/render_helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ func (h *Helm) Render(_ string) (string, error) {
commonHelmArgs = append(commonHelmArgs, "--include-crds")
}

for _, capa := range helmConfig.Capabilities {
commonHelmArgs = append(commonHelmArgs, "--api-versions", capa)
}
var outputs []string

for _, chartDir := range chartDirs {
Expand Down

0 comments on commit 1a13ee1

Please sign in to comment.