From e87b2fce58e5c3bcf8371eb969f07b797a5f51e4 Mon Sep 17 00:00:00 2001 From: linoleparquet Date: Tue, 19 Sep 2023 17:11:04 -0400 Subject: [PATCH 1/3] fix(rss2twitter): fix templating and add unit tests (#663) --- charts/rss2twitter/README.md | 9 +++++ charts/rss2twitter/tests/defaults_test.yaml | 39 +++++++++++++++++++ .../tests/secrets_default_values.yaml | 5 +++ charts/rss2twitter/values.yaml | 8 +++- 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 charts/rss2twitter/README.md create mode 100644 charts/rss2twitter/tests/defaults_test.yaml create mode 100644 charts/rss2twitter/tests/secrets_default_values.yaml diff --git a/charts/rss2twitter/README.md b/charts/rss2twitter/README.md new file mode 100644 index 000000000..b20038839 --- /dev/null +++ b/charts/rss2twitter/README.md @@ -0,0 +1,9 @@ +# RSS 2 Twitter + +This chart deploys [rss2twitter](https://github.com/umputun/rss2twitter). + +## Running this yourself + +``` +helm install -f values.yaml -f values.local.yaml --name rss2twitter . +``` diff --git a/charts/rss2twitter/tests/defaults_test.yaml b/charts/rss2twitter/tests/defaults_test.yaml new file mode 100644 index 000000000..cbd770105 --- /dev/null +++ b/charts/rss2twitter/tests/defaults_test.yaml @@ -0,0 +1,39 @@ +suite: default tests +values: + - ../values.yaml + - secrets_default_values.yaml +templates: + - _helper.tpl + - deployment.yaml + - exclusion-patterns-configmap.yaml + - secret.yaml +tests: + - it: should define the default deployment with the image umputun/rss2twitter + template: deployment.yaml + asserts: + - hasDocuments: + count: 1 + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].image + value: umputun/rss2twitter:v0.7.0 + - it: should create a Secret with the correct value + template: secret.yaml + asserts: + - hasDocuments: + count: 1 + - isKind: + of: Secret + - equal: + path: data.TWI_CONSUMER_KEY + value: Y29uc3VtZXIta2V5 + - equal: + path: data.TWI_CONSUMER_SECRET + value: Y29uc3VtZXItc2VjcmV0 + - equal: + path: data.TWI_ACCESS_TOKEN + value: YWNjZXNzLXRva2Vu + - equal: + path: data.TWI_ACCESS_SECRET + value: YWNjZXNzLXNlY3JldA== diff --git a/charts/rss2twitter/tests/secrets_default_values.yaml b/charts/rss2twitter/tests/secrets_default_values.yaml new file mode 100644 index 000000000..d8730b1d5 --- /dev/null +++ b/charts/rss2twitter/tests/secrets_default_values.yaml @@ -0,0 +1,5 @@ +twitter: + consumerKey: consumer-key + consumerSecret: consumer-secret + accessToken: access-token + accessSecret: access-secret diff --git a/charts/rss2twitter/values.yaml b/charts/rss2twitter/values.yaml index c84424cdf..3f2afca6a 100644 --- a/charts/rss2twitter/values.yaml +++ b/charts/rss2twitter/values.yaml @@ -16,7 +16,7 @@ podSecurityContext: {} securityContext: capabilities: drop: - - ALL + - ALL readOnlyRootFilesystem: true runAsUser: 1001 # app resources: {} @@ -40,3 +40,9 @@ env: # disables publishing to twitter and sends updates to logger only dryMode: true debugMode: false + +twitter: + consumerKey: "" + consumerSecret: "" + accessToken: "" + accessSecret: "" From 138d4064e7333321f803366dc2326e1288a81a0d Mon Sep 17 00:00:00 2001 From: linoleparquet Date: Wed, 20 Sep 2023 08:23:49 -0400 Subject: [PATCH 2/3] fix(rss2twitter): fix unit tests --- ...ults_test.yaml => custom_values_test.yaml} | 21 +++++++------------ .../tests/defaults_values_test.yaml | 17 +++++++++++++++ .../tests/secrets_default_values.yaml | 5 ----- 3 files changed, 24 insertions(+), 19 deletions(-) rename charts/rss2twitter/tests/{defaults_test.yaml => custom_values_test.yaml} (61%) create mode 100644 charts/rss2twitter/tests/defaults_values_test.yaml delete mode 100644 charts/rss2twitter/tests/secrets_default_values.yaml diff --git a/charts/rss2twitter/tests/defaults_test.yaml b/charts/rss2twitter/tests/custom_values_test.yaml similarity index 61% rename from charts/rss2twitter/tests/defaults_test.yaml rename to charts/rss2twitter/tests/custom_values_test.yaml index cbd770105..e2487f5fd 100644 --- a/charts/rss2twitter/tests/defaults_test.yaml +++ b/charts/rss2twitter/tests/custom_values_test.yaml @@ -1,24 +1,17 @@ -suite: default tests -values: - - ../values.yaml - - secrets_default_values.yaml +suite: Test with custom values templates: - _helper.tpl - deployment.yaml - exclusion-patterns-configmap.yaml - secret.yaml tests: - - it: should define the default deployment with the image umputun/rss2twitter - template: deployment.yaml - asserts: - - hasDocuments: - count: 1 - - isKind: - of: Deployment - - equal: - path: spec.template.spec.containers[0].image - value: umputun/rss2twitter:v0.7.0 - it: should create a Secret with the correct value + set: + twitter: + consumerKey: consumer-key + consumerSecret: consumer-secret + accessToken: access-token + accessSecret: access-secret template: secret.yaml asserts: - hasDocuments: diff --git a/charts/rss2twitter/tests/defaults_values_test.yaml b/charts/rss2twitter/tests/defaults_values_test.yaml new file mode 100644 index 000000000..5f172b639 --- /dev/null +++ b/charts/rss2twitter/tests/defaults_values_test.yaml @@ -0,0 +1,17 @@ +suite: Test with default values +templates: + - _helper.tpl + - deployment.yaml + - exclusion-patterns-configmap.yaml + - secret.yaml +tests: + - it: should define the default deployment with the image umputun/rss2twitter + template: deployment.yaml + asserts: + - hasDocuments: + count: 1 + - isKind: + of: Deployment + - equal: + path: spec.template.spec.containers[0].image + value: umputun/rss2twitter:v0.7.0 diff --git a/charts/rss2twitter/tests/secrets_default_values.yaml b/charts/rss2twitter/tests/secrets_default_values.yaml deleted file mode 100644 index d8730b1d5..000000000 --- a/charts/rss2twitter/tests/secrets_default_values.yaml +++ /dev/null @@ -1,5 +0,0 @@ -twitter: - consumerKey: consumer-key - consumerSecret: consumer-secret - accessToken: access-token - accessSecret: access-secret From 38c8587131c0c1278e6d62842059b0c81bddb4af Mon Sep 17 00:00:00 2001 From: linoleparquet Date: Wed, 20 Sep 2023 10:21:56 -0400 Subject: [PATCH 3/3] fix(rss2twitter): bump version --- charts/rss2twitter/Chart.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/rss2twitter/Chart.yaml b/charts/rss2twitter/Chart.yaml index 5750a91f7..461656d89 100644 --- a/charts/rss2twitter/Chart.yaml +++ b/charts/rss2twitter/Chart.yaml @@ -2,4 +2,4 @@ apiVersion: v2 description: A Helm chart for https://github.com/umputun/rss2twitter name: rss2twitter type: application -version: 0.0.4 +version: 0.0.5