Skip to content

Commit 07ba184

Browse files
[Feature] Allow raw json value for license token-v2 (#988)
1 parent 65bbce5 commit 07ba184

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- (Feature) (ACS) Improve Reconciliation Loop
66
- (Bugfix) Allow missing Monitoring CRD
77
- (Feature) (ACS) Add Resource plan
8+
- (Feature) Allow raw json value for license token-v2
89

910
## [1.2.12](https://github.com/arangodb/kube-arangodb/tree/1.2.12) (2022-05-10)
1011
- (Feature) Add CoreV1 Endpoints Inspector

pkg/util/k8sutil/license.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
package k8sutil
2222

2323
import (
24+
"encoding/base64"
25+
"encoding/json"
26+
2427
"github.com/arangodb/kube-arangodb/pkg/util"
2528
"github.com/arangodb/kube-arangodb/pkg/util/constants"
2629
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil/inspector/secret"
@@ -56,8 +59,18 @@ func GetLicenseFromSecret(secret secret.Inspector, name string) (LicenseSecret,
5659
if v1, ok1 := s.Data[constants.SecretKeyV2License]; ok1 {
5760
l.V2 = License(v1)
5861
} else if v2, ok2 := s.Data[constants.SecretKeyV2Token]; ok2 {
59-
l.V2 = License(v2)
62+
licenseV2 := v2
63+
// some customers put the raw JSON-encoded value, but operator and DB servers expect the base64-encoded value
64+
if isJSONBytes(v2) {
65+
base64.StdEncoding.Encode(v2, licenseV2)
66+
}
67+
l.V2 = License(licenseV2)
6068
}
6169

6270
return l, true
6371
}
72+
73+
func isJSONBytes(s []byte) bool {
74+
var js json.RawMessage
75+
return json.Unmarshal(s, &js) == nil
76+
}

0 commit comments

Comments
 (0)