mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
cli: add config and images command
Extends the existing zot CLI to add commands for listing all images and their details on a zot server. Listing all images introduces the need for configurations. Each configuration has a name and URL at the least. Check 'zot config -h' for more details. The user can specify the URL of zot server explicitly while running the command or configure a URL and pass it directly. Adding a configuration: zot config add aci-zot <zot-url> Run 'zot config --help' for more. Listing all images: zot images --url <zot-url> Pass a config instead of the url: zot images <config-name> Filter the list of images by image name: zot images <config-name> --name <image-name> Run 'zot images --help' for all details - Stores configurations in '$HOME/.zot' file Add CLI README
This commit is contained in:
+10
-9
@@ -3,6 +3,7 @@ package cli_test
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
"github.com/anuvu/zot/pkg/cli"
|
||||
@@ -16,13 +17,13 @@ func TestUsage(t *testing.T) {
|
||||
|
||||
Convey("Test usage", t, func(c C) {
|
||||
os.Args = []string{"cli_test", "help"}
|
||||
err := cli.NewRootCmd().Execute()
|
||||
err := cli.NewRootCmd(os.TempDir()).Execute()
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("Test version", t, func(c C) {
|
||||
os.Args = []string{"cli_test", "--version"}
|
||||
err := cli.NewRootCmd().Execute()
|
||||
err := cli.NewRootCmd(os.TempDir()).Execute()
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
@@ -34,19 +35,19 @@ func TestServe(t *testing.T) {
|
||||
|
||||
Convey("Test serve help", t, func(c C) {
|
||||
os.Args = []string{"cli_test", "serve", "-h"}
|
||||
err := cli.NewRootCmd().Execute()
|
||||
err := cli.NewRootCmd(os.TempDir()).Execute()
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("Test serve config", t, func(c C) {
|
||||
Convey("unknown config", func(c C) {
|
||||
os.Args = []string{"cli_test", "serve", "/tmp/x"}
|
||||
So(func() { _ = cli.NewRootCmd().Execute() }, ShouldPanic)
|
||||
os.Args = []string{"cli_test", "serve", path.Join(os.TempDir(), "/x")}
|
||||
So(func() { _ = cli.NewRootCmd(os.TempDir()).Execute() }, ShouldPanic)
|
||||
})
|
||||
|
||||
Convey("non-existent config", func(c C) {
|
||||
os.Args = []string{"cli_test", "serve", "/tmp/x.yaml"}
|
||||
So(func() { _ = cli.NewRootCmd().Execute() }, ShouldPanic)
|
||||
os.Args = []string{"cli_test", "serve", path.Join(os.TempDir(), "/x.yaml")}
|
||||
So(func() { _ = cli.NewRootCmd(os.TempDir()).Execute() }, ShouldPanic)
|
||||
})
|
||||
|
||||
Convey("bad config", func(c C) {
|
||||
@@ -59,7 +60,7 @@ func TestServe(t *testing.T) {
|
||||
err = tmpfile.Close()
|
||||
So(err, ShouldBeNil)
|
||||
os.Args = []string{"cli_test", "serve", tmpfile.Name()}
|
||||
So(func() { _ = cli.NewRootCmd().Execute() }, ShouldPanic)
|
||||
So(func() { _ = cli.NewRootCmd(os.TempDir()).Execute() }, ShouldPanic)
|
||||
})
|
||||
})
|
||||
}
|
||||
@@ -71,7 +72,7 @@ func TestGC(t *testing.T) {
|
||||
|
||||
Convey("Test gc", t, func(c C) {
|
||||
os.Args = []string{"cli_test", "garbage-collect", "-h"}
|
||||
err := cli.NewRootCmd().Execute()
|
||||
err := cli.NewRootCmd(os.TempDir()).Execute()
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user