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-03-24 15:21:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/helmify (Old) and /work/SRC/openSUSE:Factory/.helmify.new.31432 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "helmify" Fri Mar 24 15:21:28 2023 rev:5 rq:1074070 version:0.3.33 Changes: -------- --- /work/SRC/openSUSE:Factory/helmify/helmify.changes 2023-03-22 22:32:38.958799238 +0100 +++ /work/SRC/openSUSE:Factory/.helmify.new.31432/helmify.changes 2023-03-24 15:21:44.823302766 +0100 @@ -1,0 +2,7 @@ +Fri Mar 24 05:41:38 UTC 2023 - ka...@b1-systems.de + +- Update to version 0.3.33: + * support StatefulSet + * update supported resources + +------------------------------------------------------------------- Old: ---- helmify-0.3.32.obscpio New: ---- helmify-0.3.33.obscpio ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ helmify.spec ++++++ --- /var/tmp/diff_new_pack.WBE9Mi/_old 2023-03-24 15:21:45.563306624 +0100 +++ /var/tmp/diff_new_pack.WBE9Mi/_new 2023-03-24 15:21:45.567306645 +0100 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: helmify -Version: 0.3.32 +Version: 0.3.33 Release: 0 Summary: Creates Helm chart from Kubernetes yaml License: MIT ++++++ _service ++++++ --- /var/tmp/diff_new_pack.WBE9Mi/_old 2023-03-24 15:21:45.603306834 +0100 +++ /var/tmp/diff_new_pack.WBE9Mi/_new 2023-03-24 15:21:45.611306875 +0100 @@ -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.3.32</param> + <param name="revision">v0.3.33</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.WBE9Mi/_old 2023-03-24 15:21:45.631306979 +0100 +++ /var/tmp/diff_new_pack.WBE9Mi/_new 2023-03-24 15:21:45.635307001 +0100 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/arttor/helmify/</param> - <param name="changesrevision">64081304dcc4a5cde8e0c038c78ebf709f95ad6a</param></service></servicedata> + <param name="changesrevision">f9a41896286bb996f954e2bcf1641ec04d2d0745</param></service></servicedata> (No newline at EOF) ++++++ helmify-0.3.32.obscpio -> helmify-0.3.33.obscpio ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/README.md new/helmify-0.3.33/README.md --- old/helmify-0.3.32/README.md 2023-03-22 14:21:38.000000000 +0100 +++ new/helmify-0.3.33/README.md 2023-03-23 16:15:12.000000000 +0100 @@ -89,14 +89,14 @@ ## Status Supported k8s resources: -- deployment -- daemonset -- service, Ingress +- Deployment, DaemonSet, StatefulSet +- Job, CronJob +- Service, Ingress - PersistentVolumeClaim -- RBAC (serviceaccount, (cluster-)role, (cluster-)rolebinding) -- configs (configmap, secret) +- RBAC (ServiceAccount, (cluster-)role, (cluster-)roleBinding) +- configs (ConfigMap, Secret) - webhooks (cert, issuer, ValidatingWebhookConfiguration) -- custom resource definitions +- custom resource definitions (CRD) ### Known issues - Helmify will not overwrite `Chart.yaml` file if presented. Done on purpose. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/examples/app/templates/nginx.yaml new/helmify-0.3.33/examples/app/templates/nginx.yaml --- old/helmify-0.3.32/examples/app/templates/nginx.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helmify-0.3.33/examples/app/templates/nginx.yaml 2023-03-23 16:15:12.000000000 +0100 @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "app.fullname" . }}-nginx + labels: + app: nginx + {{- include "app.labels" . | nindent 4 }} +spec: + type: {{ .Values.nginx.type }} + selector: + app: nginx + {{- include "app.selectorLabels" . | nindent 4 }} + ports: + {{- .Values.nginx.ports | toYaml | nindent 2 -}} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/examples/app/templates/statefulset.yaml new/helmify-0.3.33/examples/app/templates/statefulset.yaml --- old/helmify-0.3.32/examples/app/templates/statefulset.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helmify-0.3.33/examples/app/templates/statefulset.yaml 2023-03-23 16:15:12.000000000 +0100 @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "app.fullname" . }}-web + labels: + {{- include "app.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.web.replicas }} + selector: + matchLabels: + app: nginx + serviceName: {{ include "app.fullname" . }}-nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - env: + - name: KUBERNETES_CLUSTER_DOMAIN + value: {{ quote .Values.kubernetesClusterDomain }} + image: {{ .Values.web.nginx.image.repository }}:{{ .Values.web.nginx.image.tag + | default .Chart.AppVersion }} + name: nginx + ports: + - containerPort: 80 + name: web + resources: {} + volumeMounts: + - mountPath: /usr/share/nginx/html + name: www + updateStrategy: {} + volumeClaimTemplates: + - metadata: + creationTimestamp: null + name: www + spec: + accessModes: + - ReadWriteOnce + resources: {{ .Values.web.volumeClaims.www | toYaml | nindent 8 }} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/examples/app/values.yaml new/helmify-0.3.33/examples/app/values.yaml --- old/helmify-0.3.32/examples/app/values.yaml 2023-03-22 14:21:38.000000000 +0100 +++ new/helmify-0.3.33/examples/app/values.yaml 2023-03-23 16:15:12.000000000 +0100 @@ -79,8 +79,24 @@ port: 8443 targetPort: https type: ClusterIP +nginx: + ports: + - name: web + port: 80 + targetPort: 0 + type: ClusterIP pvc: mySamplePvClaim: storageClass: manual storageLimit: 5Gi storageRequest: 3Gi +web: + nginx: + image: + repository: registry.k8s.io/nginx-slim + tag: "0.8" + replicas: 2 + volumeClaims: + www: + requests: + storage: 1Gi diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/pkg/app/app.go new/helmify-0.3.33/pkg/app/app.go --- old/helmify-0.3.32/pkg/app/app.go 2023-03-22 14:21:38.000000000 +0100 +++ new/helmify-0.3.33/pkg/app/app.go 2023-03-23 16:15:12.000000000 +0100 @@ -3,6 +3,7 @@ import ( "context" "github.com/arttor/helmify/pkg/processor/job" + "github.com/arttor/helmify/pkg/processor/statefulset" "io" "os" "os/signal" @@ -48,6 +49,7 @@ crd.New(), daemonset.New(), deployment.New(), + statefulset.New(), storage.New(), service.New(), service.NewIngress(), diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/pkg/helmify/values.go new/helmify-0.3.33/pkg/helmify/values.go --- old/helmify-0.3.32/pkg/helmify/values.go 2023-03-22 14:21:38.000000000 +0100 +++ new/helmify-0.3.33/pkg/helmify/values.go 2023-03-23 16:15:12.000000000 +0100 @@ -54,13 +54,16 @@ // AddYaml - adds given value to values and returns its helm template representation as Yaml {{ .Values.<valueName> | toYaml | indent i }} // indent <= 0 will be omitted. -func (v *Values) AddYaml(value interface{}, indent int, name ...string) (string, error) { +func (v *Values) AddYaml(value interface{}, indent int, newLine bool, name ...string) (string, error) { name = toCamelCase(name) err := unstructured.SetNestedField(*v, value, name...) if err != nil { return "", errors.Wrapf(err, "unable to set value: %v", name) } if indent > 0 { + if newLine { + return "{{ .Values." + strings.Join(name, ".") + fmt.Sprintf(" | toYaml | nindent %d }}", indent), nil + } return "{{ .Values." + strings.Join(name, ".") + fmt.Sprintf(" | toYaml | indent %d }}", indent), nil } return "{{ .Values." + strings.Join(name, ".") + " | toYaml }}", nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/pkg/processor/configmap/configmap.go new/helmify-0.3.33/pkg/processor/configmap/configmap.go --- old/helmify-0.3.32/pkg/processor/configmap/configmap.go 2023-03-22 14:21:38.000000000 +0100 +++ new/helmify-0.3.33/pkg/processor/configmap/configmap.go 2023-03-23 16:15:12.000000000 +0100 @@ -104,7 +104,7 @@ } if strings.Contains(value, "\n") { value = format.RemoveTrailingWhitespaces(value) - templatedVal, err := values.AddYaml(value, 1, valuesNamePath...) + templatedVal, err := values.AddYaml(value, 1, false, valuesNamePath...) if err != nil { logrus.WithError(err).Errorf("unable to process multiline configmap data: %v", valuesNamePath) continue diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/pkg/processor/statefulset/statefulset.go new/helmify-0.3.33/pkg/processor/statefulset/statefulset.go --- old/helmify-0.3.32/pkg/processor/statefulset/statefulset.go 1970-01-01 01:00:00.000000000 +0100 +++ new/helmify-0.3.33/pkg/processor/statefulset/statefulset.go 2023-03-23 16:15:12.000000000 +0100 @@ -0,0 +1,160 @@ +package statefulset + +import ( + "github.com/arttor/helmify/pkg/processor/pod" + "io" + "strings" + "text/template" + + "github.com/arttor/helmify/pkg/helmify" + "github.com/arttor/helmify/pkg/processor" + yamlformat "github.com/arttor/helmify/pkg/yaml" + "github.com/iancoleman/strcase" + "github.com/pkg/errors" + appsv1 "k8s.io/api/apps/v1" + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var statefulsetGVC = schema.GroupVersionKind{ + Group: "apps", + Version: "v1", + Kind: "StatefulSet", +} + +var statefulsetTempl, _ = template.New("statefulset").Parse( + `{{- .Meta }} +spec: +{{ .Spec }}`) + +// New creates processor for k8s StatefulSet resource. +func New() helmify.Processor { + return &statefulset{} +} + +type statefulset struct{} + +// Process k8s StatefulSet object into template. Returns false if not capable of processing given resource type. +func (d statefulset) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstructured) (bool, helmify.Template, error) { + if obj.GroupVersionKind() != statefulsetGVC { + return false, nil, nil + } + ss := appsv1.StatefulSet{} + err := runtime.DefaultUnstructuredConverter.FromUnstructured(obj.Object, &ss) + if err != nil { + return true, nil, errors.Wrap(err, "unable to cast to StatefulSet") + } + meta, err := processor.ProcessObjMeta(appMeta, obj) + if err != nil { + return true, nil, err + } + + ssSpec := ss.Spec + ssSpecMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&ssSpec) + if err != nil { + return true, nil, err + } + delete((ssSpecMap["template"].(map[string]interface{}))["metadata"].(map[string]interface{}), "creationTimestamp") + + values := helmify.Values{} + + name := appMeta.TrimName(obj.GetName()) + nameCamel := strcase.ToLowerCamel(name) + + if ssSpec.ServiceName != "" { + servName := appMeta.TemplatedName(ssSpec.ServiceName) + ssSpecMap["serviceName"] = servName + } + + if ssSpec.Replicas != nil { + repl, err := values.Add(*ssSpec.Replicas, nameCamel, "replicas") + if err != nil { + return true, nil, err + } + ssSpecMap["replicas"] = repl + } + + for i, claim := range ssSpec.VolumeClaimTemplates { + volName := claim.ObjectMeta.Name + delete(((ssSpecMap["volumeClaimTemplates"].([]interface{}))[i]).(map[string]interface{}), "status") + if claim.Spec.StorageClassName != nil { + scName := appMeta.TemplatedName(*claim.Spec.StorageClassName) + err = unstructured.SetNestedField(((ssSpecMap["volumeClaimTemplates"].([]interface{}))[i]).(map[string]interface{}), scName, "spec", "storageClassName") + if err != nil { + return true, nil, err + } + } + if claim.Spec.VolumeName != "" { + vName := appMeta.TemplatedName(claim.Spec.VolumeName) + err = unstructured.SetNestedField(((ssSpecMap["volumeClaimTemplates"].([]interface{}))[i]).(map[string]interface{}), vName, "spec", "volumeName") + if err != nil { + return true, nil, err + } + } + + resMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&claim.Spec.Resources) + if err != nil { + return true, nil, err + } + resName, err := values.AddYaml(resMap, 8, true, nameCamel, "volumeClaims", volName) + if err != nil { + return true, nil, err + } + err = unstructured.SetNestedField(((ssSpecMap["volumeClaimTemplates"].([]interface{}))[i]).(map[string]interface{}), resName, "spec", "resources") + if err != nil { + return true, nil, err + } + } + + // process pod spec: + podSpecMap, podValues, err := pod.ProcessSpec(nameCamel, appMeta, ssSpec.Template.Spec) + if err != nil { + return true, nil, err + } + err = values.Merge(podValues) + if err != nil { + return true, nil, err + } + err = unstructured.SetNestedMap(ssSpecMap, podSpecMap, "template", "spec") + if err != nil { + return true, nil, err + } + + spec, err := yamlformat.Marshal(ssSpecMap, 2) + if err != nil { + return true, nil, err + } + spec = strings.ReplaceAll(spec, "'", "") + + return true, &result{ + values: values, + data: struct { + Meta string + Spec string + }{ + Meta: meta, + Spec: spec, + }, + }, nil +} + +type result struct { + data struct { + Meta string + Spec string + } + values helmify.Values +} + +func (r *result) Filename() string { + return "statefulset.yaml" +} + +func (r *result) Values() helmify.Values { + return r.values +} + +func (r *result) Write(writer io.Writer) error { + return statefulsetTempl.Execute(writer, r.data) +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helmify-0.3.32/test_data/sample-app.yaml new/helmify-0.3.33/test_data/sample-app.yaml --- old/helmify-0.3.32/test_data/sample-app.yaml 2023-03-22 14:21:38.000000000 +0100 +++ new/helmify-0.3.33/test_data/sample-app.yaml 2023-03-23 16:15:12.000000000 +0100 @@ -282,4 +282,51 @@ - /bin/sh - -c - date; echo Hello from the Kubernetes cluster - restartPolicy: OnFailure \ No newline at end of file + restartPolicy: OnFailure +--- +apiVersion: v1 +kind: Service +metadata: + name: nginx + labels: + app: nginx +spec: + ports: + - port: 80 + name: web + clusterIP: None + selector: + app: nginx +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: web +spec: + serviceName: "nginx" + replicas: 2 + selector: + matchLabels: + app: nginx + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: registry.k8s.io/nginx-slim:0.8 + ports: + - containerPort: 80 + name: web + volumeMounts: + - name: www + mountPath: /usr/share/nginx/html + volumeClaimTemplates: + - metadata: + name: www + spec: + accessModes: [ "ReadWriteOnce" ] + resources: + requests: + storage: 1Gi ++++++ helmify.obsinfo ++++++ --- /var/tmp/diff_new_pack.WBE9Mi/_old 2023-03-24 15:21:45.795307834 +0100 +++ /var/tmp/diff_new_pack.WBE9Mi/_new 2023-03-24 15:21:45.799307855 +0100 @@ -1,5 +1,5 @@ name: helmify -version: 0.3.32 -mtime: 1679491298 -commit: 64081304dcc4a5cde8e0c038c78ebf709f95ad6a +version: 0.3.33 +mtime: 1679584512 +commit: f9a41896286bb996f954e2bcf1641ec04d2d0745 ++++++ vendor.tar.gz ++++++ /work/SRC/openSUSE:Factory/helmify/vendor.tar.gz /work/SRC/openSUSE:Factory/.helmify.new.31432/vendor.tar.gz differ: char 5, line 1