Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

shipperctl validate chart command #46 #59

Closed
wants to merge 6 commits into from

Conversation

osdrv
Copy link
Contributor

@osdrv osdrv commented Dec 12, 2018

This pull request is aiming to implement a new shipperctl command which will perform a quick probe of a helm chart and report potential issues.

@osdrv osdrv added the enhancement New feature or request label Dec 12, 2018
@osdrv osdrv changed the title [WIP] chipperctl validate chart command #46 [WIP] shipperctl validate chart command #46 Dec 13, 2018
@osdrv osdrv changed the title [WIP] shipperctl validate chart command #46 shipperctl validate chart command #46 Dec 14, 2018
@osdrv
Copy link
Contributor Author

osdrv commented Dec 14, 2018

Hey folks, this PR is now in an i-think-it's-ready-for-a-review state. Please give it a quick look and let me know your impressions @kanatohodets @parhamdoustdar @isutton

pkg/chart/validate.go Outdated Show resolved Hide resolved
pkg/chart/validate.go Outdated Show resolved Hide resolved
pkg/chart/validate.go Outdated Show resolved Hide resolved
pkg/controller/installation/errors.go Outdated Show resolved Hide resolved
@osdrv
Copy link
Contributor Author

osdrv commented Dec 18, 2018

@ksurent I really appreciate your feedback. Very much helpful!

ksurent
ksurent previously approved these changes Dec 18, 2018
Copy link
Contributor

@kanatohodets kanatohodets left a comment

Choose a reason for hiding this comment

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

I really dig extracting validation behavior out of the guts of a controller into a library and re-using it from shipperctl.

However, I think this changeset introduces a regression: the old error checks were against the chart as rendered with the values from the Release, while the validation here is against the chart as rendered with the default values.

return err
}

if err := shipperchart.Validate(chart); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need to pass rel.Spec.Environment.Values into Validate.

Helm Charts can have conditional branches based on values, which might cause the Chart to render completely differently with and without a particular value. In the extreme case, you can consider something like:

{{- if .Values.injectDebugService -}}                                                                                                                                              
apiVersion: v1
kind: Service
metadata:
  name: my-debug-service
spec:
  type: ClusterIP
  ports:
  - name: web
    port: 80
    targetPort: 8888
  selector:
    mode: debug
{{- end -}} 

where a Service object is only rendered when someone has enabled the 'debug' value on the Chart. This might be the difference between Shipper finding a Chart valid or not.

return err
}

renderedManifests, err := i.renderManifests(chart)
Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about having values be a param, I might do the same for renderManifests: have it take name, namespace, and values as arguments instead of inferring them from the associated Release.

The reason is that eventually we want to change the InstallationTarget objects to be independently usable, without requiring an associated Release, as per #5. This is purely a target of opportunity though, so if it looks like a gnarly change, totally fine to skip.

if loadErr != nil {
return fmt.Errorf("Failed to load chart under path %q: %s", chartPath, loadErr.Error())
}
if validateErr := shipperchart.Validate(chart); validateErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we change Validate to take values as an argument, we'll need to come up with the UI for users to specify those values. Probably the most intuitive way would be to do it exactly like helm, with --set foo=bar or -f values.yaml, but neither of those arguments really make sense in a Shipper world: you never use them when you're using Shipper, you just write your app.yaml.

I could imagine doing something like -f app.yaml instead. However, then you have a full Application object which specifies its own Chart, which makes it odd to validate only the Chart bit -- especially if you're validating a Chart that is different from the one specified in the Application. Most likely don't want to validate a Chart independent of an Application; you should instead validate the entire Application.

In that case the command would be better expressed as something like shipperctl validate app -f app.yaml, and part of doing so is downloading/validating the Chart. What do you think?

Choose a reason for hiding this comment

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

I think that both validations are useful, I would want to validate that the app.yaml and the charts referenced in it are ok but I would also a quick way to check if an existing chart would work with shipper, in the second case using the default values should be ok.

@kanatohodets
Copy link
Contributor

Build should start working once rebased on master (codegen needed updating)

@osdrv
Copy link
Contributor Author

osdrv commented Jul 29, 2019

Closing this PR due to an uncertainty regarding it's applicability and usability.

@osdrv osdrv closed this Jul 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants