grim/convey

Parents 8e2f8d06ceca
Children 62c5ff7d150e
Move the docker compatiblity for login and logout to wrapper docker tasks
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/login.go Mon Oct 11 00:26:37 2021 -0500
@@ -0,0 +1,42 @@
+package docker
+
+import (
+ "fmt"
+
+ log "github.com/sirupsen/logrus"
+
+ "keep.imfreedom.org/grim/convey/environment"
+ "keep.imfreedom.org/grim/convey/podman"
+ "keep.imfreedom.org/grim/convey/runtime"
+ "keep.imfreedom.org/grim/convey/tasks"
+)
+
+type Login struct {
+ Server string `yaml:"server"`
+ Username string `yaml:"username"`
+ Password string `yaml:"password"`
+
+ realLogin *podman.Login
+}
+
+func (l *Login) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error {
+ return l.realLogin.Execute(name, logger, stageEnv, rt)
+}
+
+func (l *Login) New() tasks.Task {
+ return &Login{}
+}
+
+func (l *Login) Valid() error {
+ l.realLogin = &podman.Login{
+ Registry: l.Server,
+ Username: l.Username,
+ Password: l.Password,
+ }
+
+ return l.realLogin.Valid()
+}
+
+func (l *Login) Deprecated() error {
+ return fmt.Errorf("docker/login has been deprecated in favor of podman/login since 0.15.0")
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/docker/logout.go Mon Oct 11 00:26:37 2021 -0500
@@ -0,0 +1,38 @@
+package docker
+
+import (
+ "fmt"
+
+ log "github.com/sirupsen/logrus"
+
+ "keep.imfreedom.org/grim/convey/environment"
+ "keep.imfreedom.org/grim/convey/podman"
+ "keep.imfreedom.org/grim/convey/runtime"
+ "keep.imfreedom.org/grim/convey/tasks"
+)
+
+type Logout struct {
+ Server string `yaml:"server"`
+
+ realLogout *podman.Logout
+}
+
+func (l *Logout) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error {
+ return l.realLogout.Execute(name, logger, stageEnv, rt)
+}
+
+func (l *Logout) New() tasks.Task {
+ return &Logout{}
+}
+
+func (l *Logout) Valid() error {
+ l.realLogout = &podman.Logout{
+ Registry: l.Server,
+ }
+
+ return l.realLogout.Valid()
+}
+
+func (l *Logout) Deprecated() error {
+ return fmt.Errorf("docker/logout has been deprecated in favor of podman/logout since 0.15.0")
+}
--- a/docker/tasks.go Mon Oct 11 00:17:47 2021 -0500
+++ b/docker/tasks.go Mon Oct 11 00:26:37 2021 -0500
@@ -8,9 +8,9 @@
Tasks = map[string]tasks.Task{
"docker/import": &Import{},
"docker/export": &Export{},
- //"docker/login": &Login{},
- // "docker/logout": &Logout{},
- "docker/push": &Push{},
+ "docker/login": &Login{},
+ "docker/logout": &Logout{},
+ "docker/push": &Push{},
// "docker/run": &Run{},
}
)
--- a/podman/login.go Mon Oct 11 00:17:47 2021 -0500
+++ b/podman/login.go Mon Oct 11 00:26:37 2021 -0500
@@ -15,9 +15,6 @@
Registry string `yaml:"registry"`
Username string `yaml:"username"`
Password string `yaml:"password"`
-
- // for backwards compatibility with the old docker task
- Server string `yaml:"server"`
}
func (l *Login) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error {
@@ -43,12 +40,6 @@
}
func (l *Login) Valid() error {
- // Map the old docker/logout server setting to the new registry setting.
- if l.Server != "" && l.Registry == "" {
- l.Registry = l.Server
- }
-
- // normal new stuff
if l.Registry == "" {
return ErrNoRegistry
}
--- a/podman/login_test.go Mon Oct 11 00:17:47 2021 -0500
+++ b/podman/login_test.go Mon Oct 11 00:26:37 2021 -0500
@@ -50,16 +50,3 @@
g.Expect(l.Valid()).To(MatchError(ErrNoPassword))
}
-
-func TestLoginBackwardsCompatible(t *testing.T) {
- g := NewGomegaWithT(t)
-
- l := &Login{
- Server: "docker.io",
- Username: "username",
- Password: "password",
- }
-
- g.Expect(l.Valid()).To(BeNil())
- g.Expect(l.Registry).To(Equal("docker.io"))
-}
--- a/podman/logout.go Mon Oct 11 00:17:47 2021 -0500
+++ b/podman/logout.go Mon Oct 11 00:26:37 2021 -0500
@@ -11,9 +11,6 @@
type Logout struct {
Registry string `yaml:"registry"`
-
- // for backwards compatibility with the old docker task
- Server string `yaml:"server"`
}
func (l *Logout) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error {
@@ -35,11 +32,6 @@
}
func (l *Logout) Valid() error {
- // Map the old docker/logout server setting to the new registry setting.
- if l.Server != "" && l.Registry == "" {
- l.Registry = l.Server
- }
-
if l.Registry == "" {
return ErrNoRegistry
}
--- a/podman/logout_test.go Mon Oct 11 00:17:47 2021 -0500
+++ b/podman/logout_test.go Mon Oct 11 00:26:37 2021 -0500
@@ -23,14 +23,3 @@
g.Expect(l.Valid()).To(MatchError(ErrNoRegistry))
}
-
-func TestLogoutBackwardCompatible(t *testing.T) {
- g := NewGomegaWithT(t)
-
- l := &Logout{
- Server: "docker.io",
- }
-
- g.Expect(l.Valid()).To(BeNil())
- g.Expect(l.Registry).To(Equal("docker.io"))
-}
--- a/podman/push.go Mon Oct 11 00:17:47 2021 -0500
+++ b/podman/push.go Mon Oct 11 00:26:37 2021 -0500
@@ -12,10 +12,6 @@
type Push struct {
Tags yaml.StringOrSlice `yaml:"tags"`
-
- // for backwards compatibility with the old docker task
- Image string `yaml:"image"`
- Images yaml.StringOrSlice `yaml:"images"`
}
func (p *Push) Execute(name string, logger *log.Entry, stageEnv environment.Environment, rt *runtime.Runtime) error {
@@ -43,17 +39,6 @@
}
func (p *Push) Valid() error {
- // The old docker overwrote the images value if the image attribute was
- // set.
- if p.Image != "" {
- p.Tags = yaml.StringOrSlice{p.Image}
- p.Images = nil
- }
-
- if p.Images != nil {
- p.Tags = p.Images
- }
-
if len(p.Tags) == 0 {
return ErrNoTags
}
--- a/podman/push_test.go Mon Oct 11 00:17:47 2021 -0500
+++ b/podman/push_test.go Mon Oct 11 00:26:37 2021 -0500
@@ -35,25 +35,3 @@
g.Expect(p.Valid()).To(MatchError(ErrNoTags))
}
-
-func TestPushBackwardsCompatibleImage(t *testing.T) {
- g := NewGomegaWithT(t)
-
- p := &Push{
- Image: "foo",
- }
-
- g.Expect(p.Valid()).To(BeNil())
- g.Expect(p.Tags).To(Equal(yaml.StringOrSlice{"foo"}))
-}
-
-func TestPushBackwardsCompatibleImages(t *testing.T) {
- g := NewGomegaWithT(t)
-
- p := Push{
- Images: yaml.StringOrSlice{"foo", "bar"},
- }
-
- g.Expect(p.Valid()).To(BeNil())
- g.Expect(p.Tags).To(Equal(yaml.StringOrSlice{"foo", "bar"}))
-}