Skip to content

Commit

Permalink
Add login and logout methods for convenience of use
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-cmsoft committed Nov 21, 2024
1 parent 89e9999 commit f530382
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/login.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cmd

import (
craneCmd "github.com/google/go-containerregistry/cmd/crane/cmd"
"github.com/spf13/cobra"
)

func LoginCmd() *cobra.Command {

// For simplicity, and because we use the library quite a bit, we'll just replicate the crane login CMD
// and update the usage instructions to match the gooci style

command := craneCmd.NewCmdAuthLogin()
command.Short = "Login to a remote registry"
command.Example = ""

return command
}
17 changes: 17 additions & 0 deletions cmd/logout.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cmd

import (
craneCmd "github.com/google/go-containerregistry/cmd/crane/cmd"
"github.com/spf13/cobra"
)

func LogoutCmd() *cobra.Command {

// For simplicity, and because we use the library quite a bit, we'll just replicate the crane logout CMD
// and update the usage instructions to match the gooci style

command := craneCmd.NewCmdAuthLogout()
command.Example = ""

return command
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/docker/cli v27.1.1+incompatible // indirect
github.com/docker/distribution v2.8.2+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o
github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8=
github.com/vbatts/tar-split v0.11.3 h1:hLFqsOLQ1SsppQNTMpkpPXClLDfC2A3Zgy9OUU+RVck=
github.com/vbatts/tar-split v0.11.3/go.mod h1:9QlHN18E+fEH7RdG+QAJJcuya3rqT7eXSTY7wGrAokY=
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220906165534-d0df966e6959/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
2 changes: 2 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func main() {

rootCmd.AddCommand(cmd.UploadReleaseCmd())
rootCmd.AddCommand(cmd.DownloadReleaseCmd())
rootCmd.AddCommand(cmd.LoginCmd())
rootCmd.AddCommand(cmd.LogoutCmd())

if err := rootCmd.Execute(); err != nil {
log.Fatal(err)
Expand Down

0 comments on commit f530382

Please sign in to comment.