grim/convey

Bump the version for release
v0.14.0-alpha3
2018-02-20, Gary Kramlich
166a6d1979fa
Bump the version for release
// Convey
// Copyright 2016-2018 Gary Kramlich <grim@reaperworld.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
package aws
import (
"fmt"
"github.com/aphistic/gomol"
"github.com/kballard/go-shellquote"
"bitbucket.org/rw_grim/convey/command"
"bitbucket.org/rw_grim/convey/docker"
"bitbucket.org/rw_grim/convey/environment"
"bitbucket.org/rw_grim/convey/state"
"bitbucket.org/rw_grim/convey/tasks"
)
// ECRGetLogin represents an `aws ecr get-login` command.
type ECRGetLogin struct {
Region string `yaml:"region"`
}
// Execute runs the `aws ecr get-login` command and calls docker login with the
// results.
func (ecr *ECRGetLogin) Execute(name string, logger *gomol.LogAdapter, env []string, st *state.State) error {
fullEnv := environment.Merge(env, st.GetEnv())
cmd := command.NewGenerator("aws", "ecr", "get-login")
if ecr.Region != "" {
region, err := environment.Mapper(ecr.Region, fullEnv)
if err != nil {
return err
}
cmd.Append("--region", region)
}
stdout, stderr, err := command.RunOutput(name, cmd.Command(), st.PlanTimeout)
if err != nil {
nErr := logger.Warnf("error: %s", stderr)
if nErr != nil {
fmt.Printf("error writing warning: %s\n", nErr)
err = nErr
}
return err
}
argv, err := shellquote.Split(stdout)
if err != nil {
return err
}
task, err := docker.ParseCommand(argv)
if err != nil {
return err
}
return task.Execute(name, logger, env, st)
}
// New creates a aws/ecr-get-login task.
func (ecr *ECRGetLogin) New() tasks.Task {
return &ECRGetLogin{}
}
// Valid checks that the build task is valid.
func (ecr *ECRGetLogin) Valid() error {
return nil
}