github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/worker/uniter/runner/jujuc/application-version-set.go (about)

     1  // Copyright 2016 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package jujuc
     5  
     6  import (
     7  	"github.com/juju/cmd"
     8  	"github.com/juju/errors"
     9  )
    10  
    11  type applicationVersionSetCommand struct {
    12  	cmd.CommandBase
    13  	ctx Context
    14  
    15  	version string
    16  }
    17  
    18  // NewApplicationVersionSetCommand creates an application-version-set command.
    19  func NewApplicationVersionSetCommand(ctx Context) (cmd.Command, error) {
    20  	cmd := &applicationVersionSetCommand{ctx: ctx}
    21  	return cmd, nil
    22  }
    23  
    24  // Info is part of the cmd.Command interface.
    25  func (c *applicationVersionSetCommand) Info() *cmd.Info {
    26  	doc := `
    27  application-version-set tells Juju which version of the application
    28  software is running. This could be a package version number or some
    29  other useful identifier, such as a Git hash, that indicates the
    30  version of the deployed software. (It shouldn't be confused with the
    31  charm revision.) The version set will be displayed in "juju status"
    32  output for the application.
    33  `
    34  	return &cmd.Info{
    35  		Name:    "application-version-set",
    36  		Args:    "<new-version>",
    37  		Purpose: "specify which version of the application is deployed",
    38  		Doc:     doc,
    39  	}
    40  }
    41  
    42  // Init is part of the cmd.Command interface.
    43  func (c *applicationVersionSetCommand) Init(args []string) error {
    44  	if len(args) < 1 {
    45  		return errors.New("no version specified")
    46  	}
    47  	c.version = args[0]
    48  	return cmd.CheckEmpty(args[1:])
    49  }
    50  
    51  // Run is part of the cmd.Command interface.
    52  func (c *applicationVersionSetCommand) Run(ctx *cmd.Context) error {
    53  	return c.ctx.SetUnitWorkloadVersion(c.version)
    54  }