mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-22 10:24:35 +02:00
Add integration with Hashicorp Vault, AWS SSM, SecretsManager (#906)
* feat: Add integration with Hashicorp Vault, AWS SSM, SecretsManager Fields which are rendered: Release.Values, Release.SetValues.Value, Release.SetValues.Values Example: ``` values: - foo: ref+vault://mykv/foo?address=http://127.0.0.1:8200#/mykey set: - name: xyz values: - ref+vault://mykv/foo?address=http://127.0.0.1:8200#/mykey3 ``` Resolves #881 * feat: Update integration with variantdev/vals New ref+.\* secret formats are used: https://github.com/variantdev/vals/tree/6565695a031f407a1066bdd31ae313db6a33ec0a#suported-backends Resolves #881
This commit is contained in:
committed by
KUOKA Yusuke
parent
849ed63999
commit
4680010c60
@@ -13,6 +13,7 @@ import (
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"github.com/roboll/helmfile/pkg/remote"
|
||||
"github.com/roboll/helmfile/pkg/state"
|
||||
"github.com/variantdev/vals"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
@@ -20,6 +21,11 @@ import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
const (
|
||||
// cache size for improving performance of ref+.* secrets rendering
|
||||
valsCacheSize = 512
|
||||
)
|
||||
|
||||
type App struct {
|
||||
KubeContext string
|
||||
Logger *zap.SugaredLogger
|
||||
@@ -49,6 +55,8 @@ type App struct {
|
||||
remote *remote.Remote
|
||||
|
||||
helmExecer helmexec.Interface
|
||||
|
||||
valsRuntime vals.Evaluator
|
||||
}
|
||||
|
||||
func New(conf ConfigProvider) *App {
|
||||
@@ -78,6 +86,13 @@ func Init(app *App) *App {
|
||||
app.fileExistsAt = fileExistsAt
|
||||
app.fileExists = fileExists
|
||||
app.directoryExistsAt = directoryExistsAt
|
||||
|
||||
var err error
|
||||
app.valsRuntime, err = vals.New(valsCacheSize)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Failed to initialize vals runtime: %v", err))
|
||||
}
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
@@ -274,6 +289,7 @@ func (a *App) loadDesiredStateFromYaml(file string, opts ...LoadOpts) (*state.He
|
||||
KubeContext: a.KubeContext,
|
||||
glob: a.glob,
|
||||
helm: a.helmExecer,
|
||||
valsRuntime: a.valsRuntime,
|
||||
}
|
||||
|
||||
var op LoadOpts
|
||||
|
||||
+9
-2
@@ -18,6 +18,7 @@ import (
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"github.com/roboll/helmfile/pkg/state"
|
||||
"github.com/roboll/helmfile/pkg/testhelper"
|
||||
"github.com/variantdev/vals"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"gotest.tools/env"
|
||||
@@ -440,8 +441,8 @@ func TestVisitDesiredStatesWithReleasesFiltered_EmbeddedSelectors(t *testing.T)
|
||||
helmfiles:
|
||||
- path: helmfile.d/a*.yaml
|
||||
selectors:
|
||||
- name=prometheus
|
||||
- name=zipkin
|
||||
- name=prometheus
|
||||
- name=zipkin
|
||||
- helmfile.d/b*.yaml
|
||||
- path: helmfile.d/c*.yaml
|
||||
selectors: []
|
||||
@@ -1944,6 +1945,11 @@ releases:
|
||||
var buffer bytes.Buffer
|
||||
logger := helmexec.NewLogger(&buffer, "debug")
|
||||
|
||||
valsRuntime, err := vals.New(32)
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error creating vals runtime: %v", err)
|
||||
}
|
||||
|
||||
app := appWithFs(&App{
|
||||
glob: filepath.Glob,
|
||||
abs: filepath.Abs,
|
||||
@@ -1952,6 +1958,7 @@ releases:
|
||||
Logger: logger,
|
||||
helmExecer: helm,
|
||||
Namespace: "testNamespace",
|
||||
valsRuntime: valsRuntime,
|
||||
}, files)
|
||||
app.Template(configImpl{set: []string{"foo=a", "bar=b"}})
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/roboll/helmfile/pkg/environment"
|
||||
"github.com/roboll/helmfile/pkg/helmexec"
|
||||
"github.com/roboll/helmfile/pkg/state"
|
||||
"github.com/variantdev/vals"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
@@ -26,8 +27,9 @@ type desiredStateLoader struct {
|
||||
abs func(string) (string, error)
|
||||
glob func(string) ([]string, error)
|
||||
|
||||
logger *zap.SugaredLogger
|
||||
helm helmexec.Interface
|
||||
logger *zap.SugaredLogger
|
||||
helm helmexec.Interface
|
||||
valsRuntime vals.Evaluator
|
||||
}
|
||||
|
||||
func (ld *desiredStateLoader) Load(f string, opts LoadOpts) (*state.HelmState, error) {
|
||||
@@ -128,7 +130,7 @@ func (ld *desiredStateLoader) loadFileWithOverrides(inheritedEnv, overrodeEnv *e
|
||||
}
|
||||
|
||||
func (a *desiredStateLoader) underlying() *state.StateCreator {
|
||||
c := state.NewCreator(a.logger, a.readFile, a.fileExists, a.abs, a.glob, a.helm)
|
||||
c := state.NewCreator(a.logger, a.readFile, a.fileExists, a.abs, a.glob, a.helm, a.valsRuntime)
|
||||
c.LoadFile = a.loadFile
|
||||
return c
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user