grim/convey
Clone
Summary
Browse
Changes
Graph
required_version should be required-version to match other attributes.
2018-02-18, Gary Kramlich
b4e7049d5ec1
required_version should be required-version to match other attributes.
// 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
(
"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
// 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
{
logger
.
Warnf
(
"error: %s"
,
stderr
)
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
}