From 8afc3a3f49df4e978abc4f77c107fadd808fb0e0 Mon Sep 17 00:00:00 2001 From: Jesus Parada Date: Mon, 13 Nov 2023 18:34:42 -0600 Subject: [PATCH 1/2] FOPTS-2224 The MD5 hash of the files is verified to ensure the integrity of the uploaded files --- CHANGELOG.md | 4 +++ README.md | 2 +- helm-chart/Chart.yaml | 4 +-- helm-chart/README.md | 4 +-- helm-chart/cbi-oi-kubecost-exporter-1.7.0.tgz | Bin 0 -> 4421 bytes helm-chart/values.yaml | 2 +- index.yaml | 28 +++++++++++----- main.go | 31 ++++++++++++++++++ 8 files changed, 60 insertions(+), 15 deletions(-) create mode 100644 helm-chart/cbi-oi-kubecost-exporter-1.7.0.tgz diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d6eef..749d0de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## v1.7 + +- The MD5 hash of the files is verified to ensure the integrity of the uploaded files. + ## v1.6 - Save two months of cvs files instead of only current month. diff --git a/README.md b/README.md index a1b79f5..28ebe5d 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ You should see 200/201s in the logs, which indicates that the exporter is workin | flexera.shard | string | `"NAM"` | Shard ("NAM", "EU", "AU") | | image.pullPolicy | string | `"Always"` | | | image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | | -| image.tag | string | `"1.6"` | | +| image.tag | string | `"1.7"` | | | imagePullSecrets | list | `[]` | | | includePreviousMonth | bool | `false` | Include data from previous month to the export process, only if we have files from every day of the previous month. | | kubecost.aggregation | string | `"pod"` | Aggregation Level ("namespace", "controller", "pod") | diff --git a/helm-chart/Chart.yaml b/helm-chart/Chart.yaml index 7d8694e..364f9ea 100644 --- a/helm-chart/Chart.yaml +++ b/helm-chart/Chart.yaml @@ -6,10 +6,10 @@ description: Kubecost exporter helm chart for Kubernetes # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.6.0 +version: 1.7.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.6" +appVersion: "1.7" diff --git a/helm-chart/README.md b/helm-chart/README.md index 5cf9b3f..2f62ee3 100644 --- a/helm-chart/README.md +++ b/helm-chart/README.md @@ -1,6 +1,6 @@ # cbi-oi-kubecost-exporter -![Version: 1.6.0](https://img.shields.io/badge/Version-1.6.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.6](https://img.shields.io/badge/AppVersion-1.6-informational?style=flat-square) +![Version: 1.7.0](https://img.shields.io/badge/Version-1.7.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.7](https://img.shields.io/badge/AppVersion-1.7-informational?style=flat-square) ### Kubecost exporter helm chart for Kubernetes @@ -94,7 +94,7 @@ You should see 200/201s in the logs, which indicates that the exporter is workin | flexera.shard | string | `"NAM"` | Shard ("NAM", "EU", "AU") | | image.pullPolicy | string | `"Always"` | | | image.repository | string | `"public.ecr.aws/flexera/cbi-oi-kubecost-exporter"` | | -| image.tag | string | `"1.6"` | | +| image.tag | string | `"1.7"` | | | imagePullSecrets | list | `[]` | | | includePreviousMonth | bool | `false` | Include data from previous month to the export process, only if we have files from every day of the previous month. | | kubecost.aggregation | string | `"pod"` | Aggregation Level ("namespace", "controller", "pod") | diff --git a/helm-chart/cbi-oi-kubecost-exporter-1.7.0.tgz b/helm-chart/cbi-oi-kubecost-exporter-1.7.0.tgz new file mode 100644 index 0000000000000000000000000000000000000000..a90c6ee9754575c181915e984c10e61283160da6 GIT binary patch literal 4421 zcmV-L5xVXliwG0|00000|0w_~VMtOiV@ORlOnEsqVl!4SWK%V1T2nbTPgYhoO;>Dc zVQyr3R8em|NM&qo0PH;dbK5ws`?LNEtn+TB&8y{)e7*I&-WxY@+g$TCa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gl`3OkP?Ow9vK!S0R&Z zP95e7iYyR>pLg((-%#tKE6H{nzOq$PCEh(Aix zD=L80B*up!roS~-fU{w(3h2V`kY$jYSo$WGzKNx8V(FV$`X-jXiKTC1>3@+}dX>v1 z@O?ssxh2XzdPOg&%0V;c?IAdAu Date: Mon, 13 Nov 2023 19:54:04 -0600 Subject: [PATCH 2/2] FOPTS-2224 Added unit tests for md5 hash from File Bytes --- main_test.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main_test.go b/main_test.go index 02adc94..f58f586 100644 --- a/main_test.go +++ b/main_test.go @@ -1,6 +1,7 @@ package main import ( + "encoding/hex" "encoding/json" "os" "reflect" @@ -488,3 +489,25 @@ func TestApp_DaysInMonth(t *testing.T) { }) } } + +func TestGetMD5FromFileBytes(t *testing.T) { + // Define a test case with an input byte slice and the expected MD5 hash + testCases := []struct { + input []byte + expected string + }{ + {[]byte("Hello, World!"), "65a8e27d8879283831b664bd8b7f0ad4"}, + {[]byte("12345"), "827ccb0eea8a706c4c34a16891f84e7b"}, + {[]byte(""), "d41d8cd98f00b204e9800998ecf8427e"}, + {[]byte("*/&!"), "e720300025e73ebfd5320f06e5e1919a"}, + } + + for _, testCase := range testCases { + t.Run(hex.EncodeToString(testCase.input), func(t *testing.T) { + result := getMD5FromFileBytes(testCase.input) + if result != testCase.expected { + t.Errorf("Expected: %s, Got: %s", testCase.expected, result) + } + }) + } +}