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

Return charts for specific namespace and global namespace. #1588

Merged
merged 4 commits into from
Mar 18, 2020

Conversation

absoludity
Copy link
Contributor

@absoludity absoludity commented Mar 17, 2020

Ref #1521 . Gives the assetsvc knowledge of the kubeapps namespace and updates getPaginatedChartList so that it returns charts in a specific namespace together with those from the kubeapps (global) namespace.

While there, found, tested and fixed another issue related to the SQL params (need to use dynamic numbering for the params).

The asset-sync commands are updated to store the kubeappsNamespace but this is not yet set in the environment or used, though it may enable us to stop the frontend from needing to know the kubeapps namespace.

@absoludity absoludity requested a review from andresmgot March 17, 2020 02:11
Copy link
Contributor

@andresmgot andresmgot left a comment

Choose a reason for hiding this comment

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

Great. LGTM

clauses = append(clauses, "repo_namespace = $1")
queryParams = append(queryParams, namespace)
queryParams = append(queryParams, namespace, m.GetKubeappsNamespace())
clauses = append(clauses, fmt.Sprintf("(repo_namespace = $%d OR repo_namespace = $%d)", len(queryParams)-1, len(queryParams)))
Copy link
Contributor

Choose a reason for hiding this comment

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

this would be more readable if it were $1 and $2 but I understand why you are calculating those anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, like I had it initially. Unfortunate given they may not be the first and second... ah, that's what you mean, that if these are included they will always be the first and second params, it's only really the following one which needs to be calculated... true. Updated :)

@@ -215,3 +217,7 @@ SELECT ID FROM %s WHERE namespace=$1 AND name=$2
func (m *PostgresAssetManager) GetDB() PostgresDB {
return m.DB
}

func (m *PostgresAssetManager) GetKubeappsNamespace() string {
return m.kubeappsNamespace
Copy link
Contributor

Choose a reason for hiding this comment

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

In theory nor the GetDB or this GetKubeappsNamespace are needed if we expose those properties but I am fine anyway. Is there a reason why you added this apart than for standardization?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, because when the initial postgres integration was done, the PostgresAssetManagerIface interface was defined above and embedded in the postgresAssetManager struct at https://github.com/kubeapps/kubeapps/blob/master/cmd/assetsvc/postgresql_utils.go#L34 . Since you can't add properties to an interface, only methods, this means that when handling an instance of postgresAssetManager, you can only get to the methods defined on the interface, not the properties of the underlying struct implementing that interface, without adding type conversions etc.

So yes, I do think we could clean these up and remove a layer or two - there seem to be multiple private implementations of both postgres and mongo (for assetsvc and asset-sync) which I don't think are necessary. But I've not attempted to do that work here.

@absoludity absoludity merged commit 6f1ea36 into master Mar 18, 2020
@absoludity absoludity deleted the 1521-charts-per-namespace-with-global branch March 18, 2020 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants