juju / charmstore-client

Client for charmstore.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

charm push allows pushing of a charm that's not been built

mitechie opened this issue · comments

It should detect that I have a layer.yaml file and if there's no hooks directory fail to push the charm. This would prevent sending up the unbuilt version of the code up to the charmstore.

I ran charm proof on a layer and got the following:

$ charm proof
I: metadata name (giraph) must match directory name (layer-giraph) exactly for local deployment.
I: no hooks directory
I: missing recommended hook install
I: missing recommended hook start
I: missing recommended hook stop
I: File config.yaml not found.

Perhaps we should change the I: no hooks directory to an E, and require charm push to run proof first. That way, push would fail because proof would fail. Also, we shouldn't let people push charms that don't pass proof.

I think just detecting the presence or lack of a .build.manifest file should be enough. If that's missing, disable push (or, better yet, require a --force option).

It looks like this would be the section of code to modify.

Just hit this again when someone accidentally pushed/released a charm layer:

https://jujucharms.com/telegraf/8

While it does have a ./hooks directory, it does not have a ./wheelhouse, or other things you would expect in a built reactive charm. +1 to @johnsca for having proof or push or release check for -f layer.yaml && -f .build.manifest before allowing the action to succeed.

Not all charms will have a layer.yaml. It's also technically valid to have a charm with no hooks, though it would be pointless in practice. I'm fine with either -f .build.manifest or making the check for the hooks directory fatal and forcing proof before push.

Oh, I missed the bit about having hooks leading to false positives. Could do both, but the .build.manifest check would be quick and easy.

I also just realized that I misread what you were saying about layers.yaml. I agree that the condition should be something like:

if not force and (-f layer.yaml and not -f .build.manifest):
    fail "Attempting to push source layer"

@kwmonroe I should note that, since charm proof is implemented in charm-tools, it would likely be too difficult to be practical to have charm push gate on it, unless we wrapped charm push in charm-tools.