Add status-set, container-spec-set, config-get #8163

Merged
merged 1 commit into from Dec 1, 2017

Conversation

Projects
None yet
3 participants
Owner

wallyworld commented Dec 1, 2017

Description of change

Copy across status-set and config-get from unit.
Modify status-set to only set application status.
Add container-spec-set hook tool.

QA steps

run the unit tests

+ "gopkg.in/yaml.v2"
+)
+
+// ContainerspecSetCommand implements the status-set command.
@axw

axw Dec 1, 2017

Member

s/status-set/container-spec-set/

+`
+ return &cmd.Info{
+ Name: "container-spec-set",
+ Args: "<spec yaml> [<unit-name>]",
@axw

axw Dec 1, 2017

Member

seems pretty unlikely that a charm will be able to set the spec as YAML as a positional argument
maybe accept a file with -f, and have it default to stdin?

+`
+ return &cmd.Info{
+ Name: "container-spec-set",
+ Args: "<spec yaml> [<unit-name>]",
@axw

axw Dec 1, 2017

Member

make unit name a flag, since it's optional? similar to how we have a flag for specifying a relation for other commands

axw approved these changes Dec 1, 2017

LGTM with a few small things

+ rawYaml, err := ioutil.ReadAll(file)
+ if err != nil {
+ return "", errors.Trace(err)
+ }
@axw

axw Dec 1, 2017

Member

I think you can replace all of this with
rawYaml, err := s.specFile.Read(ctx)

+ return "", errors.Trace(err)
+ }
+ if len(rawYaml) == 0 {
+ return "", errors.New("container spec file required")
@axw

axw Dec 1, 2017

Member

I think we could be more helpful:

no container spec specified: pipe container spec to command, or specify a file with --file

?

@wallyworld

wallyworld Dec 1, 2017

Owner

fair point

+ return "", errors.New("container spec file required")
+ }
+
+ var data map[string]interface{}
@axw

axw Dec 1, 2017

Member

Sorry I missed this before - why are we mandating YAML here? If we even need it at all, it would be better to put it in the SetContainerSpec method, as potentially other things might want to set the spec.

@wallyworld

wallyworld Dec 1, 2017

Owner

We generally try and do such syntactic validation close to the source, but yeah, probably no need to mandate a format. Later we should add provider specific validation.

Owner

wallyworld commented Dec 1, 2017

$$merge$$

Contributor

jujubot commented Dec 1, 2017

Status: merge request accepted. Url: http://ci.jujucharms.com/job/github-merge-juju

Contributor

jujubot commented Dec 1, 2017

Build failed: Tests failed
build url: http://ci.jujucharms.com/job/github-merge-juju/625

Owner

wallyworld commented Dec 1, 2017

$$merge$$

Contributor

jujubot commented Dec 1, 2017

Status: merge request accepted. Url: http://ci.jujucharms.com/job/github-merge-juju

@jujubot jujubot merged commit 21489e9 into juju:develop Dec 1, 2017

1 check passed

continuous-integration/jenkins/pr-merge This commit looks good
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment