Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variable for JGroups labels #126

Merged
merged 1 commit into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pkg/deploy/che_configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type CheConfigMap struct {
CheWorkspacePluginBrokerInitImage string `json:"CHE_WORKSPACE_PLUGIN__BROKER_INIT_IMAGE,omitempty"`
CheWorkspacePluginBrokerUnifiedImage string `json:"CHE_WORKSPACE_PLUGIN__BROKER_UNIFIED_IMAGE,omitempty"`
CheServerSecureExposerJwtProxyImage string `json:"CHE_SERVER_SECURE__EXPOSER_JWTPROXY_IMAGE,omitempty"`
CheJGroupsKubernetesLabels string `json:"KUBERNETES_LABEL,omitempty"`
}

// GetConfigMapData gets env values from CR spec and returns a map with key:value
Expand Down Expand Up @@ -147,6 +148,7 @@ func GetConfigMapData(cr *orgv1.CheCluster) (cheEnv map[string]string) {
pluginRegistryUrl := cr.Status.PluginRegistryURL
cheLogLevel := util.GetValue(cr.Spec.Server.CheLogLevel, DefaultCheLogLevel)
cheDebug := util.GetValue(cr.Spec.Server.CheDebug, DefaultCheDebug)
cheLabels := util.MapToKeyValuePairs(GetLabels(cr, util.GetValue(cr.Spec.Server.CheFlavor, DefaultCheFlavor)))

data := &CheConfigMap{
CheMultiUser: "true",
Expand Down Expand Up @@ -186,6 +188,7 @@ func GetConfigMapData(cr *orgv1.CheCluster) (cheEnv map[string]string) {
CheWorkspacePluginBrokerInitImage: DefaultCheWorkspacePluginBrokerInitImage(cr, cheFlavor),
CheWorkspacePluginBrokerUnifiedImage: DefaultCheWorkspacePluginBrokerUnifiedImage(cr, cheFlavor),
CheServerSecureExposerJwtProxyImage: DefaultCheServerSecureExposerJwtProxyImage(cr, cheFlavor),
CheJGroupsKubernetesLabels: cheLabels,
}

out, err := json.Marshal(data)
Expand Down
10 changes: 10 additions & 0 deletions pkg/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client/config"
"strings"
"time"
"bytes"
"fmt"
)


Expand Down Expand Up @@ -61,6 +63,14 @@ func GeneratePasswd(stringLength int) (passwd string) {
return passwd
}

func MapToKeyValuePairs(m map[string]string) string {
buff := new(bytes.Buffer)
for key, value := range m {
fmt.Fprintf(buff, "%s=%s,", key, value)
}
return strings.TrimSuffix(buff.String(), ",")
}

func DetectOpenShift() (isOpenshift bool, isOpenshift4 bool, anError error) {
tests := IsTestMode()
if !tests {
Expand Down