diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..497beec --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,23 @@ +fail_fast: true +repos: +- repo: local + hooks: + - id: helm-docs + name: docs + entry: make + args: ["helm-docs"] + language: system + pass_filenames: false + - id: lint + name: lint + entry: make + args: ["lint-all"] + language: system + pass_filenames: false + - id: unit-test + name: unit-test + entry: make + args: ["unit-test-all"] + language: system + pass_filenames: false + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5786ce6 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [2020] Clastix Labs + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Makefile b/Makefile index 8564d9d..874eb98 100644 --- a/Makefile +++ b/Makefile @@ -5,11 +5,33 @@ helm-docs: HELMDOCS_VERSION := v1.11.0 helm-docs: docker @docker run -v "$(SRC_ROOT):/helm-docs" jnorwood/helm-docs:$(HELMDOCS_VERSION) --chart-search-root /helm-docs -lint: docker - @docker run -v "$(SRC_ROOT):/workdir" --entrypoint /bin/sh quay.io/helmpack/chart-testing:v3.3.1 -c cd /workdir && ct lint --config ./charts/ct.yaml --lint-conf ./charts/lint.yaml --all --debug - @docker run -v "$(SRC_ROOT):/workdir" --entrypoint /bin/sh quay.io/helmpack/chart-testing:v3.3.1 -c cd /workdir && ct lint --config ./examples/ct.yaml --all --debug +# Tested Versions +HELM_VERSIONS = v3.5.4 v3.6.3 v3.7.1 v3.8.2 -unit-test: docker +# Uses Helm Version as parameter (eg. make lint/v3.8.0) +.PHONY: lint +lint/%: docker + @echo "\n\033[0;31mLinting Helm Chart with Helm $(*)\033[0m\n" + @docker run -v "$(SRC_ROOT):/workdir" --entrypoint /bin/sh --platform linux/amd64 quay.io/helmpack/chart-testing:v3.3.1 \ + -c "curl -s https://get.helm.sh/helm-$*-linux-amd64.tar.gz | tar zx && mv linux-amd64/helm /usr/local/bin/helm && cd /workdir && ct lint --config ./charts/ct.yaml --lint-conf ./charts/lint.yaml --all --debug" + +# Lint all versions +lint-all: $(foreach HELM_VERSION,$(HELM_VERSIONS),lint/$(HELM_VERSION)) + +# Uses Helm Version as parameter (eg. make unit-test/v3.8.0) +.PHONY: unit-test +unit-test/%: docker helm-locks + @echo "\n\033[0;31mRunning unit tests for Helm $(*)\033[0m\n" + @docker run -v "$(SRC_ROOT):/workdir" --entrypoint /bin/sh --platform linux/amd64 quay.io/helmpack/chart-testing:v3.3.1 \ + -c "curl -s https://get.helm.sh/helm-$*-linux-amd64.tar.gz | tar zx && mv linux-amd64/helm /usr/local/bin/helm && cd /workdir && helm plugin install https://github.com/quintush/helm-unittest > /dev/null || true && ct lint --config ./examples/ct.yaml --lint-conf ./charts/lint.yaml --all --debug" + +# Unit test all versions +unit-test-all: $(foreach HELM_VERSION,$(HELM_VERSIONS),unit-test/$(HELM_VERSION)) + +# Remove Helm Locks +.PHONY: helm-locks +helm-locks: + find "$(SRC_ROOT)/examples" -name Chart.lock -type f -delete docker: @hash docker 2>/dev/null || {\ diff --git a/charts/ct.yaml b/charts/ct.yaml index 91b96c7..8ce7bd8 100644 --- a/charts/ct.yaml +++ b/charts/ct.yaml @@ -6,7 +6,8 @@ chart-dirs: - charts/ chart-repos: - buttahtoast=https://buttahtoast.github.io/helm-charts/ -validate-chart-schema: true +validate-chart-schema: false +check-version-increment: true validate-maintainers: true validate-yaml: true helm-extra-args: "--timeout 600s" diff --git a/charts/helmize/Chart.yaml b/charts/helmize/Chart.yaml index decc1b0..a2c0b8f 100644 --- a/charts/helmize/Chart.yaml +++ b/charts/helmize/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: helmize description: Go Sprig based deployment engine (GitOps Tool) type: library -version: "0.1.0" +version: "0.1.1" appVersion: "0.1.0" home: https://helmize.dev icon: https://raw.githubusercontent.com/buttahtoast/helmize/main/hugo/icon/icon.png @@ -18,4 +18,6 @@ maintainers: - name: oliverbaehler email: oliverbaehler@hotmail.com annotations: - artifacthub.io/prerelease: "false" \ No newline at end of file + artifacthub.io/prerelease: "false" + artifacthub.io/changes: | + - "[Fixed]: Skip empty files and do not throw an error" \ No newline at end of file diff --git a/charts/helmize/README.md b/charts/helmize/README.md index b07f5b9..8385d7e 100644 --- a/charts/helmize/README.md +++ b/charts/helmize/README.md @@ -1,6 +1,6 @@ # Helmize -![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) +![Version: 0.1.1](https://img.shields.io/badge/Version-0.1.1-informational?style=flat-square) ![Type: library](https://img.shields.io/badge/Type-library-informational?style=flat-square) ![AppVersion: 0.1.0](https://img.shields.io/badge/AppVersion-0.1.0-informational?style=flat-square) Helmize is a simple deployment library wrapped in a library helm chart. It's purpose is to simplify complex infrastructure deployments where you change deployed manifests based on given conditions. This project is thought for people that bootstrap complex infrastructure setup on kubernetes and want to simplify their file structure. diff --git a/charts/helmize/templates/config/_types.tpl b/charts/helmize/templates/config/_types.tpl index 4a1eeb4..530d216 100644 --- a/charts/helmize/templates/config/_types.tpl +++ b/charts/helmize/templates/config/_types.tpl @@ -10,7 +10,7 @@ {{ include "helmize.config.defaults.conditions" $ }}: types: [ "slice" ] {{ include "helmize.config.defaults.force" $ }}: - types: [ "bool", "int" ] + types: [ "bool" ] default: false {{ include "helmize.config.defaults.file_excludes" $ }}: types: [ "string", "slice" ] diff --git a/charts/helmize/templates/core/func/_train.tpl b/charts/helmize/templates/core/func/_train.tpl index a7f8530..32e3be3 100644 --- a/charts/helmize/templates/core/func/_train.tpl +++ b/charts/helmize/templates/core/func/_train.tpl @@ -232,9 +232,7 @@ {{/* Partial Files */}} {{- $_ := set $file "partial_files" $partial_files -}} - - {{- else -}} - {{- $_ := set $return "errors" (list (dict "error" "File not found or empty content" "file" $file_name)) -}} + {{- end -}} {{/* Benchmark */}} diff --git a/examples/example-customization/unit_tests/__snapshot__/snapshot_test.yaml.snap b/examples/example-customization/unit_tests/__snapshot__/snapshot_test.yaml.snap index c035a6c..563d9d0 100644 --- a/examples/example-customization/unit_tests/__snapshot__/snapshot_test.yaml.snap +++ b/examples/example-customization/unit_tests/__snapshot__/snapshot_test.yaml.snap @@ -1,62 +1,5 @@ -manifest snapshot: +Manifest snapshot: 1: | - apiVersion: apps/v1 - kind: DaemonSet - metadata: - labels: - app: web - name: octopus-deployment - spec: - selector: - matchLabels: - octopusexport: OctopusExport - template: - metadata: - labels: - app: web - octopusexport: OctopusExport - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - name: jmx - ports: - - containerPort: 9001 - name: jmx - updateStrategy: - type: RollingUpdate - 2: | apiVersion: apps/v1 kind: Deployment metadata: @@ -66,171 +9,7 @@ manifest snapshot: app: web new_label: existing_deploy name: octopus-deployment - spec: - replicas: 1 - selector: - matchLabels: - octopusexport: OctopusExport - strategy: - type: RollingUpdate - template: - metadata: - labels: - app: web - octopusexport: OctopusExport - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - name: jmx - ports: - - containerPort: 9001 - name: jmx - 3: | - apiVersion: v1 - kind: Pod - metadata: - labels: - app: web - name: octopus-deployment - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - name: jmx - ports: - - containerPort: 9001 - name: jmx - 4: | - apiVersion: apps/v1 - kind: StatefulSet - metadata: - labels: - app: web - k8s.io/inject_port: "true" - name: octopus-deployment - spec: - podManagementPolicy: OrderedReady - replicas: 1 - selector: - matchLabels: - octopusexport: OctopusExport - template: - metadata: - labels: - app: web - octopusexport: OctopusExport - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: EXISTING_VAR - value: Overwrite Value - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: injected - value: env - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - env: - - name: EXISTING_VAR - value: Overwrite Value - - name: injected - value: env - name: jmx - ports: - - containerPort: 9001 - name: jmx - updateStrategy: - type: RollingUpdate - 5: | + 2: | apiVersion: apps/v1 kind: Deployment metadata: @@ -289,11 +68,12 @@ manifest snapshot: ports: - containerPort: 9001 name: jmx -summary snapshot: +Summary snapshot: 1: | conditions: - config: allow_root: true + any: false key_types: - string - slice @@ -301,15 +81,14 @@ summary snapshot: data: sample: data errors: [] - keys: - - / + keys: [] name: resources - paths: - - structure/resources/ + paths: [] root_path: resources value: {} - config: allow_root: true + any: false data: sample: data default: resources @@ -329,80 +108,49 @@ summary snapshot: sample: data errors: [] keys: - - / - resources name: additional paths: - - structure/additional/ - structure/additional/resources/ root_path: additional value: resources errors: - error: No Kind Defined file: - - super + - deployment-octopus-deployment.yaml renderer: customization.renderers.sidecar + paths: + - config: + fork: false + no_match: append + pattern: false + render: true + subpath: false + data: + sample: data + paths: + - structure/additional/resources/ + renderers: + - customization.renderers.additional + value: resources wagons: - - checksum: 78ff2c4e51363e2cc309b526aa8d36a1ae6fe33808c21c901f0d56fd2e1750ba + - checksum: e11bccee8d1ffab55dbbc4a799e4e8aade095385c611c747b043a1b839d41679 content: apiVersion: apps/v1 - kind: DaemonSet + kind: Deployment metadata: labels: + additional_label1: value_1 + additional_label2: value2 app: web + new_label: existing_deploy name: octopus-deployment - spec: - selector: - matchLabels: - octopusexport: OctopusExport - template: - metadata: - labels: - app: web - octopusexport: OctopusExport - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - name: jmx - ports: - - containerPort: 9001 - name: jmx - updateStrategy: - type: RollingUpdate debug: [] - errors: [] + errors: + - error: No Kind Defined + file: + - deployment-octopus-deployment.yaml + renderer: customization.renderers.sidecar files: - _order: 0 config: @@ -410,23 +158,25 @@ summary snapshot: no_match: append pattern: false render: true - subpath: true + subpath: false data: sample: data - file: structure/resources/daemonset.yaml + file: structure/additional/resources/existing_deploy.yaml ids: - - daemonset-octopus-deployment.yaml - path: structure/resources/ - renderers: [] - value: {} + - deployment-octopus-deployment.yaml + path: structure/additional/resources/ + renderers: + - customization.renderers.additional + value: resources id: - - daemonset-octopus-deployment.yaml + - deployment-octopus-deployment.yaml render: true renderers: + - customization.renderers.additional - customization.renderers.sidecar - customization.renderers.env subpath: . - - checksum: 45f608708a5e392398e86f5606ea0319d565c9e34bf39cd45ff68161d63d8347 + - checksum: a3bcc618b14cc676702197947ed522014f5f3835884c42a3c8915bcfd9e6a97f content: apiVersion: apps/v1 kind: Deployment @@ -435,20 +185,18 @@ summary snapshot: additional_label1: value_1 additional_label2: value2 app: web - new_label: existing_deploy - name: octopus-deployment + name: new-deployment spec: replicas: 1 selector: matchLabels: - octopusexport: OctopusExport + app: new-deployment strategy: type: RollingUpdate template: metadata: labels: - app: web - octopusexport: OctopusExport + app: new-deployment spec: affinity: podAntiAffinity: @@ -492,21 +240,6 @@ summary snapshot: errors: [] files: - _order: 1 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: true - data: - sample: data - file: structure/resources/deploy.yaml - ids: - - deployment-octopus-deployment.yaml - path: structure/resources/ - renderers: [] - value: {} - - _order: 5 config: fork: false no_match: append @@ -515,359 +248,7 @@ summary snapshot: subpath: false data: sample: data - file: structure/additional/resources/existing_deploy.yaml - ids: - - deployment-octopus-deployment.yaml - path: structure/additional/ - renderers: - - customization.renderers.additional - value: resources - - _order: 7 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: false - data: - sample: data - file: structure/additional/resources/existing_deploy.yaml - ids: - - deployment-octopus-deployment.yaml - path: structure/additional/resources/ - renderers: - - customization.renderers.additional - value: resources - id: - - deployment-octopus-deployment.yaml - render: true - renderers: - - customization.renderers.additional - - customization.renderers.sidecar - - customization.renderers.env - subpath: . - - checksum: ee92be1d80df1ceba397f956d633a6c7a9e116de3cfaa10c91fbc5fadf8b7239 - content: - apiVersion: v1 - metadata: - labels: - app: web - render: "false" - name: octopus-deployment - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - debug: - - debug: super is a super identifier - identifier-template: customization.identifier.template - errors: - - error: No Kind Defined - file: - - super - renderer: customization.renderers.sidecar - files: - - _order: 2 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: true - data: - sample: data - file: structure/resources/no-kind.yaml - ids: - - super - path: structure/resources/ - renderers: [] - value: {} - id: - - super - render: true - renderers: - - customization.renderers.sidecar - - customization.renderers.env - subpath: . - - checksum: 3229288b236dfb437d25a8fa2af6ec93b4b90a1f916a79447be91771556cbbf1 - content: - apiVersion: v1 - kind: Pod - metadata: - labels: - app: web - name: octopus-deployment - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - name: jmx - ports: - - containerPort: 9001 - name: jmx - debug: [] - errors: [] - files: - - _order: 3 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: true - data: - sample: data - file: structure/resources/pod.yaml - ids: - - pod-octopus-deployment.yaml - path: structure/resources/ - renderers: [] - value: {} - id: - - pod-octopus-deployment.yaml - render: true - renderers: - - customization.renderers.sidecar - - customization.renderers.env - subpath: . - - checksum: 2f6c2dd291aff4e399854a468a3cc8f1a752724e5b5dc22b104982e04dc624ee - content: - apiVersion: apps/v1 - kind: StatefulSet - metadata: - labels: - app: web - k8s.io/inject_port: "true" - name: octopus-deployment - spec: - podManagementPolicy: OrderedReady - replicas: 1 - selector: - matchLabels: - octopusexport: OctopusExport - template: - metadata: - labels: - app: web - octopusexport: OctopusExport - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: EXISTING_VAR - value: Overwrite Value - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: injected - value: env - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - env: - - name: EXISTING_VAR - value: Overwrite Value - - name: injected - value: env - name: jmx - ports: - - containerPort: 9001 - name: jmx - updateStrategy: - type: RollingUpdate - debug: - - debug: statefulset/octopus-deployment/nginx injected labels - renderer: customization.renderers.env - - debug: statefulset/octopus-deployment/jmx injected labels - renderer: customization.renderers.env - errors: [] - files: - - _order: 4 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: true - data: - sample: data - file: structure/resources/statefulset.yaml - ids: - - statefulset-octopus-deployment.yaml - path: structure/resources/ - renderers: [] - value: {} - id: - - statefulset-octopus-deployment.yaml - render: true - renderers: - - customization.renderers.sidecar - - customization.renderers.env - subpath: . - - checksum: a3bcc618b14cc676702197947ed522014f5f3835884c42a3c8915bcfd9e6a97f - content: - apiVersion: apps/v1 - kind: Deployment - metadata: - labels: - additional_label1: value_1 - additional_label2: value2 - app: web - name: new-deployment - spec: - replicas: 1 - selector: - matchLabels: - app: new-deployment - strategy: - type: RollingUpdate - template: - metadata: - labels: - app: new-deployment - spec: - affinity: - podAntiAffinity: - preferredDuringSchedulingIgnoredDuringExecution: - - podAffinityTerm: - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - web - topologyKey: kubernetes.io/hostname - weight: 100 - containers: - - env: - - name: DEMO_GREETING - value: Hello from the environment - - name: DEMO_FAREWELL - value: Such a sweet sorrow - - name: EXISTING_VAR - value: Some existing value - image: nginx - name: nginx - ports: - - containerPort: 80 - - command: - - java - - -XX:+UnlockExperimentalVMOptions - - -XX:+UseCGroupMemoryLimitForHeap - - -XX:MaxRAMFraction=1 - - -XshowSettings:vm - - -jar - - jmx_prometheus_httpserver.jar - - "90001" - - /opt/jmx-config/jmx-prometheus.yml - name: jmx - ports: - - containerPort: 9001 - name: jmx - debug: [] - errors: [] - files: - - _order: 6 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: false - data: - sample: data - file: structure/additional/resources/new_deploy.yaml - ids: - - deployment-new-deployment.yaml - path: structure/additional/ - renderers: - - customization.renderers.additional - value: resources - - _order: 8 - config: - fork: false - no_match: append - pattern: false - render: true - subpath: false - data: - sample: data - file: structure/additional/resources/new_deploy.yaml + file: structure/additional/resources/new_deploy.yaml ids: - deployment-new-deployment.yaml path: structure/additional/resources/ @@ -881,4 +262,4 @@ summary snapshot: - customization.renderers.additional - customization.renderers.sidecar - customization.renderers.env - subpath: resources + subpath: . diff --git a/examples/example-data/structure/layer_1/layer1-empty.yaml b/examples/example-data/structure/layer_1/layer1-empty.yaml new file mode 100644 index 0000000..73b314f --- /dev/null +++ b/examples/example-data/structure/layer_1/layer1-empty.yaml @@ -0,0 +1 @@ +--- \ No newline at end of file diff --git a/examples/example-data/structure/layer_2/layer2-empty.yaml b/examples/example-data/structure/layer_2/layer2-empty.yaml new file mode 100644 index 0000000..73b314f --- /dev/null +++ b/examples/example-data/structure/layer_2/layer2-empty.yaml @@ -0,0 +1 @@ +--- \ No newline at end of file diff --git a/examples/example-data/structure/layer_3/layer3-empty.yaml b/examples/example-data/structure/layer_3/layer3-empty.yaml new file mode 100644 index 0000000..73b314f --- /dev/null +++ b/examples/example-data/structure/layer_3/layer3-empty.yaml @@ -0,0 +1 @@ +--- \ No newline at end of file diff --git a/examples/example-data/unit_tests/__snapshot__/snapshot_test.yaml.snap b/examples/example-data/unit_tests/__snapshot__/snapshot_test.yaml.snap index 128fcd9..e7396bf 100644 --- a/examples/example-data/unit_tests/__snapshot__/snapshot_test.yaml.snap +++ b/examples/example-data/unit_tests/__snapshot__/snapshot_test.yaml.snap @@ -236,13 +236,45 @@ Summary snapshot: render: true renderers: [] subpath: . + - content: {} + debug: [] + errors: [] + files: + - _order: 1 + config: + fork: false + no_match: append + pattern: false + render: true + subpath: true + data: + class: vertical-class + domain: east.vertical.public.domain + layer_1: + overwrite: this + remove: false + layer_2: + sampler: true + layer_3: + other: true + file: structure/layer_1/layer1-empty.yaml + ids: + - layer1-empty.yaml + path: structure/layer_1/ + renderers: [] + value: {} + id: + - layer1-empty.yaml + render: true + renderers: [] + subpath: . - checksum: e73ebdb9a8d141b5b7fd2885c1fc044a74312adfa47b70189418953dc5d1d0a3 content: Value: {} debug: [] errors: [] files: - - _order: 1 + - _order: 2 config: fork: false no_match: append @@ -287,7 +319,7 @@ Summary snapshot: debug: [] errors: [] files: - - _order: 2 + - _order: 3 config: fork: false no_match: append @@ -315,13 +347,45 @@ Summary snapshot: render: true renderers: [] subpath: . + - content: {} + debug: [] + errors: [] + files: + - _order: 4 + config: + fork: false + no_match: append + pattern: false + render: true + subpath: true + data: + class: vertical-class + domain: east.vertical.public.domain + layer_1: + overwrite: this + remove: false + layer_2: + sampler: true + layer_3: + other: true + file: structure/layer_2/layer2-empty.yaml + ids: + - layer2-empty.yaml + path: structure/layer_2/ + renderers: [] + value: east + id: + - layer2-empty.yaml + render: true + renderers: [] + subpath: . - checksum: 1f029017f09741e3e8d36030a34d3d3b8663b008b1588eedf886c973af280b84 content: Value: east debug: [] errors: [] files: - - _order: 3 + - _order: 5 config: fork: false no_match: append @@ -366,7 +430,7 @@ Summary snapshot: debug: [] errors: [] files: - - _order: 4 + - _order: 6 config: fork: false no_match: append @@ -394,13 +458,45 @@ Summary snapshot: render: true renderers: [] subpath: . + - content: {} + debug: [] + errors: [] + files: + - _order: 7 + config: + fork: false + no_match: append + pattern: false + render: true + subpath: true + data: + class: vertical-class + domain: east.vertical.public.domain + layer_1: + overwrite: this + remove: false + layer_2: + sampler: true + layer_3: + other: true + file: structure/layer_3/layer3-empty.yaml + ids: + - layer3-empty.yaml + path: structure/layer_3/ + renderers: [] + value: {} + id: + - layer3-empty.yaml + render: true + renderers: [] + subpath: . - checksum: e73ebdb9a8d141b5b7fd2885c1fc044a74312adfa47b70189418953dc5d1d0a3 content: Value: {} debug: [] errors: [] files: - - _order: 5 + - _order: 8 config: fork: false no_match: append diff --git a/examples/example-identifiers/unit_tests/__snapshot__/snapshot_test.yaml.snap b/examples/example-identifiers/unit_tests/__snapshot__/snapshot_test.yaml.snap index c198fb0..4951dff 100644 --- a/examples/example-identifiers/unit_tests/__snapshot__/snapshot_test.yaml.snap +++ b/examples/example-identifiers/unit_tests/__snapshot__/snapshot_test.yaml.snap @@ -1,4 +1,4 @@ -manifest snapshot: +Manifest snapshot: 1: | apiVersion: apps/v1 kind: Deployment @@ -316,7 +316,7 @@ manifest snapshot: targetPort: 80 selector: app: nginx -summary snapshot: +Summary snapshot: 1: | conditions: - config: diff --git a/examples/reference/unit_tests/__snapshot__/snapshot_test.yaml.snap b/examples/reference/unit_tests/__snapshot__/snapshot_test.yaml.snap index 887ceee..c7c154e 100644 --- a/examples/reference/unit_tests/__snapshot__/snapshot_test.yaml.snap +++ b/examples/reference/unit_tests/__snapshot__/snapshot_test.yaml.snap @@ -1,4 +1,4 @@ -'[Reference]: Manifest Snapshot': +Manifest snapshot: 1: | apiVersion: apps/v1 kind: Deployment @@ -133,7 +133,7 @@ - hosts: - frontend.test.east.company.com secretName: frontend-tls -'[Reference]: Summary Snapshot': +Summary snapshot: 1: | conditions: - config: