--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/data/aws-ecr-get-login.txt Tue Feb 13 22:42:18 2018 -0600
@@ -0,0 +1,1 @@
+docker login -u AWS -p password -e none https://1234567890.dkr.ecr.us-east-2.amazonaws.com --- a/docker/docker_test.go Tue Feb 13 20:47:39 2018 -0600
+++ b/docker/docker_test.go Tue Feb 13 22:42:18 2018 -0600
@@ -34,5 +34,6 @@
s.AddSuite(&dockerSuite{})
s.AddSuite(&workspaceSuite{})
+ s.AddSuite(&parserSuite{}) --- a/docker/parser.go Tue Feb 13 20:47:39 2018 -0600
+++ b/docker/parser.go Tue Feb 13 22:42:18 2018 -0600
@@ -33,6 +33,9 @@
login := app.Command("login", "")
loginUsername := login.Flag("username", "").Short('u').Default("").String()
loginPassword := login.Flag("password", "").Short('p').Default("").String()
+ // `aws ecr get-login adds environment variables to the login command, + // this handles that, but we ignore them. + login.Flag("env", "").Short('e').Default("").Strings() loginServer := login.Arg("", "").String()
logout := app.Command("logout", "")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/parser_test.go Tue Feb 13 22:42:18 2018 -0600
@@ -0,0 +1,47 @@
+// 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/sweet" + "github.com/kballard/go-shellquote" + . "github.com/onsi/gomega" +type parserSuite struct{} +func (s *parserSuite) TestECRGetLogin(t sweet.T) { + // load the file with our test data + data := t.Sweet().LoadFile("data/aws-ecr-get-login.txt") + // shell split the data from the file + argv, err := shellquote.Split(string(data)) + Expect(err).To(BeNil()) + task, err := ParseCommand(argv) + Expect(err).To(BeNil()) + Expect(task).To(Not(BeNil())) + // make sure we can type assert into a Login command + Expect(task).To(BeAssignableToTypeOf(&Login{})) + // now check the login command + Expect(login.Username).To(Equal("AWS")) + Expect(login.Password).To(Equal("password")) + Expect(login.Server).To(Equal("https://1234567890.dkr.ecr.us-east-2.amazonaws.com"))