Multiple fixes for operator-ui (#948)

- fix: create tenant from operator-ui was broken due to migration from
  standalone console to embedded console
- fix: refresh, activate and attach license in subscription page was
  broken
- fix: tenant usage report in operator-ui
- fix: show tenant encryption enabled if MINIO_KMS_SECRET_KEY is present

Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
Lenin Alevski
2021-08-18 13:23:03 -07:00
committed by GitHub
parent a09be99ae6
commit ec47df3cc1
46 changed files with 672 additions and 1948 deletions

View File

@@ -18,11 +18,14 @@ package restapi
import (
"crypto/x509"
"io/ioutil"
"net"
"strconv"
"strings"
"time"
miniov2 "github.com/minio/operator/pkg/apis/minio.min.io/v2"
xcerts "github.com/minio/pkg/certs"
"github.com/minio/pkg/env"
)
@@ -45,9 +48,6 @@ var (
// SessionDuration cookie validity duration
SessionDuration = 45 * time.Minute
// LicenseKey in memory license key used by console ui
LicenseKey = ""
)
func getMinIOServer() string {
@@ -243,13 +243,19 @@ func getPrometheusJobID() string {
// GetSubnetLicense returns the current subnet jwt license
func GetSubnetLicense() string {
// if we have a license key in memory return that
if LicenseKey != "" {
return LicenseKey
// if this is running on embedded console try to get the license from the MinIO tenant configuration
minioConfigPath := env.Get(MinIOConfigEnvFile, "")
if minioConfigPath != "" {
dat, err := ioutil.ReadFile(minioConfigPath)
if err == nil {
minioConfiguration := miniov2.ParseRawConfiguration(dat)
if val, ok := minioConfiguration[MinIOSubnetLicense]; ok {
return string(val)
}
}
}
// return license configured via environment variable
LicenseKey = env.Get(ConsoleSubnetLicense, "")
return LicenseKey
// fallback to console license env variable
return env.Get(ConsoleSubnetLicense, "")
}
var (

View File

@@ -26,6 +26,8 @@ const (
ConsoleTLSHostname = "CONSOLE_TLS_HOSTNAME"
ConsoleTLSPort = "CONSOLE_TLS_PORT"
ConsoleSubnetLicense = "CONSOLE_SUBNET_LICENSE"
MinIOConfigEnvFile = "MINIO_CONFIG_ENV_FILE"
MinIOSubnetLicense = "MINIO_SUBNET_LICENSE"
// Constants for Secure middleware
ConsoleSecureAllowedHosts = "CONSOLE_SECURE_ALLOWED_HOSTS"