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

Allow more flexible chart options #284

Merged
merged 3 commits into from
Nov 21, 2018
Merged

Conversation

lukehoban
Copy link
Member

@lukehoban lukehoban commented Nov 18, 2018

Fixes #255.
Fixes #229.
Fixes #257.

Align more closely with helm options for chart references to support all scenarios supported by Helm including (a) getting latest by passing no version (b) using explicitly repo URLs (c) providing fully qualified URLs to charts.

All of the following now work:

// 1. Explicit repo/chart/version - not technically part of `helm` format but needed for back compat
repo: "stable",
chart: "nginx-lego",
version: "0.3.1",

// 2. Reference to "latest"
repo: "stable",
chart: "nginx-lego",

// 3. Helm "chart reference"
chart: "stable/nginx-lego",

// 4. Helm "chart reference" with explicit version
chart: "stable/nginx-lego",
version: "0.3.1"

// 5. Helm "chart reference and repo url" with explicit version
chart: "nginx-lego",
version: "0.3.1",
fetchOpts: {
  repo: "https://kubernetes-charts.storage.googleapis.com"
},

// 6. Helm "chart reference and repo url" 
chart: "nginx-lego",
fetchOpts: {
  repo: "https://kubernetes-charts.storage.googleapis.com"
},

// 7. Helm "absolute URL" 
chart: "https://kubernetes-charts.storage.googleapis.com/nginx-lego-0.3.1.tgz",

@lukehoban lukehoban changed the title Make version optional on helm.ChartOpts Allow more flexible chart options Nov 18, 2018
Allows the `chart` input argument to be used in more of the same ways allowed as argument to `helm install`.  Makes `repo` optional to allow chart to be provided in forms that require fully qualified references.  Actually expose the `fetchOpts` argument so that `--repo` (and other customerizations to fetch) can be passed.  Adds some additional test coverage.

All of the following now work:

// #1
repo: "stable",
chart: "nginx-lego",
version: "0.3.1",

// #2
repo: "stable",
chart: "nginx-lego",

// #3
chart: "stable/nginx-lego",

// #4
chart: "stable/nginx-lego",
version: "0.3.1"

// #5
chart: "nginx-lego",
version: "0.3.1",
fetchOpts: {
  repo: "https://kubernetes-charts.storage.googleapis.com"
},

// #6
chart: "nginx-lego",
fetchOpts: {
  repo: "https://kubernetes-charts.storage.googleapis.com"
},

// #7
chart: "https://kubernetes-charts.storage.googleapis.com/nginx-lego-0.3.1.tgz",

Fixes #229.
Fixes #257.
@lukehoban lukehoban force-pushed the lukehoban/chartversionoptional branch from 3088a11 to 01bdd26 Compare November 19, 2018 00:14
Copy link
Contributor

@hausdorff hausdorff left a comment

Choose a reason for hiding this comment

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

This is the sort of patch where you think: why didn't I do it this way to begin with?

Copy link
Contributor

@hausdorff hausdorff left a comment

Choose a reason for hiding this comment

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

Actually, I just tried this:

export const istio = new k8s.helm.v2.Chart(
    appName,
    {
        repo: "https://istio.io/charts",
        chart: "istio",
        namespace: namespace.metadata.apply(m => m.name),
        version: "1.0.1",
        // fetchOpts: { repo:  },
        // for all options check https://github.com/istio/istio/tree/master/install/kubernetes/helm/istio
        values: { kiali: { enabled: true } }
    },
    { dependsOn: [namespace], providers: { kubernetes: k8sProvider } }
);

and also this:

export const istio = new k8s.helm.v2.Chart(
    appName,
    {
        chart: "istio",
        namespace: namespace.metadata.apply(m => m.name),
        version: "1.0.1",
        fetchOpts: { repo: "https://istio.io/charts" },
        // for all options check https://github.com/istio/istio/tree/master/install/kubernetes/helm/istio
        values: { kiali: { enabled: true } }
    },
    { dependsOn: [namespace], providers: { kubernetes: k8sProvider } }
);

both of these result in this:

    error: Error: Command failed: helm fetch https\://istio.io/charts/istio --untar --version 1.0.1 --destination /var/folders/w5/n_5_kc696xxb8h9rd8d3px2r0000gp/T/tmp-41891FR25WX35Q094
    Error: Failed to fetch https://istio.io/charts/istio : 404 Not Found

Am I misunderstanding the API?

@lukehoban
Copy link
Member Author

Is that really where that chart lives? I get the same from helm:

$ helm fetch --repo https://istio.io/charts istio
Error: Failed to fetch https://istio.io/istio-1.0.1.tgz : 404 Not Found

@lukehoban
Copy link
Member Author

lukehoban commented Nov 20, 2018

Looks like there is a bug in helm here where a missing trailing slash makes helm fetch --repo <url> not work, but the same missing slash is okay in helm repo add <url>. I guess we can work around that bug and make sure there is always a trailing slash?

@lukehoban
Copy link
Member Author

Opened helm/helm#4954 to track the issue in helm.

I'm not sure it makes sense to workaround this in our layer - the fetchOpts are semantically exactly flags to helm, so trying to "fix" them up feels wrong.

Were we to have done something here where we allowed this - I could imagine us adding the workaround to it - but we haven't added support for this form at all (because it isn't really something helm supports):

repo: "https://istio.io/charts",
chart: "istio",

Given that, I'll go ahead and merge this in as is for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants