Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package helmify for openSUSE:Factory checked in at 2023-10-24 20:09:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/helmify (Old) and /work/SRC/openSUSE:Factory/.helmify.new.24901 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "helmify" Tue Oct 24 20:09:02 2023 rev:14 rq:1119925 version:0.4.7 Changes: -------- --- /work/SRC/openSUSE:Factory/helmify/helmify.changes 2023-09-28 00:34:50.940932629 +0200 +++ /work/SRC/openSUSE:Factory/.helmify.new.24901/helmify.changes 2023-10-24 20:09:10.250299392 +0200 @@ -1,0 +2,8 @@ +Tue Oct 24 09:35:09 UTC 2023 - [email protected] + +- Update to version 0.4.7: + * Stop trimming "controller-manager-" from PDB name + * Add PodDisruptionBudget processor + * fix readme wording + +------------------------------------------------------------------- Old: ---- helmify-0.4.6.obscpio New: ---- helmify-0.4.7.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ helmify.spec ++++++ --- /var/tmp/diff_new_pack.Fn5cBD/_old 2023-10-24 20:09:11.386340694 +0200 +++ /var/tmp/diff_new_pack.Fn5cBD/_new 2023-10-24 20:09:11.386340694 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: helmify -Version: 0.4.6 +Version: 0.4.7 Release: 0 Summary: Creates Helm chart from Kubernetes yaml License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.Fn5cBD/_old 2023-10-24 20:09:11.414341713 +0200 +++ /var/tmp/diff_new_pack.Fn5cBD/_new 2023-10-24 20:09:11.418341858 +0200 @@ -3,7 +3,7 @@ <param name="url">https://github.com/arttor/helmify/</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v0.4.6</param> + <param name="revision">v0.4.7</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.Fn5cBD/_old 2023-10-24 20:09:11.434342440 +0200 +++ /var/tmp/diff_new_pack.Fn5cBD/_new 2023-10-24 20:09:11.438342585 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/arttor/helmify/</param> - <param name="changesrevision">aace0334e2e65744f781e897f124653738c4c7f3</param></service></servicedata> + <param name="changesrevision">8a688a5448fbadeb0072b1babd7905f8b276fb62</param></service></servicedata> (No newline at EOF) ++++++ helmify-0.4.6.obscpio -> helmify-0.4.7.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/README.md new/helmify-0.4.7/README.md --- old/helmify-0.4.6/README.md 2023-09-27 12:13:24.000000000 +0200 +++ new/helmify-0.4.7/README.md 2023-10-24 09:49:46.000000000 +0200 @@ -7,7 +7,7 @@ [](https://pkg.go.dev/github.com/arttor/helmify?tab=doc)  -CLI that creates [Helm](https://github.com/helm/helm) charts from kubernetes yamls. +CLI that creates [Helm](https://github.com/helm/helm) charts from kubernetes manifests. Helmify reads a list of [supported k8s objects](#status) from stdin and converts it to a helm chart. Designed to generate charts for [k8s operators](#integrate-to-your-operator-sdkkubebuilder-project) but not limited to. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/examples/app/templates/myapp-pdb.yaml new/helmify-0.4.7/examples/app/templates/myapp-pdb.yaml --- old/helmify-0.4.6/examples/app/templates/myapp-pdb.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helmify-0.4.7/examples/app/templates/myapp-pdb.yaml 2023-10-24 09:49:46.000000000 +0200 @@ -0,0 +1,14 @@ +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: {{ include "app.fullname" . }}-myapp-pdb + labels: + app: nginx + {{- include "app.labels" . | nindent 4 }} +spec: + minAvailable: {{ .Values.myappPdb.minAvailable }} + maxUnavailable: {{ .Values.myappPdb.maxUnavailable }} + selector: + matchLabels: + app: nginx + {{- include "app.selectorLabels" . | nindent 6 }} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/examples/app/values.yaml new/helmify-0.4.7/examples/app/values.yaml --- old/helmify-0.4.6/examples/app/values.yaml 2023-09-27 12:13:24.000000000 +0200 +++ new/helmify-0.4.7/examples/app/values.yaml 2023-10-24 09:49:46.000000000 +0200 @@ -84,6 +84,8 @@ repository: gcr.io/kubebuilder/kube-rbac-proxy tag: v0.8.0 replicas: 3 +myappPdb: + minAvailable: 2 myappService: ports: - name: https diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/pkg/app/app.go new/helmify-0.4.7/pkg/app/app.go --- old/helmify-0.4.6/pkg/app/app.go 2023-09-27 12:13:24.000000000 +0200 +++ new/helmify-0.4.7/pkg/app/app.go 2023-10-24 09:49:46.000000000 +0200 @@ -2,14 +2,16 @@ import ( "context" - "github.com/arttor/helmify/pkg/file" - "github.com/arttor/helmify/pkg/processor/job" - "github.com/arttor/helmify/pkg/processor/statefulset" "io" "os" "os/signal" "syscall" + "github.com/arttor/helmify/pkg/file" + "github.com/arttor/helmify/pkg/processor/job" + "github.com/arttor/helmify/pkg/processor/poddisruptionbudget" + "github.com/arttor/helmify/pkg/processor/statefulset" + "github.com/sirupsen/logrus" "github.com/arttor/helmify/pkg/config" @@ -64,6 +66,7 @@ webhook.MutatingWebhook(), job.NewCron(), job.NewJob(), + poddisruptionbudget.New(), ).WithDefaultProcessor(processor.Default()) if len(config.Files) != 0 { file.Walk(config.Files, config.FilesRecursively, func(filename string, fileReader io.Reader) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/pkg/processor/poddisruptionbudget/pdb.go new/helmify-0.4.7/pkg/processor/poddisruptionbudget/pdb.go --- old/helmify-0.4.6/pkg/processor/poddisruptionbudget/pdb.go 1970-01-01 01:00:00.000000000 +0100 +++ new/helmify-0.4.7/pkg/processor/poddisruptionbudget/pdb.go 2023-10-24 09:49:46.000000000 +0200 @@ -0,0 +1,107 @@ +package poddisruptionbudget + +import ( + "bytes" + "fmt" + "io" + + "github.com/arttor/helmify/pkg/processor" + + "github.com/arttor/helmify/pkg/helmify" + yamlformat "github.com/arttor/helmify/pkg/yaml" + "github.com/iancoleman/strcase" + policyv1 "k8s.io/api/policy/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/yaml" +) + +const ( + pdbTempSpec = ` +spec: + minAvailable: {{ .Values.%[1]s.minAvailable }} + maxUnavailable: {{ .Values.%[1]s.maxUnavailable }} + selector: +%[2]s + {{- include "%[3]s.selectorLabels" . | nindent 6 }}` +) + +var pdbGVC = schema.GroupVersionKind{ + Group: "policy", + Version: "v1", + Kind: "PodDisruptionBudget", +} + +// New creates processor for k8s Service resource. +func New() helmify.Processor { + return &pdb{} +} + +type pdb struct{} + +// Process k8s Service object into template. Returns false if not capable of processing given resource type. +func (r pdb) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) { + if obj.GroupVersionKind() != pdbGVC { + return false, nil, nil + } + pdb := policyv1.PodDisruptionBudget{} + err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &pdb) + if err != nil { + return true, nil, fmt.Errorf("%w: unable to cast to pdb", err) + } + spec := pdb.Spec + values := helmify.Values{} + + meta, err := processor.ProcessObjMeta(appMeta, obj) + if err != nil { + return true, nil, err + } + + name := appMeta.TrimName(obj.GetName()) + nameCamel := strcase.ToLowerCamel(name) + + selector, _ := yaml.Marshal(pdb.Spec.Selector) + selector = yamlformat.Indent(selector, 4) + selector = bytes.TrimRight(selector, "\n ") + + if spec.MaxUnavailable != nil { + _, err := values.Add(spec.MaxUnavailable.IntValue(), nameCamel, "maxUnavailable") + if err != nil { + return true, nil, err + } + } + + if spec.MinAvailable != nil { + _, err := values.Add(spec.MinAvailable.IntValue(), nameCamel, "minAvailable") + if err != nil { + return true, nil, err + } + } + + res := meta + fmt.Sprintf(pdbTempSpec, nameCamel, selector, appMeta.ChartName()) + return true, &result{ + name: name, + data: res, + values: values, + }, nil +} + +type result struct { + name string + data string + values helmify.Values +} + +func (r *result) Filename() string { + return r.name + ".yaml" +} + +func (r *result) Values() helmify.Values { + return r.values +} + +func (r *result) Write(writer io.Writer) error { + _, err := writer.Write([]byte(r.data)) + return err +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/pkg/processor/poddisruptionbudget/pdb_test.go new/helmify-0.4.7/pkg/processor/poddisruptionbudget/pdb_test.go --- old/helmify-0.4.6/pkg/processor/poddisruptionbudget/pdb_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/helmify-0.4.7/pkg/processor/poddisruptionbudget/pdb_test.go 2023-10-24 09:49:46.000000000 +0200 @@ -0,0 +1,42 @@ +package poddisruptionbudget + +import ( + "os" + "testing" + + "github.com/arttor/helmify/pkg/metadata" + + "github.com/arttor/helmify/internal" + "github.com/stretchr/testify/assert" +) + +const pdbYaml = `apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + labels: + control-plane: controller-manager + name: my-operator-controller-manager-pdb + namespace: my-operator-system +spec: + minAvailable: 2 + selector: + matchLabels: + control-plane: controller-manager` + +func Test_pdb_Process(t *testing.T) { + var testInstance pdb + + t.Run("processed", func(t *testing.T) { + obj := internal.GenerateObj(pdbYaml) + processed, tt, err := testInstance.Process(&metadata.Service{}, obj) + _ = tt.Write(os.Stdout) + assert.NoError(t, err) + assert.Equal(t, true, processed) + }) + t.Run("skipped", func(t *testing.T) { + obj := internal.TestNs + processed, _, err := testInstance.Process(&metadata.Service{}, obj) + assert.NoError(t, err) + assert.Equal(t, false, processed) + }) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.4.6/test_data/sample-app.yaml new/helmify-0.4.7/test_data/sample-app.yaml --- old/helmify-0.4.6/test_data/sample-app.yaml 2023-09-27 12:13:24.000000000 +0200 +++ new/helmify-0.4.7/test_data/sample-app.yaml 2023-10-24 09:49:46.000000000 +0200 @@ -334,3 +334,15 @@ resources: requests: storage: 1Gi +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + labels: + app: nginx + name: myapp-pdb +spec: + minAvailable: 2 + selector: + matchLabels: + app: nginx ++++++ helmify.obsinfo ++++++ --- /var/tmp/diff_new_pack.Fn5cBD/_old 2023-10-24 20:09:11.562347094 +0200 +++ /var/tmp/diff_new_pack.Fn5cBD/_new 2023-10-24 20:09:11.566347239 +0200 @@ -1,5 +1,5 @@ name: helmify -version: 0.4.6 -mtime: 1695809604 -commit: aace0334e2e65744f781e897f124653738c4c7f3 +version: 0.4.7 +mtime: 1698133786 +commit: 8a688a5448fbadeb0072b1babd7905f8b276fb62 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/helmify/vendor.tar.gz /work/SRC/openSUSE:Factory/.helmify.new.24901/vendor.tar.gz differ: char 5, line 1
