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

Moved global repos to their own namespace and outside the kubeapps one #3990

Merged
merged 9 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
{{- if .namespace }}
namespace: {{ .namespace | quote }}
{{- else }}
namespace: {{ $.Release.Namespace | quote }}
namespace: {{ printf "%s-%s" $.Release.Namespace $.Values.apprepository.globalReposNamespaceSuffix | quote }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding making this a non-breaking change, could we instead do:

Suggested change
namespace: {{ printf "%s-%s" $.Release.Namespace $.Values.apprepository.globalReposNamespaceSuffix | quote }}
namespace: {{ printf "%s%s" $.Release.Namespace $.Values.apprepository.globalReposNamespaceSuffix | quote }}

so that if globalReposNamespaceSuffix is empty (which can be the default, initially), we will have the existing behavior? We can then update the default value to -repos-global when we do a major version change, breaking the backwards compatibility?

It'd require a conditional around the namespace creation later too, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion Michael, it makes sense. So, defaulting now to the same kubeapps namespace, would mean leaving without effect the purpose of this change until next major version 3.x?
As-is in a Kubeapps upgrade scenario, new global repos will go to the new ns and old global repos will stay in the kubeapps ns, just not being considered global anymore.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion Michael, it makes sense. So, defaulting now to the same kubeapps namespace, would mean leaving without effect the purpose of this change until next major version 3.x?

By default, yes, but we can verify it works as expected, even update CI to use it (by setting a value for the suffix) if we want, to ensure that switching the default later is a non-event (other than the instructions for users).

As-is in a Kubeapps upgrade scenario, new global repos will go to the new ns and old global repos will stay in the kubeapps ns, just not being considered global anymore.

Yep, we'll just ensure we document that in the release notes so people can move their repos as needed.

{{- end }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
{{- if $.Values.commonLabels }}
Expand All @@ -33,11 +33,15 @@ data:
{{- end }}
---
{{/* credentials are required in the release namespace for syncer jobs */}}
{{- if .namespace }}
{{- if or .namespace $.Values.apprepository.globalReposNamespaceSuffix }}
apiVersion: v1
kind: Secret
metadata:
{{- if .namespace }}
name: {{ printf "%s-apprepo-%s" .namespace .name }}
{{- else }}
name: {{ printf "%s-%s-apprepo-%s" $.Release.Namespace $.Values.apprepository.globalReposNamespaceSuffix .name }}
{{- end }}
namespace: {{ $.Release.Namespace | quote }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
{{- if $.Values.commonLabels }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
{{- if .namespace }}
namespace: {{ .namespace | quote }}
{{- else }}
namespace: {{ $.Release.Namespace | quote }}
namespace: {{ printf "%s-%s" $.Release.Namespace $.Values.apprepository.globalReposNamespaceSuffix | quote }}
{{- end }}
labels: {{- include "common.labels.standard" $ | nindent 4 }}
{{- if $.Values.commonLabels }}
Expand Down
1 change: 1 addition & 0 deletions chart/kubeapps/templates/apprepository/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ spec:
{{- end }}
- --repo-sync-cmd=/asset-syncer
- --namespace={{ .Release.Namespace }}
- --global-repos-namespace={{ .Release.Namespace }}-{{ .Values.apprepository.globalReposNamespaceSuffix }}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preferred to add a proper flag instead of passing the value through env variables

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+100.

{{- if .Values.postgresql.existingSecret }}
- --database-secret-name={{ .Values.postgresql.existingSecret }}
{{- else }}
Expand Down
1 change: 1 addition & 0 deletions chart/kubeapps/templates/dashboard/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ data:
{
"kubeappsCluster": "{{ template "kubeapps.kubeappsCluster" . -}}",
"kubeappsNamespace": "{{ .Release.Namespace }}",
"globalReposNamespace": "{{ .Release.Namespace }}-{{ .Values.apprepository.globalReposNamespaceSuffix }}",
"appVersion": "v{{ .Chart.AppVersion }}",
"authProxyEnabled": {{ .Values.authProxy.enabled }},
"oauthLoginURI": {{ .Values.authProxy.oauthLoginURI | quote }},
Expand Down
3 changes: 3 additions & 0 deletions chart/kubeapps/templates/kubeappsapis/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ spec:
{{- if .Values.pinnipedProxy.enabled }}
- --pinniped-proxy-url=http://{{ template "kubeapps.pinniped-proxy.fullname" . }}.{{ .Release.Namespace }}:{{ .Values.pinnipedProxy.containerPort }}
{{- end }}
{{- if .Values.apprepository.globalReposNamespaceSuffix }}
- --global-repos-namespace={{ .Release.Namespace }}-{{ .Values.apprepository.globalReposNamespaceSuffix }}
{{- end }}
env:
- name: GOGC
value: "50" # default is 100. 50 means increasing x2 the frequency of GC
Expand Down
4 changes: 4 additions & 0 deletions chart/kubeapps/templates/shared/global-repos-namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: "{{ .Release.Namespace }}-{{ .Values.apprepository.globalReposNamespaceSuffix }}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creates the global repos namespace

3 changes: 3 additions & 0 deletions chart/kubeapps/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ apprepository:
## - myRegistryKeySecretName
##
pullSecrets: []
## @param apprepository.globalReposNamespaceSuffix Suffix for the namespace of global repos
##
globalReposNamespaceSuffix: repos-global
Copy link
Contributor

@antgamdia antgamdia Jan 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with the rest of the comments in that the suffix should also include the - to prevent backward-incompatible changes.

Also, in order to stick close to similar names within our organization, why not go with a similar suffix as Carvel people does: -packaging-global ? (source: carvel-dev/kapp-controller@d199158)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find using the word repos more intuitive 😄
Is there any accepted terminology for this?

## @param apprepository.initialRepos [array] Initial chart repositories to configure
## e.g:
## initialRepos:
Expand Down
1 change: 1 addition & 0 deletions cmd/apprepository-controller/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func setFlags(c *cobra.Command) {
c.Flags().StringSliceVar(&serveOpts.RepoSyncImagePullSecrets, "repo-sync-image-pullsecrets", nil, "optional reference to secrets in the same namespace to use for pulling the image used by this pod")
c.Flags().StringVar(&serveOpts.RepoSyncCommand, "repo-sync-cmd", "/chart-repo", "command used to sync/delete repos for repo-sync-image")
c.Flags().StringVar(&serveOpts.KubeappsNamespace, "namespace", "kubeapps", "Namespace to discover AppRepository resources")
c.Flags().StringVar(&serveOpts.GlobalReposNamespace, "global-repos-namespace", "kubeapps-repos-global", "Namespace for global repos")
c.Flags().BoolVar(&serveOpts.ReposPerNamespace, "repos-per-namespace", true, "Defaults to watch for repos in all namespaces. Switch to false to watch only the configured namespace.")
c.Flags().StringVar(&serveOpts.DBURL, "database-url", "localhost", "Database URL")
c.Flags().StringVar(&serveOpts.DBUser, "database-user", "root", "Database user")
Expand Down
4 changes: 4 additions & 0 deletions cmd/apprepository-controller/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestParseFlagsCorrect(t *testing.T) {
RepoSyncImagePullSecrets: nil,
RepoSyncCommand: "/chart-repo",
KubeappsNamespace: "kubeapps",
GlobalReposNamespace: "kubeapps-repos-global",
ReposPerNamespace: true,
DBURL: "localhost",
DBUser: "root",
Expand Down Expand Up @@ -72,6 +73,7 @@ func TestParseFlagsCorrect(t *testing.T) {
ImagePullSecretsRefs: []v1.LocalObjectReference{{Name: "s1"}, {Name: " s2"}, {Name: " s3"}},
RepoSyncCommand: "/chart-repo",
KubeappsNamespace: "kubeapps",
GlobalReposNamespace: "kubeapps-repos-global",
ReposPerNamespace: true,
DBURL: "localhost",
DBUser: "root",
Expand All @@ -97,6 +99,7 @@ func TestParseFlagsCorrect(t *testing.T) {
"--repo-sync-image-pullsecrets", "s3",
"--repo-sync-cmd", "foo04",
"--namespace", "foo05",
"--global-repos-namespace", "kubeapps-repos-global",
"--repos-per-namespace=false",
"--database-url", "foo06",
"--database-user", "foo07",
Expand All @@ -117,6 +120,7 @@ func TestParseFlagsCorrect(t *testing.T) {
ImagePullSecretsRefs: []v1.LocalObjectReference{{Name: "s1"}, {Name: "s2"}, {Name: "s3"}},
RepoSyncCommand: "foo04",
KubeappsNamespace: "foo05",
GlobalReposNamespace: "kubeapps-repos-global",
ReposPerNamespace: false,
DBURL: "foo06",
DBUser: "foo07",
Expand Down
1 change: 1 addition & 0 deletions cmd/apprepository-controller/server/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ func apprepoSyncJobArgs(apprepo *apprepov1alpha1.AppRepository, config Config) [
args = append(args, "--user-agent-comment="+config.UserAgentComment)
}

args = append(args, "--global-repos-namespace="+config.GlobalReposNamespace)
args = append(args, "--namespace="+apprepo.GetNamespace(), apprepo.GetName(), apprepo.Spec.URL, apprepo.Spec.Type)

if len(apprepo.Spec.OCIRepositories) > 0 {
Expand Down
15 changes: 15 additions & 0 deletions cmd/apprepository-controller/server/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ func Test_newCronJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -202,6 +203,7 @@ func Test_newCronJob(t *testing.T) {
"--database-user=admin",
"--database-name=assets",
"--user-agent-comment=kubeapps/v2.3",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -293,6 +295,7 @@ func Test_newCronJob(t *testing.T) {
"--database-user=admin",
"--database-name=assets",
"--user-agent-comment=kubeapps/v2.3",
"--global-repos-namespace=kubeapps-global",
"--namespace=otherns",
"my-charts-in-otherns",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -404,6 +407,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -475,6 +479,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=my-other-namespace",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -561,6 +566,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-user=admin",
"--database-name=assets",
"--user-agent-comment=kubeapps/v2.3",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -652,6 +658,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -755,6 +762,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -860,6 +868,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -966,6 +975,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -1049,6 +1059,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -1134,6 +1145,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -1220,6 +1232,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -1307,6 +1320,7 @@ func Test_newSyncJob(t *testing.T) {
"--database-url=postgresql.kubeapps",
"--database-user=admin",
"--database-name=assets",
"--global-repos-namespace=kubeapps-global",
"--namespace=kubeapps",
"my-charts",
"https://charts.acme.com/my-charts",
Expand Down Expand Up @@ -1474,6 +1488,7 @@ func makeDefaultConfig() Config {
RepoSyncImagePullSecrets: []string{},
RepoSyncCommand: "/chart-repo",
KubeappsNamespace: "kubeapps",
GlobalReposNamespace: "kubeapps-global",
ReposPerNamespace: true,
DBURL: "postgresql.kubeapps",
DBUser: "admin",
Expand Down
1 change: 1 addition & 0 deletions cmd/apprepository-controller/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Config struct {
ImagePullSecretsRefs []corev1.LocalObjectReference
RepoSyncCommand string
KubeappsNamespace string
GlobalReposNamespace string
DBURL string
DBUser string
DBName string
Expand Down
1 change: 1 addition & 0 deletions cmd/asset-syncer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ func setRootFlags(c *cobra.Command) {
c.PersistentFlags().BoolVar(&serveOpts.TlsInsecureSkipVerify, "tls-insecure-skip-verify", false, "Skip TLS verification")
c.PersistentFlags().StringVar(&serveOpts.FilterRules, "filter-rules", "", "JSON blob with the rules to filter assets")
c.PersistentFlags().BoolVar(&serveOpts.PassCredentials, "pass-credentials", false, "pass credentials to all domains")
c.PersistentFlags().StringVar(&serveOpts.GlobalReposNamespace, "global-repos-namespace", "kubeapps-repos-global", "Namespace for global repos")
}

func setSyncFlags(c *cobra.Command) {
Expand Down
6 changes: 6 additions & 0 deletions cmd/asset-syncer/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func TestParseFlagsCorrect(t *testing.T) {
"--database-name", "foo02",
"--database-user", "foo03",
"--namespace", "foo04",
"--global-repos-namespace", "kubeapps-global",
"--user-agent-comment", "foo05",
"--debug", "true",
"--tls-insecure-skip-verify", "true",
Expand All @@ -50,6 +51,7 @@ func TestParseFlagsCorrect(t *testing.T) {
DatabaseUser: "foo03",
Debug: true,
Namespace: "foo04",
GlobalReposNamespace: "kubeapps-global",
OciRepositories: []string{"foo07"},
TlsInsecureSkipVerify: true,
FilterRules: "foo06",
Expand All @@ -65,6 +67,7 @@ func TestParseFlagsCorrect(t *testing.T) {
"--database-name", "foo02",
"--database-user", "foo03",
"--namespace", "foo04",
"--global-repos-namespace", "kubeapps-global",
"--user-agent-comment", "foo05",
"--debug", "true",
"--tls-insecure-skip-verify", "true",
Expand All @@ -78,6 +81,7 @@ func TestParseFlagsCorrect(t *testing.T) {
DatabaseUser: "foo03",
Debug: true,
Namespace: "foo04",
GlobalReposNamespace: "kubeapps-global",
OciRepositories: []string{"foo07"},
TlsInsecureSkipVerify: true,
FilterRules: "foo06",
Expand All @@ -93,6 +97,7 @@ func TestParseFlagsCorrect(t *testing.T) {
"--database-name", "foo02",
"--database-user", "foo03",
"--namespace", "foo04",
"--global-repos-namespace", "kubeapps-global",
"--user-agent-comment", "foo05",
"--debug", "true",
"--tls-insecure-skip-verify", "true",
Expand All @@ -106,6 +111,7 @@ func TestParseFlagsCorrect(t *testing.T) {
DatabaseUser: "foo03",
Debug: true,
Namespace: "foo04",
GlobalReposNamespace: "kubeapps-global",
OciRepositories: []string{"foo07"},
TlsInsecureSkipVerify: true,
FilterRules: "foo06",
Expand Down
3 changes: 1 addition & 2 deletions cmd/asset-syncer/server/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ func Delete(serveOpts Config, args []string) error {
}

dbConfig := dbutils.Config{URL: serveOpts.DatabaseURL, Database: serveOpts.DatabaseName, Username: serveOpts.DatabaseUser, Password: serveOpts.DatabasePassword}
kubeappsNamespace := serveOpts.KubeappsNamespace
manager, err := newManager(dbConfig, kubeappsNamespace)
manager, err := newManager(dbConfig, serveOpts.GlobalReposNamespace)
if err != nil {
return fmt.Errorf("Error file creating a mananger: %v", err)
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/asset-syncer/server/invalidate-cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ func InvalidateCache(serveOpts Config, args []string) error {
}

dbConfig := dbutils.Config{URL: serveOpts.DatabaseURL, Database: serveOpts.DatabaseName, Username: serveOpts.DatabaseUser, Password: serveOpts.DatabasePassword}
kubeappsNamespace := serveOpts.KubeappsNamespace
manager, err := newManager(dbConfig, kubeappsNamespace)
manager, err := newManager(dbConfig, serveOpts.GlobalReposNamespace)
if err != nil {
return fmt.Errorf("Error: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/asset-syncer/server/postgresql_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ type postgresAssetManager struct {
*dbutils.PostgresAssetManager
}

func newPGManager(config dbutils.Config, kubeappsNamespace string) (assetManager, error) {
m, err := dbutils.NewPGManager(config, kubeappsNamespace)
func newPGManager(config dbutils.Config, globalReposNamespace string) (assetManager, error) {
m, err := dbutils.NewPGManager(config, globalReposNamespace)
if err != nil {
return nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/asset-syncer/server/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ func Sync(serveOpts Config, version string, args []string) error {
}

dbConfig := dbutils.Config{URL: serveOpts.DatabaseURL, Database: serveOpts.DatabaseName, Username: serveOpts.DatabaseUser, Password: serveOpts.DatabasePassword}
kubeappsNamespace := serveOpts.KubeappsNamespace
manager, err := newManager(dbConfig, kubeappsNamespace)
globalReposNamespace := serveOpts.GlobalReposNamespace
manager, err := newManager(dbConfig, globalReposNamespace)
if err != nil {
return fmt.Errorf("Error: %v", err)
}
Expand Down
5 changes: 3 additions & 2 deletions cmd/asset-syncer/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type Config struct {
FilterRules string
PassCredentials bool
UserAgent string
GlobalReposNamespace string
KubeappsNamespace string
AuthorizationHeader string
DockerConfigJson string
Expand Down Expand Up @@ -119,8 +120,8 @@ type assetManager interface {
insertFiles(chartID string, files models.ChartFiles) error
}

func newManager(config dbutils.Config, kubeappsNamespace string) (assetManager, error) {
return newPGManager(config, kubeappsNamespace)
func newManager(config dbutils.Config, globalReposNamespace string) (assetManager, error) {
return newPGManager(config, globalReposNamespace)
}

func getSha256(src []byte) (string, error) {
Expand Down
1 change: 1 addition & 0 deletions cmd/assetsvc/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func setFlags(c *cobra.Command) {
c.Flags().StringVar(&serveOpts.DbURL, "database-url", "localhost", "Database URL")
c.Flags().StringVar(&serveOpts.DbUsername, "database-user", "root", "Database user")
c.Flags().StringVar(&serveOpts.DbName, "database-name", "charts", "Database name")
c.Flags().StringVar(&serveOpts.GlobalReposNamespace, "global-repos-namespace", "kubeapps-repos-global", "Namespace for global repos")
}

// initConfig reads in config file and ENV variables if set.
Expand Down
6 changes: 3 additions & 3 deletions cmd/assetsvc/pkg/utils/postgresql_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ type PostgresAssetManager struct {
dbutils.PostgresAssetManagerIface
}

func NewPGManager(config dbutils.Config, kubeappsNamespace string) (AssetManager, error) {
m, err := dbutils.NewPGManager(config, kubeappsNamespace)
func NewPGManager(config dbutils.Config, globalReposNamespace string) (AssetManager, error) {
m, err := dbutils.NewPGManager(config, globalReposNamespace)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -213,7 +213,7 @@ func (m *PostgresAssetManager) GenerateWhereClause(cq ChartQuery) (string, []int
whereQuery := ""

if cq.Namespace != dbutils.AllNamespaces {
whereQueryParams = append(whereQueryParams, cq.Namespace, m.GetKubeappsNamespace())
whereQueryParams = append(whereQueryParams, cq.Namespace, m.GetGlobalReposNamespace())
whereClauses = append(whereClauses, fmt.Sprintf(
"(repo_namespace = $%d OR repo_namespace = $%d)", len(whereQueryParams)-1, len(whereQueryParams),
))
Expand Down
Loading