Skip to content

Commit

Permalink
basic helm3 support as a datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
gotwarlost committed Dec 29, 2021
1 parent 2ae1106 commit 5b7f7f0
Show file tree
Hide file tree
Showing 14 changed files with 543 additions and 1 deletion.
10 changes: 10 additions & 0 deletions examples/helm3/components/apache/datasource.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
objects: import 'data://helm/apache?config-from=apache-config',
config: {
options: {
repo: 'https://charts.bitnami.com/bitnami',
},
values: {
}
}
}
1 change: 1 addition & 0 deletions examples/helm3/components/apache/index.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import 'datasource.libsonnet').objects
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
objects: import 'data://helm/github.com/VictoriaMetrics/helm-charts/raw/347d4558d9c25cd341718bf5a2ee167da042c080/packages/victoria-metrics-cluster-0.9.6.tgz?config-from=victoria-config',
config: {
options: {},
values: {}
}
}
1 change: 1 addition & 0 deletions examples/helm3/components/victoria-metrics/index.jsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(import 'datasource.libsonnet').objects
6 changes: 6 additions & 0 deletions examples/helm3/environments/base.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

// this file has the baseline default parameters
{
components: {
},
}
8 changes: 8 additions & 0 deletions examples/helm3/environments/default.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

// this file has the param overrides for the default environment
local base = import './base.libsonnet';

base {
components +: {
}
}
10 changes: 10 additions & 0 deletions examples/helm3/params.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

// this file returns the params for the current qbec environment
local env = std.extVar('qbec.io/env');
local paramsMap = import 'glob-import:environments/*.libsonnet';
local baseFile = if env == '_' then 'base' else env;
local key = 'environments/%s.libsonnet' % baseFile;

if std.objectHas(paramsMap, key)
then paramsMap[key]
else error 'no param file %s found for environment %s' % [key, env]
22 changes: 22 additions & 0 deletions examples/helm3/qbec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: qbec.io/v1alpha1
kind: App
metadata:
name: helm3
spec:
environments:
default:
defaultNamespace: charts
context: kind
vars:
computed:
- name: helmSetup
code: |
{}
- name: victoria-config
code: |
(import 'components/victoria-metrics/datasource.libsonnet').config
- name: apache-config
code: |
(import 'components/apache/datasource.libsonnet').config
dataSources:
- helm3://helm?configVar=helmSetup
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/golang/protobuf v1.5.2
github.com/google/go-jsonnet v0.18.0
github.com/googleapis/gnostic v0.2.0
github.com/iancoleman/strcase v0.2.0
github.com/jonboulle/clockwork v0.1.0
github.com/mattn/go-isatty v0.0.14
github.com/pkg/errors v0.9.1
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKEN
github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/iancoleman/strcase v0.2.0 h1:05I4QRnGpI0m37iZQRuskXh+w77mr6Z41lwQzuHLwW0=
github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
Expand Down
2 changes: 1 addition & 1 deletion vm/internal/ds/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ func (d *execSource) Init(p datasource.ConfigProvider) (fErr error) {
if err != nil {
return err
}
c.initDefaults()
err = c.assertValid()
if err != nil {
return err
}
c.initDefaults()
d.runner = newRunner(&c)
return nil
}
Expand Down
4 changes: 4 additions & 0 deletions vm/internal/ds/factory/datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/pkg/errors"
"github.com/splunk/qbec/vm/internal/ds"
"github.com/splunk/qbec/vm/internal/ds/exec"
"github.com/splunk/qbec/vm/internal/ds/helm3"
)

// Create creates a new data source from the supplied URL.
Expand All @@ -35,6 +36,7 @@ func Create(u string) (ds.DataSourceWithLifecycle, error) {
scheme := parsed.Scheme
switch scheme {
case exec.Scheme:
case helm3.Scheme:
default:
return nil, fmt.Errorf("data source URL '%s', unsupported scheme '%s'", u, scheme)
}
Expand All @@ -52,6 +54,8 @@ func Create(u string) (ds.DataSourceWithLifecycle, error) {
switch scheme {
case exec.Scheme:
return makeLazy(exec.New(name, varName)), nil
case helm3.Scheme:
return makeLazy(helm3.New(name, varName)), nil
default:
return nil, fmt.Errorf("internal error: unable to create a data source for %s", u)
}
Expand Down
Loading

0 comments on commit 5b7f7f0

Please sign in to comment.