Add new task aws/ecr-login for logging into AWS ECR. Fixed #161
--- a/ChangeLog Tue Feb 13 22:42:18 2018 -0600
+++ b/ChangeLog Tue Feb 13 22:42:39 2018 -0600
@@ -14,6 +14,7 @@
* Add copies of all VCS environment variables without their prefix as well as
a VCS environment variable. Fixed #164
+ * Added a new aws/ecr-login task for logging into AWS ECR. Fixed #161 * Write warning, error, and fatal log messages to stderr. Fixed #156
--- a/REFERENCE.md Tue Feb 13 22:42:18 2018 -0600
+++ b/REFERENCE.md Tue Feb 13 22:42:39 2018 -0600
@@ -135,6 +135,24 @@
+The `aws/ecr-login` task will log into AWS Elastic Container Registry. It +depends on the AWS cli package being installed and configured to work. +| Name | Required | Default | Description | +| ------ | -------- | ------- | ----------- | +| region | | | The AWS region to used. | A clean task will remove files from the host relative and limited to the working directory of convey.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aws/aws.go Tue Feb 13 22:42:39 2018 -0600
@@ -0,0 +1,29 @@
+// 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 intrinsic contains the intrinsic commands + "bitbucket.org/rw_grim/convey/tasks" + // Tasks is a map of intrinsic tasks. + Tasks = map[string]tasks.Task{ + "ecr-login": &ECRGetLogin{}, --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aws/data/ecr-test.yml Tue Feb 13 22:42:39 2018 -0600
@@ -0,0 +1,21 @@
+ - ACCOUNT_ID=1234567890 + destination: ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/alpine:edge + image: ${ACCOUNT_ID}.dkr.ecr.${REGION}.amazonaws.com/alpine:edge --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aws/ecr-get-login.go Tue Feb 13 22:42:39 2018 -0600
@@ -0,0 +1,75 @@
+// 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/>. + "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" +type ECRGetLogin struct { + Region string `yaml:"region"` +// Executes the `aws ecr get-login` command and calls docker login with the +func (ecr *ECRGetLogin) Execute(name string, logger *gomol.LogAdapter, env []string, st *state.State) error { + cmd := command.NewGenerator("aws", "ecr", "get-login") + region, err := environment.Mapper(ecr.Region, env) + cmd.Append("--region", region) + stdout, stderr, err := command.RunOutput(name, cmd.Command(), st.PlanTimeout) + logger.Warnf("error: %s", stderr) + argv, err := shellquote.Split(stdout) + task, err := docker.ParseCommand(argv) + return task.Execute(name, logger, env, st) +// New creates a aws/ecr-get-login task. +func (ecr *ECRGetLogin) New() tasks.Task { +// Valid checks that the build task is valid. +func (ecr *ECRGetLogin) Valid() error { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/aws/errors.go Tue Feb 13 22:42:39 2018 -0600
@@ -0,0 +1,25 @@
+// 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/>. + errNoRegion = errors.New("no region specified") --- a/config/tasks.go Tue Feb 13 22:42:18 2018 -0600
+++ b/config/tasks.go Tue Feb 13 22:42:39 2018 -0600
@@ -17,6 +17,7 @@
+ "bitbucket.org/rw_grim/convey/aws" "bitbucket.org/rw_grim/convey/docker"
"bitbucket.org/rw_grim/convey/intrinsic"
"bitbucket.org/rw_grim/convey/tasks"
@@ -36,6 +37,11 @@
TasksMap["docker/"+taskName] = task
+ for taskName, task := range aws.Tasks { + TasksMap["aws/"+taskName] = task // add the intrinsic convey tasks
for taskName, task := range intrinsic.Tasks {
TasksMap["convey/"+taskName] = task