Skip to content

Commit

Permalink
[HELM-422] validate helm archiveType value (#360)
Browse files Browse the repository at this point in the history
* [HELM-422] validate helm `archiveType` value

* use enum value instead

---------

Co-authored-by: Andreas Goelzer <agr22@3ds.com>
  • Loading branch information
agoelzer and Andreas Goelzer authored Mar 20, 2024
1 parent b898a30 commit a108017
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
24 changes: 24 additions & 0 deletions stable/database/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"required": [
"database"
],
"properties": {
"database": {
"type": "object",
"required": [
"archiveType"
],
"properties": {
"archiveType": {
"type": "string",
"enum": [
"",
"lsa"
]
}
}
}
}
}
54 changes: 54 additions & 0 deletions test/integration/template_database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,60 @@ func TestDatabaseNodePortServiceRenders(t *testing.T) {
}
}

func TestDatabaseInvalidArchiveType(t *testing.T) {
// Path to the helm chart we will test
helmChartPath := testlib.DATABASE_HELM_CHART_PATH

options := &helm.Options{
SetValues: map[string]string{
"cloud.provider": "amazon",
"database.te.externalAccess.enabled": "true",
"database.te.externalAccess.type": "NodePort",
"database.te.externalAccess.internalIP": "true",
"database.archiveType": "invalid",
},
}

_, err := helm.RenderTemplateE(t, options, helmChartPath, "release-name", []string{"templates/service.yaml"})
assert.Contains(t, err.Error(), "database.archiveType must be one of the following:")
}

func TestDatabaseLsaArchiveType(t *testing.T) {
// Path to the helm chart we will test
helmChartPath := testlib.DATABASE_HELM_CHART_PATH

options := &helm.Options{
SetValues: map[string]string{
"cloud.provider": "amazon",
"database.te.externalAccess.enabled": "true",
"database.te.externalAccess.type": "NodePort",
"database.te.externalAccess.internalIP": "true",
"database.archiveType": "lsa",
},
}

_, err := helm.RenderTemplateE(t, options, helmChartPath, "release-name", []string{"templates/service.yaml"})
assert.Nil(t, err)
}

func TestDatabaseEmptyArchiveType(t *testing.T) {
// Path to the helm chart we will test
helmChartPath := testlib.DATABASE_HELM_CHART_PATH

options := &helm.Options{
SetValues: map[string]string{
"cloud.provider": "amazon",
"database.te.externalAccess.enabled": "true",
"database.te.externalAccess.type": "NodePort",
"database.te.externalAccess.internalIP": "true",
"database.archiveType": "",
},
}

_, err := helm.RenderTemplateE(t, options, helmChartPath, "release-name", []string{"templates/service.yaml"})
assert.Nil(t, err)
}

func TestDatabaseStatefulSet(t *testing.T) {
// Path to the helm chart we will test
helmChartPath := testlib.DATABASE_HELM_CHART_PATH
Expand Down

0 comments on commit a108017

Please sign in to comment.