Skip to content

Commit

Permalink
feat: add kubernetes source
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastocorp committed Sep 4, 2024
1 parent 15d3e59 commit fe21a44
Show file tree
Hide file tree
Showing 16 changed files with 328 additions and 68 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ COPY --from=builder /workspace/combi .
RUN apt update && \
apt install --yes openssh-client && \
mkdir -p ~/.ssh && \
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
ssh-keyscan -H github.com >> ~/.ssh/known_hosts && \
echo 'export SSH_KNOWN_HOSTS=~/.ssh/known_hosts' >> ~/.bashrc

ENTRYPOINT ["/combi"]
File renamed without changes.
File renamed without changes.
File renamed without changes.
75 changes: 40 additions & 35 deletions docs/samples/v1alpha2/libconfig/combi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,17 @@ global:
config:
mergedConfig: ./docs/samples/v1alpha2/libconfig/merged.cnf
source:
type: raw
type: kubernetes
git:
sshUrl: "git@github.com:freepik-company/combi.git"
sshKeyFilepath: "/path/to/private_key"
branch: "main"
filepath: "docs/samples/v1alpha2/libconfig/source.cnf"
kubernetes:
kind: ConfigMap
namespace: default
name: source
key: config.cnf
rawConfig: |
datadir="/var/lib/proxysql"
Expand All @@ -55,40 +60,40 @@ config:
}
conditions:
mandatory: []
optional: []
# mandatory:
# - name: "search primitive value to check condition"
# template: |
# {{- $config := . -}}
# {{- printf "%s" $config.int64field -}}
# value: "500L"
# - name: "search group value to check condition"
# template: |
# {{- $config := . -}}
# {{- printf "%s" $config.mysql_variables.threads -}}
# value: "2"
# - name: "search list value to check condition"
# template: |
# {{- $config := . -}}
# {{- range $i, $v := $config.mysql_servers -}}
# {{- if (eq $v.hostgroup "0" ) -}}
# {{- printf "%s" $v.max_connections -}}
# {{- end -}}
# {{- end -}}
# value: "1000"
# - name: "search env variable to check condition"
# template: |
# {{- printf "%s" (env "MANDATORY_ENV_VAR") -}}
# value: "true"
# optional:
# - name: "print array values condition"
# template: |
# {{- $config := . -}}
# {{- range $k, $v := $config.array_test -}}
# [{{- printf "%v" $k -}}] => {{- printf "%v, " $v -}}
# {{- end -}}
# value: ""
# mandatory: []
mandatory:
- name: "search primitive value to check condition"
template: |
{{- $config := . -}}
{{- printf "%s" $config.int64field -}}
value: "500L"
- name: "search group value to check condition"
template: |
{{- $config := . -}}
{{- printf "%s" $config.mysql_variables.threads -}}
value: "2"
- name: "search list value to check condition"
template: |
{{- $config := . -}}
{{- range $i, $v := $config.mysql_servers -}}
{{- if (eq $v.hostgroup "0" ) -}}
{{- printf "%s" $v.max_connections -}}
{{- end -}}
{{- end -}}
value: "1000"
- name: "search env variable to check condition"
template: |
{{- printf "%s" (env "MANDATORY_ENV_VAR") -}}
value: "true"
# optional: []
optional:
- name: "print array values condition"
template: |
{{- $config := . -}}
{{- range $k, $v := $config.array_test -}}
[{{- printf "%v" $k -}}] => {{- printf "%v, " $v -}}
{{- end -}}
value: ""

actions:
onSuccess:
Expand Down
13 changes: 13 additions & 0 deletions docs/samples/v1alpha2/libconfig/configmap-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: source
data:
config.cnf: |
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="admin:admin;radmin:radmin"
mysql_ifaces="0.0.0.0:6032"
}
6 changes: 6 additions & 0 deletions docs/samples/v1alpha2/libconfig/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- secret-source.yaml
- configmap-source.yaml
14 changes: 14 additions & 0 deletions docs/samples/v1alpha2/libconfig/secret-source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: Secret
metadata:
name: source
type: Opaque
stringData:
config.cnf: |
datadir="/var/lib/proxysql"
admin_variables=
{
admin_credentials="admin:admin;radmin:radmin"
mysql_ifaces="0.0.0.0:6032"
}
45 changes: 40 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ require (
github.com/go-git/go-git/v5 v5.12.0
github.com/spf13/cobra v1.8.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.31.0
k8s.io/client-go v0.31.0
sigs.k8s.io/yaml v1.4.0
)

Expand All @@ -22,27 +24,60 @@ require (
github.com/alecthomas/repr v0.4.0 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.5.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/x448/float16 v0.8.4 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/crypto v0.24.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)
Loading

0 comments on commit fe21a44

Please sign in to comment.