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

fix: dont always override namespace #264

Conversation

cameronbraid
Copy link
Contributor

@cameronbraid cameronbraid commented Jan 27, 2021

The current promote process always sets OverrideNamespace, making it impossible to make it blank.

This PR allows multiple namespaces to be used by leaving OverrideNamespace blank and specifying a namespace per release.

It keeps old behaviour by initially setting OverrideNamespace when adding the first release and then leaving the release.namespace blank for any further additions

For example after first release in ns 'jx'

namespace: jx
repositories:
- name: dev
  url: http://chartmuseum-jx.34.78.195.22.nip.io
releases:
- chart: dev/myapp
  version: 1.2.3
  name: myapp-1-2-3

The user then can edit the file to move the toplevel namespace into the release as per :

namespace: ""
repositories:
- name: dev
  url: http://chartmuseum-jx.34.78.195.22.nip.io
releases:
- chart: dev/myapp
  version: 1.2.3
  name: myapp-1-2-3
  namespace: jx

Then a new release can be added for another namespace

namespace: ""
repositories:
- name: dev
  url: http://chartmuseum-jx.34.78.195.22.nip.io
releases:
- chart: dev/myapp
  version: 1.2.3
  name: myapp-1-2-3
  namespace: jx
- chart: dev/potato
  version: 1.2.3
  name: bar-1-2-3
  namespace: bar

Without this change, each time the helmfile is re-written to have the toplevel namespace set to 'jx'

allows multiple namespaces to be used by leaving OverrideNamespace blank and specifying a namespace per release.

Keeps old behaviour by setting OverrideNamespace when adding the first release and then leaving the release namespace blank for any further additions
@jenkins-x-bot-test
Copy link
Contributor

Hi @cameronbraid. Thanks for your PR.

I'm waiting for a jenkins-x or todo member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the jenkins-x/lighthouse repository.

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
20.8% 20.8% Duplication

@cameronbraid
Copy link
Contributor Author

cameronbraid commented Jan 27, 2021

I am also thinking about how to define the namespace (and possibly other fields) for a release before the first release happens.

One idea could be to enhance the per env promote.yaml file introduced in #263

given the following nested helmfile

helmfiles/jx/helmfile.yaml

namespace: jx
repositories:
- name: dev
  url: https://chartmuseum-dev.drivenow.com.au

the following config could be used to define the release template for dev/foo :

helmfiles/jx/promote.yaml

apiVersion: promote.jenkins-x.io/v1alpha1
kind: HelmfilePromote
spec:
  releaseTemplates:
    dev/foo:
      namespace: bar
      values: ["bar-values.yaml"]

so that when promotion happens the helmfile is rewritten by first applying the releaseTemplate, then applying the promotion change which results in :

helmfiles/jx/helmfile.yaml

namespace: jx
repositories:
- name: dev
  url: https://chartmuseum-dev.drivenow.com.au
releases:
- chart: dev/foo
  version: 0.0.1
  name: foo
  namespace: bar
  values:
  - jx-values.yaml
  - bar-values.yaml

@jstrachan
Copy link
Contributor

/ok-to-test

@jstrachan
Copy link
Contributor

BTW I really like the idea of being able to define inside an app's repo, more configuration for how a promotion looks in an arbitrary namespace/environment git repository

@jstrachan
Copy link
Contributor

/lgtm

@jenkins-x-bot-test
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jstrachan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@jenkins-x-bot-test jenkins-x-bot-test merged commit 00a995c into jenkins-x-plugins:master Jan 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants