Skip to content

Commit

Permalink
>=7.6.0: set allowed license upload types (elastic#2257)
Browse files Browse the repository at this point in the history
  • Loading branch information
pebrc authored and mjmbischoff committed Jan 13, 2020
1 parent c619ac0 commit 54e537c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/apis/elasticsearch/v1/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ const (
XPackSecurityTransportSslEnabled = "xpack.security.transport.ssl.enabled"
XPackSecurityTransportSslKey = "xpack.security.transport.ssl.key"
XPackSecurityTransportSslVerificationMode = "xpack.security.transport.ssl.verification_mode"

XPackLicenseUploadTypes = "xpack.license.upload.types" // >= 7.6.0
)

var UnsupportedSettings = []string{
Expand Down
7 changes: 7 additions & 0 deletions pkg/controller/elasticsearch/settings/merged_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
common "github.com/elastic/cloud-on-k8s/pkg/controller/common/settings"
"github.com/elastic/cloud-on-k8s/pkg/controller/common/version"
escerts "github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/certificates"
"github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/client"
"github.com/elastic/cloud-on-k8s/pkg/controller/elasticsearch/volume"
)

Expand Down Expand Up @@ -113,5 +114,11 @@ func xpackConfig(ver version.Version, httpCfg commonv1.HTTPConfig, certResources
cfg[esv1.XPackSecurityAuthcRealmsNativeNative1Order] = -99
}

if ver.IsSameOrAfter(version.MustParse("7.6.0")) {
cfg[esv1.XPackLicenseUploadTypes] = []string{
string(client.ElasticsearchLicenseTypeTrial), string(client.ElasticsearchLicenseTypeEnterprise),
}
}

return &CanonicalConfig{common.MustCanonicalConfig(cfg)}
}
16 changes: 16 additions & 0 deletions pkg/controller/elasticsearch/settings/merged_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,22 @@ func TestNewMergedESConfig(t *testing.T) {
require.Equal(t, 1, len(cfg.HasKeys([]string{esv1.DiscoverySeedProviders})))
},
},
{
name: "prior to 7.6.0, we should not set allowed license upload types",
version: "7.5.0",
cfgData: map[string]interface{}{},
assert: func(cfg CanonicalConfig) {
require.Equal(t, 0, len(cfg.HasKeys([]string{esv1.XPackLicenseUploadTypes})))
},
},
{
name: "starting 7.6.0, we should set allowed license upload types",
version: "7.6.0",
cfgData: map[string]interface{}{},
assert: func(cfg CanonicalConfig) {
require.Equal(t, 1, len(cfg.HasKeys([]string{esv1.XPackLicenseUploadTypes})))
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 54e537c

Please sign in to comment.