diff --git a/README.md b/README.md index 2b3e11b51..c9da4c50c 100644 --- a/README.md +++ b/README.md @@ -144,8 +144,7 @@ create: | create.with\_clean | Clean up unused layers before creating rootfs | | create.uid_mappings | UID mapping for image translation, e.g.: \:\:\ | | create.gid_mappings | GID mapping for image translation, e.g.: \:\:\ | -| create.json | Format the output as JSON | -| create.without_mount | Don't perform the rootfs mount and return the mount information in the json output. Only usable with --json. | +| create.without_mount | Don't perform the rootfs mount. | | clean.ignore\_images | Images to ignore during cleanup | | clean.threshold\_bytes | Disk usage of the store directory at which cleanup should trigger | @@ -198,35 +197,22 @@ grootfs --store /mnt/btrfs create /my-rootfs.tar my-image-id #### Output -The output of this command is the image path -(`/mnt/btrfs/images//my-image-id`) which has the following structure: - -* The `` is the effective user id running the command. +The output of this command is a json object which has the following structure: ``` - -|____ rootfs/ -|____ image.json +{ + "rootfs": "...", # complete path to the image rootfs, which lives in /rootfs + "config": {...}, # contents of image config, also writen to /image.json +} ``` -* The `rootfs` folder is where the root filesystem lives. -* The `image.json` file follows the [OCI image +* The `/rootfs` folder is where the root filesystem lives. +* The `/image.json` file follows the [OCI image description](https://github.com/opencontainers/image-spec/blob/master/serialization.md#image-json-description) schema. -##### JSON - -When create is provided with a `--json` flag, it will print the output as json. -The json will contain: - -``` -{ - "rootfs": "...", # complete path to the image rootfs - "config": {...}, # contents of image config, also writen to /image.json -} -``` -If `--without-mount` flag is provided (or `create.without_mount = true` in config), +If the `--without-mount` flag is provided (or `create.without_mount = true` in config), the json output will also contain the `mount` key: ``` @@ -240,11 +226,10 @@ the json output will also contain the `mount` key: ... ``` -Special notes about `--without-mount`/`create.without_mount`: +The `--without-mount` option exists so that GrootFS can be run as non-root. The mount information is compatible +with [OCI container spec](https://github.com/opencontainers/runtime-spec/blob/master/config.md#example-linux). + -* It can only be used in combination with the `--json` (or `create.json` in config) option -* This option exists so that GrootFS can be run as non-root. The mount information -is compatible with [OCI container spec](https://github.com/opencontainers/runtime-spec/blob/master/config.md#example-linux). #### User/Group ID Mapping diff --git a/commands/config/builder.go b/commands/config/builder.go index a02352367..b97b3f7f7 100644 --- a/commands/config/builder.go +++ b/commands/config/builder.go @@ -27,7 +27,6 @@ type Create struct { ExcludeImageFromQuota bool `yaml:"exclude_image_from_quota"` WithClean bool `yaml:"with_clean"` WithoutMount bool `yaml:"without_mount"` - Json bool `yaml:"json"` DiskLimitSizeBytes int64 `yaml:"disk_limit_size_bytes"` InsecureRegistries []string `yaml:"insecure_registries"` GIDMappings []string `yaml:"gid_mappings"` @@ -228,18 +227,6 @@ func (b *Builder) WithMount(mount bool, noMount bool) *Builder { return b } -func (b *Builder) WithJson(json bool, noJson bool) *Builder { - if json { - b.config.Create.Json = true - } - - if noJson { - b.config.Create.Json = false - } - - return b -} - func load(configPath string) (Config, error) { configContent, err := ioutil.ReadFile(configPath) if err != nil { diff --git a/commands/config/builder_test.go b/commands/config/builder_test.go index 5a5eccb99..eed57f6e1 100644 --- a/commands/config/builder_test.go +++ b/commands/config/builder_test.go @@ -31,7 +31,6 @@ var _ = Describe("Builder", func() { GIDMappings: []string{"config-gid-mapping"}, InsecureRegistries: []string{"http://example.org"}, DiskLimitSizeBytes: int64(1000), - Json: false, } cleanCfg = config.Clean{ @@ -602,47 +601,6 @@ var _ = Describe("Builder", func() { }) }) - Describe("WithJson", func() { - Context("when no-json is set, and json is not set", func() { - BeforeEach(func() { - cfg.Create.Json = true - }) - - It("overrides the config's entry", func() { - builder = builder.WithJson(false, true) - config, err := builder.Build() - Expect(err).NotTo(HaveOccurred()) - Expect(config.Create.Json).To(BeFalse()) - }) - }) - - Context("when no-json is not set, and json is set", func() { - BeforeEach(func() { - cfg.Create.Json = false - }) - - It("overrides the config's entry", func() { - builder = builder.WithJson(true, false) - config, err := builder.Build() - Expect(err).NotTo(HaveOccurred()) - Expect(config.Create.Json).To(BeTrue()) - }) - }) - - Context("when no-json is not set, and json is not set", func() { - BeforeEach(func() { - cfg.Create.Json = true - }) - - It("uses the config value", func() { - builder = builder.WithJson(false, false) - config, err := builder.Build() - Expect(err).NotTo(HaveOccurred()) - Expect(config.Create.Json).To(BeTrue()) - }) - }) - }) - Describe("WithMount", func() { Context("when without-mount is set, and with-mount is not set", func() { BeforeEach(func() { diff --git a/commands/create.go b/commands/create.go index a6cd7fdbf..aebe9c0de 100644 --- a/commands/create.go +++ b/commands/create.go @@ -71,15 +71,7 @@ var CreateCommand = cli.Command{ }, cli.BoolFlag{ Name: "without-mount", - Usage: "Do not mount the root filesystem. Must be used in conjunction with --json.", - }, - cli.BoolFlag{ - Name: "json", - Usage: "Print RootFS Path and container config as JSON", - }, - cli.BoolFlag{ - Name: "no-json", - Usage: "Do NOT print RootFS Path and container config as JSON", + Usage: "Do not mount the root filesystem.", }, cli.StringFlag{ Name: "username", @@ -110,7 +102,6 @@ var CreateCommand = cli.Command{ WithExcludeImageFromQuota(ctx.Bool("exclude-image-from-quota"), ctx.IsSet("exclude-image-from-quota")). WithClean(ctx.IsSet("with-clean"), ctx.IsSet("without-clean")). - WithJson(ctx.IsSet("json"), ctx.IsSet("no-json")). WithMount(ctx.IsSet("with-mount"), ctx.IsSet("without-mount")) cfg, err := configBuilder.Build() @@ -218,7 +209,6 @@ var CreateCommand = cli.Command{ createSpec := groot.CreateSpec{ ID: id, - Json: cfg.Create.Json, Mount: !cfg.Create.WithoutMount, BaseImage: baseImage, DiskLimit: cfg.Create.DiskLimitSizeBytes, @@ -236,19 +226,12 @@ var CreateCommand = cli.Command{ return newExitError(humanizedError, 1) } - var output string - if cfg.Create.Json { - jsonBytes, err := json.Marshal(image) - if err != nil { - logger.Error("formatting output", err) - return newExitError(err.Error(), 1) - } - output = string(jsonBytes) - } else { - output = image.Path + jsonBytes, err := json.Marshal(image) + if err != nil { + logger.Error("formatting output", err) + return newExitError(err.Error(), 1) } - - fmt.Println(output) + fmt.Println(string(jsonBytes)) usage, err := sm.MeasureStore(logger) if err != nil { @@ -344,13 +327,5 @@ func validateOptions(ctx *cli.Context, cfg config.Config) error { return errorspkg.New("with-clean and without-clean cannot be used together") } - if ctx.IsSet("json") && ctx.IsSet("no-json") { - return errorspkg.New("json and no-json cannot be used together") - } - - if cfg.Create.WithoutMount && !cfg.Create.Json { - return errorspkg.New("without-mount option must be used with the json option") - } - return nil } diff --git a/groot/creator.go b/groot/creator.go index 2433aed32..8996f8552 100644 --- a/groot/creator.go +++ b/groot/creator.go @@ -17,7 +17,6 @@ type CreateSpec struct { ID string BaseImage string DiskLimit int64 - Json bool Mount bool ExcludeBaseImageFromQuota bool CleanOnCreate bool diff --git a/integration/create_local_test.go b/integration/create_local_test.go index 9e5e1585c..7db9dbf60 100644 --- a/integration/create_local_test.go +++ b/integration/create_local_test.go @@ -49,7 +49,6 @@ var _ = Describe("Create with local images", func() { BaseImage: baseImagePath, ID: "random-id", Mount: mountByDefault(), - Json: true, } }) @@ -87,7 +86,6 @@ var _ = Describe("Create with local images", func() { ID: "another-random-id", BaseImage: baseImagePath, Mount: false, - Json: true, }) Expect(err).NotTo(HaveOccurred()) @@ -127,7 +125,6 @@ var _ = Describe("Create with local images", func() { ID: "my-image-1", BaseImage: baseImagePath, Mount: true, - Json: true, }) Expect(err).NotTo(HaveOccurred()) @@ -146,7 +143,6 @@ var _ = Describe("Create with local images", func() { ID: "my-image-2", BaseImage: baseImage2Path, Mount: true, - Json: true, } _, err := Runner.Create(createSpec) Expect(err).NotTo(HaveOccurred()) @@ -234,7 +230,6 @@ var _ = Describe("Create with local images", func() { ID: "random-id-2", BaseImage: baseImagePath, Mount: mountByDefault(), - Json: true, }) Expect(err).NotTo(HaveOccurred()) Expect(Runner.EnsureMounted(image)).To(Succeed()) @@ -259,7 +254,6 @@ var _ = Describe("Create with local images", func() { ID: "random-id-2", BaseImage: baseImagePath, Mount: mountByDefault(), - Json: true, }) Expect(Runner.EnsureMounted(image)).To(Succeed()) Expect(err).NotTo(HaveOccurred()) @@ -274,7 +268,6 @@ var _ = Describe("Create with local images", func() { BaseImage: "/invalid/image", ID: "random-id", Mount: false, - Json: true, }) Expect(err).To(MatchError(ContainSubstring("stat /invalid/image: no such file or directory"))) }) diff --git a/integration/create_overlayxfs_test.go b/integration/create_overlayxfs_test.go index 339212330..b15cd8f6e 100644 --- a/integration/create_overlayxfs_test.go +++ b/integration/create_overlayxfs_test.go @@ -44,7 +44,6 @@ var _ = Describe("Create (overlay-xfs only)", func() { BaseImage: baseImagePath, ID: "random-id", Mount: mountByDefault(), - Json: !mountByDefault(), DiskLimit: tenMegabytes, } }) diff --git a/integration/create_remote_test.go b/integration/create_remote_test.go index f20acd970..c23523e3a 100644 --- a/integration/create_remote_test.go +++ b/integration/create_remote_test.go @@ -85,12 +85,12 @@ var _ = Describe("Create with remote images", func() { ID: "random-id", Mount: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) Expect(err).NotTo(HaveOccurred()) @@ -104,43 +104,41 @@ var _ = Describe("Create with remote images", func() { Eventually(sess).Should(gexec.Exit(0)) }) - Context("when the --json flag is provided", func() { - It("outputs a json with the correct `rootfs` key", func() { - image, err := Runner.WithJson().Create(groot.CreateSpec{ - BaseImage: "docker:///busybox:1.26.2", - ID: "random-id", - Mount: true, - UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, - }, - GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, - }, - }) - Expect(err).NotTo(HaveOccurred()) - - Expect(image.Rootfs).To(Equal(filepath.Join(StorePath, store.ImageDirName, "random-id", "rootfs"))) + It("outputs a json with the correct `rootfs` key", func() { + image, err := Runner.Create(groot.CreateSpec{ + BaseImage: "docker:///busybox:1.26.2", + ID: "random-id", + Mount: true, + UIDMappings: []groot.IDMappingSpec{ + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, + }, + GIDMappings: []groot.IDMappingSpec{ + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, + }, }) + Expect(err).NotTo(HaveOccurred()) - It("outputs a json with the correct `config` key", func() { - image, err := Runner.WithJson().Create(groot.CreateSpec{ - BaseImage: "docker:///busybox:1.26.2", - ID: "random-id", - Mount: true, - UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, - }, - GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, - }, - }) - Expect(err).NotTo(HaveOccurred()) - Expect(image.Image.RootFS.DiffIDs[0]).To(Equal("sha256:" + testhelpers.BusyBoxImage.Layers[0].ChainID)) + Expect(image.Rootfs).To(Equal(filepath.Join(StorePath, store.ImageDirName, "random-id", "rootfs"))) + }) + + It("outputs a json with the correct `config` key", func() { + image, err := Runner.Create(groot.CreateSpec{ + BaseImage: "docker:///busybox:1.26.2", + ID: "random-id", + Mount: true, + UIDMappings: []groot.IDMappingSpec{ + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, + }, + GIDMappings: []groot.IDMappingSpec{ + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, + }, }) + Expect(err).NotTo(HaveOccurred()) + Expect(image.Image.RootFS.DiffIDs[0]).To(Equal("sha256:" + testhelpers.BusyBoxImage.Layers[0].ChainID)) }) Context("when the image is bigger than available memory", func() { @@ -232,12 +230,12 @@ var _ = Describe("Create with remote images", func() { ID: "random-id", Mount: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) Expect(err).NotTo(HaveOccurred()) @@ -261,12 +259,12 @@ var _ = Describe("Create with remote images", func() { ID: "random-id", Mount: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) Expect(err).NotTo(HaveOccurred()) @@ -434,7 +432,6 @@ var _ = Describe("Create with remote images", func() { BaseImage: baseImageURL, ID: "random-id", Mount: mountByDefault(), - Json: !mountByDefault(), ExcludeBaseImageFromQuota: true, DiskLimit: 10, }) @@ -448,7 +445,6 @@ var _ = Describe("Create with remote images", func() { BaseImage: baseImageURL, ID: "random-id", Mount: mountByDefault(), - Json: !mountByDefault(), DiskLimit: 10, }) Expect(err).To(MatchError(ContainSubstring("layers exceed disk quota"))) diff --git a/integration/create_test.go b/integration/create_test.go index d4e9c6475..9d9b9ac85 100644 --- a/integration/create_test.go +++ b/integration/create_test.go @@ -83,7 +83,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "random-id", Mount: mountByDefault(), - Json: true, }) Expect(err).ToNot(HaveOccurred()) @@ -111,14 +110,13 @@ var _ = Describe("Create", func() { ID: "some-id", BaseImage: baseImagePath, Mount: mountByDefault(), - Json: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) Expect(err).NotTo(HaveOccurred()) @@ -155,16 +153,15 @@ var _ = Describe("Create", func() { image, err := Runner.WithLogLevel(lager.DEBUG). Create(groot.CreateSpec{ Mount: mountByDefault(), - Json: true, ID: "some-id", BaseImage: baseImagePath, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) Expect(err).NotTo(HaveOccurred()) @@ -194,7 +191,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "random-id", Mount: false, - Json: true, }) Expect(err).ToNot(HaveOccurred()) Expect(storePath).To(BeADirectory()) @@ -210,7 +206,6 @@ var _ = Describe("Create", func() { ID: "some-id", BaseImage: baseImagePath, Mount: false, - Json: true, }) Expect(err).NotTo(HaveOccurred()) @@ -238,14 +233,13 @@ var _ = Describe("Create", func() { ID: "some-id", BaseImage: baseImagePath, Mount: false, - Json: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: 1000, NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: 1000, NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: 1000, NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: 1000, NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) @@ -274,12 +268,11 @@ var _ = Describe("Create", func() { ID: "some-id", BaseImage: baseImagePath, Mount: false, - Json: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) @@ -297,7 +290,6 @@ var _ = Describe("Create", func() { ID: "random-id", BaseImage: "my-image", Mount: false, - Json: true, }) Expect(err).To(HaveOccurred()) Expect(logBuffer).To(gbytes.Say(`"id":"random-id"`)) @@ -318,7 +310,6 @@ var _ = Describe("Create", func() { ID: "random-id", DiskLimit: tenMegabytes, Mount: mountByDefault(), - Json: !mountByDefault(), }) Expect(err).ToNot(HaveOccurred()) @@ -333,7 +324,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "random-id", Mount: mountByDefault(), - Json: !mountByDefault(), }) Expect(err).To(MatchError(ContainSubstring("disk limit cannot be negative"))) }) @@ -347,7 +337,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "random-id", Mount: mountByDefault(), - Json: !mountByDefault(), }) Expect(err).ToNot(HaveOccurred()) @@ -369,14 +358,13 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "foobar", Mount: false, - Json: true, UIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootUID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootUID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, GIDMappings: []groot.IDMappingSpec{ - groot.IDMappingSpec{HostID: int(GrootGID), NamespaceID: 0, Size: 1}, - groot.IDMappingSpec{HostID: 100000, NamespaceID: 1, Size: 65000}, + {HostID: int(GrootGID), NamespaceID: 0, Size: 1}, + {HostID: 100000, NamespaceID: 1, Size: 65000}, }, }) Expect(err).ToNot(HaveOccurred()) @@ -388,7 +376,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "foobar2", Mount: false, - Json: true, }) Expect(err).To(MatchError("store already initialized with a different mapping")) }) @@ -420,7 +407,6 @@ var _ = Describe("Create", func() { ID: "my-empty", BaseImage: "docker:///cfgarden/empty:v0.1.1", Mount: false, - Json: true, CleanOnCreate: true, }) Expect(err).NotTo(HaveOccurred()) @@ -460,7 +446,6 @@ var _ = Describe("Create", func() { ID: "my-empty", BaseImage: "docker:///cfgarden/empty:v0.1.1", Mount: true, - Json: true, CleanOnCreate: false, }) Expect(err).NotTo(HaveOccurred()) @@ -487,24 +472,12 @@ var _ = Describe("Create", func() { }) }) - Context("when both json and no-json flags are given", func() { - It("returns an error", func() { - _, err := Runner.WithJson().WithNoJson().Create(groot.CreateSpec{ - ID: "my-empty", - BaseImage: "docker:///cfgarden/empty:v0.1.1", - Mount: false, - }) - Expect(err).To(MatchError(ContainSubstring("json and no-json cannot be used together"))) - }) - }) - Context("when the id is already being used", func() { JustBeforeEach(func() { _, err := Runner.Create(groot.CreateSpec{ ID: "random-id", BaseImage: baseImagePath, Mount: false, - Json: true, }) Expect(err).NotTo(HaveOccurred()) }) @@ -514,7 +487,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "random-id", Mount: false, - Json: true, }) Expect(err).To(MatchError(ContainSubstring("image for id `random-id` already exists"))) }) @@ -537,7 +509,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "this/is/not/okay", Mount: false, - Json: true, }) Expect(err).To(MatchError(ContainSubstring("id `this/is/not/okay` contains invalid characters: `/`"))) }) @@ -549,7 +520,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "random-id", Mount: false, - Json: true, }) Expect(err).To(MatchError("Image id 'random-id': Store path filesystem (/mnt/ext4) is incompatible with requested driver")) }) @@ -561,7 +531,6 @@ var _ = Describe("Create", func() { BaseImage: baseImagePath, ID: "some-id", Mount: true, - Json: true, }) Expect(err).To(MatchError(ContainSubstring("filesystem driver not supported: dinosaurfs"))) }) @@ -573,7 +542,6 @@ var _ = Describe("Create", func() { ID: "some-id", BaseImage: "*@#%^!&", Mount: false, - Json: true, }) Expect(err).To(MatchError(ContainSubstring("parsing image url: parse"))) Expect(err).To(MatchError(ContainSubstring("invalid URL escape"))) @@ -595,7 +563,6 @@ var _ = Describe("Create", func() { ID: "random-id", BaseImage: baseImagePath, Mount: mountByDefault(), - Json: true, } }) @@ -677,7 +644,6 @@ var _ = Describe("Create", func() { ID: "random-id", DiskLimit: 104857600, Mount: mountByDefault(), - Json: !mountByDefault(), }) Expect(err).NotTo(HaveOccurred()) @@ -698,7 +664,6 @@ var _ = Describe("Create", func() { ID: "random-id", BaseImage: baseImagePath, Mount: mountByDefault(), - Json: true, }) Expect(err).NotTo(HaveOccurred()) @@ -746,22 +711,19 @@ var _ = Describe("Create", func() { }) }) - Describe("json", func() { - It("returns an image json as output", func() { - image, err := Runner.Create(groot.CreateSpec{ - ID: "random-id", - BaseImage: baseImagePath, - Json: true, - Mount: false, - }) - Expect(err).ToNot(HaveOccurred()) - - expectedRootfs := filepath.Join(StorePath, store.ImageDirName, "random-id/rootfs") - Expect(image.Rootfs).To(Equal(expectedRootfs)) - Expect(image.Mount).NotTo(BeNil()) - Expect(image.Mount.Destination).To(Equal(expectedRootfs)) - Expect(image.Image).To(BeNil()) + It("returns an image json as output", func() { + image, err := Runner.Create(groot.CreateSpec{ + ID: "random-id", + BaseImage: baseImagePath, + Mount: false, }) + Expect(err).ToNot(HaveOccurred()) + + expectedRootfs := filepath.Join(StorePath, store.ImageDirName, "random-id/rootfs") + Expect(image.Rootfs).To(Equal(expectedRootfs)) + Expect(image.Mount).NotTo(BeNil()) + Expect(image.Mount.Destination).To(Equal(expectedRootfs)) + Expect(image.Image).To(BeNil()) }) Describe("without mount", func() { @@ -769,7 +731,6 @@ var _ = Describe("Create", func() { image, err := Runner.Create(groot.CreateSpec{ ID: "some-id", BaseImage: baseImagePath, - Json: true, Mount: false, }) Expect(err).NotTo(HaveOccurred()) @@ -790,7 +751,6 @@ var _ = Describe("Create", func() { ID: "some-id", BaseImage: baseImagePath, Mount: false, - Json: true, }) Expect(err).NotTo(HaveOccurred()) }) @@ -830,18 +790,6 @@ var _ = Describe("Create", func() { )) }) }) - - Context("but `json` is not set", func() { - It("returns an error", func() { - _, err := Runner.Create(groot.CreateSpec{ - ID: "my-empty", - BaseImage: "docker:///cfgarden/empty:v0.1.1", - Mount: false, - Json: false, - }) - Expect(err).To(MatchError(ContainSubstring("without-mount option must be used with the json option"))) - }) - }) }) }) diff --git a/integration/runner/create.go b/integration/runner/create.go index f1f9ac633..f0e4d0ddd 100644 --- a/integration/runner/create.go +++ b/integration/runner/create.go @@ -46,14 +46,8 @@ func (r Runner) Create(spec groot.CreateSpec) (groot.ImageInfo, error) { } imageInfo := groot.ImageInfo{} - - if r.Json || spec.Json { - json.Unmarshal([]byte(output), &imageInfo) - imageInfo.Path = filepath.Dir(imageInfo.Rootfs) - } else { - imageInfo.Path = output - imageInfo.Rootfs = filepath.Join(imageInfo.Path, "rootfs") - } + json.Unmarshal([]byte(output), &imageInfo) + imageInfo.Path = filepath.Dir(imageInfo.Rootfs) return imageInfo, nil } @@ -94,19 +88,6 @@ func (r Runner) makeCreateArgs(spec groot.CreateSpec) []string { } } - if r.Json || r.NoJson { - if r.Json { - args = append(args, "--json") - } - if r.NoJson { - args = append(args, "--no-json") - } - } else { - if spec.Json { - args = append(args, "--json") - } - } - if spec.Mount { args = append(args, "--with-mount") } else { diff --git a/integration/runner/globals.go b/integration/runner/globals.go index 79ee278fa..16b369ebd 100644 --- a/integration/runner/globals.go +++ b/integration/runner/globals.go @@ -237,22 +237,6 @@ func (r Runner) WithNoClean() Runner { return nr } -/////////////////////////////////////////////////////////////////////////////// -// Json -/////////////////////////////////////////////////////////////////////////////// - -func (r Runner) WithJson() Runner { - nr := r - nr.Json = true - return nr -} - -func (r Runner) WithNoJson() Runner { - nr := r - nr.NoJson = true - return nr -} - /////////////////////////////////////////////////////////////////////////////// // SysProcAttributes /////////////////////////////////////////////////////////////////////////////// diff --git a/integration/runner/runner.go b/integration/runner/runner.go index 613fc9b9d..f8c5279ff 100644 --- a/integration/runner/runner.go +++ b/integration/runner/runner.go @@ -52,9 +52,6 @@ type Runner struct { // Clean on Create CleanOnCreate bool NoCleanOnCreate bool - // Jason - Json bool - NoJson bool SysCredential *syscall.Credential } diff --git a/playground/config.yml b/playground/config.yml index 9febdb51d..cbe9cad9b 100644 --- a/playground/config.yml +++ b/playground/config.yml @@ -14,7 +14,6 @@ clean: create: insecure_registries: [] with_clean: false - json: false without_mount: false uid_mappings: - "0:4294967294:1" diff --git a/playground/privileged_config.yml b/playground/privileged_config.yml index c4e982794..67d2cc773 100644 --- a/playground/privileged_config.yml +++ b/playground/privileged_config.yml @@ -14,5 +14,4 @@ clean: create: insecure_registries: [] with_clean: false - json: false without_mount: false diff --git a/vendor/github.com/containers/image b/vendor/github.com/containers/image index 165795ddc..9fcd2ba2c 160000 --- a/vendor/github.com/containers/image +++ b/vendor/github.com/containers/image @@ -1 +1 @@ -Subproject commit 165795ddcbebe9754b565ca95e00b49779dbc959 +Subproject commit 9fcd2ba2c6983f74026db5f2c0f79b529a098dee