Skip to content

Commit

Permalink
Fix helm chart artifact hub enabled property (#4680)
Browse files Browse the repository at this point in the history
- value of false always defaults to true
- flip to disabled, rather than enabled
- also fix property names
  • Loading branch information
richard-cox authored Oct 14, 2020
1 parent 53b2169 commit 7f6cd53
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions deploy/kubernetes/console/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ spec:
value: "{{.Values.kube.registry.hostname}}/{{.Values.kube.organization}}/stratos-kube-terminal:{{.Values.consoleVersion}}"
- name: STRATOS_KUBERNETES_DASHBOARD_IMAGE
value: "{{.Values.console.kubeDashboardImage}}"
- name: ARTIFACT_HUB_ENABLED
value: {{ default "true" .Values.console.artifactHubEnabled | quote }}
- name: ARTIFACT_HUB_DISABLED
value: {{ default "false" .Values.console.artifactHubDisabled | quote }}
{{- include "stratosJetstreamEnv" . | indent 8 }}
readinessProbe:
httpGet:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function generateHelmEntities(): StratosBaseCatalogEntity[] {
registrationComponent: HelmHubRegistrationComponent,
registeredLimit: (store: Store<AppState>): Observable<number> => store.select('auth').pipe(
filter(auth => !!auth.sessionData['plugin-config']),
map(auth => auth.sessionData['plugin-config'].helmHubEnabled === 'true' ? 1 : 0),
map(auth => auth.sessionData['plugin-config'].artifactHubDisabled === 'true' ? 0 : 1),
)
},
],
Expand Down
2 changes: 1 addition & 1 deletion src/jetstream/config.example
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ INVITE_USER_CLIENT_SECRET=
# HELM_CACHE_FOLDER=./helm-cache

# Enabled Artifact Hub
# ARTIFACT_HUB_ENABLED=false
# ARTIFACT_HUB_DISABLED=false
26 changes: 13 additions & 13 deletions src/jetstream/plugins/monocular/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ import (
)

const (
helmEndpointType = "helm"
helmHubEndpointType = "hub"
helmRepoEndpointType = "repo"
stratosPrefix = "/pp/v1/"
kubeReleaseNameEnvVar = "STRATOS_HELM_RELEASE"
cacheFolderEnvVar = "HELM_CACHE_FOLDER"
defaultCacheFolder = "./.helm-cache"
helmHubEnabledEnvVar = "ARTIFACT_HUB_ENABLED"
helmHubEnabled = "helmHubEnabled"
helmEndpointType = "helm"
helmHubEndpointType = "hub"
helmRepoEndpointType = "repo"
stratosPrefix = "/pp/v1/"
kubeReleaseNameEnvVar = "STRATOS_HELM_RELEASE"
cacheFolderEnvVar = "HELM_CACHE_FOLDER"
defaultCacheFolder = "./.helm-cache"
artifactHubDisabledEnvVar = "ARTIFACT_HUB_DISABLED"
artifactHubDisabled = "artifactHubDisabled"
)

// Monocular is a plugin for Monocular
Expand Down Expand Up @@ -59,10 +59,10 @@ func Init(portalProxy interfaces.PortalProxy) (interfaces.StratosPlugin, error)
func (m *Monocular) Init() error {
log.Debug("Monocular init .... ")

if val, ok := m.portalProxy.Env().Lookup(helmHubEnabledEnvVar); ok {
m.portalProxy.GetConfig().PluginConfig[helmHubEnabled] = val
if val, ok := m.portalProxy.Env().Lookup(artifactHubDisabledEnvVar); ok {
m.portalProxy.GetConfig().PluginConfig[artifactHubDisabled] = val
} else {
m.portalProxy.GetConfig().PluginConfig[helmHubEnabled] = "true"
m.portalProxy.GetConfig().PluginConfig[artifactHubDisabled] = "false"
}

m.CacheFolder = m.portalProxy.Env().String(cacheFolderEnvVar, defaultCacheFolder)
Expand Down Expand Up @@ -246,7 +246,7 @@ func (m *Monocular) validateExternalMonocularEndpoint(cnsi string) (*interfaces.
return &endpoint, nil
}

if m.portalProxy.GetConfig().PluginConfig[helmHubEnabled] != "true" {
if m.portalProxy.GetConfig().PluginConfig[artifactHubDisabled] != "true" {
return nil, echo.NewHTTPError(http.StatusInternalServerError, errors.New("Artifact Hub is disabled"))
}

Expand Down

0 comments on commit 7f6cd53

Please sign in to comment.