diff options
191 files changed, 1234 insertions, 18054 deletions
diff --git a/docs/source/markdown/podman-attach.1.md b/docs/source/markdown/podman-attach.1.md index eb770d07d..c4a5eec50 100644 --- a/docs/source/markdown/podman-attach.1.md +++ b/docs/source/markdown/podman-attach.1.md @@ -14,24 +14,24 @@ or name, either to view its ongoing output or to control it interactively. You can detach from the container (and leave it running) using a configurable key sequence. The default sequence is `ctrl-p,ctrl-q`. -Configure the keys sequence using the **\-\-detach-keys** option, or specifying +Configure the keys sequence using the **--detach-keys** option, or specifying it in the **containers.conf** file: see **containers.conf(5)** for more information. ## OPTIONS -#### **\-\-detach-keys**=*sequence* +#### **--detach-keys**=*sequence* Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-no-stdin** +#### **--no-stdin** Do not attach STDIN. The default is false. -#### **\-\-sig-proxy**=*true*|*false* +#### **--sig-proxy**=*true*|*false* Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied. The default is *true*. diff --git a/docs/source/markdown/podman-auto-update.1.md b/docs/source/markdown/podman-auto-update.1.md index 12e8bc70f..1bb5d4bbe 100644 --- a/docs/source/markdown/podman-auto-update.1.md +++ b/docs/source/markdown/podman-auto-update.1.md @@ -38,7 +38,7 @@ Podman ships with a `podman-auto-update.service` systemd unit. This unit is tri ## OPTIONS -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. diff --git a/docs/source/markdown/podman-build.1.md b/docs/source/markdown/podman-build.1.md index 1d6aa3d40..f173b24b4 100644 --- a/docs/source/markdown/podman-build.1.md +++ b/docs/source/markdown/podman-build.1.md @@ -45,14 +45,14 @@ command to see these containers. External containers can be removed with the ## OPTIONS -#### **\-\-add-host**=*host* +#### **--add-host**=*host* Add a custom host-to-IP mapping (host:ip) -Add a line to /etc/hosts. The format is hostname:ip. The **\-\-add-host** option +Add a line to /etc/hosts. The format is hostname:ip. The **--add-host** option can be set multiple times. -#### **\-\-annotation**=*annotation* +#### **--annotation**=*annotation* Add an image *annotation* (e.g. annotation=*value*) to the image metadata. Can be used multiple times. @@ -60,12 +60,12 @@ be used multiple times. Note: this information is not present in Docker image formats, so it is discarded when writing images in Docker formats. -#### **\-\-arch**=*arch* +#### **--arch**=*arch* Set the ARCH of the image to the provided value instead of the architecture of the host. -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. @@ -76,26 +76,26 @@ Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-build-arg**=*arg=value* +#### **--build-arg**=*arg=value* Specifies a build argument and its value, which will be interpolated in instructions read from the Containerfiles in the same way that environment variables are, but which will not be added to environment variable list in the resulting image's configuration. -#### **\-\-cache-from** +#### **--cache-from** Images to utilize as potential cache sources. Podman does not currently support caching so this is a NOOP. (This option is not available with the remote Podman client) -#### **\-\-cap-add**=*CAP\_xxx* +#### **--cap-add**=*CAP\_xxx* When executing RUN instructions, run the command specified in the instruction with the specified capability added to its capability set. Certain capabilities are granted by default; this option can be used to add more. -#### **\-\-cap-drop**=*CAP\_xxx* +#### **--cap-drop**=*CAP\_xxx* When executing RUN instructions, run the command specified in the instruction with the specified capability removed from its capability set. @@ -104,40 +104,40 @@ CAP\_FSETID, CAP\_KILL, CAP\_MKNOD, CAP\_NET\_BIND\_SERVICE, CAP\_SETFCAP, CAP\_SETGID, CAP\_SETPCAP, CAP\_SETUID, and CAP\_SYS\_CHROOT capabilities are granted by default; this option can be used to remove them. -If a capability is specified to both the **\-\-cap-add** and **\-\-cap-drop** +If a capability is specified to both the **--cap-add** and **--cap-drop** options, it will be dropped, regardless of the order in which the options were given. -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-cgroup-parent**=*path* +#### **--cgroup-parent**=*path* Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist. -#### **\-\-compress** +#### **--compress** This option is added to be aligned with other containers CLIs. Podman doesn't communicate with a daemon or a remote server. Thus, compressing the data before sending it is irrelevant to Podman. (This option is not available with the remote Podman client) -#### **\-\-cni-config-dir**=*directory* +#### **--cni-config-dir**=*directory* Location of CNI configuration files which will dictate which plugins will be used to configure network interfaces and routing for containers created for handling `RUN` instructions, if those containers will be run in their own network namespaces, and networking is not disabled. -#### **\-\-cni-plugin-path**=*directory[:directory[:directory[...]]]* +#### **--cni-plugin-path**=*directory[:directory[:directory[...]]]* List of directories in which the CNI plugins which will be used for configuring network namespaces can be found. -#### **\-\-cpu-period**=*limit* +#### **--cpu-period**=*limit* Set the CPU period for the Completely Fair Scheduler (CFS), which is a duration in microseconds. Once the container's CPU quota is used up, it will @@ -148,20 +148,20 @@ On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpu-quota**=*limit* +#### **--cpu-quota**=*limit* Limit the CPU Completely Fair Scheduler (CFS) quota. Limit the container's CPU usage. By default, containers run with the full CPU resource. The limit is a number in microseconds. If you provide a number, the container will be allowed to use that much CPU time until the CPU period -ends (controllable via **\-\-cpu-period**). +ends (controllable via **--cpu-period**). On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpu-shares**, **-c**=*shares* +#### **--cpu-shares**, **-c**=*shares* CPU shares (relative weight) @@ -169,7 +169,7 @@ By default, all containers get the same proportion of CPU cycles. This proportion can be modified by changing the container's CPU share weighting relative to the weighting of all other running containers. -To modify the proportion from the default of 1024, use the **\-\-cpu-shares** +To modify the proportion from the default of 1024, use the **--cpu-shares** flag to set the weighting to 2 or higher. The proportion will only apply when CPU-intensive processes are running. @@ -199,11 +199,11 @@ division of CPU shares: 101 {C1} 1 100% of CPU1 102 {C1} 2 100% of CPU2 -#### **\-\-cpuset-cpus**=*num* +#### **--cpuset-cpus**=*num* CPUs in which to allow execution (0-3, 0,1) -#### **\-\-cpuset-mems**=*nodes* +#### **--cpuset-mems**=*nodes* Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. @@ -212,26 +212,26 @@ If you have four memory nodes on your system (0-3), use `--cpuset-mems=0,1` then processes in your container will only use memory from the first two memory nodes. -#### **\-\-creds**=*creds* +#### **--creds**=*creds* The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-decryption-key**=*key[:passphrase]* +#### **--decryption-key**=*key[:passphrase]* The [key[:passphrase]] to be used for decryption of images. Key can point to keys and/or certificates. Decryption will be tried with all keys. If the key is protected by a passphrase, it is required to be passed in the argument and omitted otherwise. -#### **\-\-device**=_host-device_[**:**_container-device_][**:**_permissions_] +#### **--device**=_host-device_[**:**_container-device_][**:**_permissions_] Add a host device to the container. Optional *permissions* parameter can be used to specify device permissions, it is combination of **r** for read, **w** for write, and **m** for **mknod**(2). -Example: **\-\-device=/dev/sdc:/dev/xvdc:rwm**. +Example: **--device=/dev/sdc:/dev/xvdc:rwm**. Note: if _host_device_ is a symbolic link then it will be resolved first. The container will only store the major and minor numbers of the host device. @@ -239,24 +239,24 @@ The container will only store the major and minor numbers of the host device. Note: if the user only has access rights via a group, accessing the device from inside a rootless container will fail. The **crun**(1) runtime offers a workaround for this by adding the option -#### **\-\-annotation run.oci.keep_original_groups=1**. +#### **--annotation run.oci.keep_original_groups=1**. -#### **\-\-disable-compression**, **-D** +#### **--disable-compression**, **-D** Don't compress filesystem layers when building the image unless it is required by the location where the image is being written. This is the default setting, because image layers are compressed automatically when they are pushed to registries, and images being written to local storage would only need to be decompressed again to be stored. Compression can be forced in all cases by -specifying **\-\-disable-compression=false**. +specifying **--disable-compression=false**. -#### **\-\-disable-content-trust** +#### **--disable-content-trust** This is a Docker specific option to disable image verification to a Docker registry and is not supported by Podman. This flag is a NOOP and provided solely for scripting compatibility. (This option is not available with the remote Podman client) -#### **\-\-dns**=*dns* +#### **--dns**=*dns* Set custom DNS servers to be used during the build. @@ -269,15 +269,15 @@ The special value **none** can be specified to disable creation of /etc/resolv.conf in the container by Podman. The /etc/resolv.conf file in the image will be used without changes. -#### **\-\-dns-option**=*option* +#### **--dns-option**=*option* Set custom DNS options to be used during the build. -#### **\-\-dns-search**=*domain* +#### **--dns-search**=*domain* Set custom DNS search domains to be used during the build. -#### **\-\-file**, **-f**=*Containerfile* +#### **--file**, **-f**=*Containerfile* Specifies a Containerfile which contains instructions for building the image, either a local file or an **http** or **https** URL. If more than one @@ -290,12 +290,12 @@ context. If you specify `-f -`, the Containerfile contents will be read from stdin. -#### **\-\-force-rm**=*true|false* +#### **--force-rm**=*true|false* Always remove intermediate containers after a build, even if the build fails (default true). -#### **\-\-format** +#### **--format** Control the format for the built image's manifest and configuration data. Recognized formats include *oci* (OCI image-spec v1.0, the default) and @@ -304,28 +304,28 @@ Recognized formats include *oci* (OCI image-spec v1.0, the default) and Note: You can also override the default format by setting the BUILDAH\_FORMAT environment variable. `export BUILDAH_FORMAT=docker` -#### **\-\-from** +#### **--from** Overrides the first `FROM` instruction within the Containerfile. If there are multiple FROM instructions in a Containerfile, only the first is changed. -**-h**, **\-\-help** +**-h**, **--help** Print usage statement -#### **\-\-http-proxy** +#### **--http-proxy** Pass through HTTP Proxy environment variables. -#### **\-\-iidfile**=*ImageIDfile* +#### **--iidfile**=*ImageIDfile* Write the image ID to the file. -#### **\-\-ignorefile** +#### **--ignorefile** Path to an alternative .dockerignore file. -#### **\-\-ipc**=*how* +#### **--ipc**=*how* Sets the configuration for IPC namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate @@ -334,7 +334,7 @@ that the IPC namespace in which `podman` itself is being run should be reused, or it can be the path to an IPC namespace which is already in use by another process. -#### **\-\-isolation**=*type* +#### **--isolation**=*type* Controls what type of isolation is used for running processes as part of `RUN` instructions. Recognized types include *oci* (OCI-compatible runtime, the @@ -348,13 +348,13 @@ chroot(1) than container technology). Note: You can also override the default isolation type by setting the BUILDAH\_ISOLATION environment variable. `export BUILDAH_ISOLATION=oci` -#### **\-\-jobs**=*number* +#### **--jobs**=*number* Run up to N concurrent stages in parallel. If the number of jobs is greater than 1, stdin will be read from /dev/null. If 0 is specified, then there is no limit in the number of jobs that run in parallel. -#### **\-\-label**=*label* +#### **--label**=*label* Add an image *label* (e.g. label=*value*) to the image metadata. Can be used multiple times. @@ -369,24 +369,24 @@ capabilities is a subset of the default list. If the specified capabilities are not in the default set, Podman will print an error message and will run the container with the default capabilities. -#### **\-\-layers** +#### **--layers** Cache intermediate images during the build process (Default is `true`). Note: You can also override the default value of layers by setting the BUILDAH\_LAYERS environment variable. `export BUILDAH_LAYERS=true` -#### **\-\-logfile**=*filename* +#### **--logfile**=*filename* Log output which would be sent to standard output and standard error to the specified file instead of to standard output and standard error. -#### **\-\-manifest** "manifest" +#### **--manifest** "manifest" Name of the manifest list to which the image will be added. Creates the manifest list if it does not exist. This option is useful for building multi architecture images. -#### **\-\-memory**, **-m**=*LIMIT* +#### **--memory**, **-m**=*LIMIT* Memory limit (format: `<number>[<unit>]`, where unit = b (bytes), k (kilobytes), m (megabytes), or g (gigabytes)) @@ -397,18 +397,18 @@ not limited. The actual limit may be rounded up to a multiple of the operating system's page size (the value would be very large, that's millions of trillions). -#### **\-\-memory-swap**=*LIMIT* +#### **--memory-swap**=*LIMIT* A limit value equal to memory plus swap. Must be used with the **-m** -(**\-\-memory**) flag. The swap `LIMIT` should always be larger than **-m** -(**\-\-memory**) value. By default, the swap `LIMIT` will be set to double +(**--memory**) flag. The swap `LIMIT` should always be larger than **-m** +(**--memory**) value. By default, the swap `LIMIT` will be set to double the value of --memory. The format of `LIMIT` is `<number>[<unit>]`. Unit can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap. -#### **\-\-network**=*mode*, **\-\-net** +#### **--network**=*mode*, **--net** Sets the configuration for network namespaces when handling `RUN` instructions. @@ -421,17 +421,17 @@ considered insecure. - **ns:**_path_: path to a network namespace to join. - **private**: create a new namespace for the container (default). -#### **\-\-no-cache** +#### **--no-cache** Do not use existing cached images for the container build. Build from the start with a new set of cached layers. -#### **\-\-os**=*string* +#### **--os**=*string* Set the OS to the provided value instead of the current operating system of the host. -#### **\-\-pid**=*pid* +#### **--pid**=*pid* Sets the configuration for PID namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate @@ -440,13 +440,13 @@ that the PID namespace in which `podman` itself is being run should be reused, or it can be the path to a PID namespace which is already in use by another process. -#### **\-\-platform**="Linux" +#### **--platform**="Linux" This option has no effect on the build. Other container engines use this option to control the execution platform for the build (e.g., Windows, Linux) which is not required for Buildah as it supports only Linux. -#### **\-\-pull** +#### **--pull** When the option is specified or set to "true", pull the image. Raise an error if the image could not be pulled, even if the image is present locally. @@ -455,28 +455,28 @@ If the option is disabled (with *--pull=false*) or not specified, pull the image from the registry only if the image is not present locally. Raise an error if the image is not found in the registries and is not present locally. -#### **\-\-pull-always** +#### **--pull-always** Pull the image from the first registry it is found in as listed in registries.conf. Raise an error if not found in the registries, even if the image is present locally. -#### **\-\-pull-never** +#### **--pull-never** Do not pull the image from the registry, use only the local version. Raise an error if the image is not present locally. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output messages which indicate which instruction is being processed, and of progress when pulling images from a registry, and when writing the output image. -#### **\-\-rm**=*true|false* +#### **--rm**=*true|false* Remove intermediate containers after a successful build (default true). -#### **\-\-runtime**=*path* +#### **--runtime**=*path* The *path* to an alternate OCI-compatible runtime, which will be used to run commands specified by the **RUN** instruction. @@ -485,7 +485,7 @@ Note: You can also override the default runtime by setting the BUILDAH\_RUNTIME environment variable. `export BUILDAH_RUNTIME=/usr/local/bin/runc` -#### **\-\-secret**=**id=id,src=path** +#### **--secret**=**id=id,src=path** Pass secret information to be used in the Containerfile for building images in a safe way that will not end up stored in the final image, or be seen in other stages. @@ -496,7 +496,7 @@ To later use the secret, use the --mount flag in a `RUN` instruction within a `C `RUN --mount=type=secret,id=mysecret cat /run/secrets/mysecret` -#### **\-\-security-opt**=*option* +#### **--security-opt**=*option* Security Options @@ -516,7 +516,7 @@ container - `seccomp=profile.json` : White listed syscalls seccomp Json file to be used as a seccomp filter -#### **\-\-shm-size**=*size* +#### **--shm-size**=*size* Size of `/dev/shm`. The format is `<number><unit>`. `number` must be greater than `0`. @@ -524,40 +524,40 @@ Unit is optional and can be `b` (bytes), `k` (kilobytes), `m`(megabytes), or `g` (gigabytes). If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses `64m`. -#### **\-\-sign-by**=*fingerprint* +#### **--sign-by**=*fingerprint* Sign the image using a GPG key with the specified FINGERPRINT. (This option is not available with the remote Podman client) -#### **\-\-squash** +#### **--squash** Squash all of the image's new layers into a single new layer; any preexisting layers are not squashed. -#### **\-\-squash-all** +#### **--squash-all** Squash all of the new image's layers (including those inherited from a base image) into a single new layer. -#### **\-\-stdin** +#### **--stdin** Pass stdin into the RUN containers. Sometime commands being RUN within a Containerfile want to request information from the user. For example apt asking for a confirmation for install. Use --stdin to be able to interact from the terminal during the build. -#### **\-\-tag**, **-t**=*imageName* +#### **--tag**, **-t**=*imageName* Specifies the name which will be assigned to the resulting image if the build process completes successfully. If _imageName_ does not include a registry name, the registry name *localhost* will be prepended to the image name. -#### **\-\-target**=*stageName* +#### **--target**=*stageName* Set the target build stage to build. When building a Containerfile with multiple build stages, --target can be used to specify an intermediate build stage by name as the final stage for the resulting image. Commands after the target stage will be skipped. -#### **\-\-timestamp** *seconds* +#### **--timestamp** *seconds* Set the create timestamp to seconds since epoch to allow for deterministic builds (defaults to current time). By default, the created timestamp is changed @@ -568,12 +568,12 @@ specified and therefore not changed, allowing the image's sha256 hash to remain same. All files committed to the layers of the image will be created with the timestamp. -#### **\-\-tls-verify**=*true|false* +#### **--tls-verify**=*true|false* Require HTTPS and verify certificates when talking to container registries (defaults to true). (This option is not available with the remote Podman client) -#### **\-\-ulimit**=*type*=*soft-limit*[:*hard-limit*] +#### **--ulimit**=*type*=*soft-limit*[:*hard-limit*] Specifies resource limits to apply to processes launched when processing `RUN` instructions. This option can be specified multiple times. Recognized resource @@ -594,7 +594,7 @@ types include: "sigpending": maximum number of pending signals (ulimit -i) "stack": maximum stack size (ulimit -s) -#### **\-\-userns**=*how* +#### **--userns**=*how* Sets the configuration for user namespaces when handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate @@ -603,7 +603,7 @@ the user namespace in which `podman` itself is being run should be reused, or it can be the path to an user namespace which is already in use by another process. -#### **\-\-userns-uid-map**=*mapping* +#### **--userns-uid-map**=*mapping* Directly specifies a UID mapping which should be used to set ownership, at the filesystem level, on the working container's contents. @@ -624,7 +624,7 @@ If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-uid-map are specified, but --userns-gid-map is specified, the UID map will be set to use the same numeric values as the GID map. -#### **\-\-userns-gid-map**=*mapping* +#### **--userns-gid-map**=*mapping* Directly specifies a GID mapping which should be used to set ownership, at the filesystem level, on the working container's contents. @@ -645,7 +645,7 @@ If none of --userns-uid-map-user, --userns-gid-map-group, or --userns-gid-map are specified, but --userns-uid-map is specified, the GID map will be set to use the same numeric values as the UID map. -#### **\-\-userns-uid-map-user**=*user* +#### **--userns-uid-map-user**=*user* Specifies that a UID mapping which should be used to set ownership, at the filesystem level, on the working container's contents, can be found in entries @@ -660,7 +660,7 @@ suitable user name to use as the default setting for this option. mappings are relative to the rootless user namespace in the container, rather than being relative to the host as it would be when run rootfull. -#### **\-\-userns-gid-map-group**=*group* +#### **--userns-gid-map-group**=*group* Specifies that a GID mapping which should be used to set ownership, at the filesystem level, on the working container's contents, can be found in entries @@ -675,7 +675,7 @@ suitable group name to use as the default setting for this option. mappings are relative to the rootless user namespace in the container, rather than being relative to the host as it would be when run rootfull. -#### **\-\-uts**=*how* +#### **--uts**=*how* Sets the configuration for UTS namespaces when the handling `RUN` instructions. The configured value can be "" (the empty string) or "container" to indicate @@ -684,11 +684,11 @@ that the UTS namespace in which `podman` itself is being run should be reused, or it can be the path to a UTS namespace which is already in use by another process. -#### **\-\-variant**="" +#### **--variant**="" Set the architecture variant of the image to be pulled. -#### **\-\-volume**, **-v**[=*[HOST-DIR:CONTAINER-DIR[:OPTIONS]]*] +#### **--volume**, **-v**[=*[HOST-DIR:CONTAINER-DIR[:OPTIONS]]*] Create a bind mount. If you specify, ` -v /HOST-DIR:/CONTAINER-DIR`, Podman bind mounts `/HOST-DIR` in the host to `/CONTAINER-DIR` in the Podman diff --git a/docs/source/markdown/podman-commit.1.md b/docs/source/markdown/podman-commit.1.md index 35ee1d010..7485e9bd9 100644 --- a/docs/source/markdown/podman-commit.1.md +++ b/docs/source/markdown/podman-commit.1.md @@ -22,39 +22,39 @@ If *image* is not provided, the values for the `REPOSITORY` and `TAG` values of ## OPTIONS -#### **\-\-author**, **-a**=*author* +#### **--author**, **-a**=*author* Set the author for the committed image -#### **\-\-change**, **-c**=*instruction* +#### **--change**, **-c**=*instruction* Apply the following possible instructions to the created image: **CMD** | **ENTRYPOINT** | **ENV** | **EXPOSE** | **LABEL** | **ONBUILD** | **STOPSIGNAL** | **USER** | **VOLUME** | **WORKDIR** Can be set multiple times -#### **\-\-format**, **-f**=*format* +#### **--format**, **-f**=*format* Set the format of the image manifest and metadata. The currently supported formats are _oci_ and _docker_. If not specifically set, the default format used is _oci_. -#### **\-\-iidfile**=*ImageIDfile* +#### **--iidfile**=*ImageIDfile* Write the image ID to the file. -#### **\-\-include-volumes** +#### **--include-volumes** Include in the committed image any volumes added to the container by the `--volume` or `--mount` options to the `podman create` and `podman run` commands. -#### **\-\-message**, **-m**=*message* +#### **--message**, **-m**=*message* Set commit message for committed image. The message field is not supported in _oci_ format. -#### **\-\-pause**, **-p** +#### **--pause**, **-p** Pause the container when creating an image -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output diff --git a/docs/source/markdown/podman-completion.1.md b/docs/source/markdown/podman-completion.1.md index cff9c7878..4ebe4e2e1 100644 --- a/docs/source/markdown/podman-completion.1.md +++ b/docs/source/markdown/podman-completion.1.md @@ -14,11 +14,11 @@ These script are used by the shell to provide suggestions and complete commands Usually these scripts are automatically installed via the package manager. ## OPTIONS -#### **\-\-file**, **-f** +#### **--file**, **-f** Write the generated output to file. -#### **\-\-no-desc** +#### **--no-desc** Do not provide description in the completions. diff --git a/docs/source/markdown/podman-container-checkpoint.1.md b/docs/source/markdown/podman-container-checkpoint.1.md index a93464508..46b6cb646 100644 --- a/docs/source/markdown/podman-container-checkpoint.1.md +++ b/docs/source/markdown/podman-container-checkpoint.1.md @@ -10,61 +10,61 @@ podman\-container\-checkpoint - Checkpoints one or more running containers Checkpoints all the processes in one or more containers. You may use container IDs or names as input. ## OPTIONS -#### **\-\-keep**, **-k** +#### **--keep**, **-k** Keep all temporary log and statistics files created by CRIU during checkpointing. These files are not deleted if checkpointing fails for further debugging. If checkpointing succeeds these files are theoretically not needed, but if these files are needed Podman can keep the files for further analysis. -#### **\-\-all**, **-a** +#### **--all**, **-a** Checkpoint all running containers. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, checkpoint the last created container. (This option is not available with the remote Podman client) -#### **\-\-leave-running**, **-R** +#### **--leave-running**, **-R** Leave the container running after checkpointing instead of stopping it. -#### **\-\-tcp-established** +#### **--tcp-established** Checkpoint a container with established TCP connections. If the checkpoint image contains established TCP connections, this options is required during restore. Defaults to not checkpointing containers with established TCP connections. -#### **\-\-export**, **-e** +#### **--export**, **-e** Export the checkpoint to a tar.gz file. The exported checkpoint can be used to import the container on another system and thus enabling container live migration. This checkpoint archive also includes all changes to the container's -root file-system, if not explicitly disabled using **\-\-ignore-rootfs** +root file-system, if not explicitly disabled using **--ignore-rootfs** -#### **\-\-ignore-rootfs** +#### **--ignore-rootfs** -This only works in combination with **\-\-export, -e**. If a checkpoint is -exported to a tar.gz file it is possible with the help of **\-\-ignore-rootfs** +This only works in combination with **--export, -e**. If a checkpoint is +exported to a tar.gz file it is possible with the help of **--ignore-rootfs** to explicitly disable including changes to the root file-system into the checkpoint archive file. -#### **\-\-ignore-volumes** +#### **--ignore-volumes** -This option must be used in combination with the **\-\-export, -e** option. +This option must be used in combination with the **--export, -e** option. When this option is specified, the content of volumes associated with the container will not be included into the checkpoint tar.gz file. -#### **\-\-pre-checkpoint**, **-P** +#### **--pre-checkpoint**, **-P** Dump the container's memory information only, leaving the container running. Later operations will supersede prior dumps. It only works on runc 1.0-rc3 or higher. -#### **\-\-with-previous** +#### **--with-previous** Check out the container with previous criu image files in pre-dump. It only works -without **\-\-pre-checkpoint** or **-P**. It only works on runc 1.0-rc3 or higher. +without **--pre-checkpoint** or **-P**. It only works on runc 1.0-rc3 or higher. ## EXAMPLE diff --git a/docs/source/markdown/podman-container-cleanup.1.md b/docs/source/markdown/podman-container-cleanup.1.md index 9f9b90fc2..19d0b7818 100644 --- a/docs/source/markdown/podman-container-cleanup.1.md +++ b/docs/source/markdown/podman-container-cleanup.1.md @@ -12,26 +12,26 @@ Sometimes container's mount points and network stacks can remain if the podman c ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Cleanup all containers. -#### **\-\-exec**=_session_ +#### **--exec**=_session_ Clean up an exec session for a single container. -Can only be specified if a single container is being cleaned up (conflicts with **\-\-all** as such). -If **\-\-rm** is not specified, temporary files for the exec session will be cleaned up; if it is, the exec session will be removed from the container. -Conflicts with **\-\-rmi** as the container is not being cleaned up so the image cannot be removed. +Can only be specified if a single container is being cleaned up (conflicts with **--all** as such). +If **--rm** is not specified, temporary files for the exec session will be cleaned up; if it is, the exec session will be removed from the container. +Conflicts with **--rmi** as the container is not being cleaned up so the image cannot be removed. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-rm** +#### **--rm** After cleanup, remove the container entirely. -#### **\-\-rmi** +#### **--rmi** After cleanup, remove the image entirely. diff --git a/docs/source/markdown/podman-container-exists.1.md b/docs/source/markdown/podman-container-exists.1.md index 28f1832a2..381d968ab 100644 --- a/docs/source/markdown/podman-container-exists.1.md +++ b/docs/source/markdown/podman-container-exists.1.md @@ -14,10 +14,10 @@ was an issue accessing the local storage. ## OPTIONS -#### **\-\-external**=*true|false* +#### **--external**=*true|false* Check for external containers as well as Podman containers. These external containers are generally created via other container technology such as Buildah or CRI-O. -**-h**, **\-\-help** +**-h**, **--help** Print usage statement ## EXAMPLES diff --git a/docs/source/markdown/podman-container-prune.1.md b/docs/source/markdown/podman-container-prune.1.md index abdf58981..b199f9ebb 100644 --- a/docs/source/markdown/podman-container-prune.1.md +++ b/docs/source/markdown/podman-container-prune.1.md @@ -11,7 +11,7 @@ podman-container-prune - Remove all stopped containers from local storage ## OPTIONS -#### **\-\-filter**=*filters* +#### **--filter**=*filters* Provide filter values. @@ -26,11 +26,11 @@ The until filter can be Unix timestamps, date formatted timestamps, or Go durati The label filter accepts two formats. One is the label=... (label=_key_ or label=_key=value_), which removes containers with the specified labels. The other format is the label!=... (label!=_key_ or label!=_key=value_), which removes containers without the specified labels. -#### **\-\-force**, **-f** +#### **--force**, **-f** Do not provide an interactive prompt for container removal. -**-h**, **\-\-help** +**-h**, **--help** Print usage statement diff --git a/docs/source/markdown/podman-container-restore.1.md b/docs/source/markdown/podman-container-restore.1.md index 3b517fb3d..ef8722279 100644 --- a/docs/source/markdown/podman-container-restore.1.md +++ b/docs/source/markdown/podman-container-restore.1.md @@ -10,7 +10,7 @@ podman\-container\-restore - Restores one or more containers from a checkpoint Restores a container from a checkpoint. You may use container IDs or names as input. ## OPTIONS -#### **\-\-keep**, **-k** +#### **--keep**, **-k** Keep all temporary log and statistics files created by CRIU during checkpointing as well as restoring. These files are not deleted if restoring @@ -21,18 +21,18 @@ files created during checkpointing. The size required by the checkpoint directory is roughly the same as the amount of memory required by the processes in the checkpointed container. -Without the **-k**, **\-\-keep** option the checkpoint will be consumed and cannot be used +Without the **-k**, **--keep** option the checkpoint will be consumed and cannot be used again. -#### **\-\-all**, **-a** +#### **--all**, **-a** Restore all checkpointed containers. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, restore the last created container. (This option is not available with the remote Podman client) -#### **\-\-tcp-established** +#### **--tcp-established** Restore a container with established TCP connections. If the checkpoint image contains established TCP connections, this option is required during restore. @@ -40,58 +40,58 @@ If the checkpoint image does not contain established TCP connections this option is ignored. Defaults to not restoring containers with established TCP connections. -#### **\-\-import**, **-i** +#### **--import**, **-i** Import a checkpoint tar.gz file, which was exported by Podman. This can be used to import a checkpointed container from another host. Do not specify a *container* argument when using this option. -#### **\-\-import-previous** +#### **--import-previous** Import a pre-checkpoint tar.gz file which was exported by Podman. This option -must be used with **-i** or **\-\-import**. It only works on runc 1.0-rc3 or higher. +must be used with **-i** or **--import**. It only works on runc 1.0-rc3 or higher. -#### **\-\-name**, **-n** +#### **--name**, **-n** -This is only available in combination with **\-\-import, -i**. If a container is restored -from a checkpoint tar.gz file it is possible to rename it with **\-\-name, -n**. This +This is only available in combination with **--import, -i**. If a container is restored +from a checkpoint tar.gz file it is possible to rename it with **--name, -n**. This way it is possible to restore a container from a checkpoint multiple times with different names. -If the **\-\-name, -n** option is used, Podman will not attempt to assign the same IP +If the **--name, -n** option is used, Podman will not attempt to assign the same IP address to the container it was using before checkpointing as each IP address can only be used once and the restored container will have another IP address. This also means -that **\-\-name, -n** cannot be used in combination with **\-\-tcp-established**. +that **--name, -n** cannot be used in combination with **--tcp-established**. -#### **\-\-ignore-rootfs** +#### **--ignore-rootfs** -This is only available in combination with **\-\-import, -i**. If a container is restored +This is only available in combination with **--import, -i**. If a container is restored from a checkpoint tar.gz file it is possible that it also contains all root file-system -changes. With **\-\-ignore-rootfs** it is possible to explicitly disable applying these +changes. With **--ignore-rootfs** it is possible to explicitly disable applying these root file-system changes to the restored container. -#### **\-\-ignore-static-ip** +#### **--ignore-static-ip** -If the container was started with **\-\-ip** the restored container also tries to use that +If the container was started with **--ip** the restored container also tries to use that IP address and restore fails if that IP address is already in use. This can happen, if -a container is restored multiple times from an exported checkpoint with **\-\-name, -n**. +a container is restored multiple times from an exported checkpoint with **--name, -n**. -Using **\-\-ignore-static-ip** tells Podman to ignore the IP address if it was configured -with **\-\-ip** during container creation. +Using **--ignore-static-ip** tells Podman to ignore the IP address if it was configured +with **--ip** during container creation. -#### **\-\-ignore-static-mac** +#### **--ignore-static-mac** -If the container was started with **\-\-mac-address** the restored container also +If the container was started with **--mac-address** the restored container also tries to use that MAC address and restore fails if that MAC address is already in use. This can happen, if a container is restored multiple times from an -exported checkpoint with **\-\-name, -n**. +exported checkpoint with **--name, -n**. -Using **\-\-ignore-static-mac** tells Podman to ignore the MAC address if it was -configured with **\-\-mac-address** during container creation. +Using **--ignore-static-mac** tells Podman to ignore the MAC address if it was +configured with **--mac-address** during container creation. -#### **\-\-ignore-volumes** +#### **--ignore-volumes** -This option must be used in combination with the **\-\-import, -i** option. +This option must be used in combination with the **--import, -i** option. When restoring containers from a checkpoint tar.gz file with this option, the content of associated volumes will not be restored. diff --git a/docs/source/markdown/podman-container-runlabel.1.md b/docs/source/markdown/podman-container-runlabel.1.md index 9557303b6..aee849cbd 100644 --- a/docs/source/markdown/podman-container-runlabel.1.md +++ b/docs/source/markdown/podman-container-runlabel.1.md @@ -41,7 +41,7 @@ is used. Any additional arguments will be appended to the command. ## OPTIONS -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. @@ -49,39 +49,39 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-display** +#### **--display** Display the label's value of the image having populated its environment variables. The runlabel command will not execute if --display is specified. -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-creds**=*[username[:password]]* +#### **--creds**=*[username[:password]]* The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-name**, **-n**=*name* +#### **--name**, **-n**=*name* Use this name for creating content for the container. NAME will default to the IMAGENAME if it is not specified. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output information when pulling images -#### **\-\-replace** +#### **--replace** If a container exists of the default or given name, as needed it will be stopped, deleted and a new container will be created from this image. -#### **\-\-tls-verify** +#### **--tls-verify** Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, diff --git a/docs/source/markdown/podman-create.1.md b/docs/source/markdown/podman-create.1.md index b4593e07a..d03d48506 100644 --- a/docs/source/markdown/podman-create.1.md +++ b/docs/source/markdown/podman-create.1.md @@ -65,22 +65,22 @@ and specified with a _tag_. $ podman create oci-archive:/tmp/fedora echo hello ## OPTIONS -#### **\-\-add-host**=*host* +#### **--add-host**=*host* Add a custom host-to-IP mapping (host:ip) -Add a line to /etc/hosts. The format is hostname:ip. The **\-\-add-host** +Add a line to /etc/hosts. The format is hostname:ip. The **--add-host** option can be set multiple times. -#### **\-\-annotation**=*key=value* +#### **--annotation**=*key=value* Add an annotation to the container. The format is key=value. -The **\-\-annotation** option can be set multiple times. +The **--annotation** option can be set multiple times. -#### **\-\-arch**=*ARCH* +#### **--arch**=*ARCH* Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`. -#### **\-\-attach**, **-a**=*location* +#### **--attach**, **-a**=*location* Attach to STDIN, STDOUT or STDERR. @@ -91,30 +91,30 @@ error. It can even pretend to be a TTY (this is what most command line executables expect) and pass along signals. The **-a** option can be set for each of stdin, stdout, and stderr. -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-blkio-weight**=*weight* +#### **--blkio-weight**=*weight* Block IO weight (relative weight) accepts a weight value between 10 and 1000. -#### **\-\-blkio-weight-device**=*weight* +#### **--blkio-weight-device**=*weight* Block IO weight (relative device weight, format: `DEVICE_NAME:WEIGHT`). -#### **\-\-cap-add**=*capability* +#### **--cap-add**=*capability* Add Linux capabilities -#### **\-\-cap-drop**=*capability* +#### **--cap-drop**=*capability* Drop Linux capabilities -#### **\-\-cgroupns**=*mode* +#### **--cgroupns**=*mode* Set the cgroup namespace mode for the container. **`host`**: use the host's cgroup namespace inside the container. @@ -124,34 +124,34 @@ Set the cgroup namespace mode for the container. If the host uses cgroups v1, the default is set to **host**. On cgroups v2 the default is **private**. -#### **\-\-cgroups**=*mode* +#### **--cgroups**=*mode* Determines whether the container will create CGroups. Valid values are *enabled*, *disabled*, *no-conmon*, *split*, which the default being *enabled*. The *enabled* option will create a new cgroup under the cgroup-parent. -The *disabled* option will force the container to not create CGroups, and thus conflicts with CGroup options (**\-\-cgroupns** and **\-\-cgroup-parent**). +The *disabled* option will force the container to not create CGroups, and thus conflicts with CGroup options (**--cgroupns** and **--cgroup-parent**). The *no-conmon* option disables a new CGroup only for the conmon process. The *split* option splits the current cgroup in two sub-cgroups: one for conmon and one for the container payload. It is not possible to set *--cgroup-parent* with *split*. -#### **\-\-cgroup-parent**=*path* +#### **--cgroup-parent**=*path* Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist. -#### **\-\-cgroup-conf**=*KEY=VALUE* +#### **--cgroup-conf**=*KEY=VALUE* -When running on cgroup v2, specify the cgroup file to write to and its value. For example **\-\-cgroup-conf=memory.high=1073741824** sets the memory.high limit to 1GB. +When running on cgroup v2, specify the cgroup file to write to and its value. For example **--cgroup-conf=memory.high=1073741824** sets the memory.high limit to 1GB. -#### **\-\-cidfile**=*id* +#### **--cidfile**=*id* Write the container ID to the file -#### **\-\-conmon-pidfile**=*path* +#### **--conmon-pidfile**=*path* Write the pid of the `conmon` process to a file. `conmon` runs in a separate process than Podman, so this is necessary when using systemd to restart Podman containers. (This option is not available with the remote Podman client) -#### **\-\-cpu-period**=*limit* +#### **--cpu-period**=*limit* Set the CPU period for the Completely Fair Scheduler (CFS), which is a duration in microseconds. Once the container's CPU quota is used up, it will @@ -162,26 +162,26 @@ On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpu-quota**=*limit* +#### **--cpu-quota**=*limit* Limit the CPU Completely Fair Scheduler (CFS) quota. Limit the container's CPU usage. By default, containers run with the full CPU resource. The limit is a number in microseconds. If you provide a number, the container will be allowed to use that much CPU time until the CPU period -ends (controllable via **\-\-cpu-period**). +ends (controllable via **--cpu-period**). On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpu-rt-period**=*microseconds* +#### **--cpu-rt-period**=*microseconds* Limit the CPU real-time period in microseconds Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. -#### **\-\-cpu-rt-runtime**=*microseconds* +#### **--cpu-rt-runtime**=*microseconds* Limit the CPU real-time runtime in microseconds @@ -190,7 +190,7 @@ Period of 1,000,000us and Runtime of 950,000us means that this container could c The sum of all runtimes across containers cannot exceed the amount allotted to the parent cgroup. -#### **\-\-cpu-shares**=*shares* +#### **--cpu-shares**=*shares* CPU shares (relative weight) @@ -198,7 +198,7 @@ By default, all containers get the same proportion of CPU cycles. This proportio can be modified by changing the container's CPU share weighting relative to the weighting of all other running containers. -To modify the proportion from the default of 1024, use the **\-\-cpu-shares** +To modify the proportion from the default of 1024, use the **--cpu-shares** flag to set the weighting to 2 or higher. The proportion will only apply when CPU-intensive processes are running. @@ -227,21 +227,21 @@ PID container CPU CPU share 101 {C1} 1 100% of CPU1 102 {C1} 2 100% of CPU2 -#### **\-\-cpus**=*number* +#### **--cpus**=*number* Number of CPUs. The default is *0.0* which means no limit. This is shorthand -for **\-\-cpu-period** and **\-\-cpu-quota**, so you may only set either -#### **\-\-cpus** or **\-\-cpu-period** and **\-\-cpu-quota**. +for **--cpu-period** and **--cpu-quota**, so you may only set either +#### **--cpus** or **--cpu-period** and **--cpu-quota**. On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpuset-cpus**=*cpus* +#### **--cpuset-cpus**=*cpus* CPUs in which to allow execution (0-3, 0,1) -#### **\-\-cpuset-mems**=*nodes* +#### **--cpuset-mems**=*nodes* Memory nodes (MEMs) in which to allow execution (0-3, 0,1). Only effective on NUMA systems. @@ -249,13 +249,13 @@ If you have four memory nodes on your system (0-3), use `--cpuset-mems=0,1` then processes in your container will only use memory from the first two memory nodes. -#### **\-\-device**=_host-device_[**:**_container-device_][**:**_permissions_] +#### **--device**=_host-device_[**:**_container-device_][**:**_permissions_] Add a host device to the container. Optional *permissions* parameter can be used to specify device permissions, it is combination of **r** for read, **w** for write, and **m** for **mknod**(2). -Example: **\-\-device=/dev/sdc:/dev/xvdc:rwm**. +Example: **--device=/dev/sdc:/dev/xvdc:rwm**. Note: if _host_device_ is a symbolic link then it will be resolved first. The container will only store the major and minor numbers of the host device. @@ -268,56 +268,56 @@ Podman may load kernel modules required for using the specified device. The devices that podman will load modules when necessary are: /dev/fuse. -#### **\-\-device-cgroup-rule**="type major:minor mode" +#### **--device-cgroup-rule**="type major:minor mode" Add a rule to the cgroup allowed devices list. The rule is expected to be in the format specified in the Linux kernel documentation (Documentation/cgroup-v1/devices.txt): - type: a (all), c (char), or b (block); - major and minor: either a number, or * for all; - mode: a composition of r (read), w (write), and m (mknod(2)). -#### **\-\-device-read-bps**=*path* +#### **--device-read-bps**=*path* Limit read rate (bytes per second) from a device (e.g. --device-read-bps=/dev/sda:1mb) -#### **\-\-device-read-iops**=*path* +#### **--device-read-iops**=*path* Limit read rate (IO per second) from a device (e.g. --device-read-iops=/dev/sda:1000) -#### **\-\-device-write-bps**=*path* +#### **--device-write-bps**=*path* Limit write rate (bytes per second) to a device (e.g. --device-write-bps=/dev/sda:1mb) -#### **\-\-device-write-iops**=*path* +#### **--device-write-iops**=*path* Limit write rate (IO per second) to a device (e.g. --device-write-iops=/dev/sda:1000) -#### **\-\-disable-content-trust** +#### **--disable-content-trust** This is a Docker specific option to disable image verification to a Docker registry and is not supported by Podman. This flag is a NOOP and provided solely for scripting compatibility. -#### **\-\-dns**=*dns* +#### **--dns**=*dns* -Set custom DNS servers. Invalid if using **\-\-dns** and **\-\-network** that is set to 'none' or `container:<name|id>`. +Set custom DNS servers. Invalid if using **--dns** and **--network** that is set to 'none' or `container:<name|id>`. This option can be used to override the DNS configuration passed to the container. Typically this is necessary when the host DNS configuration is invalid for the container (e.g., 127.0.0.1). When this -is the case the **\-\-dns** flags is necessary for every run. +is the case the **--dns** flags is necessary for every run. The special value **none** can be specified to disable creation of **/etc/resolv.conf** in the container by Podman. The **/etc/resolv.conf** file in the image will be used without changes. -#### **\-\-dns-opt**=*option* +#### **--dns-opt**=*option* -Set custom DNS options. Invalid if using **\-\-dns-opt** and **\-\-network** that is set to 'none' or `container:<name|id>`. +Set custom DNS options. Invalid if using **--dns-opt** and **--network** that is set to 'none' or `container:<name|id>`. -#### **\-\-dns-search**=*domain* +#### **--dns-search**=*domain* -Set custom DNS search domains. Invalid if using **\-\-dns-search** and **\-\-network** that is set to 'none' or `container:<name|id>`. (Use --dns-search=. if you don't wish to set the search domain) +Set custom DNS search domains. Invalid if using **--dns-search** and **--network** that is set to 'none' or `container:<name|id>`. (Use --dns-search=. if you don't wish to set the search domain) -#### **\-\-entrypoint**=*"command"* | *'["command", "arg1", ...]'* +#### **--entrypoint**=*"command"* | *'["command", "arg1", ...]'* Overwrite the default ENTRYPOINT of the image @@ -329,12 +329,12 @@ default nature or behavior, so that when you set an ENTRYPOINT you can run the container as if it were that binary, complete with default options, and you can pass in more options via the COMMAND. But, sometimes an operator may want to run something else inside the container, so you can override the default ENTRYPOINT -at runtime by using a **\-\-entrypoint** and a string to specify the new +at runtime by using a **--entrypoint** and a string to specify the new ENTRYPOINT. You need to specify multi option commands in the form of a json string. -#### **\-\-env**, **-e**=*env* +#### **--env**, **-e**=*env* Set environment variables @@ -342,26 +342,26 @@ This option allows arbitrary environment variables that are available for the pr See [**Environment**](#environment) note below for precedence and examples. -#### **\-\-env-host**=*true|false* +#### **--env-host**=*true|false* Use host environment inside of the container. See **Environment** note below for precedence. (This option is not available with the remote Podman client) -#### **\-\-env-file**=*file* +#### **--env-file**=*file* Read in a line delimited file of environment variables. See **Environment** note below for precedence. -#### **\-\-expose**=*port* +#### **--expose**=*port* Expose a port, or a range of ports (e.g. --expose=3300-3310) to set up port redirection on the host system. -#### **\-\-gidmap**=*container_gid:host_gid:amount* +#### **--gidmap**=*container_gid:host_gid:amount* GID map for the user namespace. Using this flag will run the container with user namespace enabled. It conflicts with the `--userns` and `--subgidname` flags. The following example maps uids 0-2000 in the container to the uids 30000-31999 on the host and gids 0-2000 in the container to the gids 30000-31999 on the host. `--gidmap=0:30000:2000` -#### **\-\-group-add**=*group|keep-groups* +#### **--group-add**=*group|keep-groups* Add additional groups to assign to primary user running within the container process. @@ -373,7 +373,7 @@ runtime to pass the group access into the container. Currently only available with the `crun` OCI runtime. Note: `keep-groups` is exclusive, you cannot add any other groups with this flag. (Not available for remote commands) -#### **\-\-health-cmd**=*"command"* | *'["command", "arg1", ...]'* +#### **--health-cmd**=*"command"* | *'["command", "arg1", ...]'* Set or alter a healthcheck command for a container. The command is a command to be executed inside your container that determines your container health. The command is required for other healthcheck options @@ -382,35 +382,35 @@ to be applied. A value of `none` disables existing healthchecks. Multiple options can be passed in the form of a JSON array; otherwise, the command will be interpreted as an argument to `/bin/sh -c`. -#### **\-\-health-interval**=*interval* +#### **--health-interval**=*interval* Set an interval for the healthchecks (a value of `disable` results in no automatic timer setup) (default "30s") -#### **\-\-health-retries**=*retries* +#### **--health-retries**=*retries* The number of retries allowed before a healthcheck is considered to be unhealthy. The default value is `3`. -#### **\-\-health-start-period**=*period* +#### **--health-start-period**=*period* The initialization time needed for a container to bootstrap. The value can be expressed in time format like `2m3s`. The default value is `0s` -#### **\-\-health-timeout**=*timeout* +#### **--health-timeout**=*timeout* The maximum time allowed to complete the healthcheck before an interval is considered failed. Like start-period, the value can be expressed in a time format such as `1m22s`. The default value is `30s`. -#### **\-\-hostname**=*name*, **-h** +#### **--hostname**=*name*, **-h** Container host name Sets the container host name that is available inside the container. Can only be used with a private UTS namespace `--uts=private` (default). If `--pod` is specified and the pod shares the UTS namespace (default) the pod's hostname will be used. -#### **\-\-help** +#### **--help** Print usage statement -#### **\-\-http-proxy**=*true|false* +#### **--http-proxy**=*true|false* By default proxy environment variables are passed into the container if set for the Podman process. This can be disabled by setting the `--http-proxy` @@ -430,7 +430,7 @@ container: Defaults to `true` -#### **\-\-image-volume**, **builtin-volume**=*bind|tmpfs|ignore* +#### **--image-volume**, **builtin-volume**=*bind|tmpfs|ignore* Tells Podman how to handle the builtin image volumes. Default is **bind**. @@ -439,37 +439,37 @@ Tells Podman how to handle the builtin image volumes. Default is **bind**. content that disappears when the container is stopped. - **ignore**: All volumes are just ignored and no action is taken. -#### **\-\-init** +#### **--init** Run an init inside the container that forwards signals and reaps processes. -#### **\-\-init-path**=*path* +#### **--init-path**=*path* Path to the container-init binary. -#### **\-\-interactive**, **-i**=*true|false* +#### **--interactive**, **-i**=*true|false* Keep STDIN open even if not attached. The default is *false*. -#### **\-\-ip6**=*ip* +#### **--ip6**=*ip* Not implemented -#### **\-\-ip**=*ip* +#### **--ip**=*ip* Specify a static IP address for the container, for example **10.88.64.128**. This option can only be used if the container is joined to only a single network - i.e., `--network=_network-name_` is used at most once - and if the container is not joining another container's network namespace via `--network=container:_id_`. The address must be within the CNI network's IP address pool (default **10.88.0.0/16**). -#### **\-\-ipc**=*ipc* +#### **--ipc**=*ipc* Default is to create a private IPC namespace (POSIX SysV IPC) for the container `container:<name|id>`: reuses another container shared memory, semaphores and message queues `host`: use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure. `ns:<path>` path to an IPC namespace to join. -#### **\-\-kernel-memory**=*number[unit]* +#### **--kernel-memory**=*number[unit]* Kernel memory limit (format: `<number>[<unit>]`, where unit = b (bytes), k (kilobytes), m (megabytes), or g (gigabytes)) @@ -479,34 +479,34 @@ is not limited. If you specify a limit, it may be rounded up to a multiple of the operating system's page size and the value can be very large, millions of trillions. -#### **\-\-label**, **-l**=*label* +#### **--label**, **-l**=*label* Add metadata to a container (e.g., --label com.example.key=value) -#### **\-\-label-file**=*file* +#### **--label-file**=*file* Read in a line delimited file of labels -#### **\-\-link-local-ip**=*ip* +#### **--link-local-ip**=*ip* Not implemented -#### **\-\-log-driver**="*k8s-file*" +#### **--log-driver**="*k8s-file*" Logging driver for the container. Currently available options are *k8s-file*, *journald*, and *none*, with *json-file* aliased to *k8s-file* for scripting compatibility. -#### **\-\-log-opt**=*name*=*value* +#### **--log-opt**=*name*=*value* Set custom logging configuration. The following *name*s are supported: - **path**: specify a path to the log file -(e.g. **\-\-log-opt path=/var/log/container/mycontainer.json**); +(e.g. **--log-opt path=/var/log/container/mycontainer.json**); - **max-size**: specify a max size of the log file -(e.g. **\-\-log-opt max-size=10mb**); +(e.g. **--log-opt max-size=10mb**); - **tag**: specify a custom log tag for the container -(e.g. **\-\-log-opt tag="{{.ImageName}}"**. +(e.g. **--log-opt tag="{{.ImageName}}"**. It supports the same keys as **podman inspect --format**. @@ -518,7 +518,7 @@ It supports the same keys as `podman inspect --format`. It is currently supported only by the journald log driver. -#### **\-\-mac-address**=*address* +#### **--mac-address**=*address* Container MAC address (e.g. 92:d0:c6:0a:29:33) @@ -526,7 +526,7 @@ Remember that the MAC address in an Ethernet network must be unique. The IPv6 link-local address will be based on the device's MAC address according to RFC4862. -#### **\-\-memory**, **-m**=*limit* +#### **--memory**, **-m**=*limit* Memory limit (format: `<number>[<unit>]`, where unit = b (bytes), k (kilobytes), m (megabytes), or g (gigabytes)) @@ -536,32 +536,32 @@ RAM. If a limit of 0 is specified (not using **-m**), the container's memory is not limited. The actual limit may be rounded up to a multiple of the operating system's page size (the value would be very large, that's millions of trillions). -#### **\-\-memory-reservation**=*limit* +#### **--memory-reservation**=*limit* Memory soft limit (format: `<number>[<unit>]`, where unit = b (bytes), k (kilobytes), m (megabytes), or g (gigabytes)) After setting memory reservation, when the system detects memory contention or low memory, containers are forced to restrict their consumption to their -reservation. So you should always set the value below **\-\-memory**, otherwise the +reservation. So you should always set the value below **--memory**, otherwise the hard limit will take precedence. By default, memory reservation will be the same as memory limit. -#### **\-\-memory-swap**=*limit* +#### **--memory-swap**=*limit* A limit value equal to memory plus swap. Must be used with the **-m** -(**\-\-memory**) flag. The swap `LIMIT` should always be larger than **-m** -(**\-\-memory**) value. By default, the swap `LIMIT` will be set to double +(**--memory**) flag. The swap `LIMIT` should always be larger than **-m** +(**--memory**) value. By default, the swap `LIMIT` will be set to double the value of --memory. The format of `LIMIT` is `<number>[<unit>]`. Unit can be `b` (bytes), `k` (kilobytes), `m` (megabytes), or `g` (gigabytes). If you don't specify a unit, `b` is used. Set LIMIT to `-1` to enable unlimited swap. -#### **\-\-memory-swappiness**=*number* +#### **--memory-swappiness**=*number* Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100. -#### **\-\-mount**=*type=TYPE,TYPE-SPECIFIC-OPTION[,...]* +#### **--mount**=*type=TYPE,TYPE-SPECIFIC-OPTION[,...]* Attach a filesystem mount to the container @@ -618,7 +618,7 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and · notmpcopyup: Disable copying files from the image to the tmpfs. -#### **\-\-name**=*name* +#### **--name**=*name* Assign a name to the container @@ -628,13 +628,13 @@ UUID short identifier (“f78375b1c487”) Name (“jonah”) podman generates a UUID for each container, and if a name is not assigned -to the container with **\-\-name** then it will generate a random +to the container with **--name** then it will generate a random string name. The name is useful any place you need to identify a container. This works for both background and foreground containers. -#### **\-\-network**=*mode*, **\-\-net** +#### **--network**=*mode*, **--net** -Set the network mode for the container. Invalid if using **\-\-dns**, **\-\-dns-opt**, or **\-\-dns-search** with **\-\-network** that is set to **none** or **container:**_id_. If used together with **\-\-pod**, the container will not join the pod's network namespace. +Set the network mode for the container. Invalid if using **--dns**, **--dns-opt**, or **--dns-search** with **--network** that is set to **none** or **container:**_id_. If used together with **--pod**, the container will not join the pod's network namespace. Valid _mode_ values are: @@ -657,33 +657,33 @@ Valid _mode_ values are: - **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default. - **port_handler=slirp4netns**: Use the slirp4netns port forwarding. -#### **\-\-network-alias**=*alias* +#### **--network-alias**=*alias* Add network-scoped alias for the container -#### **\-\-no-healthcheck**=*true|false* +#### **--no-healthcheck**=*true|false* Disable any defined healthchecks for container. -#### **\-\-no-hosts**=*true|false* +#### **--no-hosts**=*true|false* Do not create /etc/hosts for the container. -By default, Podman will manage /etc/hosts, adding the container's own IP address and any hosts from **\-\-add-host**. -#### **\-\-no-hosts** disables this, and the image's **/etc/host** will be preserved unmodified. -This option conflicts with **\-\-add-host**. +By default, Podman will manage /etc/hosts, adding the container's own IP address and any hosts from **--add-host**. +#### **--no-hosts** disables this, and the image's **/etc/host** will be preserved unmodified. +This option conflicts with **--add-host**. -#### **\-\-oom-kill-disable**=*true|false* +#### **--oom-kill-disable**=*true|false* Whether to disable OOM Killer for the container or not. -#### **\-\-oom-score-adj**=*num* +#### **--oom-score-adj**=*num* Tune the host's OOM preferences for containers (accepts -1000 to 1000) -#### **\-\-os**=*OS* +#### **--os**=*OS* Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`. -#### **\-\-pid**=*pid* +#### **--pid**=*pid* Set the PID mode for the container Default is to create a private PID namespace for the container @@ -692,25 +692,25 @@ Default is to create a private PID namespace for the container - `ns`: join the specified PID namespace - `private`: create a new namespace for the container (default) -#### **\-\-pids-limit**=*limit* +#### **--pids-limit**=*limit* Tune the container's pids limit. Set `0` to have unlimited pids for the container. (default "4096" on systems that support PIDS cgroups). -#### **\-\-platform**=*OS/ARCH* +#### **--platform**=*OS/ARCH* Specify the platform for selecting the image. (Conflicts with --arch and --os) The `--platform` option can be used to override the current architecture and operating system. -#### **\-\-pod**=*name* +#### **--pod**=*name* Run container in an existing pod. If you want Podman to make the pod for you, preference the pod name with `new:`. To make a pod with more granular options, use the `podman pod create` command before creating a container. -#### **\-\-pod-id-file**=*path* +#### **--pod-id-file**=*path* Run container in an existing pod and read the pod's ID from the specified file. If a container is run within a pod, and the pod has an infra-container, the infra-container will be started before the container is. -#### **\-\-privileged**=*true|false* +#### **--privileged**=*true|false* Give extended privileges to this container. The default is *false*. @@ -726,7 +726,7 @@ container. Rootless containers cannot have more privileges than the account that launched them. -#### **\-\-publish**, **-p**=*port* +#### **--publish**, **-p**=*port* Publish a container's port, or range of ports, to the host @@ -749,7 +749,7 @@ associated ports. If one container binds to a port, no other container can use t within the pod while it is in use. Containers in the pod can also communicate over localhost by having one container bind to localhost in the pod, and another connect to that port. -#### **\-\-publish-all**, **-P**=*true|false* +#### **--publish-all**, **-P**=*true|false* Publish all exposed ports to random ports on the host interfaces. The default is *false*. @@ -761,7 +761,7 @@ port to a random port on the host within an *ephemeral port range* defined by `/proc/sys/net/ipv4/ip_local_port_range`. To find the mapping between the host ports and the exposed ports, use `podman port`. -#### **\-\-pull**=*missing* +#### **--pull**=*missing* Pull image before creating ("always"|"missing"|"never") (default "missing"). 'missing': default value, attempt to pull the latest image from the registries listed in registries.conf if a local image does not exist.Raise an error if the image is not in any listed registry and is not present locally. @@ -770,11 +770,11 @@ Pull image before creating ("always"|"missing"|"never") (default "missing"). Defaults to *missing*. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output information when pulling images -#### **\-\-read-only**=*true|false* +#### **--read-only**=*true|false* Mount the container's root filesystem as read only. @@ -782,21 +782,21 @@ By default a container will have its root filesystem writable allowing processes to write files anywhere. By specifying the `--read-only` flag the container will have its root filesystem mounted as read only prohibiting any writes. -#### **\-\-read-only-tmpfs**=*true|false* +#### **--read-only-tmpfs**=*true|false* If container is running in --read-only mode, then mount a read-write tmpfs on /run, /tmp, and /var/tmp. The default is *true* -#### **\-\-replace**=**true**|**false** +#### **--replace**=**true**|**false** If another container with the same name already exists, replace and remove it. The default is **false**. -#### **\-\-requires**=**container** +#### **--requires**=**container** Specify one or more requirements. A requirement is a dependency container that will be started before this container. Containers can be specified by name or ID, with multiple containers being separated by commas. -#### **\-\-restart**=*policy* +#### **--restart**=*policy* Restart policy to follow when containers exit. Restart policy will not take effect if a container is stopped via the `podman kill` or `podman stop` commands. @@ -812,18 +812,18 @@ Please note that restart will not restart containers after a system reboot. If this functionality is required in your environment, you can invoke Podman from a systemd unit file, or create an init script for whichever init system is in use. To generate systemd unit files, please see *podman generate systemd* -#### **\-\-rm**=*true|false* +#### **--rm**=*true|false* Automatically remove the container when it exits. The default is *false*. -#### **\-\-rootfs** +#### **--rootfs** If specified, the first argument refers to an exploded container on the file system. This is useful to run a container without requiring any image management, the rootfs of the container is assumed to be managed externally. -#### **\-\-sdnotify**=**container**|**conmon**|**ignore** +#### **--sdnotify**=**container**|**conmon**|**ignore** Determines how to use the NOTIFY_SOCKET, as passed with systemd and Type=notify. @@ -834,13 +834,13 @@ has started. The socket is never passed to the runtime or the container. The **ignore** option removes NOTIFY_SOCKET from the environment for itself and child processes, for the case where some other process above Podman uses NOTIFY_SOCKET and Podman should not use it. -#### **\-\-seccomp-policy**=*policy* +#### **--seccomp-policy**=*policy* Specify the policy to select the seccomp profile. If set to *image*, Podman will look for a "io.containers.seccomp.profile" label in the container-image config and use its value as a seccomp profile. Otherwise, Podman will follow the *default* policy by applying the default profile unless specified otherwise via *--security-opt seccomp* as described below. Note that this feature is experimental and may change in the future. -#### **\-\-secret**=*secret*[,opt=opt ...] +#### **--secret**=*secret*[,opt=opt ...] Give the container access to a secret. Can be specified multiple times. @@ -860,7 +860,7 @@ Secret Options - `type=mount|env` : How the secret will be exposed to the container. Default mount. - `target=target` : Target of secret. Defauts to secret name. -#### **\-\-security-opt**=*option* +#### **--security-opt**=*option* Security Options @@ -892,30 +892,30 @@ Note: Labeling can be disabled for all containers by setting label=false in the Note: Labeling can be disabled for all containers by setting label=false in the **containers.conf** (`/etc/containers/containers.conf` or `$HOME/.config/containers/containers.conf`) file. -#### **\-\-shm-size**=*size* +#### **--shm-size**=*size* Size of `/dev/shm` (format: `<number>[<unit>]`, where unit = b (bytes), k (kilobytes), m (megabytes), or g (gigabytes)) If you omit the unit, the system uses bytes. If you omit the size entirely, the system uses `64m`. When size is `0`, there is no limit on the amount of memory used for IPC by the container. -#### **\-\-stop-signal**=*SIGTERM* +#### **--stop-signal**=*SIGTERM* Signal to stop a container. Default is SIGTERM. -#### **\-\-stop-timeout**=*seconds* +#### **--stop-timeout**=*seconds* Timeout (in seconds) to stop a container. Default is 10. Remote connections use local containers.conf for defaults -#### **\-\-subgidname**=*name* +#### **--subgidname**=*name* Name for GID map from the `/etc/subgid` file. Using this flag will run the container with user namespace enabled. This flag conflicts with `--userns` and `--gidmap`. -#### **\-\-subuidname**=*name* +#### **--subuidname**=*name* Name for UID map from the `/etc/subuid` file. Using this flag will run the container with user namespace enabled. This flag conflicts with `--userns` and `--uidmap`. -#### **\-\-sysctl**=*SYSCTL* +#### **--sysctl**=*SYSCTL* Configure namespaced kernel parameters at runtime @@ -931,7 +931,7 @@ Network Namespace - current sysctls allowed: Note: if you use the --network=host option these sysctls will not be allowed. -#### **\-\-systemd**=*true|false|always* +#### **--systemd**=*true|false|always* Run container in systemd mode. The default is *true*. @@ -955,13 +955,13 @@ The `container_manage_cgroup` boolean must be enabled for this to be allowed on `setsebool -P container_manage_cgroup true` -#### **\-\-timeout**=*seconds* +#### **--timeout**=*seconds* Maximum time a container is allowed to run before conmon sends it the kill signal. By default containers will run until they exit or are stopped by `podman stop`. -#### **\-\-tmpfs**=*fs* +#### **--tmpfs**=*fs* Create a tmpfs mount @@ -974,7 +974,7 @@ options are the same as the Linux default `mount` flags. If you do not specify any options, the systems uses the following options: `rw,noexec,nosuid,nodev`. -#### **\-\-tty**, **-t**=*true|false* +#### **--tty**, **-t**=*true|false* Allocate a pseudo-TTY. The default is *false*. @@ -985,20 +985,20 @@ interactive shell. The default is false. Note: The **-t** option is incompatible with a redirection of the Podman client standard input. -#### **\-\-tz**=*timezone* +#### **--tz**=*timezone* Set timezone in container. This flag takes area-based timezones, GMT time, as well as `local`, which sets the timezone in the container to match the host machine. See `/usr/share/zoneinfo/` for valid timezones. Remote connections use local containers.conf for defaults -#### **\-\-umask**=*umask* +#### **--umask**=*umask* Set the umask inside the container. Defaults to `0022`. Remote connections use local containers.conf for defaults -#### **\-\-uidmap**=*container_uid*:*from_uid*:*amount* +#### **--uidmap**=*container_uid*:*from_uid*:*amount* Run the container in a new user namespace using the supplied mapping. This -option conflicts with the **\-\-userns** and **\-\-subuidname** options. This +option conflicts with the **--userns** and **--subuidname** options. This option provides a way to map host UIDs to container UIDs. It can be passed several times to map different ranges. @@ -1006,7 +1006,7 @@ The _from_uid_ value is based upon the user running the command, either rootfull * rootfull user: *container_uid*:*host_uid*:*amount* * rootless user: *container_uid*:*intermediate_uid*:*amount* -When **podman create** is called by a privileged user, the option **\-\-uidmap** +When **podman create** is called by a privileged user, the option **--uidmap** works as a direct mapping between host UIDs and container UIDs. host UID -> container UID @@ -1028,7 +1028,7 @@ happens over two mapping steps: host UID -> intermediate UID -> container UID -The **\-\-uidmap** option only influences the second mapping step. +The **--uidmap** option only influences the second mapping step. The first mapping step is derived by Podman from the contents of the file _/etc/subuid_ and the UID of the user calling Podman. @@ -1046,7 +1046,7 @@ First mapping step: To be able to use intermediate UIDs greater than zero, the user needs to have subordinate UIDs configured in _/etc/subuid_. See **subuid**(5). -The second mapping step is configured with **\-\-uidmap**. +The second mapping step is configured with **--uidmap**. If for example _amount_ is **5** the second mapping step would look like: @@ -1059,16 +1059,16 @@ If for example _amount_ is **5** the second mapping step would look like: | _from_uid_ + 4 | _container_uid_ + 4 | Even if a user does not have any subordinate UIDs in _/etc/subuid_, -**\-\-uidmap** could still be used to map the normal UID of the user to a +**--uidmap** could still be used to map the normal UID of the user to a container UID by running `podman create --uidmap $container_uid:0:1 --user $container_uid ...`. -#### **\-\-ulimit**=*option* +#### **--ulimit**=*option* Ulimit options You can pass `host` to copy the current configuration from the host. -#### **\-\-user**, **-u**=*user* +#### **--user**, **-u**=*user* Sets the username or UID used and optionally the groupname or GID for the specified command. @@ -1077,9 +1077,9 @@ The following examples are all valid: Without this argument the command will be run as root in the container. -#### **\-\-userns**=*mode* +#### **--userns**=*mode* -Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **\-\-uidmap** and **\-\-gidmap** options. +Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options. Valid _mode_ values are: @@ -1093,9 +1093,9 @@ Valid _mode_ values are: - **ns:**_namespace_: run the container in the given existing user namespace. - **private**: create a new namespace for the container. -This option is incompatible with **\-\-gidmap**, **\-\-uidmap**, **\-\-subuidname** and **\-\-subgidname**. +This option is incompatible with **--gidmap**, **--uidmap**, **--subuidname** and **--subgidname**. -#### **\-\-uts**=*mode* +#### **--uts**=*mode* Set the UTS namespace mode for the container. The following values are supported: @@ -1104,10 +1104,10 @@ Set the UTS namespace mode for the container. The following values are supported - **ns:[path]**: run the container in the given existing UTS namespace. - **container:[container]**: join the UTS namespace of the specified container. -#### **\-\-variant**=*VARIANT* +#### **--variant**=*VARIANT* Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7. -#### **\-\-volume**, **-v**[=*[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]*] +#### **--volume**, **-v**[=*[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]*] Create a bind mount. If you specify, ` -v /HOST-DIR:/CONTAINER-DIR`, Podman bind mounts `/HOST-DIR` in the host to `/CONTAINER-DIR` in the Podman @@ -1269,7 +1269,7 @@ Note: if the user only has access rights via a group, accessing the volume from inside a rootless container will fail. Use the `--group-add keep-groups` flag to pass the user's supplementary group access into the container. -#### **\-\-volumes-from**[=*CONTAINER*[:*OPTIONS*]] +#### **--volumes-from**[=*CONTAINER*[:*OPTIONS*]] Mount volumes from the specified container(s). Used to share volumes between containers. The *options* is a comma-separated list with the following available elements: @@ -1302,7 +1302,7 @@ If the location of the volume from the source container overlaps with data residing on a target container, then the volume hides that data on the target. -#### **\-\-workdir**, **-w**=*dir* +#### **--workdir**, **-w**=*dir* Working directory inside the container @@ -1310,7 +1310,7 @@ The default working directory for running binaries within a container is the roo The image developer can set a different default with the WORKDIR instruction. The operator can override the working directory by using the **-w** option. -#### **\-\-pidfile**=*path* +#### **--pidfile**=*path* When the pidfile location is specified, the container process' PID will be written to the pidfile. (This option is not available with the remote Podman client) If the pidfile option is not specified, the container process' PID will be written to /run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile. @@ -1403,11 +1403,11 @@ Environment variables within containers can be set using multiple different opti Precedence order (later entries override earlier entries): -- **\-\-env-host** : Host environment of the process executing Podman is added. -- **\-\-http-proxy**: By default, several environment variables will be passed in from the host, such as **http_proxy** and **no_proxy**. See **\-\-http-proxy** for details. +- **--env-host** : Host environment of the process executing Podman is added. +- **--http-proxy**: By default, several environment variables will be passed in from the host, such as **http_proxy** and **no_proxy**. See **--http-proxy** for details. - Container image : Any environment variables specified in the container image. -- **\-\-env-file** : Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry. -- **\-\-env** : Any environment variables specified will override previous settings. +- **--env-file** : Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry. +- **--env** : Any environment variables specified will override previous settings. Create containers and set the environment ending with a __*__ and a ***** diff --git a/docs/source/markdown/podman-diff.1.md b/docs/source/markdown/podman-diff.1.md index 5a4132783..dbab2d4db 100644 --- a/docs/source/markdown/podman-diff.1.md +++ b/docs/source/markdown/podman-diff.1.md @@ -13,11 +13,11 @@ Displays changes on a container or image's filesystem. The container or image w ## OPTIONS -#### **\-\-format** +#### **--format** Alter the output into a different format. The only valid format for diff is `json`. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-events.1.md b/docs/source/markdown/podman-events.1.md index 0a73712b3..4f9e9418f 100644 --- a/docs/source/markdown/podman-events.1.md +++ b/docs/source/markdown/podman-events.1.md @@ -70,16 +70,16 @@ The *volume* type will report the following statuses: ## OPTIONS -#### **\-\-help** +#### **--help** Print usage statement. -#### **\-\-format** +#### **--format** Format the output to JSON Lines or using the given Go template. -#### **\-\-filter**=*filter* +#### **--filter**=*filter* Filter events that are displayed. They must be in the format of "filter=value". The following filters are supported: @@ -93,12 +93,12 @@ filters are supported: In the case where an ID is used, the ID may be in its full or shortened form. -#### **\-\-since**=*timestamp* +#### **--since**=*timestamp* Show all events created since the given timestamp -#### **\-\-until**=*timestamp* +#### **--until**=*timestamp* Show all events created until the given timestamp diff --git a/docs/source/markdown/podman-exec.1.md b/docs/source/markdown/podman-exec.1.md index f412cadd8..524ee50f0 100644 --- a/docs/source/markdown/podman-exec.1.md +++ b/docs/source/markdown/podman-exec.1.md @@ -13,37 +13,37 @@ podman\-exec - Execute a command in a running container ## OPTIONS -#### **\-\-detach**, **-d** +#### **--detach**, **-d** Start the exec session, but do not attach to it. The command will run in the background and the exec session will be automatically removed when it completes. The **podman exec** command will print the ID of the exec session and exit immediately after it starts. -#### **\-\-detach-keys**=*sequence* +#### **--detach-keys**=*sequence* Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*. -#### **\-\-env**, **-e** +#### **--env**, **-e** You may specify arbitrary environment variables that are available for the command to be executed. -#### **\-\-env-file**=*file* +#### **--env-file**=*file* Read in a line delimited file of environment variables. -#### **\-\-interactive**, **-i**=*true|false* +#### **--interactive**, **-i**=*true|false* When set to true, keep stdin open even if not attached. The default is *false*. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-preserve-fds**=*N* +#### **--preserve-fds**=*N* Pass down to the process N additional file descriptors (in addition to 0, 1, 2). The total FDs will be 3+N. -#### **\-\-privileged** +#### **--privileged** Give extended privileges to this container. The default is *false*. @@ -59,17 +59,17 @@ points, Apparmor/SELinux separation, and Seccomp filters are all disabled. Rootless containers cannot have more privileges than the account that launched them. -#### **\-\-tty**, **-t** +#### **--tty**, **-t** Allocate a pseudo-TTY. -#### **\-\-user**, **-u** +#### **--user**, **-u** Sets the username or UID used and optionally the groupname or GID for the specified command. The following examples are all valid: --user [user | user:group | uid | uid:gid | user:gid | uid:group ] -#### **\-\-workdir**, **-w**=*path* +#### **--workdir**, **-w**=*path* Working directory inside the container diff --git a/docs/source/markdown/podman-export.1.md b/docs/source/markdown/podman-export.1.md index 172be035e..63989a4db 100644 --- a/docs/source/markdown/podman-export.1.md +++ b/docs/source/markdown/podman-export.1.md @@ -24,11 +24,11 @@ Note: `:` is a restricted character and cannot be part of the file name. ## OPTIONS -#### **\-\-output**, **-o** +#### **--output**, **-o** Write to a file, default is STDOUT -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-generate-kube.1.md b/docs/source/markdown/podman-generate-kube.1.md index a426d2c3c..2e00b58b6 100644 --- a/docs/source/markdown/podman-generate-kube.1.md +++ b/docs/source/markdown/podman-generate-kube.1.md @@ -20,11 +20,11 @@ Note that the generated Kubernetes YAML file can be used to re-run the deploymen ## OPTIONS -#### **\-\-filename**, **-f**=**filename** +#### **--filename**, **-f**=**filename** Output to the given file, instead of STDOUT. If the file already exists, `generate kube` will refuse to replace it and return an error. -#### **\-\-service**, **-s** +#### **--service**, **-s** Generate a Kubernetes service object in addition to the Pods. Used to generate a Service specification for the corresponding Pod output. In particular, if the object has portmap bindings, the service specification will include a NodePort declaration to expose the service. A random port is assigned by Podman in the specification. diff --git a/docs/source/markdown/podman-generate-systemd.1.md b/docs/source/markdown/podman-generate-systemd.1.md index 7dccc5c1f..4b77c5721 100644 --- a/docs/source/markdown/podman-generate-systemd.1.md +++ b/docs/source/markdown/podman-generate-systemd.1.md @@ -14,46 +14,46 @@ _Note: If you use this command with the remote client, you would still have to p ## OPTIONS -#### **\-\-files**, **-f** +#### **--files**, **-f** Generate files instead of printing to stdout. The generated files are named {container,pod}-{ID,name}.service and will be placed in the current working directory. Note: On a system with SELinux enabled, the generated files will inherit contexts from the current working directory. Depending on the SELinux setup, changes to the generated files using `restorecon`, `chcon`, or `semanage` may be required to allow systemd to access these files. Alternatively, use the `-Z` option when running `mv` or `cp`. -#### **\-\-format**=*format* +#### **--format**=*format* Print the created units in specified format (json). If `--files` is specified the paths to the created files will be printed instead of the unit content. -#### **\-\-name**, **-n** +#### **--name**, **-n** Use the name of the container for the start, stop, and description in the unit file -#### **\-\-new** +#### **--new** Using this flag will yield unit files that do not expect containers and pods to exist. Instead, new containers and pods are created based on their configuration files. The unit files are created best effort and may need to be further edited; please review the generated files carefully before using them in production. -#### **\-\-no-header** +#### **--no-header** Do not generate the header including meta data such as the Podman version and the timestamp. -#### **\-\-time**, **-t**=*value* +#### **--time**, **-t**=*value* Override the default stop timeout for the container with the given value. -#### **\-\-restart-policy**=*policy* +#### **--restart-policy**=*policy* Set the systemd restart policy. The restart-policy must be one of: "no", "on-success", "on-failure", "on-abnormal", "on-watchdog", "on-abort", or "always". The default policy is *on-failure*. -#### **\-\-container-prefix**=*prefix* +#### **--container-prefix**=*prefix* Set the systemd unit name prefix for containers. The default is *container*. -#### **\-\-pod-prefix**=*prefix* +#### **--pod-prefix**=*prefix* Set the systemd unit name prefix for pods. The default is *pod*. -#### **\-\-separator**=*separator* +#### **--separator**=*separator* Set the systemd unit name separator between the name/id of a container/pod and the prefix. The default is *-*. diff --git a/docs/source/markdown/podman-healthcheck-run.1.md b/docs/source/markdown/podman-healthcheck-run.1.md index 41abef204..fa10d5dca 100644 --- a/docs/source/markdown/podman-healthcheck-run.1.md +++ b/docs/source/markdown/podman-healthcheck-run.1.md @@ -21,7 +21,7 @@ Possible errors that can occur during the healthcheck are: * container is not running ## OPTIONS -#### **\-\-help** +#### **--help** Print usage statement diff --git a/docs/source/markdown/podman-history.1.md b/docs/source/markdown/podman-history.1.md index cebb45054..2dd41e9f5 100644 --- a/docs/source/markdown/podman-history.1.md +++ b/docs/source/markdown/podman-history.1.md @@ -12,9 +12,9 @@ podman\-history - Show the history of an image **podman history** displays the history of an image by printing out information about each layer used in the image. The information printed out for each layer include Created (time and date), Created By, Size, and Comment. The output can -be truncated or not using the **\-\-no-trunc** flag. If the **\-\-human** flag is +be truncated or not using the **--no-trunc** flag. If the **--human** flag is set, the time of creation and size are printed out in a human readable format. -The **\-\-quiet** flag displays the ID of the image only when set and the **\-\-format** +The **--quiet** flag displays the ID of the image only when set and the **--format** flag is used to print the information using the Go template provided by the user. Valid placeholders for the Go template are listed below: @@ -29,26 +29,26 @@ Valid placeholders for the Go template are listed below: ## OPTIONS -#### **\-\-human**, **-H**=*true|false* +#### **--human**, **-H**=*true|false* Display sizes and dates in human readable format (default *true*). -#### **\-\-no-trunc**=*true|false* +#### **--no-trunc**=*true|false* Do not truncate the output (default *false*). -#### **\-\-notruncate** +#### **--notruncate** Do not truncate the output -#### **\-\-quiet**, **-q**=*true|false* +#### **--quiet**, **-q**=*true|false* Print the numeric IDs only (default *false*). -#### **\-\-format**=*format* +#### **--format**=*format* Alter the output for a format like 'json' or a Go template. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-image-diff.1.md b/docs/source/markdown/podman-image-diff.1.md index 4c03fcd09..9b1dfa45a 100644 --- a/docs/source/markdown/podman-image-diff.1.md +++ b/docs/source/markdown/podman-image-diff.1.md @@ -11,7 +11,7 @@ Displays changes on a container or image's filesystem. The container or image w ## OPTIONS -#### **\-\-format** +#### **--format** Alter the output into a different format. The only valid format for diff is `json`. diff --git a/docs/source/markdown/podman-image-exists.1.md b/docs/source/markdown/podman-image-exists.1.md index 370d28daa..5d5cb1647 100644 --- a/docs/source/markdown/podman-image-exists.1.md +++ b/docs/source/markdown/podman-image-exists.1.md @@ -14,7 +14,7 @@ was an issue accessing the local storage. ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-image-mount.1.md b/docs/source/markdown/podman-image-mount.1.md index 766f337ad..8cb9684a7 100644 --- a/docs/source/markdown/podman-image-mount.1.md +++ b/docs/source/markdown/podman-image-mount.1.md @@ -22,11 +22,11 @@ returned. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Mount all images. -#### **\-\-format**=*format* +#### **--format**=*format* Print the mounted images in specified format (json). diff --git a/docs/source/markdown/podman-image-prune.1.md b/docs/source/markdown/podman-image-prune.1.md index 16e6c9b03..73024ffb8 100644 --- a/docs/source/markdown/podman-image-prune.1.md +++ b/docs/source/markdown/podman-image-prune.1.md @@ -14,11 +14,11 @@ does not have any containers based on it. The image prune command does not prune cache images that only use layers that are necessary for other images. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove dangling images and images that have no associated containers. -#### **\-\-filter**=*filters* +#### **--filter**=*filters* Provide filter values. @@ -33,11 +33,11 @@ The until filter can be Unix timestamps, date formatted timestamps, or Go durati The label filter accepts two formats. One is the label=... (label=_key_ or label=_key=value_), which removes images with the specified labels. The other format is the label!=... (label!=_key_ or label!=_key=value_), which removes images without the specified labels. -#### **\-\-force**, **-f** +#### **--force**, **-f** Do not provide an interactive prompt for container removal. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-image-sign.1.md b/docs/source/markdown/podman-image-sign.1.md index 994578530..b9addc062 100644 --- a/docs/source/markdown/podman-image-sign.1.md +++ b/docs/source/markdown/podman-image-sign.1.md @@ -15,24 +15,24 @@ By default, the signature will be written into `/var/lib/containers/sigstore` fo ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement. -#### **\-\-all**, **-a** +#### **--all**, **-a** Sign all the manifests of the multi-architecture image (default false). -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-directory**, **-d**=*dir* +#### **--directory**, **-d**=*dir* Store the signatures in the specified directory. Default: /var/lib/containers/sigstore -#### **\-\-sign-by**=*identity* +#### **--sign-by**=*identity* Override the default identity of the signature. diff --git a/docs/source/markdown/podman-image-tree.1.md b/docs/source/markdown/podman-image-tree.1.md index 5f5473f28..fe36929cc 100644 --- a/docs/source/markdown/podman-image-tree.1.md +++ b/docs/source/markdown/podman-image-tree.1.md @@ -13,11 +13,11 @@ If you do not provide a *tag*, Podman will default to `latest` for the *image*. Layers are indicated with image tags as `Top Layer of`, when the tag is known locally. ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-whatrequires** +#### **--whatrequires** Show all child images and layers of the specified image diff --git a/docs/source/markdown/podman-image-trust.1.md b/docs/source/markdown/podman-image-trust.1.md index 63280c4d7..6e2c2287a 100644 --- a/docs/source/markdown/podman-image-trust.1.md +++ b/docs/source/markdown/podman-image-trust.1.md @@ -37,15 +37,15 @@ Require signature (“signedBy”). Trust may be updated using the command **podman image trust set** for an existing trust scope. ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement. -#### **\-\-pubkeysfile**=*KEY1*, **-f** +#### **--pubkeysfile**=*KEY1*, **-f** A path to an exported public key on the local system. Key paths will be referenced in policy.json. Any path to a file may be used but locating the file in **/etc/pki/containers** is recommended. Options may be used multiple times to - require an image be signed by multiple keys. The **\-\-pubkeysfile** option is required for the **signedBy** type. + require an image be signed by multiple keys. The **--pubkeysfile** option is required for the **signedBy** type. -#### **\-\-type**=*value*, **-t** +#### **--type**=*value*, **-t** The trust type for this policy entry. Accepted values: **signedBy** (default): Require signatures with corresponding list of @@ -56,10 +56,10 @@ Trust may be updated using the command **podman image trust set** for an existin ## show OPTIONS -#### **\-\-raw** +#### **--raw** Output trust policy file as raw JSON -#### **\-\-json**, **-j** +#### **--json**, **-j** Output trust as JSON for machine parsing ## EXAMPLES diff --git a/docs/source/markdown/podman-image-unmount.1.md b/docs/source/markdown/podman-image-unmount.1.md index 075ae5968..62e879fa1 100644 --- a/docs/source/markdown/podman-image-unmount.1.md +++ b/docs/source/markdown/podman-image-unmount.1.md @@ -19,11 +19,11 @@ counter reaches zero indicating no other processes are using the mount. An unmount can be forced with the --force flag. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** All of the currently mounted images will be unmounted. -#### **\-\-force**, **-f** +#### **--force**, **-f** Force the unmounting of specified images' root file system, even if other processes have mounted it. diff --git a/docs/source/markdown/podman-images.1.md b/docs/source/markdown/podman-images.1.md index 4aac40a61..23cce450a 100644 --- a/docs/source/markdown/podman-images.1.md +++ b/docs/source/markdown/podman-images.1.md @@ -15,15 +15,15 @@ Displays locally stored images, their names, and their IDs. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Show all images (by default filter out the intermediate image layers). The default is false. -#### **\-\-digests** +#### **--digests** Show image digests -#### **\-\-filter**=*filter*, **-f** +#### **--filter**=*filter*, **-f** Filter output based on conditions provided @@ -47,7 +47,7 @@ Filter output based on conditions provided **reference=** Filter by image name, specified as regular expressions. -#### **\-\-format**=*format* +#### **--format**=*format* Change the default output format. This can be of a supported type like 'json' or a Go template. @@ -64,23 +64,23 @@ Valid placeholders for the Go template are listed below: | .Size | Size of layer on disk | | .History | History of the image layer | -#### **\-\-history** +#### **--history** Display the history of image names. If an image gets re-tagged or untagged, then the image name history gets prepended (latest image first). This is especially useful when undoing a tag operation or an image does not contain any name because it has been untagged. -#### **\-\-noheading**, **-n** +#### **--noheading**, **-n** Omit the table headings from the listing of images. -#### **\-\-no-trunc** +#### **--no-trunc** Do not truncate output. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Lists only the image IDs. -#### **\-\-sort**=*sort* +#### **--sort**=*sort* Sort by created, id, repository, size or tag (default: created) diff --git a/docs/source/markdown/podman-import.1.md b/docs/source/markdown/podman-import.1.md index 171ba4fbd..989e23b74 100644 --- a/docs/source/markdown/podman-import.1.md +++ b/docs/source/markdown/podman-import.1.md @@ -11,34 +11,34 @@ podman\-import - Import a tarball and save it as a filesystem image ## DESCRIPTION **podman import** imports a tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) and saves it as a filesystem image. Remote tarballs can be specified using a URL. -Various image instructions can be configured with the **\-\-change** flag and -a commit message can be set using the **\-\-message** flag. +Various image instructions can be configured with the **--change** flag and +a commit message can be set using the **--message** flag. **reference**, if present, is a tag to assign to the image. **podman import** is used for importing from the archive generated by **podman export**, that includes the container's filesystem. To import the archive of image layers created by **podman save**, use **podman load**. Note: `:` is a restricted character and cannot be part of the file name. ## OPTIONS -#### **\-\-change**=*instruction*, **-c** +#### **--change**=*instruction*, **-c** Apply the following possible instructions to the created image: **CMD** | **ENTRYPOINT** | **ENV** | **EXPOSE** | **LABEL** | **STOPSIGNAL** | **USER** | **VOLUME** | **WORKDIR** Can be set multiple times -#### **\-\-message**, **-m**=*message* +#### **--message**, **-m**=*message* Set commit message for imported image -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Shows progress on the import -**\-\-verbose** +**--verbose** Print additional debugging information -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-info.1.md b/docs/source/markdown/podman-info.1.md index ee7961be0..4af51d3eb 100644 --- a/docs/source/markdown/podman-info.1.md +++ b/docs/source/markdown/podman-info.1.md @@ -15,11 +15,11 @@ Displays information pertinent to the host, current storage stats, configured co ## OPTIONS -#### **\-\-debug**, **-D** +#### **--debug**, **-D** Show additional information -#### **\-\-format**=*format*, **-f** +#### **--format**=*format*, **-f** Change output format to "json" or a Go template. diff --git a/docs/source/markdown/podman-init.1.md b/docs/source/markdown/podman-init.1.md index 4fd552e65..5f3636686 100644 --- a/docs/source/markdown/podman-init.1.md +++ b/docs/source/markdown/podman-init.1.md @@ -18,11 +18,11 @@ This can be used to inspect the container before it runs, or debug why a contain ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Initialize all containers. Containers that have already initialized (including containers that have been started and are running) are ignored. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-inspect.1.md b/docs/source/markdown/podman-inspect.1.md index 7feb36de1..bfd0cea3d 100644 --- a/docs/source/markdown/podman-inspect.1.md +++ b/docs/source/markdown/podman-inspect.1.md @@ -24,24 +24,24 @@ For more inspection options, see: ## OPTIONS -#### **\-\-type**, **-t**=*type* +#### **--type**, **-t**=*type* Return JSON for the specified type. Type can be 'container', 'image', 'volume', 'network', 'pod', or 'all' (default: all) (Only meaningful when invoked as *podman inspect*) -#### **\-\-format**, **-f**=*format* +#### **--format**, **-f**=*format* Format the output using the given Go template. The keys of the returned JSON can be used as the values for the --format flag (see examples below). -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. This option can be used to inspect the latest pod created when used with --type pod. (This option is not available with the remote Podman client or when invoked as *podman image inspect*.) -#### **\-\-size**, **-s** +#### **--size**, **-s** In addition to normal output, display the total file size if the type is a container. diff --git a/docs/source/markdown/podman-kill.1.md b/docs/source/markdown/podman-kill.1.md index e4e984836..e5f1d4bbe 100644 --- a/docs/source/markdown/podman-kill.1.md +++ b/docs/source/markdown/podman-kill.1.md @@ -12,20 +12,20 @@ podman\-kill - Kill the main process in one or more containers The main process inside each container specified will be sent SIGKILL, or any signal specified with option --signal. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Signal all running containers. This does not include paused containers. -#### **\-\-cidfile** +#### **--cidfile** Read container ID from the specified file and remove the container. Can be specified multiple times. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-signal**, **-s** +#### **--signal**, **-s** Signal to send to the container. For more information on Linux signals, refer to *man signal(7)*. diff --git a/docs/source/markdown/podman-load.1.md b/docs/source/markdown/podman-load.1.md index 4f3208377..3ff03e9e7 100644 --- a/docs/source/markdown/podman-load.1.md +++ b/docs/source/markdown/podman-load.1.md @@ -26,7 +26,7 @@ Note: `:` is a restricted character and cannot be part of the file name. ## OPTIONS -#### **\-\-input**, **-i**=*input* +#### **--input**, **-i**=*input* Read from archive file, default is STDIN. @@ -34,11 +34,11 @@ The remote client requires the use of this option. NOTE: Use the environment variable `TMPDIR` to change the temporary storage location of container images. Podman defaults to use `/var/tmp`. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress the progress output -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-login.1.md b/docs/source/markdown/podman-login.1.md index c7779788f..274869042 100644 --- a/docs/source/markdown/podman-login.1.md +++ b/docs/source/markdown/podman-login.1.md @@ -28,41 +28,41 @@ For more details about format and configurations of the auth.json file, please r ## OPTIONS -#### **\-\-password**, **-p**=*password* +#### **--password**, **-p**=*password* Password for registry -#### **\-\-password-stdin** +#### **--password-stdin** Take the password from stdin -#### **\-\-username**, **-u**=*username* +#### **--username**, **-u**=*username* Username for registry -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json. Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-get-login** +#### **--get-login** Return the logged-in user for the registry. Return error if no login is found. -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-tls-verify**=*true|false* +#### **--tls-verify**=*true|false* Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, TLS verification will be used unless the target registry is listed as an insecure registry in registries.conf. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-logout.1.md b/docs/source/markdown/podman-logout.1.md index caa8c9021..c35c4856b 100644 --- a/docs/source/markdown/podman-logout.1.md +++ b/docs/source/markdown/podman-logout.1.md @@ -21,18 +21,18 @@ All the cached credentials can be removed by setting the **all** flag. ## OPTIONS -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json. Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove the cached credentials for all registries in the auth file -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-logs.1.md b/docs/source/markdown/podman-logs.1.md index 863e8278a..8f1301102 100644 --- a/docs/source/markdown/podman-logs.1.md +++ b/docs/source/markdown/podman-logs.1.md @@ -15,7 +15,7 @@ any logs at the time you execute podman logs). ## OPTIONS -#### **\-\-follow**, **-f** +#### **--follow**, **-f** Follow log output. Default is false. @@ -23,28 +23,28 @@ Note: If you are following a container which is removed `podman container rm` or removed on exit `podman run --rm ...`, then there is a chance the the log file will be removed before `podman logs` reads the final content. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-names**, **-n** +#### **--names**, **-n** Output the container name in the log -#### **\-\-since**=*TIMESTAMP* +#### **--since**=*TIMESTAMP* Show logs since TIMESTAMP. The --since option can be Unix timestamps, date formatted timestamps, or Go duration strings (e.g. 10m, 1h30m) computed relative to the client machine's time. Supported formats for date formatted time stamps include RFC3339Nano, RFC3339, 2006-01-02T15:04:05, 2006-01-02T15:04:05.999999999, 2006-01-02Z07:00, and 2006-01-02. -#### **\-\-tail**=*LINES* +#### **--tail**=*LINES* Output the specified number of LINES at the end of the logs. LINES must be an integer. Defaults to -1, which prints all lines -#### **\-\-timestamps**, **-t** +#### **--timestamps**, **-t** Show timestamps in the log outputs. The default is false diff --git a/docs/source/markdown/podman-machine-init.1.md b/docs/source/markdown/podman-machine-init.1.md index 8947967aa..32aae91c1 100644 --- a/docs/source/markdown/podman-machine-init.1.md +++ b/docs/source/markdown/podman-machine-init.1.md @@ -20,15 +20,15 @@ and a user account inside the VM are added. ## OPTIONS -#### **\-\-cpus**=*number* +#### **--cpus**=*number* Number of CPUs. -#### **\-\-disk-size**=*number* +#### **--disk-size**=*number* Size of the disk for the guest VM in GB. -#### **\-\-ignition-path** +#### **--ignition-path** Fully qualified path of the ignition file. @@ -37,15 +37,15 @@ will be copied into the user's CONF_DIR and renamed. Additionally, no SSH keys be generated nor will a system connection be made. It is assumed that the user will do these things manually or handle otherwise. -#### **\-\-image-path** +#### **--image-path** Fully qualified path of the uncompressed image file -#### **\-\-memory**, **-m**=*number* +#### **--memory**, **-m**=*number* Memory (in MB). -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-machine-list.1.md b/docs/source/markdown/podman-machine-list.1.md index 922c19fdf..cad7e614b 100644 --- a/docs/source/markdown/podman-machine-list.1.md +++ b/docs/source/markdown/podman-machine-list.1.md @@ -18,7 +18,7 @@ tied to the Linux kernel. ## OPTIONS -#### **\-\-format**=*format* +#### **--format**=*format* Format list output using a Go template. @@ -31,11 +31,11 @@ Valid placeholders for the Go template are listed below: | .LastUp | Time since the VM was last run | | .VMType | VM type | -#### **\-\-help** +#### **--help** Print usage statement. -#### **\-\-noheading** +#### **--noheading** Omit the table headings from the listing of pods. diff --git a/docs/source/markdown/podman-machine-rm.1.md b/docs/source/markdown/podman-machine-rm.1.md index e80f26d6d..4da17fdcb 100644 --- a/docs/source/markdown/podman-machine-rm.1.md +++ b/docs/source/markdown/podman-machine-rm.1.md @@ -19,23 +19,23 @@ is used. ## OPTIONS -#### **\-\-help** +#### **--help** Print usage statement. -#### **\-\-force** +#### **--force** Delete without confirmation -#### **\-\-save-ignition** +#### **--save-ignition** Do not delete the generated ignition file -#### **\-\-save-image** +#### **--save-image** Do not delete the VM image -#### **\-\-save-keys** +#### **--save-keys** Do not delete the SSH keys for the VM. The system connection is always deleted. diff --git a/docs/source/markdown/podman-machine-ssh.1.md b/docs/source/markdown/podman-machine-ssh.1.md index 30cbaf4bd..a5cf69107 100644 --- a/docs/source/markdown/podman-machine-ssh.1.md +++ b/docs/source/markdown/podman-machine-ssh.1.md @@ -17,7 +17,7 @@ with the virtual machine is established. ## OPTIONS -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-machine-start.1.md b/docs/source/markdown/podman-machine-start.1.md index b21bbd65c..3ab5e96ba 100644 --- a/docs/source/markdown/podman-machine-start.1.md +++ b/docs/source/markdown/podman-machine-start.1.md @@ -21,7 +21,7 @@ Only one Podman managed VM can be active at a time. If a VM is already running, ## OPTIONS -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-machine-stop.1.md b/docs/source/markdown/podman-machine-stop.1.md index e2037144c..fc31e0bee 100644 --- a/docs/source/markdown/podman-machine-stop.1.md +++ b/docs/source/markdown/podman-machine-stop.1.md @@ -18,7 +18,7 @@ tied to the Linux kernel. ## OPTIONS -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-manifest-add.1.md b/docs/source/markdown/podman-manifest-add.1.md index 2727843da..59d5e5d2c 100644 --- a/docs/source/markdown/podman-manifest-add.1.md +++ b/docs/source/markdown/podman-manifest-add.1.md @@ -15,25 +15,25 @@ The list image's ID. ## OPTIONS -#### **\-\-all** +#### **--all** If the image which should be added to the list or index is itself a list or index, add all of the contents to the local list. By default, only one image from such a list or index will be added to the list or index. Combining *--all* with any of the other options described below is NOT recommended. -#### **\-\-annotation** *annotation=value* +#### **--annotation** *annotation=value* Set an annotation on the entry for the newly-added image. -#### **\-\-arch** +#### **--arch** Override the architecture which the list or index records as a requirement for the image. If *imageName* refers to a manifest list or image index, the architecture information will be retrieved from it. Otherwise, it will be retrieved from the image's configuration information. -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. @@ -41,39 +41,39 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-creds**=*creds* +#### **--creds**=*creds* The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-features** +#### **--features** Specify the features list which the list or index records as requirements for the image. This option is rarely used. -#### **\-\-os** +#### **--os** Override the OS which the list or index records as a requirement for the image. If *imagename* refers to a manifest list or image index, the OS information will be retrieved from it. Otherwise, it will be retrieved from the image's configuration information. -#### **\-\-os-version** +#### **--os-version** Specify the OS version which the list or index records as a requirement for the image. This option is rarely used. -#### **\-\-tls-verify** +#### **--tls-verify** Require HTTPS and verify certificates when talking to container registries (defaults to true). -#### **\-\-variant** +#### **--variant** Specify the variant which the list or index records for the image. This option is typically used to distinguish between multiple entries which share the same diff --git a/docs/source/markdown/podman-manifest-annotate.1.md b/docs/source/markdown/podman-manifest-annotate.1.md index 70b077e5b..2126b71ec 100644 --- a/docs/source/markdown/podman-manifest-annotate.1.md +++ b/docs/source/markdown/podman-manifest-annotate.1.md @@ -12,39 +12,39 @@ Adds or updates information about an image included in a manifest list or image ## OPTIONS -#### **\-\-annotation** *annotation=value* +#### **--annotation** *annotation=value* Set an annotation on the entry for the specified image. -#### **\-\-arch** +#### **--arch** Override the architecture which the list or index records as a requirement for the image. This is usually automatically retrieved from the image's configuration information, so it is rarely necessary to use this option. -#### **\-\-features** +#### **--features** Specify the features list which the list or index records as requirements for the image. This option is rarely used. -#### **\-\-os** +#### **--os** Override the OS which the list or index records as a requirement for the image. This is usually automatically retrieved from the image's configuration information, so it is rarely necessary to use this option. -#### **\-\-os-features** +#### **--os-features** Specify the OS features list which the list or index records as requirements for the image. This option is rarely used. -#### **\-\-os-version** +#### **--os-version** Specify the OS version which the list or index records as a requirement for the image. This option is rarely used. -#### **\-\-variant** +#### **--variant** Specify the variant which the list or index records for the image. This option is typically used to distinguish between multiple entries which share the same diff --git a/docs/source/markdown/podman-manifest-create.1.md b/docs/source/markdown/podman-manifest-create.1.md index 3017fb515..3a3d5e4b0 100644 --- a/docs/source/markdown/podman-manifest-create.1.md +++ b/docs/source/markdown/podman-manifest-create.1.md @@ -16,7 +16,7 @@ index. ## OPTIONS -#### **\-\-all** +#### **--all** If any of the images which should be added to the new list or index are themselves lists or indexes, add all of their contents. By default, only one diff --git a/docs/source/markdown/podman-manifest-exists.1.md b/docs/source/markdown/podman-manifest-exists.1.md index 944cc04c8..e15110126 100644 --- a/docs/source/markdown/podman-manifest-exists.1.md +++ b/docs/source/markdown/podman-manifest-exists.1.md @@ -14,7 +14,7 @@ An exit code of `125` indicates there was another issue. ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement. diff --git a/docs/source/markdown/podman-manifest-push.1.md b/docs/source/markdown/podman-manifest-push.1.md index 5236dd7c3..5097ada64 100644 --- a/docs/source/markdown/podman-manifest-push.1.md +++ b/docs/source/markdown/podman-manifest-push.1.md @@ -14,12 +14,12 @@ The list image's ID and the digest of the image's manifest. ## OPTIONS -#### **\-\-all** +#### **--all** Push the images mentioned in the manifest list or image index, in addition to the list or index itself. (Default true) -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. @@ -27,42 +27,42 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-creds**=*creds* +#### **--creds**=*creds* The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-digestfile**=*Digestfile* +#### **--digestfile**=*Digestfile* After copying the image, write the digest of the resulting image to the file. -#### **\-\-format**, **-f**=*format* +#### **--format**, **-f**=*format* Manifest list type (oci or v2s2) to use when pushing the list (default is oci). -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** When writing the manifest, suppress progress output -#### **\-\-rm** +#### **--rm** Delete the manifest list or image index from local storage if pushing succeeds. -#### **\-\-remove-signatures** +#### **--remove-signatures** Don't copy signatures when pushing images. -#### **\-\-sign-by**=*fingerprint* +#### **--sign-by**=*fingerprint* Sign the pushed images using the GPG key that matches the specified fingerprint. -#### **\-\-tls-verify** +#### **--tls-verify** Require HTTPS and verify certificates when talking to container registries. (defaults to true) diff --git a/docs/source/markdown/podman-mount.1.md b/docs/source/markdown/podman-mount.1.md index 780437a9c..1b1b09120 100644 --- a/docs/source/markdown/podman-mount.1.md +++ b/docs/source/markdown/podman-mount.1.md @@ -26,21 +26,21 @@ returned. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Mount all podman containers. (External containers will not be mounted) -#### **\-\-format**=*format* +#### **--format**=*format* Print the mounted containers in specified format (json). -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-notruncate** +#### **--notruncate** Do not truncate IDs in output. diff --git a/docs/source/markdown/podman-network-connect.1.md b/docs/source/markdown/podman-network-connect.1.md index bb765a677..cff4336d6 100644 --- a/docs/source/markdown/podman-network-connect.1.md +++ b/docs/source/markdown/podman-network-connect.1.md @@ -13,7 +13,7 @@ Once connected, the container can communicate with other containers in the same This command is not available for rootless users. ## OPTIONS -#### **\-\-alias** +#### **--alias** Add network-scoped alias for the container. If the network is using the `dnsname` CNI plugin, these aliases can be used for name resolution on the given network. Multiple *--alias* options may be specified as input. diff --git a/docs/source/markdown/podman-network-create.1.md b/docs/source/markdown/podman-network-create.1.md index 9a8c4f72d..3d5d98055 100644 --- a/docs/source/markdown/podman-network-create.1.md +++ b/docs/source/markdown/podman-network-create.1.md @@ -18,16 +18,16 @@ If no options are provided, Podman will assign a free subnet and name for your n Upon completion of creating the network, Podman will display the path to the newly added network file. ## OPTIONS -#### **\-\-disable-dns** +#### **--disable-dns** Disables the DNS plugin for this network which if enabled, can perform container to container name resolution. -#### **\-\-driver**, **-d** +#### **--driver**, **-d** Driver to manage the network (default "bridge"). Currently only `bridge` is supported. -#### **\-\-opt**=*option*, **-o** +#### **--opt**=*option*, **-o** Set driver specific options. @@ -35,37 +35,37 @@ For the `bridge` driver the following options are supported: `mtu` and `vlan`. The `mtu` option sets the Maximum Transmission Unit (MTU) and takes an integer value. The `vlan` option assign VLAN tag and enables vlan\_filtering. Defaults to none. -#### **\-\-gateway** +#### **--gateway** Define a gateway for the subnet. If you want to provide a gateway address, you must also provide a *subnet* option. -#### **\-\-internal** +#### **--internal** Restrict external access of this network. Note when using this option, the dnsname plugin will be automatically disabled. -#### **\-\-ip-range** +#### **--ip-range** Allocate container IP from a range. The range must be a complete subnet and in CIDR notation. The *ip-range* option must be used with a *subnet* option. -#### **\-\-label** +#### **--label** Set metadata for a network (e.g., --label mykey=value). -#### **\-\-macvlan** +#### **--macvlan** *This option is being deprecated* Create a *Macvlan* based connection rather than a classic bridge. You must pass an interface name from the host for the Macvlan connection. -#### **\-\-subnet** +#### **--subnet** The subnet in CIDR notation. -#### **\-\-ipv6** +#### **--ipv6** Enable IPv6 (Dual Stack) networking. You must pass a IPv6 subnet. The *subnet* option must be used with the *ipv6* option. diff --git a/docs/source/markdown/podman-network-disconnect.1.md b/docs/source/markdown/podman-network-disconnect.1.md index ed5a5637a..8b7125282 100644 --- a/docs/source/markdown/podman-network-disconnect.1.md +++ b/docs/source/markdown/podman-network-disconnect.1.md @@ -12,7 +12,7 @@ Disconnects a container from a network. This command is not available for rootless users. ## OPTIONS -#### **\-\-force**, **-f** +#### **--force**, **-f** Force the container to disconnect from a network diff --git a/docs/source/markdown/podman-network-exists.1.md b/docs/source/markdown/podman-network-exists.1.md index bc3c88014..3ad3ccedb 100644 --- a/docs/source/markdown/podman-network-exists.1.md +++ b/docs/source/markdown/podman-network-exists.1.md @@ -15,7 +15,7 @@ of `0` when the network is found. A `1` will be returned otherwise. An exit cod ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-network-inspect.1.md b/docs/source/markdown/podman-network-inspect.1.md index af6907906..56515d0c1 100644 --- a/docs/source/markdown/podman-network-inspect.1.md +++ b/docs/source/markdown/podman-network-inspect.1.md @@ -10,7 +10,7 @@ podman\-network\-inspect - Displays the raw CNI network configuration for one or Display the raw (JSON format) network configuration. ## OPTIONS -#### **\-\-format**, **-f** +#### **--format**, **-f** Pretty-print networks to JSON or using a Go template. diff --git a/docs/source/markdown/podman-network-ls.1.md b/docs/source/markdown/podman-network-ls.1.md index 464efdc21..a5c6ff0c0 100644 --- a/docs/source/markdown/podman-network-ls.1.md +++ b/docs/source/markdown/podman-network-ls.1.md @@ -10,7 +10,7 @@ podman\-network\-ls - Display a summary of CNI networks Displays a list of existing podman networks. ## OPTIONS -#### **\-\-filter**, **-f** +#### **--filter**, **-f** Filter output based on conditions given. Multiple filters can be given with multiple uses of the --filter flag. @@ -27,7 +27,7 @@ Valid filters are listed below: | plugin | [Plugin] CNI plugins included in a network (e.g `bridge`,`portmap`,`firewall`,`tuning`,`dnsname`,`macvlan`) | | driver | [Driver] Only `bridge` is supported | -#### **\-\-format** +#### **--format** Change the default output format. This can be of a supported type like 'json' or a Go template. @@ -41,15 +41,15 @@ Valid placeholders for the Go template are listed below: | .Labels | Network labels | | .Version | CNI Version of the config file | -#### **\-\-noheading** +#### **--noheading** Omit the table headings from the listing of networks. -#### **\-\-no-trunc** +#### **--no-trunc** -Do not truncate the network ID. The network ID is not displayed by default and must be specified with **\-\-format**. +Do not truncate the network ID. The network ID is not displayed by default and must be specified with **--format**. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** The `quiet` option will restrict the output to only the network names. diff --git a/docs/source/markdown/podman-network-prune.1.md b/docs/source/markdown/podman-network-prune.1.md index 909db462c..af0a7295d 100644 --- a/docs/source/markdown/podman-network-prune.1.md +++ b/docs/source/markdown/podman-network-prune.1.md @@ -12,7 +12,7 @@ has no containers connected or configured to connect to it. It will not remove the so-called default network which goes by the name of *podman*. ## OPTIONS -#### **\-\-force**, **-f** +#### **--force**, **-f** Do not prompt for confirmation diff --git a/docs/source/markdown/podman-network-reload.1.md b/docs/source/markdown/podman-network-reload.1.md index 8f88585f2..1d9f34f2e 100644 --- a/docs/source/markdown/podman-network-reload.1.md +++ b/docs/source/markdown/podman-network-reload.1.md @@ -16,11 +16,11 @@ the network connectivity. This command is not available for rootless users since rootless containers are not affected by such connectivity problems. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Reload network configuration of all containers. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-network-rm.1.md b/docs/source/markdown/podman-network-rm.1.md index 9777975df..ad4bc11e2 100644 --- a/docs/source/markdown/podman-network-rm.1.md +++ b/docs/source/markdown/podman-network-rm.1.md @@ -10,7 +10,7 @@ podman\-network\-rm - Remove one or more CNI networks Delete one or more Podman networks. ## OPTIONS -#### **\-\-force**, **-f** +#### **--force**, **-f** The `force` option will remove all containers that use the named network. If the container is running, the container will be stopped and removed. diff --git a/docs/source/markdown/podman-pause.1.md b/docs/source/markdown/podman-pause.1.md index 98948739c..123362822 100644 --- a/docs/source/markdown/podman-pause.1.md +++ b/docs/source/markdown/podman-pause.1.md @@ -13,7 +13,7 @@ Pauses all the processes in one or more containers. You may use container IDs o ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Pause all running containers. diff --git a/docs/source/markdown/podman-play-kube.1.md b/docs/source/markdown/podman-play-kube.1.md index ab2019139..98b303ae7 100644 --- a/docs/source/markdown/podman-play-kube.1.md +++ b/docs/source/markdown/podman-play-kube.1.md @@ -37,7 +37,7 @@ A Kubernetes PersistentVolumeClaim represents a Podman named volume. Only the Pe ## OPTIONS -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. @@ -45,58 +45,58 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-configmap**=*path* +#### **--configmap**=*path* Use Kubernetes configmap YAML at path to provide a source for environment variable values within the containers of the pod. Note: The *--configmap* option can be used multiple times or a comma-separated list of paths can be used to pass multiple Kubernetes configmap YAMLs. -#### **\-\-creds** +#### **--creds** The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-ip**=*IP address* +#### **--ip**=*IP address* Assign a static ip address to the pod. This option can be specified several times when play kube creates more than one pod. -#### **\-\-log-driver**=driver +#### **--log-driver**=driver Set logging driver for all created containers. -#### **\-\-mac-address**=*MAC address* +#### **--mac-address**=*MAC address* Assign a static mac address to the pod. This option can be specified several times when play kube creates more than one pod. -#### **\-\-network**=*networks*, **\-\-net** +#### **--network**=*networks*, **--net** A comma-separated list of the names of CNI networks the pod should join. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output information when pulling images -#### **\-\-seccomp-profile-root**=*path* +#### **--seccomp-profile-root**=*path* Directory path for seccomp profiles (default: "/var/lib/kubelet/seccomp"). (This option is not available with the remote Podman client) -#### **\-\-start**=*true|false* +#### **--start**=*true|false* Start the pod after creating it, set to false to only create it. -#### **\-\-tls-verify**=*true|false* +#### **--tls-verify**=*true|false* Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, TLS verification will be used unless the target registry is listed as an insecure registry in registries.conf. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-pod-create.1.md b/docs/source/markdown/podman-pod-create.1.md index 701c0edf6..37eb098d1 100644 --- a/docs/source/markdown/podman-pod-create.1.md +++ b/docs/source/markdown/podman-pod-create.1.md @@ -15,71 +15,71 @@ containers added to it. The pod id is printed to STDOUT. You can then use ## OPTIONS -#### **\-\-add-host**=_host_:_ip_ +#### **--add-host**=_host_:_ip_ Add a host to the /etc/hosts file shared between all containers in the pod. -#### **\-\-cgroup-parent**=*path* +#### **--cgroup-parent**=*path* Path to cgroups under which the cgroup for the pod will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist. -#### **\-\-dns**=*ipaddr* +#### **--dns**=*ipaddr* Set custom DNS servers in the /etc/resolv.conf file that will be shared between all containers in the pod. A special option, "none" is allowed which disables creation of /etc/resolv.conf for the pod. -#### **\-\-dns-opt**=*option* +#### **--dns-opt**=*option* Set custom DNS options in the /etc/resolv.conf file that will be shared between all containers in the pod. -#### **\-\-dns-search**=*domain* +#### **--dns-search**=*domain* Set custom DNS search domains in the /etc/resolv.conf file that will be shared between all containers in the pod. -#### **\-\-help** +#### **--help** Print usage statement. -#### **\-\-hostname**=name +#### **--hostname**=name Set a hostname to the pod -#### **\-\-infra**=**true**|**false** +#### **--infra**=**true**|**false** Create an infra container and associate it with the pod. An infra container is a lightweight container used to coordinate the shared kernel namespace of a pod. Default: true. -#### **\-\-infra-conmon-pidfile**=*file* +#### **--infra-conmon-pidfile**=*file* Write the pid of the infra container's **conmon** process to a file. As **conmon** runs in a separate process than Podman, this is necessary when using systemd to manage Podman containers and pods. -#### **\-\-infra-command**=*command* +#### **--infra-command**=*command* The command that will be run to start the infra container. Default: "/pause". -#### **\-\-infra-image**=*image* +#### **--infra-image**=*image* The image that will be created for the infra container. Default: "k8s.gcr.io/pause:3.1". -#### **\-\-ip**=*ipaddr* +#### **--ip**=*ipaddr* Set a static IP for the pod's shared network. -#### **\-\-label**=*label*, **-l** +#### **--label**=*label*, **-l** Add metadata to a pod (e.g., --label com.example.key=value). -#### **\-\-label-file**=*label* +#### **--label-file**=*label* Read in a line delimited file of labels. -#### **\-\-mac-address**=*address* +#### **--mac-address**=*address* Set a static MAC address for the pod's shared network. -#### **\-\-name**=*name*, **-n** +#### **--name**=*name*, **-n** Assign a name to the pod. -#### **\-\-network**=*mode*, **\-\-net** +#### **--network**=*mode*, **--net** Set network mode for the pod. Supported values are - **bridge**: Create a network stack on the default bridge. This is the default for rootfull containers. @@ -96,19 +96,19 @@ Set network mode for the pod. Supported values are - **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default. - **port_handler=slirp4netns**: Use the slirp4netns port forwarding. -#### **\-\-network-alias**=strings +#### **--network-alias**=strings Add a DNS alias for the container. When the container is joined to a CNI network with support for the dnsname plugin, the container will be accessible through this name from other containers in the network. -#### **\-\-no-hosts**=**true**|**false** +#### **--no-hosts**=**true**|**false** Disable creation of /etc/hosts for the pod. -#### **\-\-pod-id-file**=*path* +#### **--pod-id-file**=*path* Write the pod ID to the file. -#### **\-\-publish**=*port*, **-p** +#### **--publish**=*port*, **-p** Publish a port or range of ports from the pod to the host. @@ -119,11 +119,11 @@ Use `podman port` to see the actual mapping: `podman port CONTAINER $CONTAINERPO NOTE: This cannot be modified once the pod is created. -#### **\-\-replace**=**true**|**false** +#### **--replace**=**true**|**false** If another pod with the same name already exists, replace and remove it. The default is **false**. -#### **\-\-share**=*namespace* +#### **--share**=*namespace* A comma-separated list of kernel namespaces to share. If none or "" is specified, no namespaces will be shared. The namespaces to choose from are ipc, net, pid, uts. @@ -133,7 +133,7 @@ UUID short identifier (“f78375b1c487”) Name (“jonah”) podman generates a UUID for each pod, and if a name is not assigned -to the container with **\-\-name** then a random string name will be generated +to the container with **--name** then a random string name will be generated for it. The name is useful any place you need to identify a pod. ## EXAMPLES diff --git a/docs/source/markdown/podman-pod-inspect.1.md b/docs/source/markdown/podman-pod-inspect.1.md index 9265b824c..1f4e6cb06 100644 --- a/docs/source/markdown/podman-pod-inspect.1.md +++ b/docs/source/markdown/podman-pod-inspect.1.md @@ -11,12 +11,12 @@ Displays configuration and state information about a given pod. It also display that belong to the pod. ## OPTIONS -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, use the last created pod. If you use methods other than Podman to run pods such as CRI-O, the last started pod could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-format**=*format*, **-f** +#### **--format**=*format*, **-f** Change the default output format. This can be of a supported type like 'json' or a Go template. diff --git a/docs/source/markdown/podman-pod-kill.1.md b/docs/source/markdown/podman-pod-kill.1.md index 38bcaab17..d4eef2307 100644 --- a/docs/source/markdown/podman-pod-kill.1.md +++ b/docs/source/markdown/podman-pod-kill.1.md @@ -10,16 +10,16 @@ podman\-pod\-kill - Kill the main process of each container in one or more pods The main process of each container inside the pods specified will be sent SIGKILL, or any signal specified with option --signal. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Sends signal to all containers associated with a pod. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, use the last created pod. If you use methods other than Podman to run pods such as CRI-O, the last started pod could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-signal**, **-s** +#### **--signal**, **-s** Signal to send to the containers in the pod. For more information on Linux signals, refer to *man signal(7)*. diff --git a/docs/source/markdown/podman-pod-pause.1.md b/docs/source/markdown/podman-pod-pause.1.md index 51dee5939..2c849a932 100644 --- a/docs/source/markdown/podman-pod-pause.1.md +++ b/docs/source/markdown/podman-pod-pause.1.md @@ -11,11 +11,11 @@ Pauses all the running processes in the containers of one or more pods. You may ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Pause all pods. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, pause the last created pod. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-pod-prune.1.md b/docs/source/markdown/podman-pod-prune.1.md index 7b7137186..e90164c15 100644 --- a/docs/source/markdown/podman-pod-prune.1.md +++ b/docs/source/markdown/podman-pod-prune.1.md @@ -11,7 +11,7 @@ podman-pod-prune - Remove all stopped pods and their containers ## OPTIONS -#### **\-\-force**, **-f** +#### **--force**, **-f** Force removal of all running pods and their containers. The default is false. ## EXAMPLES diff --git a/docs/source/markdown/podman-pod-ps.1.md b/docs/source/markdown/podman-pod-ps.1.md index d4fd6d41c..c1f5fd5e3 100644 --- a/docs/source/markdown/podman-pod-ps.1.md +++ b/docs/source/markdown/podman-pod-ps.1.md @@ -26,39 +26,39 @@ By default it lists: ## OPTIONS -#### **\-\-ctr-names** +#### **--ctr-names** Includes the container names in the container info field -#### **\-\-ctr-ids** +#### **--ctr-ids** Includes the container IDs in the container info field -#### **\-\-ctr-status** +#### **--ctr-status** Includes the container statuses in the container info field -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Show the latest pod created (all states) (This option is not available with the remote Podman client) -#### **\-\-noheading** +#### **--noheading** Omit the table headings from the listing of pods. -#### **\-\-no-trunc** +#### **--no-trunc** Display the extended information -#### **\-\-ns** +#### **--ns** Display namespace information of the pod -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Print the numeric IDs of the pods only -#### **\-\-format**=*format* +#### **--format**=*format* Pretty-print containers to JSON or using a Go template @@ -76,13 +76,13 @@ Valid placeholders for the Go template are listed below: | .InfraID | Pod infra container ID | | .Networks | Show all networks connected to the infra container | -#### **\-\-sort** +#### **--sort** Sort by created, ID, name, status, or number of containers Default: created -#### **\-\-filter**, **-f**=*filter* +#### **--filter**, **-f**=*filter* Filter output based on conditions given. Multiple filters can be given with multiple uses of the --filter flag. @@ -103,7 +103,7 @@ Valid filters are listed below: | ctr-status | Container status within the pod | | ctr-number | Number of containers in the pod | -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-pod-restart.1.md b/docs/source/markdown/podman-pod-restart.1.md index 15261d5aa..65d05f977 100644 --- a/docs/source/markdown/podman-pod-restart.1.md +++ b/docs/source/markdown/podman-pod-restart.1.md @@ -14,11 +14,11 @@ When restarting multiple pods, an error from restarting one pod will not effect ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Restarts all pods -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, restart the last created pod. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-pod-rm.1.md b/docs/source/markdown/podman-pod-rm.1.md index 025bedc61..d185385b6 100644 --- a/docs/source/markdown/podman-pod-rm.1.md +++ b/docs/source/markdown/podman-pod-rm.1.md @@ -11,25 +11,25 @@ podman\-pod\-rm - Remove one or more stopped pods and containers ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove all pods. Can be used in conjunction with \-f as well. -#### **\-\-ignore**, **-i** +#### **--ignore**, **-i** Ignore errors when specified pods are not in the container store. A user might have decided to manually remove a pod which would lead to a failure during the ExecStop directive of a systemd service referencing that pod. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, remove the last created pod. (This option is not available with the remote Podman client) -#### **\-\-force**, **-f** +#### **--force**, **-f** Stop running containers and delete all stopped containers before removal of pod. -#### **\-\-pod-id-file** +#### **--pod-id-file** Read pod ID from the specified file and remove the pod. Can be specified multiple times. diff --git a/docs/source/markdown/podman-pod-start.1.md b/docs/source/markdown/podman-pod-start.1.md index 78656b954..40a71d879 100644 --- a/docs/source/markdown/podman-pod-start.1.md +++ b/docs/source/markdown/podman-pod-start.1.md @@ -12,15 +12,15 @@ to be started. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Starts all pods -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, start the last created pod. (This option is not available with the remote Podman client) -#### **\-\-pod-id-file** +#### **--pod-id-file** Read pod ID from the specified file and start the pod. Can be specified multiple times. diff --git a/docs/source/markdown/podman-pod-stats.1.md b/docs/source/markdown/podman-pod-stats.1.md index 6d67295d8..3158ffc1c 100644 --- a/docs/source/markdown/podman-pod-stats.1.md +++ b/docs/source/markdown/podman-pod-stats.1.md @@ -11,23 +11,23 @@ Display a live stream of containers in one or more pods resource usage statistic ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Show all containers. Only running containers are shown by default -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, use the last created pod. (This option is not available with the remote Podman client) -#### **\-\-no-reset** +#### **--no-reset** Do not clear the terminal/screen in between reporting intervals -#### **\-\-no-stream** +#### **--no-stream** Disable streaming pod stats and only pull the first result, default setting is false -#### **\-\-format**=*template* +#### **--format**=*template* Pretty-print container statistics to JSON or using a Go template diff --git a/docs/source/markdown/podman-pod-stop.1.md b/docs/source/markdown/podman-pod-stop.1.md index b68ee2377..77f6af433 100644 --- a/docs/source/markdown/podman-pod-stop.1.md +++ b/docs/source/markdown/podman-pod-stop.1.md @@ -11,25 +11,25 @@ Stop containers in one or more pods. You may use pod IDs or names as input. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Stops all pods -#### **\-\-ignore**, **-i** +#### **--ignore**, **-i** Ignore errors when specified pods are not in the container store. A user might have decided to manually remove a pod which would lead to a failure during the ExecStop directive of a systemd service referencing that pod. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, stop the last created pod. (This option is not available with the remote Podman client) -#### **\-\-time**, **-t**=*time* +#### **--time**, **-t**=*time* Timeout to wait before forcibly stopping the containers in the pod. -#### **\-\-pod-id-file** +#### **--pod-id-file** Read pod ID from the specified file and stop the pod. Can be specified multiple times. diff --git a/docs/source/markdown/podman-pod-top.1.md b/docs/source/markdown/podman-pod-top.1.md index ea86c3999..d374a0dca 100644 --- a/docs/source/markdown/podman-pod-top.1.md +++ b/docs/source/markdown/podman-pod-top.1.md @@ -11,11 +11,11 @@ Display the running processes of containers in a pod. The *format-descriptors* a ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, use the last created pod. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-pod-unpause.1.md b/docs/source/markdown/podman-pod-unpause.1.md index 75230113f..98022a50b 100644 --- a/docs/source/markdown/podman-pod-unpause.1.md +++ b/docs/source/markdown/podman-pod-unpause.1.md @@ -11,11 +11,11 @@ Unpauses all the paused processes in the containers of one or more pods. You ma ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Unpause all pods. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the pod name or ID, unpause the last created pod. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-port.1.md b/docs/source/markdown/podman-port.1.md index 1db174e7d..7a84d181a 100644 --- a/docs/source/markdown/podman-port.1.md +++ b/docs/source/markdown/podman-port.1.md @@ -13,12 +13,12 @@ List port mappings for the *container* or lookup the public-facing port that is ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** List all known port mappings for running containers. When using this option, you cannot pass any container names or private ports/protocols as filters. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-ps.1.md b/docs/source/markdown/podman-ps.1.md index b9d12adc6..40d26b86d 100644 --- a/docs/source/markdown/podman-ps.1.md +++ b/docs/source/markdown/podman-ps.1.md @@ -13,7 +13,7 @@ podman\-ps - Prints out information about containers **podman container ls** [*options*] ## DESCRIPTION -**podman ps** lists the running containers on the system. Use the **\-\-all** flag to view +**podman ps** lists the running containers on the system. Use the **--all** flag to view all the containers information. By default it lists: * container id @@ -26,17 +26,17 @@ all the containers information. By default it lists: ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Show all the containers created by Podman, default is only running containers. Note: Podman shares containers storage with other tools such as Buildah and CRI-O. In some cases these `external` containers might also exist in the same storage. Use the `--external` option to see these external containers. External containers show the 'storage' status. -#### **\-\-external** +#### **--external** Display external containers that are not controlled by Podman but are stored in containers storage. These external containers are generally created via other container technology such as Buildah or CRI-O and may depend on the same container images that Podman is also using. External containers are denoted with either a 'buildah' or 'storage' in the COMMAND and STATUS column of the ps output. Only used with the --all option. -#### **\-\-filter**, **-f** +#### **--filter**, **-f** Filter what containers are shown in the output. Multiple filters can be given with multiple uses of the --filter flag. @@ -61,7 +61,7 @@ Valid filters are listed below: | network | [Network] name or full ID of network | -#### **\-\-format**=*format* +#### **--format**=*format* Pretty-print containers to JSON or using a Go template @@ -84,56 +84,56 @@ Valid placeholders for the Go template are listed below: | .Labels | All the labels assigned to the container | | .Mounts | Volumes mounted in the container | -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-last**, **-n** +#### **--last**, **-n** Print the n last created containers (all states) -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Show the latest container created (all states) (This option is not available with the remote Podman client) -#### **\-\-namespace**, **\-\-ns** +#### **--namespace**, **--ns** Display namespace information -#### **\-\-noheading** +#### **--noheading** Omit the table headings from the listing of containers. -#### **\-\-no-trunc** +#### **--no-trunc** Display the extended information -#### **\-\-pod**, **-p** +#### **--pod**, **-p** Display the pods the containers are associated with -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Print the numeric IDs of the containers only -#### **\-\-sort** +#### **--sort** Sort by command, created, id, image, names, runningfor, size, or status", Note: Choosing size will sort by size of rootFs, not alphabetically like the rest of the options Default: created -#### **\-\-size**, **-s** +#### **--size**, **-s** Display the total file size -#### **\-\-sync** +#### **--sync** Force a sync of container state with the OCI runtime. In some cases, a container's state in the runtime can become out of sync with Podman's state. This will update Podman's state based on what the OCI runtime reports. Forcibly syncing is much slower, but can resolve inconsistent state issues. -#### **\-\-watch**, **-w** +#### **--watch**, **-w** Refresh the output with current containers on an interval in seconds. diff --git a/docs/source/markdown/podman-pull.1.md b/docs/source/markdown/podman-pull.1.md index 2e038fd70..9b42d07ac 100644 --- a/docs/source/markdown/podman-pull.1.md +++ b/docs/source/markdown/podman-pull.1.md @@ -60,16 +60,16 @@ Images are stored in local image storage. ## OPTIONS -#### **\-\-all-tags**, **a** +#### **--all-tags**, **a** All tagged images in the repository will be pulled. Note: When using the all-tags flag, Podman will not iterate over the search registries in the containers-registries.conf(5) but will always use docker.io for unqualified image names. -#### **\-\-arch**=*ARCH* +#### **--arch**=*ARCH* Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`. -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. @@ -77,46 +77,46 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-creds**=*[username[:password]]* +#### **--creds**=*[username[:password]]* The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-disable-content-trust** +#### **--disable-content-trust** This is a Docker specific option to disable image verification to a Docker registry and is not supported by Podman. This flag is a NOOP and provided solely for scripting compatibility. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-os**=*OS* +#### **--os**=*OS* Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`. -#### **\-\-platform**=*OS/ARCH* +#### **--platform**=*OS/ARCH* Specify the platform for selecting the image. (Conflicts with --arch and --os) The `--platform` option can be used to override the current architecture and operating system. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output information when pulling images -#### **\-\-tls-verify**=*true|false* +#### **--tls-verify**=*true|false* Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, TLS verification will be used unless the target registry is listed as an insecure registry in registries.conf. -#### **\-\-variant**=*VARIANT* +#### **--variant**=*VARIANT* Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7. diff --git a/docs/source/markdown/podman-push.1.md b/docs/source/markdown/podman-push.1.md index 1bef7ebdb..f42ee1020 100644 --- a/docs/source/markdown/podman-push.1.md +++ b/docs/source/markdown/podman-push.1.md @@ -54,7 +54,7 @@ Images are pushed from those stored in local image storage. ## OPTIONS -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. @@ -62,49 +62,49 @@ If the authorization state is not found there, $HOME/.docker/config.json is chec Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-creds**=*[username[:password]]* +#### **--creds**=*[username[:password]]* The [username[:password]] to use to authenticate with the registry if required. If one or both values are not supplied, a command line prompt will appear and the value can be entered. The password is entered without echo. -#### **\-\-cert-dir**=*path* +#### **--cert-dir**=*path* Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. Default certificates directory is _/etc/containers/certs.d_. (This option is not available with the remote Podman client) -#### **\-\-compress** +#### **--compress** Compress tarball image layers when pushing to a directory using the 'dir' transport. (default is same compression type, compressed or uncompressed, as source) Note: This flag can only be set when using the **dir** transport -#### **\-\-digestfile** *Digestfile* +#### **--digestfile** *Digestfile* After copying the image, write the digest of the resulting image to the file. (This option is not available with the remote Podman client) -#### **\-\-disable-content-trust** +#### **--disable-content-trust** This is a Docker specific option to disable image verification to a Docker registry and is not supported by Podman. This flag is a NOOP and provided solely for scripting compatibility. -#### **\-\-format**, **-f**=*format* +#### **--format**, **-f**=*format* Manifest Type (oci, v2s2, or v2s1) to use when pushing an image. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** When writing the output image, suppress progress output -#### **\-\-remove-signatures** +#### **--remove-signatures** Discard any pre-existing signatures in the image. (This option is not available with the remote Podman client) -#### **\-\-sign-by**=*key* +#### **--sign-by**=*key* Add a signature at the destination using the specified key. (This option is not available with the remote Podman client) -#### **\-\-tls-verify**=*true|false* +#### **--tls-verify**=*true|false* Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, diff --git a/docs/source/markdown/podman-remote.1.md b/docs/source/markdown/podman-remote.1.md index 3e20e1ded..1a6c7d3cc 100644 --- a/docs/source/markdown/podman-remote.1.md +++ b/docs/source/markdown/podman-remote.1.md @@ -25,15 +25,15 @@ The `containers.conf` file should be placed under `$HOME/.config/containers/cont ## GLOBAL OPTIONS -#### **\-\-connection**=*name*, **-c** +#### **--connection**=*name*, **-c** Remote connection name -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-identity**=*path* +#### **--identity**=*path* Path to ssh identity file. If the identity file has been encrypted, Podman prompts the user for the passphrase. If no identity file is provided and no user is given, Podman defaults to the user running the podman command. @@ -44,11 +44,11 @@ Identity value resolution precedence: - environment variable `CONTAINER_SSHKEY`, if `CONTAINER_HOST` is found - `containers.conf` -#### **\-\-log-level**=*level* +#### **--log-level**=*level* Log messages above specified level: debug, info, warn, error (default), fatal or panic -#### **\-\-url**=*value* +#### **--url**=*value* URL to access Podman service (default from `containers.conf`, rootless "unix://run/user/$UID/podman/podman.sock" or as root "unix://run/podman/podman.sock). @@ -67,7 +67,7 @@ URL value resolution precedence: - `containers.conf` - `unix://run/podman/podman.sock` -#### **\-\-version** +#### **--version** Print the version diff --git a/docs/source/markdown/podman-restart.1.md b/docs/source/markdown/podman-restart.1.md index 0d6d3b595..2b37e2ea4 100644 --- a/docs/source/markdown/podman-restart.1.md +++ b/docs/source/markdown/podman-restart.1.md @@ -14,17 +14,17 @@ Containers will be stopped if they are running and then restarted. Stopped containers will not be stopped and will only be started. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Restart all containers regardless of their current state. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-running** +#### **--running** Restart all containers that are already in the *running* state. -#### **\-\-time**=*time*, **-t** +#### **--time**=*time*, **-t** Timeout to wait before forcibly stopping the container. diff --git a/docs/source/markdown/podman-rm.1.md b/docs/source/markdown/podman-rm.1.md index 1fce9d2f3..0abf2768c 100644 --- a/docs/source/markdown/podman-rm.1.md +++ b/docs/source/markdown/podman-rm.1.md @@ -14,15 +14,15 @@ Running or unusable containers will not be removed without the **-f** option. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove all containers. Can be used in conjunction with **-f** as well. -#### **\-\-cidfile** +#### **--cidfile** Read container ID from the specified file and remove the container. Can be specified multiple times. -#### **\-\-force**, **-f** +#### **--force**, **-f** Force the removal of running and paused containers. Forcing a container removal also removes containers from container storage even if the container is not known to podman. @@ -30,21 +30,21 @@ Containers could have been created by a different container engine. In addition, forcing can be used to remove unusable containers, e.g. containers whose OCI runtime has become unavailable. -#### **\-\-ignore**, **-i** +#### **--ignore**, **-i** Ignore errors when specified containers are not in the container store. A user might have decided to manually remove a container which would lead to a failure during the ExecStop directive of a systemd service referencing that container. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-volumes**, **-v** +#### **--volumes**, **-v** Remove anonymous volumes associated with the container. This does not include named volumes -created with **podman volume create**, or the **\-\-volume** option of **podman run** and **podman create**. +created with **podman volume create**, or the **--volume** option of **podman run** and **podman create**. ## EXAMPLE Remove a container by its name *mywebserver* diff --git a/docs/source/markdown/podman-rmi.1.md b/docs/source/markdown/podman-rmi.1.md index 037a0a170..765c1bd6d 100644 --- a/docs/source/markdown/podman-rmi.1.md +++ b/docs/source/markdown/podman-rmi.1.md @@ -13,11 +13,11 @@ Removes one or more locally stored images. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove all images in the local storage. -#### **\-\-force**, **-f** +#### **--force**, **-f** This option will cause podman to remove all containers that are using the image before removing the image from the system. diff --git a/docs/source/markdown/podman-run.1.md b/docs/source/markdown/podman-run.1.md index f371cacbf..b9cfb01d1 100644 --- a/docs/source/markdown/podman-run.1.md +++ b/docs/source/markdown/podman-run.1.md @@ -25,7 +25,7 @@ pull** _image_ , before it starts the container from that image. Several files will be automatically created within the container. These include _/etc/hosts_, _/etc/hostname_, and _/etc/resolv.conf_ to manage networking. These will be based on the host's version of the files, though they can be -customized with options (for example, **\-\-dns** will override the host's DNS +customized with options (for example, **--dns** will override the host's DNS servers in the created _resolv.conf_). Additionally, a container environment file is created in each container to indicate to programs they are running in a container. This file is located at _/run/.containerenv_. When using the @@ -83,20 +83,20 @@ and specified with a _tag_. $ podman run oci-archive:/tmp/fedora echo hello ## OPTIONS -#### **\-\-add-host**=_host_:_ip_ +#### **--add-host**=_host_:_ip_ Add a line to container's _/etc/hosts_ for custom host-to-IP mapping. This option can be set multiple times. -#### **\-\-annotation**=_key_=_value_ +#### **--annotation**=_key_=_value_ Add an annotation to the container. This option can be set multiple times. -#### **\-\-arch**=*ARCH* +#### **--arch**=*ARCH* Override the architecture, defaults to hosts, of the image to be pulled. For example, `arm`. -#### **\-\-attach**, **-a**=**stdin**|**stdout**|**stderr** +#### **--attach**, **-a**=**stdin**|**stdout**|**stderr** Attach to STDIN, STDOUT or STDERR. @@ -107,30 +107,30 @@ error. It can even pretend to be a TTY (this is what most commandline executables expect) and pass along signals. The **-a** option can be set for each of **stdin**, **stdout**, and **stderr**. -#### **\-\-authfile**[=*path*] +#### **--authfile**[=*path*] Path to the authentication file. Default is *${XDG_RUNTIME_DIR}/containers/auth.json*. Note: You can also override the default path of the authentication file by setting the **REGISTRY_AUTH_FILE** environment variable. -#### **\-\-blkio-weight**=*weight* +#### **--blkio-weight**=*weight* Block IO relative weight. The _weight_ is a value between **10** and **1000**. -#### **\-\-blkio-weight-device**=*device*:*weight* +#### **--blkio-weight-device**=*device*:*weight* Block IO relative device weight. -#### **\-\-cap-add**=*capability* +#### **--cap-add**=*capability* Add Linux capabilities. -#### **\-\-cap-drop**=*capability* +#### **--cap-drop**=*capability* Drop Linux capabilities. -#### **\-\-cgroupns**=*mode* +#### **--cgroupns**=*mode* Set the cgroup namespace mode for the container. @@ -141,35 +141,35 @@ Set the cgroup namespace mode for the container. If the host uses cgroups v1, the default is set to **host**. On cgroups v2, the default is **private**. -#### **\-\-cgroups**=**enabled**|**disabled**|**no-conmon**|**split** +#### **--cgroups**=**enabled**|**disabled**|**no-conmon**|**split** Determines whether the container will create CGroups. Default is **enabled**. The **enabled** option will create a new cgroup under the cgroup-parent. -The **disabled** option will force the container to not create CGroups, and thus conflicts with CGroup options (**\-\-cgroupns** and **\-\-cgroup-parent**). +The **disabled** option will force the container to not create CGroups, and thus conflicts with CGroup options (**--cgroupns** and **--cgroup-parent**). The **no-conmon** option disables a new CGroup only for the **conmon** process. -The **split** option splits the current CGroup in two sub-cgroups: one for conmon and one for the container payload. It is not possible to set **\-\-cgroup-parent** with **split**. +The **split** option splits the current CGroup in two sub-cgroups: one for conmon and one for the container payload. It is not possible to set **--cgroup-parent** with **split**. -#### **\-\-cgroup-parent**=*path* +#### **--cgroup-parent**=*path* Path to cgroups under which the cgroup for the container will be created. If the path is not absolute, the path is considered to be relative to the cgroups path of the init process. Cgroups will be created if they do not already exist. -#### **\-\-cgroup-conf**=*KEY=VALUE* +#### **--cgroup-conf**=*KEY=VALUE* -When running on cgroup v2, specify the cgroup file to write to and its value. For example **\-\-cgroup-conf=memory.high=1073741824** sets the memory.high limit to 1GB. +When running on cgroup v2, specify the cgroup file to write to and its value. For example **--cgroup-conf=memory.high=1073741824** sets the memory.high limit to 1GB. -#### **\-\-cidfile**=*file* +#### **--cidfile**=*file* Write the container ID to *file*. -#### **\-\-conmon-pidfile**=*file* +#### **--conmon-pidfile**=*file* Write the pid of the **conmon** process to a file. As **conmon** runs in a separate process than Podman, this is necessary when using systemd to restart Podman containers. (This option is not available with the remote Podman client) -#### **\-\-cpu-period**=*limit* +#### **--cpu-period**=*limit* Set the CPU period for the Completely Fair Scheduler (CFS), which is a duration in microseconds. Once the container's CPU quota is used up, it will @@ -180,26 +180,26 @@ On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpu-quota**=*limit* +#### **--cpu-quota**=*limit* Limit the CPU Completely Fair Scheduler (CFS) quota. Limit the container's CPU usage. By default, containers run with the full CPU resource. The limit is a number in microseconds. If you provide a number, the container will be allowed to use that much CPU time until the CPU period -ends (controllable via **\-\-cpu-period**). +ends (controllable via **--cpu-period**). On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpu-rt-period**=*microseconds* +#### **--cpu-rt-period**=*microseconds* Limit the CPU real-time period in microseconds. Limit the container's Real Time CPU usage. This flag tell the kernel to restrict the container's Real Time CPU usage to the period you specify. -#### **\-\-cpu-rt-runtime**=*microseconds* +#### **--cpu-rt-runtime**=*microseconds* Limit the CPU real-time runtime in microseconds. @@ -208,7 +208,7 @@ Period of 1,000,000us and Runtime of 950,000us means that this container could c The sum of all runtimes across containers cannot exceed the amount allotted to the parent cgroup. -#### **\-\-cpu-shares**=*shares* +#### **--cpu-shares**=*shares* CPU shares (relative weight). @@ -233,8 +233,8 @@ cores. Even if a container is limited to less than 100% of CPU time, it can use 100% of each individual CPU core. For example, consider a system with more than three cores. If you start one -container **{C0}** with **\-\-cpu-shares=512** running one process, and another container -**{C1}** with **\-\-cpu-shares=1024** running two processes, this can result in the following +container **{C0}** with **--cpu-shares=512** running one process, and another container +**{C1}** with **--cpu-shares=1024** running two processes, this can result in the following division of CPU shares: | PID | container | CPU | CPU share | @@ -243,30 +243,30 @@ division of CPU shares: | 101 | {C1} | 1 | 100% of CPU1 | | 102 | {C1} | 2 | 100% of CPU2 | -#### **\-\-cpus**=*number* +#### **--cpus**=*number* Number of CPUs. The default is *0.0* which means no limit. This is shorthand -for **\-\-cpu-period** and **\-\-cpu-quota**, so you may only set either -#### **\-\-cpus** or **\-\-cpu-period** and **\-\-cpu-quota**. +for **--cpu-period** and **--cpu-quota**, so you may only set either +#### **--cpus** or **--cpu-period** and **--cpu-quota**. On some systems, changing the CPU limits may not be allowed for non-root users. For more details, see https://github.com/containers/podman/blob/master/troubleshooting.md#26-running-containers-with-cpu-limits-fails-with-a-permissions-error -#### **\-\-cpuset-cpus**=*number* +#### **--cpuset-cpus**=*number* CPUs in which to allow execution. Can be specified as a comma-separated list (e.g. **0,1**), as a range (e.g. **0-3**), or any combination thereof (e.g. **0-3,7,11-15**). -#### **\-\-cpuset-mems**=*nodes* +#### **--cpuset-mems**=*nodes* Memory nodes (MEMs) in which to allow execution. Only effective on NUMA systems. -For example, if you have four memory nodes (0-3) on your system, use **\-\-cpuset-mems=0,1** +For example, if you have four memory nodes (0-3) on your system, use **--cpuset-mems=0,1** to only use memory from the first two memory nodes. -#### **\-\-detach**, **-d**=**true**|**false** +#### **--detach**, **-d**=**true**|**false** Detached mode: run the container in the background and print the new container ID. The default is *false*. @@ -276,10 +276,10 @@ detached container with **podman attach**. When attached in the tty mode, you can detach from the container (and leave it running) using a configurable key sequence. The default sequence is `ctrl-p,ctrl-q`. -Configure the keys sequence using the **\-\-detach-keys** option, or specifying +Configure the keys sequence using the **--detach-keys** option, or specifying it in the **containers.conf** file: see **containers.conf(5)** for more information. -#### **\-\-detach-keys**=*sequence* +#### **--detach-keys**=*sequence* Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*. @@ -287,13 +287,13 @@ This option can also be set in **containers.conf**(5) file. Specifying "" will disable this feature. The default is **ctrl-p,ctrl-q**. -#### **\-\-device**=_host-device_[**:**_container-device_][**:**_permissions_] +#### **--device**=_host-device_[**:**_container-device_][**:**_permissions_] Add a host device to the container. Optional *permissions* parameter can be used to specify device permissions, it is combination of **r** for read, **w** for write, and **m** for **mknod**(2). -Example: **\-\-device=/dev/sdc:/dev/xvdc:rwm**. +Example: **--device=/dev/sdc:/dev/xvdc:rwm**. Note: if _host_device_ is a symbolic link then it will be resolved first. The container will only store the major and minor numbers of the host device. @@ -306,54 +306,54 @@ Podman may load kernel modules required for using the specified device. The devices that Podman will load modules when necessary are: /dev/fuse. -#### **\-\-device-cgroup-rule**=rule +#### **--device-cgroup-rule**=rule Add a rule to the cgroup allowed devices list -#### **\-\-device-read-bps**=_path_:_rate_ +#### **--device-read-bps**=_path_:_rate_ -Limit read rate (in bytes per second) from a device (e.g. **\-\-device-read-bps=/dev/sda:1mb**). +Limit read rate (in bytes per second) from a device (e.g. **--device-read-bps=/dev/sda:1mb**). -#### **\-\-device-read-iops**=_path_:_rate_ +#### **--device-read-iops**=_path_:_rate_ -Limit read rate (in IO operations per second) from a device (e.g. **\-\-device-read-iops=/dev/sda:1000**). +Limit read rate (in IO operations per second) from a device (e.g. **--device-read-iops=/dev/sda:1000**). -#### **\-\-device-write-bps**=_path_:_rate_ +#### **--device-write-bps**=_path_:_rate_ -Limit write rate (in bytes per second) to a device (e.g. **\-\-device-write-bps=/dev/sda:1mb**). +Limit write rate (in bytes per second) to a device (e.g. **--device-write-bps=/dev/sda:1mb**). -#### **\-\-device-write-iops**=_path_:_rate_ +#### **--device-write-iops**=_path_:_rate_ -Limit write rate (in IO operations per second) to a device (e.g. **\-\-device-write-iops=/dev/sda:1000**). +Limit write rate (in IO operations per second) to a device (e.g. **--device-write-iops=/dev/sda:1000**). -#### **\-\-disable-content-trust** +#### **--disable-content-trust** This is a Docker specific option to disable image verification to a Docker registry and is not supported by Podman. This flag is a NOOP and provided solely for scripting compatibility. -#### **\-\-dns**=*ipaddr* +#### **--dns**=*ipaddr* -Set custom DNS servers. Invalid if using **\-\-dns** with **\-\-network** that is set to **none** or **container:**_id_. +Set custom DNS servers. Invalid if using **--dns** with **--network** that is set to **none** or **container:**_id_. This option can be used to override the DNS configuration passed to the container. Typically this is necessary when the host DNS configuration is invalid for the container (e.g., **127.0.0.1**). When this -is the case the **\-\-dns** flags is necessary for every run. +is the case the **--dns** flags is necessary for every run. The special value **none** can be specified to disable creation of _/etc/resolv.conf_ in the container by Podman. The _/etc/resolv.conf_ file in the image will be used without changes. -#### **\-\-dns-opt**=*option* +#### **--dns-opt**=*option* -Set custom DNS options. Invalid if using **\-\-dns-opt** with **\-\-network** that is set to **none** or **container:**_id_. +Set custom DNS options. Invalid if using **--dns-opt** with **--network** that is set to **none** or **container:**_id_. -#### **\-\-dns-search**=*domain* +#### **--dns-search**=*domain* -Set custom DNS search domains. Invalid if using **\-\-dns-search** and **\-\-network** that is set to **none** or **container:**_id_. -Use **\-\-dns-search=.** if you don't wish to set the search domain. +Set custom DNS search domains. Invalid if using **--dns-search** and **--network** that is set to **none** or **container:**_id_. +Use **--dns-search=.** if you don't wish to set the search domain. -#### **\-\-entrypoint**=*"command"* | *'["command", "arg1", ...]'* +#### **--entrypoint**=*"command"* | *'["command", "arg1", ...]'* Overwrite the default ENTRYPOINT of the image. @@ -366,12 +366,12 @@ default nature or behavior, so that when you set an ENTRYPOINT you can run the container as if it were that binary, complete with default options, and you can pass in more options via the COMMAND. But, sometimes an operator may want to run something else inside the container, so you can override the default ENTRYPOINT -at runtime by using a **\-\-entrypoint** and a string to specify the new +at runtime by using a **--entrypoint** and a string to specify the new ENTRYPOINT. You need to specify multi option commands in the form of a json string. -#### **\-\-env**, **-e**=*env* +#### **--env**, **-e**=*env* Set environment variables. @@ -379,33 +379,33 @@ This option allows arbitrary environment variables that are available for the pr See [**Environment**](#environment) note below for precedence and examples. -#### **\-\-env-host**=**true**|**false** +#### **--env-host**=**true**|**false** Use host environment inside of the container. See **Environment** note below for precedence. (This option is not available with the remote Podman client) -#### **\-\-env-file**=*file* +#### **--env-file**=*file* Read in a line delimited file of environment variables. See **Environment** note below for precedence. -#### **\-\-expose**=*port* +#### **--expose**=*port* -Expose a port, or a range of ports (e.g. **\-\-expose=3300-3310**) to set up port redirection +Expose a port, or a range of ports (e.g. **--expose=3300-3310**) to set up port redirection on the host system. -#### **\-\-gidmap**=*container_gid*:*host_gid*:*amount* +#### **--gidmap**=*container_gid*:*host_gid*:*amount* -Run the container in a new user namespace using the supplied mapping. This option conflicts with the **\-\-userns** and **\-\-subgidname** flags. +Run the container in a new user namespace using the supplied mapping. This option conflicts with the **--userns** and **--subgidname** flags. This option can be passed several times to map different ranges. If calling **podman run** as an unprivileged user, the user needs to have the right to use the mapping. See **subuid**(5). -The example maps gids **0-1999** in the container to the gids **30000-31999** on the host: **\-\-gidmap=0:30000:2000**. +The example maps gids **0-1999** in the container to the gids **30000-31999** on the host: **--gidmap=0:30000:2000**. -**Important note:** The new user namespace mapping based on **\-\-gidmap** is based on the initial mapping made in the _/etc/subgid_ file. +**Important note:** The new user namespace mapping based on **--gidmap** is based on the initial mapping made in the _/etc/subgid_ file. Assuming there is a _/etc/subgid_ mapping **groupname:100000:65536**, then **groupname** is initially mapped to a namespace starting with -gid **100000** for **65536** ids. From here the **\-\-gidmap** mapping to the new namespace starts from **0** again, but is based on the initial mapping. -Meaning **groupname** is initially mapped to gid **100000** which is referenced as **0** in the following **\-\-gidmap** mapping. In terms of the example +gid **100000** for **65536** ids. From here the **--gidmap** mapping to the new namespace starts from **0** again, but is based on the initial mapping. +Meaning **groupname** is initially mapped to gid **100000** which is referenced as **0** in the following **--gidmap** mapping. In terms of the example above: The group **groupname** is mapped to group **100000** of the initial namespace then the **30000**st id of this namespace (which is gid 130000 in this namespace) is mapped to container namespace group id **0**. (groupname -> 100000 / 30000 -> 0) -#### **\-\-group-add**=*group|keep-groups* +#### **--group-add**=*group|keep-groups* Add additional groups to assign to primary user running within the container process. @@ -417,7 +417,7 @@ runtime to pass the group access into the container. Currently only available with the `crun` OCI runtime. Note: `keep-groups` is exclusive, you cannot add any other groups with this flag. (Not available for remote commands) -#### **\-\-health-cmd**=*"command"* | *'["command", "arg1", ...]'* +#### **--health-cmd**=*"command"* | *'["command", "arg1", ...]'* Set or alter a healthcheck command for a container. The command is a command to be executed inside your container that determines your container health. The command is required for other healthcheck options @@ -426,35 +426,35 @@ to be applied. A value of **none** disables existing healthchecks. Multiple options can be passed in the form of a JSON array; otherwise, the command will be interpreted as an argument to **/bin/sh -c**. -#### **\-\-health-interval**=*interval* +#### **--health-interval**=*interval* Set an interval for the healthchecks. An _interval_ of **disable** results in no automatic timer setup. The default is **30s**. -#### **\-\-health-retries**=*retries* +#### **--health-retries**=*retries* The number of retries allowed before a healthcheck is considered to be unhealthy. The default value is **3**. -#### **\-\-health-start-period**=*period* +#### **--health-start-period**=*period* The initialization time needed for a container to bootstrap. The value can be expressed in time format like **2m3s**. The default value is **0s**. -#### **\-\-health-timeout**=*timeout* +#### **--health-timeout**=*timeout* The maximum time allowed to complete the healthcheck before an interval is considered failed. Like start-period, the value can be expressed in a time format such as **1m22s**. The default value is **30s**. -#### **\-\-help** +#### **--help** Print usage statement -#### **\-\-hostname**=*name*, **-h** +#### **--hostname**=*name*, **-h** Container host name Sets the container host name that is available inside the container. Can only be used with a private UTS namespace `--uts=private` (default). If `--pod` is specified and the pod shares the UTS namespace (default) the pod's hostname will be used. -#### **\-\-http-proxy**=**true**|**false** +#### **--http-proxy**=**true**|**false** By default proxy environment variables are passed into the container if set for the Podman process. This can be disabled by setting the value to **false**. @@ -464,12 +464,12 @@ those. This option is only needed when the host system must use a proxy but the container should not use any proxy. Proxy environment variables specified for the container in any other way will override the values that would have been passed through from the host. (Other ways to specify the proxy for the -container include passing the values with the **\-\-env** flag, or hard coding the +container include passing the values with the **--env** flag, or hard coding the proxy environment at container build time.) (This option is not available with the remote Podman client) Defaults to **true**. -#### **\-\-image-volume**, **builtin-volume**=**bind**|**tmpfs**|**ignore** +#### **--image-volume**, **builtin-volume**=**bind**|**tmpfs**|**ignore** Tells Podman how to handle the builtin image volumes. Default is **bind**. @@ -478,30 +478,30 @@ Tells Podman how to handle the builtin image volumes. Default is **bind**. content that disappears when the container is stopped. - **ignore**: All volumes are just ignored and no action is taken. -#### **\-\-init** +#### **--init** Run an init inside the container that forwards signals and reaps processes. -#### **\-\-init-path**=*path* +#### **--init-path**=*path* Path to the container-init binary. -#### **\-\-interactive**, **-i**=**true**|**false** +#### **--interactive**, **-i**=**true**|**false** When set to **true**, keep stdin open even if not attached. The default is **false**. -#### **\-\-ip6**=*ip* +#### **--ip6**=*ip* Not implemented. -#### **\-\-ip**=*ip* +#### **--ip**=*ip* Specify a static IP address for the container, for example **10.88.64.128**. This option can only be used if the container is joined to only a single network - i.e., `--network=_network-name_` is used at most once and if the container is not joining another container's network namespace via `--network=container:_id_`. The address must be within the CNI network's IP address pool (default **10.88.0.0/16**). -#### **\-\-ipc**=*mode* +#### **--ipc**=*mode* Set the IPC namespace mode for a container. The default is to create a private IPC namespace. @@ -510,7 +510,7 @@ a private IPC namespace. - **host**: use the host shared memory,semaphores and message queues inside the container. Note: the host mode gives the container full access to local shared memory and is therefore considered insecure. - **ns:**_path_: path to an IPC namespace to join. -#### **\-\-kernel-memory**=_number_[_unit_] +#### **--kernel-memory**=_number_[_unit_] Kernel memory limit. A _unit_ can be **b** (bytes), **k** (kilobytes), **m** (megabytes), or **g** (gigabytes). @@ -520,40 +520,40 @@ is not limited. If you specify a limit, it may be rounded up to a multiple of the operating system's page size and the value can be very large, millions of trillions. -#### **\-\-label**, **-l**=*key*=*value* +#### **--label**, **-l**=*key*=*value* Add metadata to a container. -#### **\-\-label-file**=*file* +#### **--label-file**=*file* Read in a line-delimited file of labels. -#### **\-\-link-local-ip**=*ip* +#### **--link-local-ip**=*ip* Not implemented. -#### **\-\-log-driver**="*driver*" +#### **--log-driver**="*driver*" Logging driver for the container. Currently available options are **k8s-file**, **journald**, and **none**, with **json-file** aliased to **k8s-file** for scripting compatibility. -#### **\-\-log-opt**=*name*=*value* +#### **--log-opt**=*name*=*value* Logging driver specific options. Set custom logging configuration. The following *name*s are supported: **path**: specify a path to the log file - (e.g. **\-\-log-opt path=/var/log/container/mycontainer.json**); + (e.g. **--log-opt path=/var/log/container/mycontainer.json**); **max-size**: specify a max size of the log file - (e.g. **\-\-log-opt max-size=10mb**); + (e.g. **--log-opt max-size=10mb**); **tag**: specify a custom log tag for the container - (e.g. **\-\-log-opt tag="{{.ImageName}}"**. + (e.g. **--log-opt tag="{{.ImageName}}"**. This option is currently supported only by the **journald** log driver. -#### **\-\-mac-address**=*address* +#### **--mac-address**=*address* Container MAC address (e.g. **92:d0:c6:0a:29:33**). @@ -561,7 +561,7 @@ Remember that the MAC address in an Ethernet network must be unique. The IPv6 link-local address will be based on the device's MAC address according to RFC4862. -#### **\-\-memory**, **-m**=_number_[_unit_] +#### **--memory**, **-m**=_number_[_unit_] Memory limit. A _unit_ can be **b** (bytes), **k** (kilobytes), **m** (megabytes), or **g** (gigabytes). @@ -571,33 +571,33 @@ RAM. If a limit of 0 is specified (not using **-m**), the container's memory is not limited. The actual limit may be rounded up to a multiple of the operating system's page size (the value would be very large, that's millions of trillions). -#### **\-\-memory-reservation**=_number_[_unit_] +#### **--memory-reservation**=_number_[_unit_] Memory soft limit. A _unit_ can be **b** (bytes), **k** (kilobytes), **m** (megabytes), or **g** (gigabytes). After setting memory reservation, when the system detects memory contention or low memory, containers are forced to restrict their consumption to their -reservation. So you should always set the value below **\-\-memory**, otherwise the +reservation. So you should always set the value below **--memory**, otherwise the hard limit will take precedence. By default, memory reservation will be the same as memory limit. -#### **\-\-memory-swap**=_number_[_unit_] +#### **--memory-swap**=_number_[_unit_] A limit value equal to memory plus swap. A _unit_ can be **b** (bytes), **k** (kilobytes), **m** (megabytes), or **g** (gigabytes). -Must be used with the **-m** (**\-\-memory**) flag. +Must be used with the **-m** (**--memory**) flag. The argument value should always be larger than that of - **-m** (**\-\-memory**) By default, it is set to double -the value of **\-\-memory**. + **-m** (**--memory**) By default, it is set to double +the value of **--memory**. Set _number_ to **-1** to enable unlimited swap. -#### **\-\-memory-swappiness**=*number* +#### **--memory-swappiness**=*number* Tune a container's memory swappiness behavior. Accepts an integer between *0* and *100*. -#### **\-\-mount**=*type=TYPE,TYPE-SPECIFIC-OPTION[,...]* +#### **--mount**=*type=TYPE,TYPE-SPECIFIC-OPTION[,...]* Attach a filesystem mount to the container @@ -653,7 +653,7 @@ Current supported mount TYPEs are **bind**, **volume**, **image**, **tmpfs** and · notmpcopyup: Disable copying files from the image to the tmpfs. -#### **\-\-name**=*name* +#### **--name**=*name* Assign a name to the container. @@ -664,13 +664,13 @@ The operator can identify a container in three ways: - Name (“jonah”). Podman generates a UUID for each container, and if a name is not assigned -to the container with **\-\-name** then it will generate a random +to the container with **--name** then it will generate a random string name. The name is useful any place you need to identify a container. This works for both background and foreground containers. -#### **\-\-network**=*mode*, **\-\-net** +#### **--network**=*mode*, **--net** -Set the network mode for the container. Invalid if using **\-\-dns**, **\-\-dns-opt**, or **\-\-dns-search** with **\-\-network** that is set to **none** or **container:**_id_. If used together with **\-\-pod**, the container will not join the pods network namespace. +Set the network mode for the container. Invalid if using **--dns**, **--dns-opt**, or **--dns-search** with **--network** that is set to **none** or **container:**_id_. If used together with **--pod**, the container will not join the pods network namespace. Valid _mode_ values are: @@ -693,34 +693,34 @@ Valid _mode_ values are: - **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default. - **port_handler=slirp4netns**: Use the slirp4netns port forwarding. -#### **\-\-network-alias**=*alias* +#### **--network-alias**=*alias* Add network-scoped alias for the container -#### **\-\-no-healthcheck**=*true|false* +#### **--no-healthcheck**=*true|false* Disable any defined healthchecks for container. -#### **\-\-no-hosts**=**true**|**false** +#### **--no-hosts**=**true**|**false** Do not create _/etc/hosts_ for the container. -By default, Podman will manage _/etc/hosts_, adding the container's own IP address and any hosts from **\-\-add-host**. -#### **\-\-no-hosts** disables this, and the image's _/etc/hosts_ will be preserved unmodified. -This option conflicts with **\-\-add-host**. +By default, Podman will manage _/etc/hosts_, adding the container's own IP address and any hosts from **--add-host**. +#### **--no-hosts** disables this, and the image's _/etc/hosts_ will be preserved unmodified. +This option conflicts with **--add-host**. -#### **\-\-oom-kill-disable**=**true**|**false** +#### **--oom-kill-disable**=**true**|**false** Whether to disable OOM Killer for the container or not. -#### **\-\-oom-score-adj**=*num* +#### **--oom-score-adj**=*num* Tune the host's OOM preferences for containers (accepts values from **-1000** to **1000**). -#### **\-\-os**=*OS* +#### **--os**=*OS* Override the OS, defaults to hosts, of the image to be pulled. For example, `windows`. -#### **\-\-pid**=*mode* +#### **--pid**=*mode* Set the PID namespace mode for the container. The default is to create a private PID namespace for the container. @@ -730,32 +730,32 @@ The default is to create a private PID namespace for the container. - **private**: create a new namespace for the container (default) - **ns:**_path_: join the specified PID namespace. -#### **\-\-pids-limit**=*limit* +#### **--pids-limit**=*limit* Tune the container's pids limit. Set to **0** to have unlimited pids for the container. The default is **4096** on systems that support "pids" cgroup controller. -#### **\-\-platform**=*OS/ARCH* +#### **--platform**=*OS/ARCH* Specify the platform for selecting the image. (Conflicts with --arch and --os) The `--platform` option can be used to override the current architecture and operating system. -#### **\-\-pod**=*name* +#### **--pod**=*name* Run container in an existing pod. If you want Podman to make the pod for you, prefix the pod name with **new:**. To make a pod with more granular options, use the **podman pod create** command before creating a container. If a container is run with a pod, and the pod has an infra-container, the infra-container will be started before the container is. -#### **\-\-pod-id-file**=*path* +#### **--pod-id-file**=*path* Run container in an existing pod and read the pod's ID from the specified file. If a container is run within a pod, and the pod has an infra-container, the infra-container will be started before the container is. -#### **\-\-preserve-fds**=*N* +#### **--preserve-fds**=*N* Pass down to the process N additional file descriptors (in addition to 0, 1, 2). The total FDs will be 3+N. (This option is not available with the remote Podman client) -#### **\-\-privileged**=**true**|**false** +#### **--privileged**=**true**|**false** Give extended privileges to this container. The default is **false**. @@ -770,7 +770,7 @@ points, Apparmor/SELinux separation, and Seccomp filters are all disabled. Rootless containers cannot have more privileges than the account that launched them. -#### **\-\-publish**, **-p**=_ip_:_hostPort_:_containerPort_ | _ip_::_containerPort_ | _hostPort_:_containerPort_ | _containerPort_ +#### **--publish**, **-p**=_ip_:_hostPort_:_containerPort_ | _ip_::_containerPort_ | _hostPort_:_containerPort_ | _containerPort_ Publish a container's port, or range of ports, to the host. @@ -793,7 +793,7 @@ associated ports. If one container binds to a port, no other container can use t within the pod while it is in use. Containers in the pod can also communicate over localhost by having one container bind to localhost in the pod, and another connect to that port. -#### **\-\-publish-all**, **-P**=**true**|**false** +#### **--publish-all**, **-P**=**true**|**false** Publish all exposed ports to random ports on the host interfaces. The default is **false**. @@ -806,7 +806,7 @@ When using this option, Podman will bind any exposed port to a random port on th within an ephemeral port range defined by */proc/sys/net/ipv4/ip_local_port_range*. To find the mapping between the host ports and the exposed ports, use **podman port**. -#### **\-\-pull**=**always**|**missing**|**never** +#### **--pull**=**always**|**missing**|**never** Pull image before running. The default is **missing**. @@ -814,33 +814,33 @@ Pull image before running. The default is **missing**. - **always**: Pull the image from the first registry it is found in as listed in registries.conf. Raise an error if not found in the registries, even if the image is present locally. - **never**: do not pull the image from the registry, use only the local version. Raise an error if the image is not present locally. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress output information when pulling images -#### **\-\-read-only**=**true**|**false** +#### **--read-only**=**true**|**false** Mount the container's root filesystem as read only. By default a container will have its root filesystem writable allowing processes -to write files anywhere. By specifying the **\-\-read-only** flag, the container will have +to write files anywhere. By specifying the **--read-only** flag, the container will have its root filesystem mounted as read only prohibiting any writes. -#### **\-\-read-only-tmpfs**=**true**|**false** +#### **--read-only-tmpfs**=**true**|**false** -If container is running in **\-\-read-only** mode, then mount a read-write tmpfs on _/run_, _/tmp_, and _/var/tmp_. The default is **true**. +If container is running in **--read-only** mode, then mount a read-write tmpfs on _/run_, _/tmp_, and _/var/tmp_. The default is **true**. -#### **\-\-replace**=**true**|**false** +#### **--replace**=**true**|**false** If another container with the same name already exists, replace and remove it. The default is **false**. -#### **\-\-requires**=**container** +#### **--requires**=**container** Specify one or more requirements. A requirement is a dependency container that will be started before this container. Containers can be specified by name or ID, with multiple containers being separated by commas. -#### **\-\-restart**=*policy* +#### **--restart**=*policy* Restart policy to follow when containers exit. Restart policy will not take effect if a container is stopped via the **podman kill** or **podman stop** commands. @@ -856,16 +856,16 @@ Please note that restart will not restart containers after a system reboot. If this functionality is required in your environment, you can invoke Podman from a **systemd.unit**(5) file, or create an init script for whichever init system is in use. To generate systemd unit files, please see **podman generate systemd**. -#### **\-\-rm**=**true**|**false** +#### **--rm**=**true**|**false** Automatically remove the container when it exits. The default is **false**. -#### **\-\-rmi**=*true|false* +#### **--rmi**=*true|false* After exit of the container, remove the image unless another container is using it. The default is *false*. -#### **\-\-rootfs** +#### **--rootfs** If specified, the first argument refers to an exploded container on the file system. @@ -875,7 +875,7 @@ of the container is assumed to be managed externally. Note: On **SELinux** systems, the rootfs needs the correct label, which is by default **unconfined_u:object_r:container_file_t**. -#### **\-\-sdnotify**=**container**|**conmon**|**ignore** +#### **--sdnotify**=**container**|**conmon**|**ignore** Determines how to use the NOTIFY_SOCKET, as passed with systemd and Type=notify. @@ -886,13 +886,13 @@ has started. The socket is never passed to the runtime or the container. The **ignore** option removes NOTIFY_SOCKET from the environment for itself and child processes, for the case where some other process above Podman uses NOTIFY_SOCKET and Podman should not use it. -#### **\-\-seccomp-policy**=*policy* +#### **--seccomp-policy**=*policy* Specify the policy to select the seccomp profile. If set to *image*, Podman will look for a "io.containers.seccomp.profile" label in the container-image config and use its value as a seccomp profile. Otherwise, Podman will follow the *default* policy by applying the default profile unless specified otherwise via *--security-opt seccomp* as described below. Note that this feature is experimental and may change in the future. -#### **\-\-secret**=*secret*[,opt=opt ...] +#### **--secret**=*secret*[,opt=opt ...] Give the container access to a secret. Can be specified multiple times. @@ -912,7 +912,7 @@ Secret Options - `type=mount|env` : How the secret will be exposed to the container. Default mount. - `target=target` : Target of secret. Defauts to secret name. -#### **\-\-security-opt**=*option* +#### **--security-opt**=*option* Security Options @@ -944,38 +944,38 @@ Note: Labeling can be disabled for all containers by setting label=false in the Note: Labeling can be disabled for all containers by setting **label=false** in the **containers.conf**(5) file. -#### **\-\-shm-size**=_number_[_unit_] +#### **--shm-size**=_number_[_unit_] Size of _/dev/shm_. A _unit_ can be **b** (bytes), **k** (kilobytes), **m** (megabytes), or **g** (gigabytes). If you omit the unit, the system uses bytes. If you omit the size entirely, the default is **64m**. When _size_ is **0**, there is no limit on the amount of memory used for IPC by the container. -#### **\-\-sig-proxy**=**true**|**false** +#### **--sig-proxy**=**true**|**false** Sets whether the signals sent to the **podman run** command are proxied to the container process. SIGCHLD, SIGSTOP, and SIGKILL are not proxied. The default is **true**. -#### **\-\-stop-signal**=*signal* +#### **--stop-signal**=*signal* Signal to stop a container. Default is **SIGTERM**. -#### **\-\-stop-timeout**=*seconds* +#### **--stop-timeout**=*seconds* Timeout to stop a container. Default is **10**. Remote connections use local containers.conf for defaults -#### **\-\-subgidname**=*name* +#### **--subgidname**=*name* Run the container in a new user namespace using the map with _name_ in the _/etc/subgid_ file. If calling **podman run** as an unprivileged user, the user needs to have the right to use the mapping. See **subgid**(5). -This flag conflicts with **\-\-userns** and **\-\-gidmap**. +This flag conflicts with **--userns** and **--gidmap**. -#### **\-\-subuidname**=*name* +#### **--subuidname**=*name* Run the container in a new user namespace using the map with _name_ in the _/etc/subuid_ file. If calling **podman run** as an unprivileged user, the user needs to have the right to use the mapping. See **subuid**(5). -This flag conflicts with **\-\-userns** and **\-\-uidmap**. +This flag conflicts with **--userns** and **--uidmap**. -#### **\-\-sysctl**=_name_=_value_ +#### **--sysctl**=_name_=_value_ Configure namespaced kernel parameters at runtime. @@ -991,15 +991,15 @@ For the IPC namespace, the following sysctls are allowed: - kernel.shm_rmid_forced - Sysctls beginning with fs.mqueue.\* -Note: if you use the **\-\-ipc=host** option, the above sysctls will not be allowed. +Note: if you use the **--ipc=host** option, the above sysctls will not be allowed. For the network namespace, the following sysctls are allowed: - Sysctls beginning with net.\* -Note: if you use the **\-\-network=host** option, these sysctls will not be allowed. +Note: if you use the **--network=host** option, these sysctls will not be allowed. -#### **\-\-systemd**=**true**|**false**|**always** +#### **--systemd**=**true**|**false**|**always** Run container in systemd mode. The default is **true**. @@ -1028,13 +1028,13 @@ The **container_manage_cgroup** boolean must be enabled for this to be allowed o setsebool -P container_manage_cgroup true ``` -#### **\-\-timeout**=*seconds* +#### **--timeout**=*seconds* Maximum time a container is allowed to run before conmon sends it the kill signal. By default containers will run until they exit or are stopped by `podman stop`. -#### **\-\-tmpfs**=*fs* +#### **--tmpfs**=*fs* Create a tmpfs mount. @@ -1049,7 +1049,7 @@ options are the same as the Linux default mount flags. If you do not specify any options, the systems uses the following options: **rw,noexec,nosuid,nodev**. -#### **\-\-tty**, **-t**=**true**|**false** +#### **--tty**, **-t**=**true**|**false** Allocate a pseudo-TTY. The default is **false**. @@ -1063,20 +1063,20 @@ interactive shell. The default is **false**. echo "asdf" | podman run --rm -i someimage /bin/cat ``` -#### **\-\-tz**=*timezone* +#### **--tz**=*timezone* Set timezone in container. This flag takes area-based timezones, GMT time, as well as `local`, which sets the timezone in the container to match the host machine. See `/usr/share/zoneinfo/` for valid timezones. Remote connections use local containers.conf for defaults -#### **\-\-umask**=*umask* +#### **--umask**=*umask* Set the umask inside the container. Defaults to `0022`. Remote connections use local containers.conf for defaults -#### **\-\-uidmap**=*container_uid*:*from_uid*:*amount* +#### **--uidmap**=*container_uid*:*from_uid*:*amount* Run the container in a new user namespace using the supplied mapping. This -option conflicts with the **\-\-userns** and **\-\-subuidname** options. This +option conflicts with the **--userns** and **--subuidname** options. This option provides a way to map host UIDs to container UIDs. It can be passed several times to map different ranges. @@ -1084,7 +1084,7 @@ The _from_uid_ value is based upon the user running the command, either rootfull * rootfull user: *container_uid*:*host_uid*:*amount* * rootless user: *container_uid*:*intermediate_uid*:*amount* -When **podman run** is called by a privileged user, the option **\-\-uidmap** +When **podman run** is called by a privileged user, the option **--uidmap** works as a direct mapping between host UIDs and container UIDs. host UID -> container UID @@ -1106,7 +1106,7 @@ happens over two mapping steps: host UID -> intermediate UID -> container UID -The **\-\-uidmap** option only influences the second mapping step. +The **--uidmap** option only influences the second mapping step. The first mapping step is derived by Podman from the contents of the file _/etc/subuid_ and the UID of the user calling Podman. @@ -1124,7 +1124,7 @@ First mapping step: To be able to use intermediate UIDs greater than zero, the user needs to have subordinate UIDs configured in _/etc/subuid_. See **subuid**(5). -The second mapping step is configured with **\-\-uidmap**. +The second mapping step is configured with **--uidmap**. If for example _amount_ is **5** the second mapping step would look like: @@ -1137,14 +1137,14 @@ If for example _amount_ is **5** the second mapping step would look like: | _from_uid_ + 4 | _container_uid_ + 4 | Even if a user does not have any subordinate UIDs in _/etc/subuid_, -**\-\-uidmap** could still be used to map the normal UID of the user to a +**--uidmap** could still be used to map the normal UID of the user to a container UID by running `podman run --uidmap $container_uid:0:1 --user $container_uid ...`. -#### **\-\-ulimit**=*option* +#### **--ulimit**=*option* Ulimit options. You can use **host** to copy the current configuration from the host. -#### **\-\-user**, **-u**=[_user_ | _user_:_group_ | _uid_ | _uid_:_gid_ | _user_:_gid_ | _uid_:_group_ ] +#### **--user**, **-u**=[_user_ | _user_:_group_ | _uid_ | _uid_:_gid_ | _user_:_gid_ | _uid_:_group_ ] Sets the username or UID used and optionally the groupname or GID for the specified command. @@ -1152,9 +1152,9 @@ Without this argument, the command will run as the user specified in the contain When a user namespace is not in use, the UID and GID used within the container and on the host will match. When user namespaces are in use, however, the UID and GID in the container may correspond to another UID and GID on the host. In rootless containers, for example, a user namespace is always used, and root in the container will by default correspond to the UID and GID of the user invoking Podman. -#### **\-\-userns**=*mode* +#### **--userns**=*mode* -Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **\-\-uidmap** and **\-\-gidmap** options. +Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options. Valid _mode_ values are: @@ -1168,9 +1168,9 @@ Valid _mode_ values are: - **ns:**_namespace_: run the container in the given existing user namespace. - **private**: create a new namespace for the container. -This option is incompatible with **\-\-gidmap**, **\-\-uidmap**, **\-\-subuidname** and **\-\-subgidname**. +This option is incompatible with **--gidmap**, **--uidmap**, **--subuidname** and **--subgidname**. -#### **\-\-uts**=*mode* +#### **--uts**=*mode* Set the UTS namespace mode for the container. The following values are supported: @@ -1179,10 +1179,10 @@ Set the UTS namespace mode for the container. The following values are supported - **ns:[path]**: run the container in the given existing UTS namespace. - **container:[container]**: join the UTS namespace of the specified container. -#### **\-\-variant**=*VARIANT* +#### **--variant**=*VARIANT* Use _VARIANT_ instead of the default architecture variant of the container image. Some images can use multiple variants of the arm architectures, such as arm/v5 and arm/v7. -#### **\-\-volume**, **-v**[=*[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]*] +#### **--volume**, **-v**[=*[[SOURCE-VOLUME|HOST-DIR:]CONTAINER-DIR[:OPTIONS]]*] Create a bind mount. If you specify _/HOST-DIR_:_/CONTAINER-DIR_, Podman bind mounts _host-dir_ in the host to _CONTAINER-DIR_ in the Podman @@ -1344,7 +1344,7 @@ Note: if the user only has access rights via a group, accessing the volume from inside a rootless container will fail. Use the `--group-add keep-groups` flag to pass the user's supplementary group access into the container. -#### **\-\-volumes-from**[=*CONTAINER*[:*OPTIONS*]] +#### **--volumes-from**[=*CONTAINER*[:*OPTIONS*]] Mount volumes from the specified container(s). Used to share volumes between containers. The *options* is a comma-separated list with the following available elements: @@ -1377,7 +1377,7 @@ If the location of the volume from the source container overlaps with data residing on a target container, then the volume hides that data on the target. -#### **\-\-workdir**, **-w**=*dir* +#### **--workdir**, **-w**=*dir* Working directory inside the container. @@ -1385,7 +1385,7 @@ The default working directory for running binaries within a container is the roo The image developer can set a different default with the WORKDIR instruction. The operator can override the working directory by using the **-w** option. -#### **\-\-pidfile**=*path* +#### **--pidfile**=*path* When the pidfile location is specified, the container process' PID will be written to the pidfile. (This option is not available with the remote Podman client) If the pidfile option is not specified, the container process' PID will be written to /run/containers/storage/${storage-driver}-containers/$CID/userdata/pidfile. @@ -1432,7 +1432,7 @@ During container image development, containers often need to write to the image content. Installing packages into _/usr_, for example. In production, applications seldom need to write to the image. Container applications write to volumes if they need to write to file systems at all. Applications can be -made more secure by running them in read-only mode using the **\-\-read-only** switch. +made more secure by running them in read-only mode using the **--read-only** switch. This protects the containers image from modification. Read only containers may still need to write temporary data. The best way to handle this is to mount tmpfs directories on _/run_ and _/tmp_. @@ -1482,7 +1482,7 @@ $ podman run -a stdin -a stdout -i -t fedora /bin/bash Using **shm_server.c** available here: https://www.cs.cf.ac.uk/Dave/C/node27.html -Testing **\-\-ipc=host** mode: +Testing **--ipc=host** mode: Host shows a shared memory segment with 7 pids attached, happens to be from httpd: @@ -1503,7 +1503,7 @@ $ podman run -it shm ipcs -m key shmid owner perms bytes nattch status ``` -Run a container with the new **\-\-ipc=host** option, and it now sees the shared memory segment from the host httpd: +Run a container with the new **--ipc=host** option, and it now sees the shared memory segment from the host httpd: ``` $ podman run -it --ipc=host shm ipcs -m @@ -1512,7 +1512,7 @@ $ podman run -it --ipc=host shm ipcs -m key shmid owner perms bytes nattch status 0x01128e25 0 root 600 1000 7 ``` -Testing **\-\-ipc=container:**_id_ mode: +Testing **--ipc=container:**_id_ mode: Start a container with a program to create a shared memory segment: ``` @@ -1532,7 +1532,7 @@ $ podman run shm ipcs -m key shmid owner perms bytes nattch status ``` -Create a 3rd container using the **\-\-ipc=container:**_id_ option, now it shows the shared memory segment from the first: +Create a 3rd container using the **--ipc=container:**_id_ option, now it shows the shared memory segment from the first: ``` $ podman run -it --ipc=container:ed735b2264ac shm ipcs -m @@ -1571,7 +1571,7 @@ $ podman run -v /var/cache/dnf:/var/cache/dnf:O -ti fedora dnf -y update $ podman run -d -e MYSQL_ROOT_PASSWORD=root --user mysql --userns=keep-id -v ~/data:/var/lib/mysql:z,U mariadb ``` -Using **\-\-mount** flags to mount a host directory as a container folder, specify +Using **--mount** flags to mount a host directory as a container folder, specify the absolute path to the directory or the volume name, and the absolute path within the container directory: @@ -1600,7 +1600,7 @@ changes will also be reflected on the host in _/var/db_. ### Using alternative security labeling You can override the default labeling scheme for each container by specifying -the **\-\-security-opt** flag. For example, you can specify the MCS/MLS level, a +the **--security-opt** flag. For example, you can specify the MCS/MLS level, a requirement for MLS systems. Specifying the level in the following command allows you to share the same content between containers. @@ -1615,7 +1615,7 @@ $ podman run --security-opt label=level:TopSecret -i -t rhel7 bash ``` To disable the security labeling for this container versus running with the -#### **\-\-permissive** flag, use the following command: +#### **--permissive** flag, use the following command: ``` $ podman run --security-opt label=disable -i -t fedora bash @@ -1633,7 +1633,7 @@ $ podman run --security-opt label=type:svirt_apache_t -i -t centos bash Note you would have to write policy defining a **svirt_apache_t** type. To mask additional specific paths in the container, specify the paths -separated by a colon using the **mask** option with the **\-\-security-opt** +separated by a colon using the **mask** option with the **--security-opt** flag. ``` @@ -1662,7 +1662,7 @@ $ podman run --security-opt unmask=/foo/bar:/sys/firmware fedora bash ### Setting device weight If you want to set _/dev/sda_ device weight to **200**, you can specify the device -weight by **\-\-blkio-weight-device** flag. Use the following command: +weight by **--blkio-weight-device** flag. Use the following command: ``` $ podman run -it --blkio-weight-device "/dev/sda:200" ubuntu @@ -1677,7 +1677,7 @@ asdf ### Setting Namespaced Kernel Parameters (Sysctls) -The **\-\-sysctl** sets namespaced kernel parameters (sysctls) in the +The **--sysctl** sets namespaced kernel parameters (sysctls) in the container. For example, to turn on IP forwarding in the containers network namespace, run this command: @@ -1689,7 +1689,7 @@ Note that not all sysctls are namespaced. Podman does not support changing sysct inside of a container that also modify the host system. As the kernel evolves we expect to see more sysctls become namespaced. -See the definition of the **\-\-sysctl** option above for the current list of +See the definition of the **--sysctl** option above for the current list of supported sysctls. ### Set UID/GID mapping in a new user namespace @@ -1756,7 +1756,7 @@ In order for users to run rootless, there must be an entry for their username in Rootless Podman works better if the fuse-overlayfs and slirp4netns packages are installed. The **fuse-overlay** package provides a userspace overlay storage driver, otherwise users need to use the **vfs** storage driver, which is diskspace expensive and does not perform well. slirp4netns is -required for VPN, without it containers need to be run with the **\-\-network=host** flag. +required for VPN, without it containers need to be run with the **--network=host** flag. ## ENVIRONMENT @@ -1764,10 +1764,10 @@ Environment variables within containers can be set using multiple different opti in the following order of precedence (later entries override earlier entries): - Container image: Any environment variables specified in the container image. -- **\-\-http-proxy**: By default, several environment variables will be passed in from the host, such as **http_proxy** and **no_proxy**. See **\-\-http-proxy** for details. -- **\-\-env-host**: Host environment of the process executing Podman is added. -- **\-\-env-file**: Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry. -- **\-\-env**: Any environment variables specified will override previous settings. +- **--http-proxy**: By default, several environment variables will be passed in from the host, such as **http_proxy** and **no_proxy**. See **--http-proxy** for details. +- **--env-host**: Host environment of the process executing Podman is added. +- **--env-file**: Any environment variables specified via env-files. If multiple files specified, then they override each other in order of entry. +- **--env**: Any environment variables specified will override previous settings. Run containers and set the environment ending with a __*__ and a __*****__: diff --git a/docs/source/markdown/podman-save.1.md b/docs/source/markdown/podman-save.1.md index cae0c4b05..ab21d2bc6 100644 --- a/docs/source/markdown/podman-save.1.md +++ b/docs/source/markdown/podman-save.1.md @@ -24,16 +24,16 @@ Note: `:` is a restricted character and cannot be part of the file name. ## OPTIONS -#### **\-\-compress** +#### **--compress** Compress tarball image layers when pushing to a directory using the 'dir' transport. (default is same compression type, compressed or uncompressed, as source) Note: This flag can only be set when using the **dir** transport i.e --format=oci-dir or --format=docker-dir -#### **\-\-output**, **-o**=*file* +#### **--output**, **-o**=*file* Write to a file, default is STDOUT -#### **\-\-format**=*format* +#### **--format**=*format* Save image to **oci-archive, oci-dir** (directory with oci manifest type), or **docker-dir** (directory with v2s2 manifest type) ``` @@ -42,16 +42,16 @@ Save image to **oci-archive, oci-dir** (directory with oci manifest type), or ** --format docker-dir ``` -#### **\-\-multi-image-archive**, **-m** +#### **--multi-image-archive**, **-m** Allow for creating archives with more than one image. Additional names will be interpreted as images instead of tags. Only supported for **docker-archive**. The default for this option can be modified via the `multi_image_archive="true"|"false"` flag in containers.conf. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Suppress the output -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-search.1.md b/docs/source/markdown/podman-search.1.md index 23aa6acd1..ec610d3ba 100644 --- a/docs/source/markdown/podman-search.1.md +++ b/docs/source/markdown/podman-search.1.md @@ -11,9 +11,9 @@ podman\-search - Search a registry for an image The user can specify which registry to search by prefixing the registry in the search term (example **registry.fedoraproject.org/fedora**), default is the registries in the **registries.search** table in the config file - **/etc/containers/registries.conf**. -The default number of results is 25. The number of results can be limited using the **\-\-limit** flag. +The default number of results is 25. The number of results can be limited using the **--limit** flag. If more than one registry is being searched, the limit will be applied to each registry. The output can be filtered -using the **\-\-filter** flag. To get all available images in a registry without a specific +using the **--filter** flag. To get all available images in a registry without a specific search term, the user can just enter the registry name with a trailing "/" (example **registry.fedoraproject.org/**). Note, searching without a search term will only work for registries that implement the v2 API. @@ -25,14 +25,14 @@ Note, searching without a search term will only work for registries that impleme ## OPTIONS -#### **\-\-authfile**=*path* +#### **--authfile**=*path* Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE environment variable. `export REGISTRY_AUTH_FILE=path` -#### **\-\-filter**, **-f**=*filter* +#### **--filter**, **-f**=*filter* Filter output based on conditions provided (default []) @@ -42,7 +42,7 @@ Supported filters are: * is-automated (boolean - true | false) - is the image automated or not * is-official (boolean - true | false) - is the image official or not -#### **\-\-format**=*format* +#### **--format**=*format* Change the output format to a Go template @@ -60,7 +60,7 @@ Valid placeholders for the Go template are listed below: Note: use .Tag only if the --list-tags is set. -#### **\-\-limit**=*limit* +#### **--limit**=*limit* Limit the number of results (default 25). Note: The results from each registry will be limited to this value. @@ -68,24 +68,24 @@ Example if limit is 10 and two registries are being searched, the total number of results will be 20, 10 from each (if there are at least 10 matches in each). The order of the search results is the order in which the API endpoint returns the results. -#### **\-\-list-tags** +#### **--list-tags** List the available tags in the repository for the specified image. **Note:** --list-tags requires the search term to be a fully specified image name. The result contains the Image name and its tag, one line for every tag associated with the image. -#### **\-\-no-trunc** +#### **--no-trunc** Do not truncate the output -#### **\-\-tls-verify**=*true|false* +#### **--tls-verify**=*true|false* Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, then TLS verification will be used. If set to false, then TLS verification will not be used if needed. If not specified, default registries will be searched through (in /etc/containers/registries.conf), and TLS will be skipped if a default registry is listed in the insecure registries. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-secret-create.1.md b/docs/source/markdown/podman-secret-create.1.md index 7aacca3fe..c70d80719 100644 --- a/docs/source/markdown/podman-secret-create.1.md +++ b/docs/source/markdown/podman-secret-create.1.md @@ -20,15 +20,15 @@ Secrets will not be committed to an image with `podman commit`, and will not be ## OPTIONS -#### **\-\-env**=*false* +#### **--env**=*false* Read secret data from environment variable -#### **\-\-driver**=*driver* +#### **--driver**=*driver* Specify the secret driver (default **file**, which is unencrypted). -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-secret-inspect.1.md b/docs/source/markdown/podman-secret-inspect.1.md index 042cc25d9..383db8375 100644 --- a/docs/source/markdown/podman-secret-inspect.1.md +++ b/docs/source/markdown/podman-secret-inspect.1.md @@ -15,11 +15,11 @@ Secrets can be queried individually by providing their full name or a unique par ## OPTIONS -#### **\-\-format**=*format* +#### **--format**=*format* Format secret output using Go template. -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-secret-ls.1.md b/docs/source/markdown/podman-secret-ls.1.md index 18119542e..6adbeca08 100644 --- a/docs/source/markdown/podman-secret-ls.1.md +++ b/docs/source/markdown/podman-secret-ls.1.md @@ -8,15 +8,15 @@ podman\-secret\-ls - List all available secrets ## DESCRIPTION -Lists all the secrets that exist. The output can be formatted to a Go template using the **\-\-format** option. +Lists all the secrets that exist. The output can be formatted to a Go template using the **--format** option. ## OPTIONS -#### **\-\-format**=*format* +#### **--format**=*format* Format secret output using Go template. -#### **\-\-noheading** +#### **--noheading** Omit the table headings from the listing of secrets. . diff --git a/docs/source/markdown/podman-secret-rm.1.md b/docs/source/markdown/podman-secret-rm.1.md index 72d6a1af4..c6f5079ba 100644 --- a/docs/source/markdown/podman-secret-rm.1.md +++ b/docs/source/markdown/podman-secret-rm.1.md @@ -18,11 +18,11 @@ the old secret value will still remain. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove all existing secrets. -#### **\-\-help** +#### **--help** Print usage statement. diff --git a/docs/source/markdown/podman-start.1.md b/docs/source/markdown/podman-start.1.md index 7085f3f47..ae05da817 100644 --- a/docs/source/markdown/podman-start.1.md +++ b/docs/source/markdown/podman-start.1.md @@ -16,33 +16,33 @@ attach to the container. ## OPTIONS -#### **\-\-attach**, **-a** +#### **--attach**, **-a** Attach container's STDOUT and STDERR. The default is false. This option cannot be used when starting multiple containers. -#### **\-\-detach-keys**=*sequence* +#### **--detach-keys**=*sequence* Specify the key sequence for detaching a container. Format is a single character `[a-Z]` or one or more `ctrl-<value>` characters where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`. Specifying "" will disable this feature. The default is *ctrl-p,ctrl-q*. -#### **\-\-interactive**, **-i** +#### **--interactive**, **-i** Attach container's STDIN. The default is false. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-sig-proxy**=*true|false* +#### **--sig-proxy**=*true|false* Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied. The default is *true* when attaching, *false* otherwise. -#### **\-\-all** +#### **--all** Start all the containers created by Podman, default is only running containers. -#### **\-\-filter**, **-f** +#### **--filter**, **-f** Filter what containers are going to be started from the given arguments. Multiple filters can be given with multiple uses of the --filter flag. diff --git a/docs/source/markdown/podman-stats.1.md b/docs/source/markdown/podman-stats.1.md index a4f4f68a3..300106796 100644 --- a/docs/source/markdown/podman-stats.1.md +++ b/docs/source/markdown/podman-stats.1.md @@ -20,24 +20,24 @@ about their networking usage. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Show all containers. Only running containers are shown by default -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-no-reset** +#### **--no-reset** Do not clear the terminal/screen in between reporting intervals -#### **\-\-no-stream** +#### **--no-stream** Disable streaming stats and only pull the first result, default setting is false -#### **\-\-format**=*template* +#### **--format**=*template* Pretty-print container statistics to JSON or using a Go template diff --git a/docs/source/markdown/podman-stop.1.md b/docs/source/markdown/podman-stop.1.md index bcb928e57..a1e9675c1 100644 --- a/docs/source/markdown/podman-stop.1.md +++ b/docs/source/markdown/podman-stop.1.md @@ -9,7 +9,7 @@ podman\-stop - Stop one or more running containers **podman container stop** [*options*] *container* ... ## DESCRIPTION -Stops one or more containers. You may use container IDs or names as input. The **\-\-time** switch +Stops one or more containers. You may use container IDs or names as input. The **--time** switch allows you to specify the number of seconds to wait before forcibly stopping the container after the stop command is issued to the container. The default is 10 seconds. By default, containers are stopped with SIGTERM and then SIGKILL after the timeout. The SIGTERM default can be overridden by the image used to create the @@ -17,26 +17,26 @@ container and also via command line when creating the container. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Stop all running containers. This does not include paused containers. -#### **\-\-cidfile** +#### **--cidfile** Read container ID from the specified file and remove the container. Can be specified multiple times. -#### **\-\-ignore**, **-i** +#### **--ignore**, **-i** Ignore errors when specified containers are not in the container store. A user might have decided to manually remove a container which would lead to a failure during the ExecStop directive of a systemd service referencing that container. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) -#### **\-\-time**, **-t**=*time* +#### **--time**, **-t**=*time* Time to wait before forcibly stopping the container diff --git a/docs/source/markdown/podman-system-connection-add.1.md b/docs/source/markdown/podman-system-connection-add.1.md index 5f5d2bc7d..32c16d6a1 100644 --- a/docs/source/markdown/podman-system-connection-add.1.md +++ b/docs/source/markdown/podman-system-connection-add.1.md @@ -15,21 +15,21 @@ The user will be prompted for the remote ssh login password or key file pass phr ## OPTIONS -#### **\-\-default**=*false*, **-d** +#### **--default**=*false*, **-d** Make the new destination the default for this user. -#### **\-\-identity**=*path* +#### **--identity**=*path* Path to ssh identity file. If the identity file has been encrypted, Podman prompts the user for the passphrase. If no identity file is provided and no user is given, Podman defaults to the user running the podman command. Podman prompts for the login password on the remote server. -#### **\-\-port**=*port*, **-p** +#### **--port**=*port*, **-p** Port for ssh destination. The default value is `22`. -#### **\-\-socket-path**=*path* +#### **--socket-path**=*path* Path to the Podman service unix domain socket on the ssh destination host diff --git a/docs/source/markdown/podman-system-df.1.md b/docs/source/markdown/podman-system-df.1.md index 98c8ad3ad..f3db2d020 100644 --- a/docs/source/markdown/podman-system-df.1.md +++ b/docs/source/markdown/podman-system-df.1.md @@ -10,11 +10,11 @@ podman\-system\-df - Show podman disk usage Show podman disk usage ## OPTIONS -#### **\-\-format**=*format* +#### **--format**=*format* Pretty-print images using a Go template -#### **\-\-verbose**, **-v** +#### **--verbose**, **-v** Show detailed information on space usage ## EXAMPLE diff --git a/docs/source/markdown/podman-system-migrate.1.md b/docs/source/markdown/podman-system-migrate.1.md index 45f2ce547..913f119b0 100644 --- a/docs/source/markdown/podman-system-migrate.1.md +++ b/docs/source/markdown/podman-system-migrate.1.md @@ -26,7 +26,7 @@ newly configured mappings. ## OPTIONS -#### **\-\-new-runtime**=*runtime* +#### **--new-runtime**=*runtime* Set a new OCI runtime for all containers. This can be used after a system upgrade which changes the default OCI runtime to move all containers to the new runtime. diff --git a/docs/source/markdown/podman-system-prune.1.md b/docs/source/markdown/podman-system-prune.1.md index 50a25bf6d..791503a2c 100644 --- a/docs/source/markdown/podman-system-prune.1.md +++ b/docs/source/markdown/podman-system-prune.1.md @@ -9,16 +9,16 @@ podman\-system\-prune - Remove all unused pod, container, image and volume data ## DESCRIPTION **podman system prune** removes all unused containers (both dangling and unreferenced), pods and optionally, volumes from local storage. -With the **\-\-all** option, you can delete all unused images. Unused images are dangling images as well as any image that does not have any containers based on it. +With the **--all** option, you can delete all unused images. Unused images are dangling images as well as any image that does not have any containers based on it. -By default, volumes are not removed to prevent important data from being deleted if there is currently no container using the volume. Use the **\-\-volumes** flag when running the command to prune volumes as well. +By default, volumes are not removed to prevent important data from being deleted if there is currently no container using the volume. Use the **--volumes** flag when running the command to prune volumes as well. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Recursively remove all unused pod, container, image and volume data (Maximum 50 iterations.) -#### **\-\-filter**=*filters* +#### **--filter**=*filters* Provide filter values. @@ -33,15 +33,15 @@ The until filter can be Unix timestamps, date formatted timestamps, or Go durati The label filter accepts two formats. One is the label=... (label=_key_ or label=_key=value_), which removes containers and images with the specified labels. The other format is the label!=... (label!=_key_ or label!=_key=value_), which removes containers and images without the specified labels. -#### **\-\-force**, **-f** +#### **--force**, **-f** Do not prompt for confirmation -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-volumes** +#### **--volumes** Prune volumes currently unused by any container diff --git a/docs/source/markdown/podman-system-reset.1.md b/docs/source/markdown/podman-system-reset.1.md index 9644d8d90..744f917df 100644 --- a/docs/source/markdown/podman-system-reset.1.md +++ b/docs/source/markdown/podman-system-reset.1.md @@ -18,11 +18,11 @@ of the relevant configurations. If the administrator modified the configuration `podman system reset` might not be able to clean up the previous storage. ## OPTIONS -#### **\-\-force**, **-f** +#### **--force**, **-f** Do not prompt for confirmation -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-system-service.1.md b/docs/source/markdown/podman-system-service.1.md index fddcece60..2c8be73c2 100644 --- a/docs/source/markdown/podman-system-service.1.md +++ b/docs/source/markdown/podman-system-service.1.md @@ -25,12 +25,12 @@ Note: The default systemd unit files (system and user) change the log-level opti ## OPTIONS -#### **\-\-time**, **-t** +#### **--time**, **-t** The time until the session expires in _seconds_. The default is 5 seconds. A value of `0` means no timeout, therefore the session will not expire. -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement. diff --git a/docs/source/markdown/podman-tag.1.md b/docs/source/markdown/podman-tag.1.md index 70a09fc3c..7eab62028 100644 --- a/docs/source/markdown/podman-tag.1.md +++ b/docs/source/markdown/podman-tag.1.md @@ -16,7 +16,7 @@ provided, then podman will default to `latest` for both the *image* and the ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-top.1.md b/docs/source/markdown/podman-top.1.md index 1bfe0dccb..09e8f7423 100644 --- a/docs/source/markdown/podman-top.1.md +++ b/docs/source/markdown/podman-top.1.md @@ -13,11 +13,11 @@ Display the running processes of the container. The *format-descriptors* are ps ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods.(This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman-unmount.1.md b/docs/source/markdown/podman-unmount.1.md index d09762d46..2832e5fdb 100644 --- a/docs/source/markdown/podman-unmount.1.md +++ b/docs/source/markdown/podman-unmount.1.md @@ -27,11 +27,11 @@ External containers are containers created in container/storage by other tools l Buildah and CRI-O. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** All of the currently mounted containers will be unmounted. -#### **\-\-force**, **-f** +#### **--force**, **-f** Force the unmounting of specified containers' root file system, even if other processes have mounted it. @@ -39,7 +39,7 @@ processes have mounted it. Note: This could cause other processes that are using the file system to fail, as the mount point could be removed without their knowledge. -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last diff --git a/docs/source/markdown/podman-unpause.1.md b/docs/source/markdown/podman-unpause.1.md index 2c344236f..ae178647a 100644 --- a/docs/source/markdown/podman-unpause.1.md +++ b/docs/source/markdown/podman-unpause.1.md @@ -13,7 +13,7 @@ Unpauses the processes in one or more containers. You may use container IDs or ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Unpause all paused containers. diff --git a/docs/source/markdown/podman-unshare.1.md b/docs/source/markdown/podman-unshare.1.md index 4451ad79c..2e7adfd34 100644 --- a/docs/source/markdown/podman-unshare.1.md +++ b/docs/source/markdown/podman-unshare.1.md @@ -26,11 +26,11 @@ The unshare session defines two environment variables: ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-rootless-cni** +#### **--rootless-cni** Join the rootless network namespace used for CNI networking. It can be used to connect to a rootless container via IP address (CNI networking). This is otherwise diff --git a/docs/source/markdown/podman-untag.1.md b/docs/source/markdown/podman-untag.1.md index 351faadbb..70053c940 100644 --- a/docs/source/markdown/podman-untag.1.md +++ b/docs/source/markdown/podman-untag.1.md @@ -13,7 +13,7 @@ Remove one or more names from an image in the local storage. The image can be r ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-version.1.md b/docs/source/markdown/podman-version.1.md index ba03c4809..a54e66372 100644 --- a/docs/source/markdown/podman-version.1.md +++ b/docs/source/markdown/podman-version.1.md @@ -12,11 +12,11 @@ OS, and Architecture. ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-format**, **-f**=*format* +#### **--format**, **-f**=*format* Change output format to "json" or a Go template. diff --git a/docs/source/markdown/podman-volume-create.1.md b/docs/source/markdown/podman-volume-create.1.md index 093b978a7..a06411000 100644 --- a/docs/source/markdown/podman-volume-create.1.md +++ b/docs/source/markdown/podman-volume-create.1.md @@ -10,24 +10,24 @@ podman\-volume\-create - Create a new volume Creates an empty volume and prepares it to be used by containers. The volume can be created with a specific name, if a name is not given a random name is -generated. You can add metadata to the volume by using the **\-\-label** flag and -driver options can be set using the **\-\-opt** flag. +generated. You can add metadata to the volume by using the **--label** flag and +driver options can be set using the **--opt** flag. ## OPTIONS -#### **\-\-driver**=*driver* +#### **--driver**=*driver* Specify the volume driver name (default **local**). Setting this to a value other than **local** Podman will attempt to create the volume using a volume plugin with the given name. Such plugins must be defined in the **volume_plugins** section of the **containers.conf**(5) configuration file. -#### **\-\-help** +#### **--help** Print usage statement -#### **\-\-label**=*label*, **-l** +#### **--label**=*label*, **-l** Set metadata for a volume (e.g., --label mykey=value). -#### **\-\-opt**=*option*, **-o** +#### **--opt**=*option*, **-o** Set driver specific options. For the default driver, **local**, this allows a volume to be configured to mount a filesystem on the host. diff --git a/docs/source/markdown/podman-volume-exists.1.md b/docs/source/markdown/podman-volume-exists.1.md index e75159d56..ead806bd9 100644 --- a/docs/source/markdown/podman-volume-exists.1.md +++ b/docs/source/markdown/podman-volume-exists.1.md @@ -14,7 +14,7 @@ of `0` when the volume is found. A `1` will be returned otherwise. An exit code ## OPTIONS -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement diff --git a/docs/source/markdown/podman-volume-inspect.1.md b/docs/source/markdown/podman-volume-inspect.1.md index 7273b817a..ea0ee91b4 100644 --- a/docs/source/markdown/podman-volume-inspect.1.md +++ b/docs/source/markdown/podman-volume-inspect.1.md @@ -9,22 +9,22 @@ podman\-volume\-inspect - Get detailed information on one or more volumes ## DESCRIPTION Display detailed information on one or more volumes. The output can be formatted using -the **\-\-format** flag and a Go template. To get detailed information about all the -existing volumes, use the **\-\-all** flag. +the **--format** flag and a Go template. To get detailed information about all the +existing volumes, use the **--all** flag. Volumes can be queried individually by providing their full name or a unique partial name. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Inspect all volumes. -#### **\-\-format**=*format*, **-f** +#### **--format**=*format*, **-f** Format volume output using Go template -#### **\-\-help** +#### **--help** Print usage statement diff --git a/docs/source/markdown/podman-volume-ls.1.md b/docs/source/markdown/podman-volume-ls.1.md index 47e44efc1..ab3813cca 100644 --- a/docs/source/markdown/podman-volume-ls.1.md +++ b/docs/source/markdown/podman-volume-ls.1.md @@ -8,29 +8,29 @@ podman\-volume\-ls - List all the available volumes ## DESCRIPTION -Lists all the volumes that exist. The output can be filtered using the **\-\-filter** -flag and can be formatted to either JSON or a Go template using the **\-\-format** -flag. Use the **\-\-quiet** flag to print only the volume names. +Lists all the volumes that exist. The output can be filtered using the **--filter** +flag and can be formatted to either JSON or a Go template using the **--format** +flag. Use the **--quiet** flag to print only the volume names. ## OPTIONS -#### **\-\-filter**=*filter*, **-f** +#### **--filter**=*filter*, **-f** Filter volume output. -#### **\-\-format**=*format* +#### **--format**=*format* Format volume output using Go template. -#### **\-\-help** +#### **--help** Print usage statement. -#### **\-\-noheading** +#### **--noheading** Omit the table headings from the listing of volumes. -#### **\-\-quiet**, **-q** +#### **--quiet**, **-q** Print volume output in quiet mode. Only print the volume names. diff --git a/docs/source/markdown/podman-volume-prune.1.md b/docs/source/markdown/podman-volume-prune.1.md index b1ca72623..9477cb5d5 100644 --- a/docs/source/markdown/podman-volume-prune.1.md +++ b/docs/source/markdown/podman-volume-prune.1.md @@ -8,18 +8,18 @@ podman\-volume\-prune - Remove all unused volumes ## DESCRIPTION -Removes unused volumes. By default all unused volumes will be removed, the **\-\-filter** flag can +Removes unused volumes. By default all unused volumes will be removed, the **--filter** flag can be used to filter specific volumes. You will be prompted to confirm the removal of all the -unused volumes. To bypass the confirmation, use the **\-\-force** flag. +unused volumes. To bypass the confirmation, use the **--force** flag. ## OPTIONS -#### **\-\-force**, **-f** +#### **--force**, **-f** Do not prompt for confirmation. -#### **\-\-filter** +#### **--filter** Filter volumes to be pruned. Volumes can be filtered by the following attributes: @@ -30,7 +30,7 @@ Filter volumes to be pruned. Volumes can be filtered by the following attributes - opt - scope -#### **\-\-help** +#### **--help** Print usage statement diff --git a/docs/source/markdown/podman-volume-rm.1.md b/docs/source/markdown/podman-volume-rm.1.md index 2727ea640..c066d1c6e 100644 --- a/docs/source/markdown/podman-volume-rm.1.md +++ b/docs/source/markdown/podman-volume-rm.1.md @@ -9,22 +9,22 @@ podman\-volume\-rm - Remove one or more volumes ## DESCRIPTION Removes one or more volumes. Only volumes that are not being used will be removed. -If a volume is being used by a container, an error will be returned unless the **\-\-force** -flag is being used. To remove all volumes, use the **\-\-all** flag. +If a volume is being used by a container, an error will be returned unless the **--force** +flag is being used. To remove all volumes, use the **--all** flag. Volumes can be removed individually by providing their full name or a unique partial name. ## OPTIONS -#### **\-\-all**, **-a** +#### **--all**, **-a** Remove all volumes. -#### **\-\-force**, **-f** +#### **--force**, **-f** Remove a volume by force. If it is being used by containers, the containers will be removed first. -#### **\-\-help** +#### **--help** Print usage statement diff --git a/docs/source/markdown/podman-wait.1.md b/docs/source/markdown/podman-wait.1.md index 3697cc94a..fac017fe6 100644 --- a/docs/source/markdown/podman-wait.1.md +++ b/docs/source/markdown/podman-wait.1.md @@ -16,17 +16,17 @@ separated by newline in the same order as they were given to the command. ## OPTIONS -#### **\-\-condition**=*state* +#### **--condition**=*state* Condition to wait on (default "stopped") -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-interval**, **-i**=*duration* +#### **--interval**, **-i**=*duration* Time interval to wait before polling for completion. A duration string is a sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". Time unit defaults to "ms". -#### **\-\-latest**, **-l** +#### **--latest**, **-l** Instead of providing the container name or ID, use the last created container. If you use methods other than Podman to run containers such as CRI-O, the last started container could be from either of those methods. (This option is not available with the remote Podman client) diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md index 3b90a0922..ab4be1307 100644 --- a/docs/source/markdown/podman.1.md +++ b/docs/source/markdown/podman.1.md @@ -25,34 +25,34 @@ man pages. ## GLOBAL OPTIONS -#### **\-\-cgroup-manager**=*manager* +#### **--cgroup-manager**=*manager* The CGroup manager to use for container cgroups. Supported values are cgroupfs or systemd. Default is systemd unless overridden in the containers.conf file. Note: Setting this flag can cause certain commands to break when called on containers previously created by the other CGroup manager type. Note: CGroup manager is not supported in rootless mode when using CGroups Version V1. -#### **\-\-cni-config-dir** +#### **--cni-config-dir** Path of the configuration directory for CNI networks. (Default: `/etc/cni/net.d`) -#### **\-\-connection**, **-c** +#### **--connection**, **-c** Connection to use for remote podman (Default connection is configured in `containers.conf`) Remote connections use local containers.conf for default. -#### **\-\-conmon** +#### **--conmon** Path of the conmon binary (Default path is configured in `containers.conf`) -#### **\-\-events-backend**=*type* +#### **--events-backend**=*type* Backend to use for storing events. Allowed values are **file**, **journald**, and **none**. When *file* is specified, the events are stored under a subdirectory -of the *tmpdir* location (see **\-\-tmpdir** below). +of the *tmpdir* location (see **--tmpdir** below). -#### **\-\-help**, **-h** +#### **--help**, **-h** Print usage statement -#### **\-\-hooks-dir**=*path* +#### **--hooks-dir**=*path* Each `*.json` file in the path configures a hook for Podman containers. For more details on the syntax of the JSON files and the semantics of hook injection, see `oci-hooks(5)`. Podman and libpod currently support both the 1.0.0 and 0.1.0 hook schemas, although the 0.1.0 schema is deprecated. @@ -68,7 +68,7 @@ Podman and libpod currently support an additional `precreate` state which is cal **WARNING**: the `precreate` hook lets you do powerful things, such as adding additional mounts to the runtime configuration. That power also makes it easy to break things. Before reporting libpod errors, try running your container with `precreate` hooks disabled to see if the problem is due to one of your hooks. -#### **\-\-identity**=*path* +#### **--identity**=*path* Path to ssh identity file. If the identity file has been encrypted, podman prompts the user for the passphrase. If no identity file is provided and no user is given, podman defaults to the user running the podman command. @@ -80,23 +80,23 @@ Identity value resolution precedence: - `containers.conf` Remote connections use local containers.conf for default. -#### **\-\-log-level**=*level* +#### **--log-level**=*level* Log messages above specified level: debug, info, warn, error (default), fatal or panic (default: "error") -#### **\-\-namespace**=*namespace* +#### **--namespace**=*namespace* Set libpod namespace. Namespaces are used to separate groups of containers and pods in libpod's state. When namespace is set, created containers and pods will join the given namespace, and only containers and pods in the given namespace will be visible to Podman. -#### **\-\-network-cmd-path**=*path* +#### **--network-cmd-path**=*path* Path to the command binary to use for setting up a network. It is currently only used for setting up a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable. -#### **\-\-remote**, **-r** +#### **--remote**, **-r** Access Podman service will be remote Remote connections use local containers.conf for default. -#### **\-\-url**=*value* +#### **--url**=*value* URL to access Podman service (default from `containers.conf`, rootless `unix://run/user/$UID/podman/podman.sock` or as root `unix://run/podman/podman.sock`). - `CONTAINER_HOST` is of the format `<schema>://[<user[:<password>]@]<host>[:<port>][<path>]` @@ -115,21 +115,21 @@ URL value resolution precedence: - `unix://run/podman/podman.sock` Remote connections use local containers.conf for default. -#### **\-\-root**=*value* +#### **--root**=*value* Storage root dir in which data, including images, is stored (default: "/var/lib/containers/storage" for UID 0, "$HOME/.local/share/containers/storage" for other users). Default root dir configured in `/etc/containers/storage.conf`. -#### **\-\-runroot**=*value* +#### **--runroot**=*value* Storage state directory where all state information is stored (default: "/run/containers/storage" for UID 0, "/run/user/$UID/run" for other users). Default state dir configured in `/etc/containers/storage.conf`. -#### **\-\-runtime**=*value* +#### **--runtime**=*value* Name of the OCI runtime as specified in containers.conf or absolute path to the OCI compatible binary used to run containers. -#### **\-\-runtime-flag**=*flag* +#### **--runtime-flag**=*flag* Adds global flags for the container runtime. To list the supported flags, please consult the manpages of the selected container runtime (`runc` is the default @@ -139,30 +139,30 @@ for cgroup V2, the default runtime is `crun`, the manpage to consult is `crun(8) Note: Do not pass the leading `--` to the flag. To pass the runc flag `--log-format json` to podman build, the option given would be `--runtime-flag log-format=json`. -#### **\-\-storage-driver**=*value* +#### **--storage-driver**=*value* Storage driver. The default storage driver for UID 0 is configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode), and is *vfs* for non-root users when *fuse-overlayfs* is not available. The `STORAGE_DRIVER` environment variable overrides the default. The --storage-driver specified driver overrides all. Overriding this option will cause the *storage-opt* settings in /etc/containers/storage.conf to be ignored. The user must specify additional options via the `--storage-opt` flag. -#### **\-\-storage-opt**=*value* +#### **--storage-opt**=*value* Storage driver option, Default storage driver options are configured in /etc/containers/storage.conf (`$HOME/.config/containers/storage.conf` in rootless mode). The `STORAGE_OPTS` environment variable overrides the default. The --storage-opt specified options overrides all. If you specify --storage-opt="", no storage options will be used. -#### **\-\-syslog**=*true|false* +#### **--syslog**=*true|false* Output logging information to syslog as well as the console (default *false*). On remote clients, logging is directed to the file $HOME/.config/containers/podman.log. -#### **\-\-tmpdir** +#### **--tmpdir** Path to the tmp directory, for libpod runtime content. NOTE --tmpdir is not used for the temporary storage of downloaded images. Use the environment variable `TMPDIR` to change the temporary storage location of downloaded container images. Podman defaults to use `/var/tmp`. -#### **\-\-version**, **-v** +#### **--version**, **-v** Print the version @@ -17,7 +17,7 @@ require ( github.com/containers/image/v5 v5.12.0 github.com/containers/ocicrypt v1.1.1 github.com/containers/psgo v1.5.2 - github.com/containers/storage v1.30.1 + github.com/containers/storage v1.30.2 github.com/coreos/go-systemd/v22 v22.3.1 github.com/coreos/stream-metadata-go v0.0.0-20210225230131-70edb9eb47b3 github.com/cri-o/ocicni v0.2.1-0.20210301205850-541cf7c703cf @@ -211,8 +211,9 @@ github.com/containers/psgo v1.5.2 h1:3aoozst/GIwsrr/5jnFy3FrJay98uujPCu9lTuSZ/Cw github.com/containers/psgo v1.5.2/go.mod h1:2ubh0SsreMZjSXW1Hif58JrEcFudQyIy9EzPUWfawVU= github.com/containers/storage v1.23.5/go.mod h1:ha26Q6ngehFNhf3AWoXldvAvwI4jFe3ETQAf/CeZPyM= github.com/containers/storage v1.29.0/go.mod h1:u84RU4CCufGeJBNTRNwMB+FoE+AiFeFw4SsMoqAOeCM= -github.com/containers/storage v1.30.1 h1:+87sZDoUp0uNsP45dWypHTWTEoy0eNDgFYjTU1XIRVQ= github.com/containers/storage v1.30.1/go.mod h1:NDJkiwxnSHD1Is+4DGcyR3SIEYSDOa0xnAW+uGQFx9E= +github.com/containers/storage v1.30.2 h1:qLYh970iu0x53n7A5nlZHO8XjfROfiyizkFyRy62Lpc= +github.com/containers/storage v1.30.2/go.mod h1:hK/eetUA5afAZ+ZFZCXIY4eBAIo7XXmfNW476axZfgQ= github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-iptables v0.4.5/go.mod h1:/mVI274lEDI2ns62jHCDnCyBF9Iwsmekav8Dbxlm1MU= @@ -678,7 +679,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= -github.com/pquerna/ffjson v0.0.0-20190813045741-dac163c6c0a9 h1:kyf9snWXHvQc+yxE9imhdI8YAm4oKeZISlaAR+x73zs= github.com/pquerna/ffjson v0.0.0-20190813045741-dac163c6c0a9/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= diff --git a/hack/xref-helpmsgs-manpages b/hack/xref-helpmsgs-manpages index 25e972fbc..cc1e233b9 100755 --- a/hack/xref-helpmsgs-manpages +++ b/hack/xref-helpmsgs-manpages @@ -331,23 +331,12 @@ sub podman_man { @most_recent_flags = (); # As of PR #8292, all options are <h4> and anchored if ($line =~ s/^\#{4}\s+//) { - # 2021-03: PR #9856: some (bleep) markdown processor converts - # double dashes to a single em-dash. We need to escape every - # instance with backslashes. This is anti-intuitive, and - # developers will naturally write --foo; try to catch that - # and warn with a helpful message. - if ($line =~ /--([a-z]+)/) { - warn "$ME: $subpath:$.: You probably need to backslash-escape '--$1' as '\\-\\-$1'\n"; - } - # If option has long and short form, long must come first. # This is a while-loop because there may be multiple long # option names, e.g. --net/--network - while ($line =~ s/^\*\*\\-\\-([a-z0-9-]+)\*\*(=\*[a-zA-Z0-9-]+\*)?(,\s+)?//g) { - # add -- to the flag name - my $flag = "--".$1; - $man{$flag} = 1; - push @most_recent_flags, $flag; + while ($line =~ s/^\*\*(--[a-z0-9-]+)\*\*(=\*[a-zA-Z0-9-]+\*)?(,\s+)?//g) { + $man{$1} = 1; + push @most_recent_flags, $1; } # Short form if ($line =~ s/^\*\*(-[a-zA-Z0-9])\*\*(=\*[a-zA-Z0-9-]+\*)?//g) { diff --git a/libpod/oci_conmon_linux.go b/libpod/oci_conmon_linux.go index 1b1d4ad59..3da49b85f 100644 --- a/libpod/oci_conmon_linux.go +++ b/libpod/oci_conmon_linux.go @@ -1016,7 +1016,12 @@ func (r *ConmonOCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Co } } - args := r.sharedConmonArgs(ctr, ctr.ID(), ctr.bundlePath(), ctr.config.PidFile, ctr.LogPath(), r.exitsDir, ociLog, ctr.LogDriver(), logTag) + pidfile := ctr.config.PidFile + if pidfile == "" { + pidfile = filepath.Join(ctr.state.RunDir, "pidfile") + } + + args := r.sharedConmonArgs(ctr, ctr.ID(), ctr.bundlePath(), pidfile, ctr.LogPath(), r.exitsDir, ociLog, ctr.LogDriver(), logTag) if ctr.config.Spec.Process.Terminal { args = append(args, "-t") diff --git a/pkg/api/handlers/compat/containers.go b/pkg/api/handlers/compat/containers.go index 263d64a7b..6bc02dd2b 100644 --- a/pkg/api/handlers/compat/containers.go +++ b/pkg/api/handlers/compat/containers.go @@ -379,6 +379,11 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, if err != nil { return nil, err } + // Docker uses UTC + if inspect != nil && inspect.State != nil { + inspect.State.StartedAt = inspect.State.StartedAt.UTC() + inspect.State.FinishedAt = inspect.State.FinishedAt.UTC() + } i, err := json.Marshal(inspect.State) if err != nil { return nil, err @@ -425,7 +430,7 @@ func LibpodToContainerJSON(l *libpod.Container, sz bool) (*types.ContainerJSON, cb := types.ContainerJSONBase{ ID: l.ID(), - Created: l.CreatedTime().Format(time.RFC3339Nano), + Created: l.CreatedTime().UTC().Format(time.RFC3339Nano), // Docker uses UTC Path: inspect.Path, Args: inspect.Args, State: &state, diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 4b7a2a71c..3f4320efa 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -324,7 +324,11 @@ loop: // break out of for/select infinite loop flush() case <-runCtx.Done(): if !failed { - report.Status = "Pull complete" + if utils.IsLibpodRequest(r) { + report.Status = "Pull complete" + } else { + report.Status = "Download complete" + } report.Id = img[0:12] if err := enc.Encode(report); err != nil { logrus.Warnf("Failed to json encode error %q", err.Error()) @@ -455,10 +459,6 @@ func ExportImages(w http.ResponseWriter, r *http.Request) { utils.Error(w, "Something went wrong.", http.StatusBadRequest, fmt.Errorf("no images to download")) return } - if len(query.Names) > 1 { - utils.Error(w, "Something went wrong.", http.StatusNotImplemented, fmt.Errorf("getting multiple image is not supported yet")) - return - } images := query.Names tmpfile, err := ioutil.TempFile("", "api.tar") @@ -474,7 +474,7 @@ func ExportImages(w http.ResponseWriter, r *http.Request) { imageEngine := abi.ImageEngine{Libpod: runtime} - saveOptions := entities.ImageSaveOptions{Format: "docker-archive", Output: tmpfile.Name()} + saveOptions := entities.ImageSaveOptions{Format: "docker-archive", Output: tmpfile.Name(), MultiImageArchive: true} if err := imageEngine.Save(r.Context(), images[0], images[1:], saveOptions); err != nil { utils.InternalServerError(w, err) return diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index ec40fdd2d..6ff557291 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -24,7 +24,7 @@ import ( "github.com/containers/podman/v3/pkg/channel" "github.com/containers/storage/pkg/archive" "github.com/gorilla/schema" - specs "github.com/opencontainers/runtime-spec/specs-go" + "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" ) @@ -553,6 +553,10 @@ loop: } } break loop + case <-r.Context().Done(): + cancel() + logrus.Infof("Client disconnect reported for build %q / %q.", registry, query.Dockerfile) + return } } } diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go index 6acfcc1c8..f5e7c0c98 100644 --- a/pkg/bindings/images/build.go +++ b/pkg/bindings/images/build.go @@ -127,6 +127,8 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO } if options.RemoveIntermediateCtrs { params.Set("rm", "1") + } else { + params.Set("rm", "0") } if len(options.From) > 0 { params.Set("from", options.From) diff --git a/pkg/specgen/generate/kube/kube.go b/pkg/specgen/generate/kube/kube.go index ccce3edba..4e41061a5 100644 --- a/pkg/specgen/generate/kube/kube.go +++ b/pkg/specgen/generate/kube/kube.go @@ -23,6 +23,10 @@ func ToPodGen(ctx context.Context, podName string, podYAML *v1.PodTemplateSpec) p := specgen.NewPodSpecGenerator() p.Name = podName p.Labels = podYAML.ObjectMeta.Labels + // Kube pods must share {ipc, net, uts} by default + p.SharedNamespaces = append(p.SharedNamespaces, "ipc") + p.SharedNamespaces = append(p.SharedNamespaces, "net") + p.SharedNamespaces = append(p.SharedNamespaces, "uts") // TODO we only configure Process namespace. We also need to account for Host{IPC,Network,PID} // which is not currently possible with pod create if podYAML.Spec.ShareProcessNamespace != nil && *podYAML.Spec.ShareProcessNamespace { diff --git a/pkg/systemd/generate/common.go b/pkg/systemd/generate/common.go index eafd45528..0f667e2f4 100644 --- a/pkg/systemd/generate/common.go +++ b/pkg/systemd/generate/common.go @@ -89,19 +89,24 @@ func filterCommonContainerFlags(command []string, argCount int) []string { // see: https://www.freedesktop.org/software/systemd/man/systemd.service.html#Command%20lines func escapeSystemdArguments(command []string) []string { for i := range command { - command[i] = strings.ReplaceAll(command[i], "$", "$$") - command[i] = strings.ReplaceAll(command[i], "%", "%%") - if strings.ContainsAny(command[i], " \t") { - command[i] = strconv.Quote(command[i]) - } else if strings.Contains(command[i], `\`) { - // strconv.Quote also escapes backslashes so - // we should replace only if strconv.Quote was not used - command[i] = strings.ReplaceAll(command[i], `\`, `\\`) - } + command[i] = escapeSystemdArg(command[i]) } return command } +func escapeSystemdArg(arg string) string { + arg = strings.ReplaceAll(arg, "$", "$$") + arg = strings.ReplaceAll(arg, "%", "%%") + if strings.ContainsAny(arg, " \t") { + arg = strconv.Quote(arg) + } else if strings.Contains(arg, `\`) { + // strconv.Quote also escapes backslashes so + // we should replace only if strconv.Quote was not used + arg = strings.ReplaceAll(arg, `\`, `\\`) + } + return arg +} + func removeDetachArg(args []string, argCount int) []string { // "--detach=false" could also be in the container entrypoint // split them off so we do not remove it there diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go index e06655a8d..eb1fb67ff 100644 --- a/pkg/systemd/generate/containers.go +++ b/pkg/systemd/generate/containers.go @@ -54,6 +54,12 @@ type containerInfo struct { // CreateCommand is the full command plus arguments of the process the // container has been created with. CreateCommand []string + // containerEnv stores the container environment variables + containerEnv []string + // ExtraEnvs contains the container environment variables referenced + // by only the key in the container create command, e.g. --env FOO. + // This is only used with --new + ExtraEnvs []string // EnvVariable is generate.EnvVariable and must not be set. EnvVariable string // ExecStartPre of the unit. @@ -87,6 +93,9 @@ After={{{{- range $index, $value := .BoundToServices -}}}}{{{{if $index}}}} {{{{ [Service] Environment={{{{.EnvVariable}}}}=%n +{{{{- if .ExtraEnvs}}}} +Environment={{{{- range $index, $value := .ExtraEnvs -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}{{{{end}}}} +{{{{- end}}}} Restart={{{{.RestartPolicy}}}} TimeoutStopSec={{{{.TimeoutStopSec}}}} {{{{- if .ExecStartPre}}}} @@ -153,6 +162,8 @@ func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSyste return nil, errors.Errorf("could not lookup container's runroot: got empty string") } + envs := config.Spec.Process.Env + info := containerInfo{ ServiceName: serviceName, ContainerNameOrID: nameOrID, @@ -163,6 +174,7 @@ func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSyste CreateCommand: createCommand, GraphRoot: graphRoot, RunRoot: runRoot, + containerEnv: envs, } return &info, nil @@ -248,6 +260,7 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst fs.BoolP("detach", "d", false, "") fs.String("name", "", "") fs.Bool("replace", false, "") + fs.StringArrayP("env", "e", nil, "") fs.Parse(remainingCmd) remainingCmd = filterCommonContainerFlags(remainingCmd, fs.NArg()) @@ -304,6 +317,24 @@ func executeContainerTemplate(info *containerInfo, options entities.GenerateSyst remainingCmd = removeReplaceArg(remainingCmd, fs.NArg()) } } + + envs, err := fs.GetStringArray("env") + if err != nil { + return "", err + } + for _, env := range envs { + // if env arg does not contain a equal sign we have to add the envar to the unit + // because it does try to red the value from the environment + if !strings.Contains(env, "=") { + for _, containerEnv := range info.containerEnv { + split := strings.SplitN(containerEnv, "=", 2) + if split[0] == env { + info.ExtraEnvs = append(info.ExtraEnvs, escapeSystemdArg(containerEnv)) + } + } + } + } + startCommand = append(startCommand, remainingCmd...) startCommand = escapeSystemdArguments(startCommand) diff --git a/pkg/systemd/generate/containers_test.go b/pkg/systemd/generate/containers_test.go index 899ba6bfa..75b08526b 100644 --- a/pkg/systemd/generate/containers_test.go +++ b/pkg/systemd/generate/containers_test.go @@ -445,6 +445,32 @@ Type=forking [Install] WantedBy=multi-user.target default.target ` + + goodNewWithEnvar := `# jadda-jadda.service +# autogenerated by Podman CI + +[Unit] +Description=Podman jadda-jadda.service +Documentation=man:podman-generate-systemd(1) +Wants=network.target +After=network-online.target +RequiresMountsFor=/var/lib/containers/storage /var/run/containers/storage + +[Service] +Environment=PODMAN_SYSTEMD_UNIT=%n +Environment=FOO=abc "BAR=my test" USER=%%a +Restart=always +TimeoutStopSec=70 +ExecStartPre=/bin/rm -f %t/jadda-jadda.pid %t/jadda-jadda.ctr-id +ExecStart=/usr/bin/podman run --conmon-pidfile %t/jadda-jadda.pid --cidfile %t/jadda-jadda.ctr-id --cgroups=no-conmon -d --env FOO --env=BAR --env=MYENV=2 -e USER awesome-image:latest +ExecStop=/usr/bin/podman stop --ignore --cidfile %t/jadda-jadda.ctr-id -t 10 +ExecStopPost=/usr/bin/podman rm --ignore -f --cidfile %t/jadda-jadda.ctr-id +PIDFile=%t/jadda-jadda.pid +Type=forking + +[Install] +WantedBy=multi-user.target default.target +` tests := []struct { name string info containerInfo @@ -873,6 +899,26 @@ WantedBy=multi-user.target default.target false, false, }, + {"good with environment variables", + containerInfo{ + Executable: "/usr/bin/podman", + ServiceName: "jadda-jadda", + ContainerNameOrID: "jadda-jadda", + RestartPolicy: "always", + PIDFile: "/var/run/containers/storage/overlay-containers/639c53578af4d84b8800b4635fa4e680ee80fd67e0e6a2d4eea48d1e3230f401/userdata/conmon.pid", + StopTimeout: 10, + PodmanVersion: "CI", + GraphRoot: "/var/lib/containers/storage", + RunRoot: "/var/run/containers/storage", + CreateCommand: []string{"I'll get stripped", "create", "--env", "FOO", "--env=BAR", "--env=MYENV=2", "-e", "USER", "awesome-image:latest"}, + containerEnv: []string{"FOO=abc", "BAR=my test", "USER=%a", "MYENV=2"}, + EnvVariable: define.EnvVariable, + }, + goodNewWithEnvar, + true, + false, + false, + }, } for _, tt := range tests { test := tt diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index 53702fa0a..037a4c01f 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -143,12 +143,8 @@ t DELETE libpod/images/test1:latest 200 t GET "images/get?names=alpine" 200 '[POSIX tar archive]' podman pull busybox -#t GET "images/get?names=alpine&names=busybox" 200 '[POSIX tar archive]' -#img_cnt=$(tar xf "$WORKDIR/curl.result.out" manifest.json -O | jq "length") -#is "$img_cnt" 2 "number of images in tar archive" -# TODO getting multiple images is not supported yet -# once it is supported replace the test below by the tests above -t GET "images/get?names=alpine&names=busybox" 501 \ - .cause="getting multiple image is not supported yet" +t GET "images/get?names=alpine&names=busybox" 200 '[POSIX tar archive]' +img_cnt=$(tar xf "$WORKDIR/curl.result.out" manifest.json -O | jq "length") +is "$img_cnt" 2 "number of images in tar archive" # vim: filetype=sh diff --git a/test/apiv2/20-containers.at b/test/apiv2/20-containers.at index 23dd374d6..a81210855 100644 --- a/test/apiv2/20-containers.at +++ b/test/apiv2/20-containers.at @@ -161,6 +161,12 @@ t GET libpod/containers/myctr/json 200 \ .OCIConfigPath~.*config\.json \ .GraphDriver.Data.MergedDir~.*merged +# Test TS are in UTC +t GET containers/myctr/json 200 \ + .Created~.*Z \ + .State.StartedAt~.*Z \ + .State.FinishedAt~.*Z + t DELETE images/localhost/newrepo:latest?force=true 200 t DELETE images/localhost/newrepo:v1?force=true 200 t DELETE images/localhost/newrepo:v2?force=true 200 diff --git a/test/buildah-bud/apply-podman-deltas b/test/buildah-bud/apply-podman-deltas index ecdb9430c..0bf9f298d 100755 --- a/test/buildah-bud/apply-podman-deltas +++ b/test/buildah-bud/apply-podman-deltas @@ -157,8 +157,7 @@ skip "FIXME FIXME FIXME podman save/load has been fixed (but not yet used in Bui ############################################################################### # BEGIN tests which are skipped due to actual podman bugs. -skip "FIXME: podman #9915" \ - "bud with --arch flag" + ############################################################################### # Done. diff --git a/test/e2e/images_test.go b/test/e2e/images_test.go index 098d58033..f6321ec1c 100644 --- a/test/e2e/images_test.go +++ b/test/e2e/images_test.go @@ -219,7 +219,6 @@ WORKDIR /test }) It("podman pull by digest and list --all", func() { - Skip("FIXME-8165: 'rmi -af' fails with 'layer not known' (#6510)") // Prevent regressing on issue #7651. digestPullAndList := func(noneTag bool) { session := podmanTest.Podman([]string{"pull", ALPINEAMD64DIGEST}) diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 3908d4075..e0af27f7a 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -28,6 +28,44 @@ metadata: spec: hostname: unknown ` +var sharedNamespacePodYaml = ` +apiVersion: v1 +kind: Pod +metadata: + creationTimestamp: "2021-05-07T17:25:01Z" + labels: + app: testpod1 + name: testpod1 +spec: + containers: + - command: + - top + - -d + - "1.5" + env: + - name: PATH + value: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin + - name: TERM + value: xterm + - name: container + value: podman + - name: HOSTNAME + value: label-pod + image: quay.io/libpod/alpine:latest + name: alpine + resources: {} + securityContext: + allowPrivilegeEscalation: true + capabilities: {} + privileged: false + readOnlyRootFilesystem: false + seLinuxOptions: {} + workingDir: / + dnsConfig: {} + restartPolicy: Never + shareProcessNamespace: true +status: {} +` var selinuxLabelPodYaml = ` apiVersion: v1 @@ -1004,6 +1042,24 @@ var _ = Describe("Podman play kube", func() { Expect(label).To(ContainSubstring("unconfined_u:system_r:spc_t:s0")) }) + It("podman play kube should share ipc,net,uts when shareProcessNamespace is set", func() { + SkipIfRootless("Requires root priviledges for sharing few namespaces") + err := writeYaml(sharedNamespacePodYaml, kubeYaml) + Expect(err).To(BeNil()) + + kube := podmanTest.Podman([]string{"play", "kube", kubeYaml}) + kube.WaitWithDefaultTimeout() + Expect(kube.ExitCode()).To(Equal(0)) + + inspect := podmanTest.Podman([]string{"inspect", "testpod1", "--format", "'{{ .SharedNamespaces }}'"}) + inspect.WaitWithDefaultTimeout() + sharednamespaces := inspect.OutputToString() + Expect(sharednamespaces).To(ContainSubstring("ipc")) + Expect(sharednamespaces).To(ContainSubstring("net")) + Expect(sharednamespaces).To(ContainSubstring("uts")) + Expect(sharednamespaces).To(ContainSubstring("pid")) + }) + It("podman play kube fail with nonexistent authfile", func() { err := generateKubeYaml("pod", getPod(), kubeYaml) Expect(err).To(BeNil()) diff --git a/test/system/001-basic.bats b/test/system/001-basic.bats index 5d44c373f..97ef61511 100644 --- a/test/system/001-basic.bats +++ b/test/system/001-basic.bats @@ -15,13 +15,6 @@ function setup() { @test "podman version emits reasonable output" { run_podman version - # FIXME FIXME FIXME: #10248: nasty message on Ubuntu cgroups v1, rootless - if [[ "$output" =~ "overlay test mount with multiple lowers failed" ]]; then - if is_rootless; then - lines=("${lines[@]:1}") - fi - fi - # First line of podman-remote is "Client:<blank>". # Just delete it (i.e. remove the first entry from the 'lines' array) if is_remote; then diff --git a/test/system/250-systemd.bats b/test/system/250-systemd.bats index b42769409..4ea192009 100644 --- a/test/system/250-systemd.bats +++ b/test/system/250-systemd.bats @@ -125,4 +125,27 @@ function service_cleanup() { service_cleanup } +# These tests can fail in dev. environment because of SELinux. +# quick fix: chcon -t container_runtime_exec_t ./bin/podman +@test "podman generate systemd - envar" { + xdg_rootless + + cname=$(random_string) + FOO=value BAR=%s run_podman create --name $cname --env FOO -e BAR --env MYVAR=myval \ + $IMAGE sh -c 'printenv && sleep 100' + + # Start systemd service to run this container + service_setup + + # Give container time to start; make sure output looks top-like + sleep 2 + run_podman logs $cname + is "$output" ".*FOO=value.*" "FOO environment variable set" + is "$output" ".*BAR=%s.*" "BAR environment variable set" + is "$output" ".*MYVAR=myval.*" "MYVAL environment variable set" + + # All good. Stop service, clean up. + service_cleanup +} + # vim: filetype=sh diff --git a/vendor/github.com/containers/storage/Makefile b/vendor/github.com/containers/storage/Makefile index 31fc7dff0..581961fed 100644 --- a/vendor/github.com/containers/storage/Makefile +++ b/vendor/github.com/containers/storage/Makefile @@ -41,34 +41,16 @@ ifeq ($(shell $(GO) help mod >/dev/null 2>&1 && echo true), true) endif RUNINVM := vagrant/runinvm.sh -FFJSON := tests/tools/build/ffjson default all: local-binary docs local-validate local-cross local-gccgo test-unit test-integration ## validate all checks, build and cross-build\nbinaries and docs, run tests in a VM clean: ## remove all built files $(RM) -f containers-storage containers-storage.* docs/*.1 docs/*.5 -sources := $(wildcard *.go cmd/containers-storage/*.go drivers/*.go drivers/*/*.go pkg/*/*.go pkg/*/*/*.go) layers_ffjson.go images_ffjson.go containers_ffjson.go pkg/archive/archive_ffjson.go - +sources := $(wildcard *.go cmd/containers-storage/*.go drivers/*.go drivers/*/*.go pkg/*/*.go pkg/*/*/*.go) containers-storage: $(sources) ## build using gc on the host $(GO) build $(MOD_VENDOR) -compiler gc $(BUILDFLAGS) ./cmd/containers-storage -layers_ffjson.go: $(FFJSON) layers.go - $(RM) $@ - $(FFJSON) layers.go - -images_ffjson.go: $(FFJSON) images.go - $(RM) $@ - $(FFJSON) images.go - -containers_ffjson.go: $(FFJSON) containers.go - $(RM) $@ - $(FFJSON) containers.go - -pkg/archive/archive_ffjson.go: $(FFJSON) pkg/archive/archive.go - $(RM) $@ - $(FFJSON) pkg/archive/archive.go - binary local-binary: containers-storage local-gccgo: ## build using gccgo on the host @@ -118,7 +100,7 @@ install.tools: make -C tests/tools $(FFJSON): - make -C tests/tools build/ffjson + make -C tests/tools install.docs: docs make -C docs install diff --git a/vendor/github.com/containers/storage/VERSION b/vendor/github.com/containers/storage/VERSION index 7f3c3affd..d1eaa3ba0 100644 --- a/vendor/github.com/containers/storage/VERSION +++ b/vendor/github.com/containers/storage/VERSION @@ -1 +1 @@ -1.30.1 +1.30.2 diff --git a/vendor/github.com/containers/storage/containers.go b/vendor/github.com/containers/storage/containers.go index 513f96c2c..90b58deda 100644 --- a/vendor/github.com/containers/storage/containers.go +++ b/vendor/github.com/containers/storage/containers.go @@ -1,7 +1,6 @@ package storage import ( - "encoding/json" "fmt" "io/ioutil" "os" diff --git a/vendor/github.com/containers/storage/containers_ffjson.go b/vendor/github.com/containers/storage/containers_ffjson.go deleted file mode 100644 index aef6becfe..000000000 --- a/vendor/github.com/containers/storage/containers_ffjson.go +++ /dev/null @@ -1,1413 +0,0 @@ -// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT. -// source: containers.go - -package storage - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/containers/storage/pkg/idtools" - "github.com/opencontainers/go-digest" - fflib "github.com/pquerna/ffjson/fflib/v1" -) - -// MarshalJSON marshal bytes to json - template -func (j *Container) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *Container) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "id":`) - fflib.WriteJsonString(buf, string(j.ID)) - buf.WriteByte(',') - if len(j.Names) != 0 { - buf.WriteString(`"names":`) - if j.Names != nil { - buf.WriteString(`[`) - for i, v := range j.Names { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.WriteString(`"image":`) - fflib.WriteJsonString(buf, string(j.ImageID)) - buf.WriteString(`,"layer":`) - fflib.WriteJsonString(buf, string(j.LayerID)) - buf.WriteByte(',') - if len(j.Metadata) != 0 { - buf.WriteString(`"metadata":`) - fflib.WriteJsonString(buf, string(j.Metadata)) - buf.WriteByte(',') - } - if len(j.BigDataNames) != 0 { - buf.WriteString(`"big-data-names":`) - if j.BigDataNames != nil { - buf.WriteString(`[`) - for i, v := range j.BigDataNames { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.BigDataSizes) != 0 { - if j.BigDataSizes == nil { - buf.WriteString(`"big-data-sizes":null`) - } else { - buf.WriteString(`"big-data-sizes":{ `) - for key, value := range j.BigDataSizes { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.FormatBits2(buf, uint64(value), 10, value < 0) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - buf.WriteByte(',') - } - if len(j.BigDataDigests) != 0 { - if j.BigDataDigests == nil { - buf.WriteString(`"big-data-digests":null`) - } else { - buf.WriteString(`"big-data-digests":{ `) - for key, value := range j.BigDataDigests { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.WriteJsonString(buf, string(value)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - buf.WriteByte(',') - } - if true { - buf.WriteString(`"created":`) - - { - - obj, err = j.Created.MarshalJSON() - if err != nil { - return err - } - buf.Write(obj) - - } - buf.WriteByte(',') - } - if len(j.UIDMap) != 0 { - buf.WriteString(`"uidmap":`) - if j.UIDMap != nil { - buf.WriteString(`[`) - for i, v := range j.UIDMap { - if i != 0 { - buf.WriteString(`,`) - } - /* Struct fall back. type=idtools.IDMap kind=struct */ - err = buf.Encode(&v) - if err != nil { - return err - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.GIDMap) != 0 { - buf.WriteString(`"gidmap":`) - if j.GIDMap != nil { - buf.WriteString(`[`) - for i, v := range j.GIDMap { - if i != 0 { - buf.WriteString(`,`) - } - /* Struct fall back. type=idtools.IDMap kind=struct */ - err = buf.Encode(&v) - if err != nil { - return err - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.Flags) != 0 { - buf.WriteString(`"flags":`) - /* Falling back. type=map[string]interface {} kind=map */ - err = buf.Encode(j.Flags) - if err != nil { - return err - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffjtContainerbase = iota - ffjtContainernosuchkey - - ffjtContainerID - - ffjtContainerNames - - ffjtContainerImageID - - ffjtContainerLayerID - - ffjtContainerMetadata - - ffjtContainerBigDataNames - - ffjtContainerBigDataSizes - - ffjtContainerBigDataDigests - - ffjtContainerCreated - - ffjtContainerUIDMap - - ffjtContainerGIDMap - - ffjtContainerFlags -) - -var ffjKeyContainerID = []byte("id") - -var ffjKeyContainerNames = []byte("names") - -var ffjKeyContainerImageID = []byte("image") - -var ffjKeyContainerLayerID = []byte("layer") - -var ffjKeyContainerMetadata = []byte("metadata") - -var ffjKeyContainerBigDataNames = []byte("big-data-names") - -var ffjKeyContainerBigDataSizes = []byte("big-data-sizes") - -var ffjKeyContainerBigDataDigests = []byte("big-data-digests") - -var ffjKeyContainerCreated = []byte("created") - -var ffjKeyContainerUIDMap = []byte("uidmap") - -var ffjKeyContainerGIDMap = []byte("gidmap") - -var ffjKeyContainerFlags = []byte("flags") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *Container) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *Container) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtContainerbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtContainernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'b': - - if bytes.Equal(ffjKeyContainerBigDataNames, kn) { - currentKey = ffjtContainerBigDataNames - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyContainerBigDataSizes, kn) { - currentKey = ffjtContainerBigDataSizes - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyContainerBigDataDigests, kn) { - currentKey = ffjtContainerBigDataDigests - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'c': - - if bytes.Equal(ffjKeyContainerCreated, kn) { - currentKey = ffjtContainerCreated - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'f': - - if bytes.Equal(ffjKeyContainerFlags, kn) { - currentKey = ffjtContainerFlags - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'g': - - if bytes.Equal(ffjKeyContainerGIDMap, kn) { - currentKey = ffjtContainerGIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'i': - - if bytes.Equal(ffjKeyContainerID, kn) { - currentKey = ffjtContainerID - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyContainerImageID, kn) { - currentKey = ffjtContainerImageID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'l': - - if bytes.Equal(ffjKeyContainerLayerID, kn) { - currentKey = ffjtContainerLayerID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffjKeyContainerMetadata, kn) { - currentKey = ffjtContainerMetadata - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffjKeyContainerNames, kn) { - currentKey = ffjtContainerNames - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'u': - - if bytes.Equal(ffjKeyContainerUIDMap, kn) { - currentKey = ffjtContainerUIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyContainerFlags, kn) { - currentKey = ffjtContainerFlags - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerGIDMap, kn) { - currentKey = ffjtContainerGIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerUIDMap, kn) { - currentKey = ffjtContainerUIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerCreated, kn) { - currentKey = ffjtContainerCreated - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyContainerBigDataDigests, kn) { - currentKey = ffjtContainerBigDataDigests - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyContainerBigDataSizes, kn) { - currentKey = ffjtContainerBigDataSizes - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyContainerBigDataNames, kn) { - currentKey = ffjtContainerBigDataNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerMetadata, kn) { - currentKey = ffjtContainerMetadata - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerLayerID, kn) { - currentKey = ffjtContainerLayerID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerImageID, kn) { - currentKey = ffjtContainerImageID - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyContainerNames, kn) { - currentKey = ffjtContainerNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyContainerID, kn) { - currentKey = ffjtContainerID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtContainernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtContainerID: - goto handle_ID - - case ffjtContainerNames: - goto handle_Names - - case ffjtContainerImageID: - goto handle_ImageID - - case ffjtContainerLayerID: - goto handle_LayerID - - case ffjtContainerMetadata: - goto handle_Metadata - - case ffjtContainerBigDataNames: - goto handle_BigDataNames - - case ffjtContainerBigDataSizes: - goto handle_BigDataSizes - - case ffjtContainerBigDataDigests: - goto handle_BigDataDigests - - case ffjtContainerCreated: - goto handle_Created - - case ffjtContainerUIDMap: - goto handle_UIDMap - - case ffjtContainerGIDMap: - goto handle_GIDMap - - case ffjtContainerFlags: - goto handle_Flags - - case ffjtContainernosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_ID: - - /* handler: j.ID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.ID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Names: - - /* handler: j.Names type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.Names = nil - } else { - - j.Names = []string{} - - wantVal := true - - for { - - var tmpJNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJNames = string(string(outBuf)) - - } - } - - j.Names = append(j.Names, tmpJNames) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ImageID: - - /* handler: j.ImageID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.ImageID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_LayerID: - - /* handler: j.LayerID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.LayerID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Metadata: - - /* handler: j.Metadata type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.Metadata = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataNames: - - /* handler: j.BigDataNames type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataNames = nil - } else { - - j.BigDataNames = []string{} - - wantVal := true - - for { - - var tmpJBigDataNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJBigDataNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJBigDataNames = string(string(outBuf)) - - } - } - - j.BigDataNames = append(j.BigDataNames, tmpJBigDataNames) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataSizes: - - /* handler: j.BigDataSizes type=map[string]int64 kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataSizes = nil - } else { - - j.BigDataSizes = make(map[string]int64, 0) - - wantVal := true - - for { - - var k string - - var tmpJBigDataSizes int64 - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJBigDataSizes type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - tmpJBigDataSizes = int64(tval) - - } - } - - j.BigDataSizes[k] = tmpJBigDataSizes - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataDigests: - - /* handler: j.BigDataDigests type=map[string]digest.Digest kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataDigests = nil - } else { - - j.BigDataDigests = make(map[string]digest.Digest, 0) - - wantVal := true - - for { - - var k string - - var tmpJBigDataDigests digest.Digest - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJBigDataDigests type=digest.Digest kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Digest", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJBigDataDigests = digest.Digest(string(outBuf)) - - } - } - - j.BigDataDigests[k] = tmpJBigDataDigests - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Created: - - /* handler: j.Created type=time.Time kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - } else { - - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = j.Created.UnmarshalJSON(tbuf) - if err != nil { - return fs.WrapErr(err) - } - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UIDMap: - - /* handler: j.UIDMap type=[]idtools.IDMap kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.UIDMap = nil - } else { - - j.UIDMap = []idtools.IDMap{} - - wantVal := true - - for { - - var tmpJUIDMap idtools.IDMap - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJUIDMap type=idtools.IDMap kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMap kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJUIDMap) - if err != nil { - return fs.WrapErr(err) - } - } - - j.UIDMap = append(j.UIDMap, tmpJUIDMap) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GIDMap: - - /* handler: j.GIDMap type=[]idtools.IDMap kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.GIDMap = nil - } else { - - j.GIDMap = []idtools.IDMap{} - - wantVal := true - - for { - - var tmpJGIDMap idtools.IDMap - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJGIDMap type=idtools.IDMap kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMap kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJGIDMap) - if err != nil { - return fs.WrapErr(err) - } - } - - j.GIDMap = append(j.GIDMap, tmpJGIDMap) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Flags: - - /* handler: j.Flags type=map[string]interface {} kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.Flags = nil - } else { - - j.Flags = make(map[string]interface{}, 0) - - wantVal := true - - for { - - var k string - - var tmpJFlags interface{} - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJFlags type=interface {} kind=interface quoted=false*/ - - { - /* Falling back. type=interface {} kind=interface */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJFlags) - if err != nil { - return fs.WrapErr(err) - } - } - - j.Flags[k] = tmpJFlags - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *containerStore) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *containerStore) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{}`) - return nil -} - -const ( - ffjtcontainerStorebase = iota - ffjtcontainerStorenosuchkey -) - -// UnmarshalJSON umarshall json - template of ffjson -func (j *containerStore) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *containerStore) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtcontainerStorebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtcontainerStorenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - } - - currentKey = ffjtcontainerStorenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtcontainerStorenosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} diff --git a/vendor/github.com/containers/storage/drivers/chown.go b/vendor/github.com/containers/storage/drivers/chown.go index 7604a86db..63bfd2d13 100644 --- a/vendor/github.com/containers/storage/drivers/chown.go +++ b/vendor/github.com/containers/storage/drivers/chown.go @@ -2,7 +2,6 @@ package graphdriver import ( "bytes" - "encoding/json" "fmt" "os" diff --git a/vendor/github.com/containers/storage/drivers/devmapper/device_setup.go b/vendor/github.com/containers/storage/drivers/devmapper/device_setup.go index 5bfbb49e2..c23097b76 100644 --- a/vendor/github.com/containers/storage/drivers/devmapper/device_setup.go +++ b/vendor/github.com/containers/storage/drivers/devmapper/device_setup.go @@ -5,7 +5,6 @@ package devmapper import ( "bufio" "bytes" - "encoding/json" "fmt" "io/ioutil" "os" diff --git a/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go b/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go index 775dc1685..3b74bcf4d 100644 --- a/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go +++ b/vendor/github.com/containers/storage/drivers/devmapper/deviceset.go @@ -4,7 +4,6 @@ package devmapper import ( "bufio" - "encoding/json" "fmt" "io" "io/ioutil" diff --git a/vendor/github.com/containers/storage/drivers/devmapper/jsoniter.go b/vendor/github.com/containers/storage/drivers/devmapper/jsoniter.go new file mode 100644 index 000000000..54db6ab4a --- /dev/null +++ b/vendor/github.com/containers/storage/drivers/devmapper/jsoniter.go @@ -0,0 +1,5 @@ +package devmapper + +import jsoniter "github.com/json-iterator/go" + +var json = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/vendor/github.com/containers/storage/drivers/jsoniter.go b/vendor/github.com/containers/storage/drivers/jsoniter.go new file mode 100644 index 000000000..097f923ab --- /dev/null +++ b/vendor/github.com/containers/storage/drivers/jsoniter.go @@ -0,0 +1,5 @@ +package graphdriver + +import jsoniter "github.com/json-iterator/go" + +var json = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/vendor/github.com/containers/storage/drivers/overlay/jsoniter.go b/vendor/github.com/containers/storage/drivers/overlay/jsoniter.go new file mode 100644 index 000000000..2a1e9d0cc --- /dev/null +++ b/vendor/github.com/containers/storage/drivers/overlay/jsoniter.go @@ -0,0 +1,5 @@ +package overlay + +import jsoniter "github.com/json-iterator/go" + +var json = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/vendor/github.com/containers/storage/drivers/overlay/mount.go b/vendor/github.com/containers/storage/drivers/overlay/mount.go index feb039592..7c8fd50a3 100644 --- a/vendor/github.com/containers/storage/drivers/overlay/mount.go +++ b/vendor/github.com/containers/storage/drivers/overlay/mount.go @@ -4,7 +4,6 @@ package overlay import ( "bytes" - "encoding/json" "flag" "fmt" "os" diff --git a/vendor/github.com/containers/storage/drivers/overlay/overlay.go b/vendor/github.com/containers/storage/drivers/overlay/overlay.go index 26f4b0a55..60eb047bd 100644 --- a/vendor/github.com/containers/storage/drivers/overlay/overlay.go +++ b/vendor/github.com/containers/storage/drivers/overlay/overlay.go @@ -620,7 +620,7 @@ func supportsOverlay(home string, homeMagic graphdriver.FsMagic, rootUID, rootGI if len(flags) < unix.Getpagesize() { err := unix.Mount("overlay", mergedDir, "overlay", 0, flags) if err == nil { - logrus.Errorf("overlay test mount with multiple lowers failed, but succeeded with a single lower") + logrus.StandardLogger().Logf(logLevel, "overlay test mount with multiple lowers failed, but succeeded with a single lower") return supportsDType, errors.Wrap(graphdriver.ErrNotSupported, "kernel too old to provide multiple lowers feature for overlay") } logrus.Debugf("overlay test mount with a single lower failed %v", err) diff --git a/vendor/github.com/containers/storage/drivers/windows/jsoniter_windows.go b/vendor/github.com/containers/storage/drivers/windows/jsoniter_windows.go new file mode 100644 index 000000000..fa1412630 --- /dev/null +++ b/vendor/github.com/containers/storage/drivers/windows/jsoniter_windows.go @@ -0,0 +1,5 @@ +package windows + +import jsoniter "github.com/json-iterator/go" + +var json = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/vendor/github.com/containers/storage/drivers/windows/windows.go b/vendor/github.com/containers/storage/drivers/windows/windows.go index c8a340801..149151741 100644 --- a/vendor/github.com/containers/storage/drivers/windows/windows.go +++ b/vendor/github.com/containers/storage/drivers/windows/windows.go @@ -6,7 +6,6 @@ import ( "archive/tar" "bufio" "bytes" - "encoding/json" "errors" "fmt" "io" diff --git a/vendor/github.com/containers/storage/ffjson_deps.go b/vendor/github.com/containers/storage/ffjson_deps.go deleted file mode 100644 index 33e5340a5..000000000 --- a/vendor/github.com/containers/storage/ffjson_deps.go +++ /dev/null @@ -1,10 +0,0 @@ -package storage - -// NOTE: this is a hack to trick go modules into vendoring the below -// dependencies. Those are required during ffjson generation -// but do NOT end up in the final file. - -import ( - _ "github.com/pquerna/ffjson/inception" // nolint:typecheck - _ "github.com/pquerna/ffjson/shared" // nolint:typecheck -) diff --git a/vendor/github.com/containers/storage/go.mod b/vendor/github.com/containers/storage/go.mod index c035e2979..08a54d60d 100644 --- a/vendor/github.com/containers/storage/go.mod +++ b/vendor/github.com/containers/storage/go.mod @@ -9,6 +9,7 @@ require ( github.com/docker/go-units v0.4.0 github.com/google/go-intervals v0.0.2 github.com/hashicorp/go-multierror v1.1.1 + github.com/json-iterator/go v1.1.11 github.com/klauspost/compress v1.12.2 github.com/klauspost/pgzip v1.2.5 github.com/mattn/go-shellwords v1.0.11 @@ -19,7 +20,6 @@ require ( github.com/opencontainers/runtime-spec v1.0.3-0.20200929063507-e6143ca7d51d github.com/opencontainers/selinux v1.8.0 github.com/pkg/errors v0.9.1 - github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 github.com/sirupsen/logrus v1.8.1 github.com/stretchr/testify v1.7.0 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 diff --git a/vendor/github.com/containers/storage/go.sum b/vendor/github.com/containers/storage/go.sum index f73f225f2..dc2cbc338 100644 --- a/vendor/github.com/containers/storage/go.sum +++ b/vendor/github.com/containers/storage/go.sum @@ -330,6 +330,8 @@ github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11 h1:uVUAXhF2To8cbw/3xN3pxj6kk7TYKs98NIrTqPlMWAQ= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= @@ -377,8 +379,10 @@ github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2J github.com/moby/sys/symlink v0.1.0/go.mod h1:GGDODQmbFOjFsXvfLVn3+ZRxkch54RkSiGqsZeMYowQ= github.com/moby/term v0.0.0-20200312100748-672ec06f55cd/go.mod h1:DdlQx2hp0Ss5/fLikoLlEeIYiATotOjgB//nb973jeo= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= github.com/munnerz/goautoneg v0.0.0-20120707110453-a547fc61f48d/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= @@ -430,8 +434,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pquerna/cachecontrol v0.0.0-20171018203845-0dec1b30a021/go.mod h1:prYjPmNq4d1NPVmpShWobRqXY3q7Vp+80DqgxxUrUIA= -github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 h1:gGBSHPOU7g8YjTbhwn+lvFm2VDEhhA+PwDIlstkgSxE= -github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M= github.com/prometheus/client_golang v0.0.0-20180209125602-c332b6f63c06/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= diff --git a/vendor/github.com/containers/storage/images.go b/vendor/github.com/containers/storage/images.go index 2808f579f..b3a2821b6 100644 --- a/vendor/github.com/containers/storage/images.go +++ b/vendor/github.com/containers/storage/images.go @@ -1,7 +1,6 @@ package storage import ( - "encoding/json" "io/ioutil" "os" "path/filepath" diff --git a/vendor/github.com/containers/storage/images_ffjson.go b/vendor/github.com/containers/storage/images_ffjson.go deleted file mode 100644 index e1954ad04..000000000 --- a/vendor/github.com/containers/storage/images_ffjson.go +++ /dev/null @@ -1,1418 +0,0 @@ -// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT. -// source: images.go - -package storage - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/opencontainers/go-digest" - fflib "github.com/pquerna/ffjson/fflib/v1" -) - -// MarshalJSON marshal bytes to json - template -func (j *Image) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *Image) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "id":`) - fflib.WriteJsonString(buf, string(j.ID)) - buf.WriteByte(',') - if len(j.Digest) != 0 { - buf.WriteString(`"digest":`) - fflib.WriteJsonString(buf, string(j.Digest)) - buf.WriteByte(',') - } - if len(j.Names) != 0 { - buf.WriteString(`"names":`) - if j.Names != nil { - buf.WriteString(`[`) - for i, v := range j.Names { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.NamesHistory) != 0 { - buf.WriteString(`"names-history":`) - if j.NamesHistory != nil { - buf.WriteString(`[`) - for i, v := range j.NamesHistory { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.TopLayer) != 0 { - buf.WriteString(`"layer":`) - fflib.WriteJsonString(buf, string(j.TopLayer)) - buf.WriteByte(',') - } - if len(j.MappedTopLayers) != 0 { - buf.WriteString(`"mapped-layers":`) - if j.MappedTopLayers != nil { - buf.WriteString(`[`) - for i, v := range j.MappedTopLayers { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.Metadata) != 0 { - buf.WriteString(`"metadata":`) - fflib.WriteJsonString(buf, string(j.Metadata)) - buf.WriteByte(',') - } - if len(j.BigDataNames) != 0 { - buf.WriteString(`"big-data-names":`) - if j.BigDataNames != nil { - buf.WriteString(`[`) - for i, v := range j.BigDataNames { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.BigDataSizes) != 0 { - if j.BigDataSizes == nil { - buf.WriteString(`"big-data-sizes":null`) - } else { - buf.WriteString(`"big-data-sizes":{ `) - for key, value := range j.BigDataSizes { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.FormatBits2(buf, uint64(value), 10, value < 0) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - buf.WriteByte(',') - } - if len(j.BigDataDigests) != 0 { - if j.BigDataDigests == nil { - buf.WriteString(`"big-data-digests":null`) - } else { - buf.WriteString(`"big-data-digests":{ `) - for key, value := range j.BigDataDigests { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.WriteJsonString(buf, string(value)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - buf.WriteByte(',') - } - if true { - buf.WriteString(`"created":`) - - { - - obj, err = j.Created.MarshalJSON() - if err != nil { - return err - } - buf.Write(obj) - - } - buf.WriteByte(',') - } - if len(j.Flags) != 0 { - buf.WriteString(`"flags":`) - /* Falling back. type=map[string]interface {} kind=map */ - err = buf.Encode(j.Flags) - if err != nil { - return err - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffjtImagebase = iota - ffjtImagenosuchkey - - ffjtImageID - - ffjtImageDigest - - ffjtImageNames - - ffjtImageNamesHistory - - ffjtImageTopLayer - - ffjtImageMappedTopLayers - - ffjtImageMetadata - - ffjtImageBigDataNames - - ffjtImageBigDataSizes - - ffjtImageBigDataDigests - - ffjtImageCreated - - ffjtImageFlags -) - -var ffjKeyImageID = []byte("id") - -var ffjKeyImageDigest = []byte("digest") - -var ffjKeyImageNames = []byte("names") - -var ffjKeyImageNamesHistory = []byte("names-history") - -var ffjKeyImageTopLayer = []byte("layer") - -var ffjKeyImageMappedTopLayers = []byte("mapped-layers") - -var ffjKeyImageMetadata = []byte("metadata") - -var ffjKeyImageBigDataNames = []byte("big-data-names") - -var ffjKeyImageBigDataSizes = []byte("big-data-sizes") - -var ffjKeyImageBigDataDigests = []byte("big-data-digests") - -var ffjKeyImageCreated = []byte("created") - -var ffjKeyImageFlags = []byte("flags") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *Image) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *Image) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtImagebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtImagenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'b': - - if bytes.Equal(ffjKeyImageBigDataNames, kn) { - currentKey = ffjtImageBigDataNames - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyImageBigDataSizes, kn) { - currentKey = ffjtImageBigDataSizes - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyImageBigDataDigests, kn) { - currentKey = ffjtImageBigDataDigests - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'c': - - if bytes.Equal(ffjKeyImageCreated, kn) { - currentKey = ffjtImageCreated - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'd': - - if bytes.Equal(ffjKeyImageDigest, kn) { - currentKey = ffjtImageDigest - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'f': - - if bytes.Equal(ffjKeyImageFlags, kn) { - currentKey = ffjtImageFlags - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'i': - - if bytes.Equal(ffjKeyImageID, kn) { - currentKey = ffjtImageID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'l': - - if bytes.Equal(ffjKeyImageTopLayer, kn) { - currentKey = ffjtImageTopLayer - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffjKeyImageMappedTopLayers, kn) { - currentKey = ffjtImageMappedTopLayers - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyImageMetadata, kn) { - currentKey = ffjtImageMetadata - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffjKeyImageNames, kn) { - currentKey = ffjtImageNames - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyImageNamesHistory, kn) { - currentKey = ffjtImageNamesHistory - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyImageFlags, kn) { - currentKey = ffjtImageFlags - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyImageCreated, kn) { - currentKey = ffjtImageCreated - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageBigDataDigests, kn) { - currentKey = ffjtImageBigDataDigests - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageBigDataSizes, kn) { - currentKey = ffjtImageBigDataSizes - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageBigDataNames, kn) { - currentKey = ffjtImageBigDataNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyImageMetadata, kn) { - currentKey = ffjtImageMetadata - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageMappedTopLayers, kn) { - currentKey = ffjtImageMappedTopLayers - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyImageTopLayer, kn) { - currentKey = ffjtImageTopLayer - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageNamesHistory, kn) { - currentKey = ffjtImageNamesHistory - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageNames, kn) { - currentKey = ffjtImageNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyImageDigest, kn) { - currentKey = ffjtImageDigest - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyImageID, kn) { - currentKey = ffjtImageID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtImagenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtImageID: - goto handle_ID - - case ffjtImageDigest: - goto handle_Digest - - case ffjtImageNames: - goto handle_Names - - case ffjtImageNamesHistory: - goto handle_NamesHistory - - case ffjtImageTopLayer: - goto handle_TopLayer - - case ffjtImageMappedTopLayers: - goto handle_MappedTopLayers - - case ffjtImageMetadata: - goto handle_Metadata - - case ffjtImageBigDataNames: - goto handle_BigDataNames - - case ffjtImageBigDataSizes: - goto handle_BigDataSizes - - case ffjtImageBigDataDigests: - goto handle_BigDataDigests - - case ffjtImageCreated: - goto handle_Created - - case ffjtImageFlags: - goto handle_Flags - - case ffjtImagenosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_ID: - - /* handler: j.ID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.ID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Digest: - - /* handler: j.Digest type=digest.Digest kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Digest", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.Digest = digest.Digest(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Names: - - /* handler: j.Names type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.Names = nil - } else { - - j.Names = []string{} - - wantVal := true - - for { - - var tmpJNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJNames = string(string(outBuf)) - - } - } - - j.Names = append(j.Names, tmpJNames) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_NamesHistory: - - /* handler: j.NamesHistory type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.NamesHistory = nil - } else { - - j.NamesHistory = []string{} - - wantVal := true - - for { - - var tmpJNamesHistory string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJNamesHistory type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJNamesHistory = string(string(outBuf)) - - } - } - - j.NamesHistory = append(j.NamesHistory, tmpJNamesHistory) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_TopLayer: - - /* handler: j.TopLayer type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.TopLayer = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_MappedTopLayers: - - /* handler: j.MappedTopLayers type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.MappedTopLayers = nil - } else { - - j.MappedTopLayers = []string{} - - wantVal := true - - for { - - var tmpJMappedTopLayers string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJMappedTopLayers type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJMappedTopLayers = string(string(outBuf)) - - } - } - - j.MappedTopLayers = append(j.MappedTopLayers, tmpJMappedTopLayers) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Metadata: - - /* handler: j.Metadata type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.Metadata = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataNames: - - /* handler: j.BigDataNames type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataNames = nil - } else { - - j.BigDataNames = []string{} - - wantVal := true - - for { - - var tmpJBigDataNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJBigDataNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJBigDataNames = string(string(outBuf)) - - } - } - - j.BigDataNames = append(j.BigDataNames, tmpJBigDataNames) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataSizes: - - /* handler: j.BigDataSizes type=map[string]int64 kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataSizes = nil - } else { - - j.BigDataSizes = make(map[string]int64, 0) - - wantVal := true - - for { - - var k string - - var tmpJBigDataSizes int64 - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJBigDataSizes type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - tmpJBigDataSizes = int64(tval) - - } - } - - j.BigDataSizes[k] = tmpJBigDataSizes - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataDigests: - - /* handler: j.BigDataDigests type=map[string]digest.Digest kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataDigests = nil - } else { - - j.BigDataDigests = make(map[string]digest.Digest, 0) - - wantVal := true - - for { - - var k string - - var tmpJBigDataDigests digest.Digest - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJBigDataDigests type=digest.Digest kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Digest", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJBigDataDigests = digest.Digest(string(outBuf)) - - } - } - - j.BigDataDigests[k] = tmpJBigDataDigests - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Created: - - /* handler: j.Created type=time.Time kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - } else { - - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = j.Created.UnmarshalJSON(tbuf) - if err != nil { - return fs.WrapErr(err) - } - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Flags: - - /* handler: j.Flags type=map[string]interface {} kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.Flags = nil - } else { - - j.Flags = make(map[string]interface{}, 0) - - wantVal := true - - for { - - var k string - - var tmpJFlags interface{} - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJFlags type=interface {} kind=interface quoted=false*/ - - { - /* Falling back. type=interface {} kind=interface */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJFlags) - if err != nil { - return fs.WrapErr(err) - } - } - - j.Flags[k] = tmpJFlags - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *imageStore) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *imageStore) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{}`) - return nil -} - -const ( - ffjtimageStorebase = iota - ffjtimageStorenosuchkey -) - -// UnmarshalJSON umarshall json - template of ffjson -func (j *imageStore) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *imageStore) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtimageStorebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtimageStorenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - } - - currentKey = ffjtimageStorenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtimageStorenosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} diff --git a/vendor/github.com/containers/storage/jsoniter.go b/vendor/github.com/containers/storage/jsoniter.go new file mode 100644 index 000000000..7dd6388d7 --- /dev/null +++ b/vendor/github.com/containers/storage/jsoniter.go @@ -0,0 +1,5 @@ +package storage + +import jsoniter "github.com/json-iterator/go" + +var json = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/vendor/github.com/containers/storage/layers.go b/vendor/github.com/containers/storage/layers.go index d398a3ff9..b0cea50d0 100644 --- a/vendor/github.com/containers/storage/layers.go +++ b/vendor/github.com/containers/storage/layers.go @@ -2,7 +2,6 @@ package storage import ( "bytes" - "encoding/json" "fmt" "io" "io/ioutil" diff --git a/vendor/github.com/containers/storage/layers_ffjson.go b/vendor/github.com/containers/storage/layers_ffjson.go deleted file mode 100644 index f61e68a21..000000000 --- a/vendor/github.com/containers/storage/layers_ffjson.go +++ /dev/null @@ -1,2267 +0,0 @@ -// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT. -// source: layers.go - -package storage - -import ( - "bytes" - "encoding/json" - "fmt" - "github.com/containers/storage/pkg/archive" - "github.com/containers/storage/pkg/idtools" - "github.com/opencontainers/go-digest" - fflib "github.com/pquerna/ffjson/fflib/v1" -) - -// MarshalJSON marshal bytes to json - template -func (j *DiffOptions) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *DiffOptions) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - if j.Compression != nil { - buf.WriteString(`{"Compression":`) - fflib.FormatBits2(buf, uint64(*j.Compression), 10, *j.Compression < 0) - } else { - buf.WriteString(`{"Compression":null`) - } - buf.WriteByte('}') - return nil -} - -const ( - ffjtDiffOptionsbase = iota - ffjtDiffOptionsnosuchkey - - ffjtDiffOptionsCompression -) - -var ffjKeyDiffOptionsCompression = []byte("Compression") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *DiffOptions) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *DiffOptions) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtDiffOptionsbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtDiffOptionsnosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'C': - - if bytes.Equal(ffjKeyDiffOptionsCompression, kn) { - currentKey = ffjtDiffOptionsCompression - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyDiffOptionsCompression, kn) { - currentKey = ffjtDiffOptionsCompression - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtDiffOptionsnosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtDiffOptionsCompression: - goto handle_Compression - - case ffjtDiffOptionsnosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Compression: - - /* handler: j.Compression type=archive.Compression kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Compression", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - j.Compression = nil - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := archive.Compression(tval) - j.Compression = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *Layer) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *Layer) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{ "id":`) - fflib.WriteJsonString(buf, string(j.ID)) - buf.WriteByte(',') - if len(j.Names) != 0 { - buf.WriteString(`"names":`) - if j.Names != nil { - buf.WriteString(`[`) - for i, v := range j.Names { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.Parent) != 0 { - buf.WriteString(`"parent":`) - fflib.WriteJsonString(buf, string(j.Parent)) - buf.WriteByte(',') - } - if len(j.Metadata) != 0 { - buf.WriteString(`"metadata":`) - fflib.WriteJsonString(buf, string(j.Metadata)) - buf.WriteByte(',') - } - if len(j.MountLabel) != 0 { - buf.WriteString(`"mountlabel":`) - fflib.WriteJsonString(buf, string(j.MountLabel)) - buf.WriteByte(',') - } - if true { - buf.WriteString(`"created":`) - - { - - obj, err = j.Created.MarshalJSON() - if err != nil { - return err - } - buf.Write(obj) - - } - buf.WriteByte(',') - } - if len(j.CompressedDigest) != 0 { - buf.WriteString(`"compressed-diff-digest":`) - fflib.WriteJsonString(buf, string(j.CompressedDigest)) - buf.WriteByte(',') - } - if j.CompressedSize != 0 { - buf.WriteString(`"compressed-size":`) - fflib.FormatBits2(buf, uint64(j.CompressedSize), 10, j.CompressedSize < 0) - buf.WriteByte(',') - } - if len(j.UncompressedDigest) != 0 { - buf.WriteString(`"diff-digest":`) - fflib.WriteJsonString(buf, string(j.UncompressedDigest)) - buf.WriteByte(',') - } - if j.UncompressedSize != 0 { - buf.WriteString(`"diff-size":`) - fflib.FormatBits2(buf, uint64(j.UncompressedSize), 10, j.UncompressedSize < 0) - buf.WriteByte(',') - } - if j.CompressionType != 0 { - buf.WriteString(`"compression":`) - fflib.FormatBits2(buf, uint64(j.CompressionType), 10, j.CompressionType < 0) - buf.WriteByte(',') - } - if len(j.UIDs) != 0 { - buf.WriteString(`"uidset":`) - if j.UIDs != nil { - buf.WriteString(`[`) - for i, v := range j.UIDs { - if i != 0 { - buf.WriteString(`,`) - } - fflib.FormatBits2(buf, uint64(v), 10, false) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.GIDs) != 0 { - buf.WriteString(`"gidset":`) - if j.GIDs != nil { - buf.WriteString(`[`) - for i, v := range j.GIDs { - if i != 0 { - buf.WriteString(`,`) - } - fflib.FormatBits2(buf, uint64(v), 10, false) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.Flags) != 0 { - buf.WriteString(`"flags":`) - /* Falling back. type=map[string]interface {} kind=map */ - err = buf.Encode(j.Flags) - if err != nil { - return err - } - buf.WriteByte(',') - } - if len(j.UIDMap) != 0 { - buf.WriteString(`"uidmap":`) - if j.UIDMap != nil { - buf.WriteString(`[`) - for i, v := range j.UIDMap { - if i != 0 { - buf.WriteString(`,`) - } - /* Struct fall back. type=idtools.IDMap kind=struct */ - err = buf.Encode(&v) - if err != nil { - return err - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.GIDMap) != 0 { - buf.WriteString(`"gidmap":`) - if j.GIDMap != nil { - buf.WriteString(`[`) - for i, v := range j.GIDMap { - if i != 0 { - buf.WriteString(`,`) - } - /* Struct fall back. type=idtools.IDMap kind=struct */ - err = buf.Encode(&v) - if err != nil { - return err - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - if len(j.BigDataNames) != 0 { - buf.WriteString(`"big-data-names":`) - if j.BigDataNames != nil { - buf.WriteString(`[`) - for i, v := range j.BigDataNames { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - return nil -} - -const ( - ffjtLayerbase = iota - ffjtLayernosuchkey - - ffjtLayerID - - ffjtLayerNames - - ffjtLayerParent - - ffjtLayerMetadata - - ffjtLayerMountLabel - - ffjtLayerCreated - - ffjtLayerCompressedDigest - - ffjtLayerCompressedSize - - ffjtLayerUncompressedDigest - - ffjtLayerUncompressedSize - - ffjtLayerCompressionType - - ffjtLayerUIDs - - ffjtLayerGIDs - - ffjtLayerFlags - - ffjtLayerUIDMap - - ffjtLayerGIDMap - - ffjtLayerBigDataNames -) - -var ffjKeyLayerID = []byte("id") - -var ffjKeyLayerNames = []byte("names") - -var ffjKeyLayerParent = []byte("parent") - -var ffjKeyLayerMetadata = []byte("metadata") - -var ffjKeyLayerMountLabel = []byte("mountlabel") - -var ffjKeyLayerCreated = []byte("created") - -var ffjKeyLayerCompressedDigest = []byte("compressed-diff-digest") - -var ffjKeyLayerCompressedSize = []byte("compressed-size") - -var ffjKeyLayerUncompressedDigest = []byte("diff-digest") - -var ffjKeyLayerUncompressedSize = []byte("diff-size") - -var ffjKeyLayerCompressionType = []byte("compression") - -var ffjKeyLayerUIDs = []byte("uidset") - -var ffjKeyLayerGIDs = []byte("gidset") - -var ffjKeyLayerFlags = []byte("flags") - -var ffjKeyLayerUIDMap = []byte("uidmap") - -var ffjKeyLayerGIDMap = []byte("gidmap") - -var ffjKeyLayerBigDataNames = []byte("big-data-names") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *Layer) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *Layer) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtLayerbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtLayernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'b': - - if bytes.Equal(ffjKeyLayerBigDataNames, kn) { - currentKey = ffjtLayerBigDataNames - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'c': - - if bytes.Equal(ffjKeyLayerCreated, kn) { - currentKey = ffjtLayerCreated - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerCompressedDigest, kn) { - currentKey = ffjtLayerCompressedDigest - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerCompressedSize, kn) { - currentKey = ffjtLayerCompressedSize - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerCompressionType, kn) { - currentKey = ffjtLayerCompressionType - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'd': - - if bytes.Equal(ffjKeyLayerUncompressedDigest, kn) { - currentKey = ffjtLayerUncompressedDigest - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerUncompressedSize, kn) { - currentKey = ffjtLayerUncompressedSize - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'f': - - if bytes.Equal(ffjKeyLayerFlags, kn) { - currentKey = ffjtLayerFlags - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'g': - - if bytes.Equal(ffjKeyLayerGIDs, kn) { - currentKey = ffjtLayerGIDs - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerGIDMap, kn) { - currentKey = ffjtLayerGIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'i': - - if bytes.Equal(ffjKeyLayerID, kn) { - currentKey = ffjtLayerID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'm': - - if bytes.Equal(ffjKeyLayerMetadata, kn) { - currentKey = ffjtLayerMetadata - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerMountLabel, kn) { - currentKey = ffjtLayerMountLabel - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'n': - - if bytes.Equal(ffjKeyLayerNames, kn) { - currentKey = ffjtLayerNames - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffjKeyLayerParent, kn) { - currentKey = ffjtLayerParent - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'u': - - if bytes.Equal(ffjKeyLayerUIDs, kn) { - currentKey = ffjtLayerUIDs - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyLayerUIDMap, kn) { - currentKey = ffjtLayerUIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyLayerBigDataNames, kn) { - currentKey = ffjtLayerBigDataNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerGIDMap, kn) { - currentKey = ffjtLayerGIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerUIDMap, kn) { - currentKey = ffjtLayerUIDMap - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerFlags, kn) { - currentKey = ffjtLayerFlags - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerGIDs, kn) { - currentKey = ffjtLayerGIDs - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerUIDs, kn) { - currentKey = ffjtLayerUIDs - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerCompressionType, kn) { - currentKey = ffjtLayerCompressionType - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerUncompressedSize, kn) { - currentKey = ffjtLayerUncompressedSize - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerUncompressedDigest, kn) { - currentKey = ffjtLayerUncompressedDigest - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerCompressedSize, kn) { - currentKey = ffjtLayerCompressedSize - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerCompressedDigest, kn) { - currentKey = ffjtLayerCompressedDigest - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerCreated, kn) { - currentKey = ffjtLayerCreated - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerMountLabel, kn) { - currentKey = ffjtLayerMountLabel - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerMetadata, kn) { - currentKey = ffjtLayerMetadata - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerParent, kn) { - currentKey = ffjtLayerParent - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyLayerNames, kn) { - currentKey = ffjtLayerNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyLayerID, kn) { - currentKey = ffjtLayerID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtLayernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtLayerID: - goto handle_ID - - case ffjtLayerNames: - goto handle_Names - - case ffjtLayerParent: - goto handle_Parent - - case ffjtLayerMetadata: - goto handle_Metadata - - case ffjtLayerMountLabel: - goto handle_MountLabel - - case ffjtLayerCreated: - goto handle_Created - - case ffjtLayerCompressedDigest: - goto handle_CompressedDigest - - case ffjtLayerCompressedSize: - goto handle_CompressedSize - - case ffjtLayerUncompressedDigest: - goto handle_UncompressedDigest - - case ffjtLayerUncompressedSize: - goto handle_UncompressedSize - - case ffjtLayerCompressionType: - goto handle_CompressionType - - case ffjtLayerUIDs: - goto handle_UIDs - - case ffjtLayerGIDs: - goto handle_GIDs - - case ffjtLayerFlags: - goto handle_Flags - - case ffjtLayerUIDMap: - goto handle_UIDMap - - case ffjtLayerGIDMap: - goto handle_GIDMap - - case ffjtLayerBigDataNames: - goto handle_BigDataNames - - case ffjtLayernosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_ID: - - /* handler: j.ID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.ID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Names: - - /* handler: j.Names type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.Names = nil - } else { - - j.Names = []string{} - - wantVal := true - - for { - - var tmpJNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJNames = string(string(outBuf)) - - } - } - - j.Names = append(j.Names, tmpJNames) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Parent: - - /* handler: j.Parent type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.Parent = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Metadata: - - /* handler: j.Metadata type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.Metadata = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_MountLabel: - - /* handler: j.MountLabel type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.MountLabel = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Created: - - /* handler: j.Created type=time.Time kind=struct quoted=false*/ - - { - if tok == fflib.FFTok_null { - - } else { - - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = j.Created.UnmarshalJSON(tbuf) - if err != nil { - return fs.WrapErr(err) - } - } - state = fflib.FFParse_after_value - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CompressedDigest: - - /* handler: j.CompressedDigest type=digest.Digest kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Digest", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.CompressedDigest = digest.Digest(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CompressedSize: - - /* handler: j.CompressedSize type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.CompressedSize = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UncompressedDigest: - - /* handler: j.UncompressedDigest type=digest.Digest kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Digest", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.UncompressedDigest = digest.Digest(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UncompressedSize: - - /* handler: j.UncompressedSize type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.UncompressedSize = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CompressionType: - - /* handler: j.CompressionType type=archive.Compression kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Compression", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.CompressionType = archive.Compression(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UIDs: - - /* handler: j.UIDs type=[]uint32 kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.UIDs = nil - } else { - - j.UIDs = []uint32{} - - wantVal := true - - for { - - var tmpJUIDs uint32 - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJUIDs type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - tmpJUIDs = uint32(tval) - - } - } - - j.UIDs = append(j.UIDs, tmpJUIDs) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GIDs: - - /* handler: j.GIDs type=[]uint32 kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.GIDs = nil - } else { - - j.GIDs = []uint32{} - - wantVal := true - - for { - - var tmpJGIDs uint32 - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJGIDs type=uint32 kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint32", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - tmpJGIDs = uint32(tval) - - } - } - - j.GIDs = append(j.GIDs, tmpJGIDs) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Flags: - - /* handler: j.Flags type=map[string]interface {} kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.Flags = nil - } else { - - j.Flags = make(map[string]interface{}, 0) - - wantVal := true - - for { - - var k string - - var tmpJFlags interface{} - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJFlags type=interface {} kind=interface quoted=false*/ - - { - /* Falling back. type=interface {} kind=interface */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJFlags) - if err != nil { - return fs.WrapErr(err) - } - } - - j.Flags[k] = tmpJFlags - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UIDMap: - - /* handler: j.UIDMap type=[]idtools.IDMap kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.UIDMap = nil - } else { - - j.UIDMap = []idtools.IDMap{} - - wantVal := true - - for { - - var tmpJUIDMap idtools.IDMap - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJUIDMap type=idtools.IDMap kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMap kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJUIDMap) - if err != nil { - return fs.WrapErr(err) - } - } - - j.UIDMap = append(j.UIDMap, tmpJUIDMap) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GIDMap: - - /* handler: j.GIDMap type=[]idtools.IDMap kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.GIDMap = nil - } else { - - j.GIDMap = []idtools.IDMap{} - - wantVal := true - - for { - - var tmpJGIDMap idtools.IDMap - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJGIDMap type=idtools.IDMap kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMap kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJGIDMap) - if err != nil { - return fs.WrapErr(err) - } - } - - j.GIDMap = append(j.GIDMap, tmpJGIDMap) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_BigDataNames: - - /* handler: j.BigDataNames type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.BigDataNames = nil - } else { - - j.BigDataNames = []string{} - - wantVal := true - - for { - - var tmpJBigDataNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJBigDataNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJBigDataNames = string(string(outBuf)) - - } - } - - j.BigDataNames = append(j.BigDataNames, tmpJBigDataNames) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *layerMountPoint) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *layerMountPoint) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"id":`) - fflib.WriteJsonString(buf, string(j.ID)) - buf.WriteString(`,"path":`) - fflib.WriteJsonString(buf, string(j.MountPoint)) - buf.WriteString(`,"count":`) - fflib.FormatBits2(buf, uint64(j.MountCount), 10, j.MountCount < 0) - buf.WriteByte('}') - return nil -} - -const ( - ffjtlayerMountPointbase = iota - ffjtlayerMountPointnosuchkey - - ffjtlayerMountPointID - - ffjtlayerMountPointMountPoint - - ffjtlayerMountPointMountCount -) - -var ffjKeylayerMountPointID = []byte("id") - -var ffjKeylayerMountPointMountPoint = []byte("path") - -var ffjKeylayerMountPointMountCount = []byte("count") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *layerMountPoint) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *layerMountPoint) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtlayerMountPointbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtlayerMountPointnosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'c': - - if bytes.Equal(ffjKeylayerMountPointMountCount, kn) { - currentKey = ffjtlayerMountPointMountCount - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'i': - - if bytes.Equal(ffjKeylayerMountPointID, kn) { - currentKey = ffjtlayerMountPointID - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'p': - - if bytes.Equal(ffjKeylayerMountPointMountPoint, kn) { - currentKey = ffjtlayerMountPointMountPoint - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.SimpleLetterEqualFold(ffjKeylayerMountPointMountCount, kn) { - currentKey = ffjtlayerMountPointMountCount - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeylayerMountPointMountPoint, kn) { - currentKey = ffjtlayerMountPointMountPoint - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeylayerMountPointID, kn) { - currentKey = ffjtlayerMountPointID - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtlayerMountPointnosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtlayerMountPointID: - goto handle_ID - - case ffjtlayerMountPointMountPoint: - goto handle_MountPoint - - case ffjtlayerMountPointMountCount: - goto handle_MountCount - - case ffjtlayerMountPointnosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_ID: - - /* handler: j.ID type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.ID = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_MountPoint: - - /* handler: j.MountPoint type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - j.MountPoint = string(string(outBuf)) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_MountCount: - - /* handler: j.MountCount type=int kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.MountCount = int(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *layerStore) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *layerStore) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{}`) - return nil -} - -const ( - ffjtlayerStorebase = iota - ffjtlayerStorenosuchkey -) - -// UnmarshalJSON umarshall json - template of ffjson -func (j *layerStore) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *layerStore) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtlayerStorebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtlayerStorenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - } - - currentKey = ffjtlayerStorenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtlayerStorenosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *simpleGetCloser) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *simpleGetCloser) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{}`) - return nil -} - -const ( - ffjtsimpleGetCloserbase = iota - ffjtsimpleGetClosernosuchkey -) - -// UnmarshalJSON umarshall json - template of ffjson -func (j *simpleGetCloser) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *simpleGetCloser) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtsimpleGetCloserbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtsimpleGetClosernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - } - - currentKey = ffjtsimpleGetClosernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtsimpleGetClosernosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} diff --git a/vendor/github.com/containers/storage/pkg/archive/archive_ffjson.go b/vendor/github.com/containers/storage/pkg/archive/archive_ffjson.go deleted file mode 100644 index c420ca358..000000000 --- a/vendor/github.com/containers/storage/pkg/archive/archive_ffjson.go +++ /dev/null @@ -1,2465 +0,0 @@ -// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT. -// source: pkg/archive/archive.go - -package archive - -import ( - "bytes" - "encoding/json" - "errors" - "fmt" - "github.com/containers/storage/pkg/idtools" - fflib "github.com/pquerna/ffjson/fflib/v1" - "os" -) - -// MarshalJSON marshal bytes to json - template -func (j *Archiver) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *Archiver) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"Untar":`) - /* Falling back. type=func(io.Reader, string, *archive.TarOptions) error kind=func */ - err = buf.Encode(j.Untar) - if err != nil { - return err - } - if j.TarIDMappings != nil { - /* Struct fall back. type=idtools.IDMappings kind=struct */ - buf.WriteString(`,"TarIDMappings":`) - err = buf.Encode(j.TarIDMappings) - if err != nil { - return err - } - } else { - buf.WriteString(`,"TarIDMappings":null`) - } - if j.ChownOpts != nil { - /* Struct fall back. type=idtools.IDPair kind=struct */ - buf.WriteString(`,"ChownOpts":`) - err = buf.Encode(j.ChownOpts) - if err != nil { - return err - } - } else { - buf.WriteString(`,"ChownOpts":null`) - } - if j.UntarIDMappings != nil { - /* Struct fall back. type=idtools.IDMappings kind=struct */ - buf.WriteString(`,"UntarIDMappings":`) - err = buf.Encode(j.UntarIDMappings) - if err != nil { - return err - } - } else { - buf.WriteString(`,"UntarIDMappings":null`) - } - buf.WriteByte('}') - return nil -} - -const ( - ffjtArchiverbase = iota - ffjtArchivernosuchkey - - ffjtArchiverUntar - - ffjtArchiverTarIDMappings - - ffjtArchiverChownOpts - - ffjtArchiverUntarIDMappings -) - -var ffjKeyArchiverUntar = []byte("Untar") - -var ffjKeyArchiverTarIDMappings = []byte("TarIDMappings") - -var ffjKeyArchiverChownOpts = []byte("ChownOpts") - -var ffjKeyArchiverUntarIDMappings = []byte("UntarIDMappings") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *Archiver) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *Archiver) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtArchiverbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtArchivernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'C': - - if bytes.Equal(ffjKeyArchiverChownOpts, kn) { - currentKey = ffjtArchiverChownOpts - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'T': - - if bytes.Equal(ffjKeyArchiverTarIDMappings, kn) { - currentKey = ffjtArchiverTarIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'U': - - if bytes.Equal(ffjKeyArchiverUntar, kn) { - currentKey = ffjtArchiverUntar - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyArchiverUntarIDMappings, kn) { - currentKey = ffjtArchiverUntarIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyArchiverUntarIDMappings, kn) { - currentKey = ffjtArchiverUntarIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyArchiverChownOpts, kn) { - currentKey = ffjtArchiverChownOpts - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyArchiverTarIDMappings, kn) { - currentKey = ffjtArchiverTarIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyArchiverUntar, kn) { - currentKey = ffjtArchiverUntar - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtArchivernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtArchiverUntar: - goto handle_Untar - - case ffjtArchiverTarIDMappings: - goto handle_TarIDMappings - - case ffjtArchiverChownOpts: - goto handle_ChownOpts - - case ffjtArchiverUntarIDMappings: - goto handle_UntarIDMappings - - case ffjtArchivernosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Untar: - - /* handler: j.Untar type=func(io.Reader, string, *archive.TarOptions) error kind=func quoted=false*/ - - { - /* Falling back. type=func(io.Reader, string, *archive.TarOptions) error kind=func */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.Untar) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_TarIDMappings: - - /* handler: j.TarIDMappings type=idtools.IDMappings kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMappings kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.TarIDMappings) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ChownOpts: - - /* handler: j.ChownOpts type=idtools.IDPair kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDPair kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.ChownOpts) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UntarIDMappings: - - /* handler: j.UntarIDMappings type=idtools.IDMappings kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMappings kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.UntarIDMappings) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *TarOptions) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *TarOptions) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"IncludeFiles":`) - if j.IncludeFiles != nil { - buf.WriteString(`[`) - for i, v := range j.IncludeFiles { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteString(`,"ExcludePatterns":`) - if j.ExcludePatterns != nil { - buf.WriteString(`[`) - for i, v := range j.ExcludePatterns { - if i != 0 { - buf.WriteString(`,`) - } - fflib.WriteJsonString(buf, string(v)) - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteString(`,"Compression":`) - fflib.FormatBits2(buf, uint64(j.Compression), 10, j.Compression < 0) - if j.NoLchown { - buf.WriteString(`,"NoLchown":true`) - } else { - buf.WriteString(`,"NoLchown":false`) - } - buf.WriteString(`,"UIDMaps":`) - if j.UIDMaps != nil { - buf.WriteString(`[`) - for i, v := range j.UIDMaps { - if i != 0 { - buf.WriteString(`,`) - } - /* Struct fall back. type=idtools.IDMap kind=struct */ - err = buf.Encode(&v) - if err != nil { - return err - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - buf.WriteString(`,"GIDMaps":`) - if j.GIDMaps != nil { - buf.WriteString(`[`) - for i, v := range j.GIDMaps { - if i != 0 { - buf.WriteString(`,`) - } - /* Struct fall back. type=idtools.IDMap kind=struct */ - err = buf.Encode(&v) - if err != nil { - return err - } - } - buf.WriteString(`]`) - } else { - buf.WriteString(`null`) - } - if j.IgnoreChownErrors { - buf.WriteString(`,"IgnoreChownErrors":true`) - } else { - buf.WriteString(`,"IgnoreChownErrors":false`) - } - if j.ChownOpts != nil { - /* Struct fall back. type=idtools.IDPair kind=struct */ - buf.WriteString(`,"ChownOpts":`) - err = buf.Encode(j.ChownOpts) - if err != nil { - return err - } - } else { - buf.WriteString(`,"ChownOpts":null`) - } - if j.IncludeSourceDir { - buf.WriteString(`,"IncludeSourceDir":true`) - } else { - buf.WriteString(`,"IncludeSourceDir":false`) - } - buf.WriteString(`,"WhiteoutFormat":`) - fflib.FormatBits2(buf, uint64(j.WhiteoutFormat), 10, j.WhiteoutFormat < 0) - buf.WriteString(`,"WhiteoutData":`) - /* Interface types must use runtime reflection. type=interface {} kind=interface */ - err = buf.Encode(j.WhiteoutData) - if err != nil { - return err - } - if j.NoOverwriteDirNonDir { - buf.WriteString(`,"NoOverwriteDirNonDir":true`) - } else { - buf.WriteString(`,"NoOverwriteDirNonDir":false`) - } - if j.RebaseNames == nil { - buf.WriteString(`,"RebaseNames":null`) - } else { - buf.WriteString(`,"RebaseNames":{ `) - for key, value := range j.RebaseNames { - fflib.WriteJsonString(buf, key) - buf.WriteString(`:`) - fflib.WriteJsonString(buf, string(value)) - buf.WriteByte(',') - } - buf.Rewind(1) - buf.WriteByte('}') - } - if j.InUserNS { - buf.WriteString(`,"InUserNS":true`) - } else { - buf.WriteString(`,"InUserNS":false`) - } - if j.CopyPass { - buf.WriteString(`,"CopyPass":true`) - } else { - buf.WriteString(`,"CopyPass":false`) - } - if j.ForceMask != nil { - buf.WriteString(`,"ForceMask":`) - fflib.FormatBits2(buf, uint64(*j.ForceMask), 10, false) - } else { - buf.WriteString(`,"ForceMask":null`) - } - buf.WriteByte('}') - return nil -} - -const ( - ffjtTarOptionsbase = iota - ffjtTarOptionsnosuchkey - - ffjtTarOptionsIncludeFiles - - ffjtTarOptionsExcludePatterns - - ffjtTarOptionsCompression - - ffjtTarOptionsNoLchown - - ffjtTarOptionsUIDMaps - - ffjtTarOptionsGIDMaps - - ffjtTarOptionsIgnoreChownErrors - - ffjtTarOptionsChownOpts - - ffjtTarOptionsIncludeSourceDir - - ffjtTarOptionsWhiteoutFormat - - ffjtTarOptionsWhiteoutData - - ffjtTarOptionsNoOverwriteDirNonDir - - ffjtTarOptionsRebaseNames - - ffjtTarOptionsInUserNS - - ffjtTarOptionsCopyPass - - ffjtTarOptionsForceMask -) - -var ffjKeyTarOptionsIncludeFiles = []byte("IncludeFiles") - -var ffjKeyTarOptionsExcludePatterns = []byte("ExcludePatterns") - -var ffjKeyTarOptionsCompression = []byte("Compression") - -var ffjKeyTarOptionsNoLchown = []byte("NoLchown") - -var ffjKeyTarOptionsUIDMaps = []byte("UIDMaps") - -var ffjKeyTarOptionsGIDMaps = []byte("GIDMaps") - -var ffjKeyTarOptionsIgnoreChownErrors = []byte("IgnoreChownErrors") - -var ffjKeyTarOptionsChownOpts = []byte("ChownOpts") - -var ffjKeyTarOptionsIncludeSourceDir = []byte("IncludeSourceDir") - -var ffjKeyTarOptionsWhiteoutFormat = []byte("WhiteoutFormat") - -var ffjKeyTarOptionsWhiteoutData = []byte("WhiteoutData") - -var ffjKeyTarOptionsNoOverwriteDirNonDir = []byte("NoOverwriteDirNonDir") - -var ffjKeyTarOptionsRebaseNames = []byte("RebaseNames") - -var ffjKeyTarOptionsInUserNS = []byte("InUserNS") - -var ffjKeyTarOptionsCopyPass = []byte("CopyPass") - -var ffjKeyTarOptionsForceMask = []byte("ForceMask") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *TarOptions) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *TarOptions) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtTarOptionsbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtTarOptionsnosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'C': - - if bytes.Equal(ffjKeyTarOptionsCompression, kn) { - currentKey = ffjtTarOptionsCompression - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsChownOpts, kn) { - currentKey = ffjtTarOptionsChownOpts - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsCopyPass, kn) { - currentKey = ffjtTarOptionsCopyPass - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'E': - - if bytes.Equal(ffjKeyTarOptionsExcludePatterns, kn) { - currentKey = ffjtTarOptionsExcludePatterns - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'F': - - if bytes.Equal(ffjKeyTarOptionsForceMask, kn) { - currentKey = ffjtTarOptionsForceMask - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'G': - - if bytes.Equal(ffjKeyTarOptionsGIDMaps, kn) { - currentKey = ffjtTarOptionsGIDMaps - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'I': - - if bytes.Equal(ffjKeyTarOptionsIncludeFiles, kn) { - currentKey = ffjtTarOptionsIncludeFiles - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsIgnoreChownErrors, kn) { - currentKey = ffjtTarOptionsIgnoreChownErrors - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsIncludeSourceDir, kn) { - currentKey = ffjtTarOptionsIncludeSourceDir - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsInUserNS, kn) { - currentKey = ffjtTarOptionsInUserNS - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'N': - - if bytes.Equal(ffjKeyTarOptionsNoLchown, kn) { - currentKey = ffjtTarOptionsNoLchown - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsNoOverwriteDirNonDir, kn) { - currentKey = ffjtTarOptionsNoOverwriteDirNonDir - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'R': - - if bytes.Equal(ffjKeyTarOptionsRebaseNames, kn) { - currentKey = ffjtTarOptionsRebaseNames - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'U': - - if bytes.Equal(ffjKeyTarOptionsUIDMaps, kn) { - currentKey = ffjtTarOptionsUIDMaps - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'W': - - if bytes.Equal(ffjKeyTarOptionsWhiteoutFormat, kn) { - currentKey = ffjtTarOptionsWhiteoutFormat - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeyTarOptionsWhiteoutData, kn) { - currentKey = ffjtTarOptionsWhiteoutData - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsForceMask, kn) { - currentKey = ffjtTarOptionsForceMask - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsCopyPass, kn) { - currentKey = ffjtTarOptionsCopyPass - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsInUserNS, kn) { - currentKey = ffjtTarOptionsInUserNS - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsRebaseNames, kn) { - currentKey = ffjtTarOptionsRebaseNames - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyTarOptionsNoOverwriteDirNonDir, kn) { - currentKey = ffjtTarOptionsNoOverwriteDirNonDir - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyTarOptionsWhiteoutData, kn) { - currentKey = ffjtTarOptionsWhiteoutData - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyTarOptionsWhiteoutFormat, kn) { - currentKey = ffjtTarOptionsWhiteoutFormat - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsIncludeSourceDir, kn) { - currentKey = ffjtTarOptionsIncludeSourceDir - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsChownOpts, kn) { - currentKey = ffjtTarOptionsChownOpts - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsIgnoreChownErrors, kn) { - currentKey = ffjtTarOptionsIgnoreChownErrors - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsGIDMaps, kn) { - currentKey = ffjtTarOptionsGIDMaps - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsUIDMaps, kn) { - currentKey = ffjtTarOptionsUIDMaps - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeyTarOptionsNoLchown, kn) { - currentKey = ffjtTarOptionsNoLchown - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsCompression, kn) { - currentKey = ffjtTarOptionsCompression - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsExcludePatterns, kn) { - currentKey = ffjtTarOptionsExcludePatterns - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeyTarOptionsIncludeFiles, kn) { - currentKey = ffjtTarOptionsIncludeFiles - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtTarOptionsnosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtTarOptionsIncludeFiles: - goto handle_IncludeFiles - - case ffjtTarOptionsExcludePatterns: - goto handle_ExcludePatterns - - case ffjtTarOptionsCompression: - goto handle_Compression - - case ffjtTarOptionsNoLchown: - goto handle_NoLchown - - case ffjtTarOptionsUIDMaps: - goto handle_UIDMaps - - case ffjtTarOptionsGIDMaps: - goto handle_GIDMaps - - case ffjtTarOptionsIgnoreChownErrors: - goto handle_IgnoreChownErrors - - case ffjtTarOptionsChownOpts: - goto handle_ChownOpts - - case ffjtTarOptionsIncludeSourceDir: - goto handle_IncludeSourceDir - - case ffjtTarOptionsWhiteoutFormat: - goto handle_WhiteoutFormat - - case ffjtTarOptionsWhiteoutData: - goto handle_WhiteoutData - - case ffjtTarOptionsNoOverwriteDirNonDir: - goto handle_NoOverwriteDirNonDir - - case ffjtTarOptionsRebaseNames: - goto handle_RebaseNames - - case ffjtTarOptionsInUserNS: - goto handle_InUserNS - - case ffjtTarOptionsCopyPass: - goto handle_CopyPass - - case ffjtTarOptionsForceMask: - goto handle_ForceMask - - case ffjtTarOptionsnosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_IncludeFiles: - - /* handler: j.IncludeFiles type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.IncludeFiles = nil - } else { - - j.IncludeFiles = []string{} - - wantVal := true - - for { - - var tmpJIncludeFiles string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJIncludeFiles type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJIncludeFiles = string(string(outBuf)) - - } - } - - j.IncludeFiles = append(j.IncludeFiles, tmpJIncludeFiles) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ExcludePatterns: - - /* handler: j.ExcludePatterns type=[]string kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.ExcludePatterns = nil - } else { - - j.ExcludePatterns = []string{} - - wantVal := true - - for { - - var tmpJExcludePatterns string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJExcludePatterns type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJExcludePatterns = string(string(outBuf)) - - } - } - - j.ExcludePatterns = append(j.ExcludePatterns, tmpJExcludePatterns) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Compression: - - /* handler: j.Compression type=archive.Compression kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for Compression", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.Compression = Compression(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_NoLchown: - - /* handler: j.NoLchown type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.NoLchown = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.NoLchown = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_UIDMaps: - - /* handler: j.UIDMaps type=[]idtools.IDMap kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.UIDMaps = nil - } else { - - j.UIDMaps = []idtools.IDMap{} - - wantVal := true - - for { - - var tmpJUIDMaps idtools.IDMap - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJUIDMaps type=idtools.IDMap kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMap kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJUIDMaps) - if err != nil { - return fs.WrapErr(err) - } - } - - j.UIDMaps = append(j.UIDMaps, tmpJUIDMaps) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_GIDMaps: - - /* handler: j.GIDMaps type=[]idtools.IDMap kind=slice quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_brace && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.GIDMaps = nil - } else { - - j.GIDMaps = []idtools.IDMap{} - - wantVal := true - - for { - - var tmpJGIDMaps idtools.IDMap - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: tmpJGIDMaps type=idtools.IDMap kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMap kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &tmpJGIDMaps) - if err != nil { - return fs.WrapErr(err) - } - } - - j.GIDMaps = append(j.GIDMaps, tmpJGIDMaps) - - wantVal = false - } - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_IgnoreChownErrors: - - /* handler: j.IgnoreChownErrors type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.IgnoreChownErrors = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.IgnoreChownErrors = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ChownOpts: - - /* handler: j.ChownOpts type=idtools.IDPair kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDPair kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.ChownOpts) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_IncludeSourceDir: - - /* handler: j.IncludeSourceDir type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.IncludeSourceDir = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.IncludeSourceDir = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_WhiteoutFormat: - - /* handler: j.WhiteoutFormat type=archive.WhiteoutFormat kind=int quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for WhiteoutFormat", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.WhiteoutFormat = WhiteoutFormat(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_WhiteoutData: - - /* handler: j.WhiteoutData type=interface {} kind=interface quoted=false*/ - - { - /* Falling back. type=interface {} kind=interface */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.WhiteoutData) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_NoOverwriteDirNonDir: - - /* handler: j.NoOverwriteDirNonDir type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.NoOverwriteDirNonDir = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.NoOverwriteDirNonDir = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_RebaseNames: - - /* handler: j.RebaseNames type=map[string]string kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.RebaseNames = nil - } else { - - j.RebaseNames = make(map[string]string, 0) - - wantVal := true - - for { - - var k string - - var tmpJRebaseNames string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - k = string(string(outBuf)) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJRebaseNames type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJRebaseNames = string(string(outBuf)) - - } - } - - j.RebaseNames[k] = tmpJRebaseNames - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_InUserNS: - - /* handler: j.InUserNS type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.InUserNS = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.InUserNS = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CopyPass: - - /* handler: j.CopyPass type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.CopyPass = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.CopyPass = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ForceMask: - - /* handler: j.ForceMask type=os.FileMode kind=uint32 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for FileMode", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - j.ForceMask = nil - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 32) - - if err != nil { - return fs.WrapErr(err) - } - - ttypval := os.FileMode(tval) - j.ForceMask = &ttypval - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *TempArchive) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *TempArchive) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - buf.WriteString(`{"Size":`) - fflib.FormatBits2(buf, uint64(j.Size), 10, j.Size < 0) - buf.WriteByte('}') - return nil -} - -const ( - ffjtTempArchivebase = iota - ffjtTempArchivenosuchkey - - ffjtTempArchiveSize -) - -var ffjKeyTempArchiveSize = []byte("Size") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *TempArchive) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *TempArchive) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjtTempArchivebase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjtTempArchivenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'S': - - if bytes.Equal(ffjKeyTempArchiveSize, kn) { - currentKey = ffjtTempArchiveSize - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeyTempArchiveSize, kn) { - currentKey = ffjtTempArchiveSize - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjtTempArchivenosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjtTempArchiveSize: - goto handle_Size - - case ffjtTempArchivenosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_Size: - - /* handler: j.Size type=int64 kind=int64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for int64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseInt(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - j.Size = int64(tval) - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} - -// MarshalJSON marshal bytes to json - template -func (j *tarAppender) MarshalJSON() ([]byte, error) { - var buf fflib.Buffer - if j == nil { - buf.WriteString("null") - return buf.Bytes(), nil - } - err := j.MarshalJSONBuf(&buf) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -// MarshalJSONBuf marshal buff to json - template -func (j *tarAppender) MarshalJSONBuf(buf fflib.EncodingBuffer) error { - if j == nil { - buf.WriteString("null") - return nil - } - var err error - var obj []byte - _ = obj - _ = err - if j.TarWriter != nil { - /* Struct fall back. type=tar.Writer kind=struct */ - buf.WriteString(`{"TarWriter":`) - err = buf.Encode(j.TarWriter) - if err != nil { - return err - } - } else { - buf.WriteString(`{"TarWriter":null`) - } - if j.Buffer != nil { - /* Struct fall back. type=bufio.Writer kind=struct */ - buf.WriteString(`,"Buffer":`) - err = buf.Encode(j.Buffer) - if err != nil { - return err - } - } else { - buf.WriteString(`,"Buffer":null`) - } - /* Falling back. type=map[uint64]string kind=map */ - buf.WriteString(`,"SeenFiles":`) - err = buf.Encode(j.SeenFiles) - if err != nil { - return err - } - if j.IDMappings != nil { - /* Struct fall back. type=idtools.IDMappings kind=struct */ - buf.WriteString(`,"IDMappings":`) - err = buf.Encode(j.IDMappings) - if err != nil { - return err - } - } else { - buf.WriteString(`,"IDMappings":null`) - } - if j.ChownOpts != nil { - /* Struct fall back. type=idtools.IDPair kind=struct */ - buf.WriteString(`,"ChownOpts":`) - err = buf.Encode(j.ChownOpts) - if err != nil { - return err - } - } else { - buf.WriteString(`,"ChownOpts":null`) - } - buf.WriteString(`,"WhiteoutConverter":`) - /* Interface types must use runtime reflection. type=archive.TarWhiteoutConverter kind=interface */ - err = buf.Encode(j.WhiteoutConverter) - if err != nil { - return err - } - if j.CopyPass { - buf.WriteString(`,"CopyPass":true`) - } else { - buf.WriteString(`,"CopyPass":false`) - } - buf.WriteByte('}') - return nil -} - -const ( - ffjttarAppenderbase = iota - ffjttarAppendernosuchkey - - ffjttarAppenderTarWriter - - ffjttarAppenderBuffer - - ffjttarAppenderSeenFiles - - ffjttarAppenderIDMappings - - ffjttarAppenderChownOpts - - ffjttarAppenderWhiteoutConverter - - ffjttarAppenderCopyPass -) - -var ffjKeytarAppenderTarWriter = []byte("TarWriter") - -var ffjKeytarAppenderBuffer = []byte("Buffer") - -var ffjKeytarAppenderSeenFiles = []byte("SeenFiles") - -var ffjKeytarAppenderIDMappings = []byte("IDMappings") - -var ffjKeytarAppenderChownOpts = []byte("ChownOpts") - -var ffjKeytarAppenderWhiteoutConverter = []byte("WhiteoutConverter") - -var ffjKeytarAppenderCopyPass = []byte("CopyPass") - -// UnmarshalJSON umarshall json - template of ffjson -func (j *tarAppender) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *tarAppender) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjttarAppenderbase - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjttarAppendernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - - case 'B': - - if bytes.Equal(ffjKeytarAppenderBuffer, kn) { - currentKey = ffjttarAppenderBuffer - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'C': - - if bytes.Equal(ffjKeytarAppenderChownOpts, kn) { - currentKey = ffjttarAppenderChownOpts - state = fflib.FFParse_want_colon - goto mainparse - - } else if bytes.Equal(ffjKeytarAppenderCopyPass, kn) { - currentKey = ffjttarAppenderCopyPass - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'I': - - if bytes.Equal(ffjKeytarAppenderIDMappings, kn) { - currentKey = ffjttarAppenderIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'S': - - if bytes.Equal(ffjKeytarAppenderSeenFiles, kn) { - currentKey = ffjttarAppenderSeenFiles - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'T': - - if bytes.Equal(ffjKeytarAppenderTarWriter, kn) { - currentKey = ffjttarAppenderTarWriter - state = fflib.FFParse_want_colon - goto mainparse - } - - case 'W': - - if bytes.Equal(ffjKeytarAppenderWhiteoutConverter, kn) { - currentKey = ffjttarAppenderWhiteoutConverter - state = fflib.FFParse_want_colon - goto mainparse - } - - } - - if fflib.EqualFoldRight(ffjKeytarAppenderCopyPass, kn) { - currentKey = ffjttarAppenderCopyPass - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeytarAppenderWhiteoutConverter, kn) { - currentKey = ffjttarAppenderWhiteoutConverter - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeytarAppenderChownOpts, kn) { - currentKey = ffjttarAppenderChownOpts - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeytarAppenderIDMappings, kn) { - currentKey = ffjttarAppenderIDMappings - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.EqualFoldRight(ffjKeytarAppenderSeenFiles, kn) { - currentKey = ffjttarAppenderSeenFiles - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeytarAppenderBuffer, kn) { - currentKey = ffjttarAppenderBuffer - state = fflib.FFParse_want_colon - goto mainparse - } - - if fflib.SimpleLetterEqualFold(ffjKeytarAppenderTarWriter, kn) { - currentKey = ffjttarAppenderTarWriter - state = fflib.FFParse_want_colon - goto mainparse - } - - currentKey = ffjttarAppendernosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if tok == fflib.FFTok_left_brace || tok == fflib.FFTok_left_bracket || tok == fflib.FFTok_integer || tok == fflib.FFTok_double || tok == fflib.FFTok_string || tok == fflib.FFTok_bool || tok == fflib.FFTok_null { - switch currentKey { - - case ffjttarAppenderTarWriter: - goto handle_TarWriter - - case ffjttarAppenderBuffer: - goto handle_Buffer - - case ffjttarAppenderSeenFiles: - goto handle_SeenFiles - - case ffjttarAppenderIDMappings: - goto handle_IDMappings - - case ffjttarAppenderChownOpts: - goto handle_ChownOpts - - case ffjttarAppenderWhiteoutConverter: - goto handle_WhiteoutConverter - - case ffjttarAppenderCopyPass: - goto handle_CopyPass - - case ffjttarAppendernosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } - -handle_TarWriter: - - /* handler: j.TarWriter type=tar.Writer kind=struct quoted=false*/ - - { - /* Falling back. type=tar.Writer kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.TarWriter) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_Buffer: - - /* handler: j.Buffer type=bufio.Writer kind=struct quoted=false*/ - - { - /* Falling back. type=bufio.Writer kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.Buffer) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_SeenFiles: - - /* handler: j.SeenFiles type=map[uint64]string kind=map quoted=false*/ - - { - - { - if tok != fflib.FFTok_left_bracket && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for ", tok)) - } - } - - if tok == fflib.FFTok_null { - j.SeenFiles = nil - } else { - - j.SeenFiles = make(map[uint64]string, 0) - - wantVal := true - - for { - - var k uint64 - - var tmpJSeenFiles string - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - /* handler: k type=uint64 kind=uint64 quoted=false*/ - - { - if tok != fflib.FFTok_integer && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for uint64", tok)) - } - } - - { - - if tok == fflib.FFTok_null { - - } else { - - tval, err := fflib.ParseUint(fs.Output.Bytes(), 10, 64) - - if err != nil { - return fs.WrapErr(err) - } - - k = uint64(tval) - - } - } - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - /* handler: tmpJSeenFiles type=string kind=string quoted=false*/ - - { - - { - if tok != fflib.FFTok_string && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for string", tok)) - } - } - - if tok == fflib.FFTok_null { - - } else { - - outBuf := fs.Output.Bytes() - - tmpJSeenFiles = string(string(outBuf)) - - } - } - - j.SeenFiles[k] = tmpJSeenFiles - - wantVal = false - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_IDMappings: - - /* handler: j.IDMappings type=idtools.IDMappings kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDMappings kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.IDMappings) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_ChownOpts: - - /* handler: j.ChownOpts type=idtools.IDPair kind=struct quoted=false*/ - - { - /* Falling back. type=idtools.IDPair kind=struct */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.ChownOpts) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_WhiteoutConverter: - - /* handler: j.WhiteoutConverter type=archive.TarWhiteoutConverter kind=interface quoted=false*/ - - { - /* Falling back. type=archive.TarWhiteoutConverter kind=interface */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &j.WhiteoutConverter) - if err != nil { - return fs.WrapErr(err) - } - } - - state = fflib.FFParse_after_value - goto mainparse - -handle_CopyPass: - - /* handler: j.CopyPass type=bool kind=bool quoted=false*/ - - { - if tok != fflib.FFTok_bool && tok != fflib.FFTok_null { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for bool", tok)) - } - } - - { - if tok == fflib.FFTok_null { - - } else { - tmpb := fs.Output.Bytes() - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - - j.CopyPass = true - - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - - j.CopyPass = false - - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - } - } - - state = fflib.FFParse_after_value - goto mainparse - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: - - return nil -} diff --git a/vendor/github.com/containers/storage/pkg/chrootarchive/archive_unix.go b/vendor/github.com/containers/storage/pkg/chrootarchive/archive_unix.go index 630826db1..9da10fe33 100644 --- a/vendor/github.com/containers/storage/pkg/chrootarchive/archive_unix.go +++ b/vendor/github.com/containers/storage/pkg/chrootarchive/archive_unix.go @@ -4,7 +4,6 @@ package chrootarchive import ( "bytes" - "encoding/json" "flag" "fmt" "io" diff --git a/vendor/github.com/containers/storage/pkg/chrootarchive/diff_unix.go b/vendor/github.com/containers/storage/pkg/chrootarchive/diff_unix.go index 4369f30c9..c884d3784 100644 --- a/vendor/github.com/containers/storage/pkg/chrootarchive/diff_unix.go +++ b/vendor/github.com/containers/storage/pkg/chrootarchive/diff_unix.go @@ -4,7 +4,6 @@ package chrootarchive import ( "bytes" - "encoding/json" "flag" "fmt" "io" diff --git a/vendor/github.com/containers/storage/pkg/chrootarchive/jsoniter.go b/vendor/github.com/containers/storage/pkg/chrootarchive/jsoniter.go new file mode 100644 index 000000000..63f970456 --- /dev/null +++ b/vendor/github.com/containers/storage/pkg/chrootarchive/jsoniter.go @@ -0,0 +1,5 @@ +package chrootarchive + +import jsoniter "github.com/json-iterator/go" + +var json = jsoniter.ConfigCompatibleWithStandardLibrary diff --git a/vendor/github.com/containers/storage/store.go b/vendor/github.com/containers/storage/store.go index 25767b7a2..b449d000c 100644 --- a/vendor/github.com/containers/storage/store.go +++ b/vendor/github.com/containers/storage/store.go @@ -2,7 +2,6 @@ package storage import ( "encoding/base64" - "encoding/json" "fmt" "io" "io/ioutil" diff --git a/vendor/github.com/containers/storage/types/options.go b/vendor/github.com/containers/storage/types/options.go index fb80b18c5..223db8f00 100644 --- a/vendor/github.com/containers/storage/types/options.go +++ b/vendor/github.com/containers/storage/types/options.go @@ -172,7 +172,10 @@ func getRootlessStorageOpts(rootlessUID int, systemOpts StoreOptions) (StoreOpti } opts.RunRoot = rootlessRuntime if systemOpts.RootlessStoragePath != "" { - opts.GraphRoot = systemOpts.RootlessStoragePath + opts.GraphRoot, err = expandEnvPath(systemOpts.RootlessStoragePath, rootlessUID) + if err != nil { + return opts, err + } } else { opts.GraphRoot = filepath.Join(dataDir, "containers", "storage") } diff --git a/vendor/github.com/containers/storage/types/utils.go b/vendor/github.com/containers/storage/types/utils.go index f64bbe859..d2dca7b68 100644 --- a/vendor/github.com/containers/storage/types/utils.go +++ b/vendor/github.com/containers/storage/types/utils.go @@ -156,8 +156,7 @@ func getRootlessUID() int { func expandEnvPath(path string, rootlessUID int) (string, error) { path = strings.Replace(path, "$UID", strconv.Itoa(rootlessUID), -1) - path = os.ExpandEnv(path) - return path, nil + return filepath.Clean(os.ExpandEnv(path)), nil } func DefaultConfigFile(rootless bool) (string, error) { diff --git a/vendor/github.com/pquerna/ffjson/LICENSE b/vendor/github.com/pquerna/ffjson/LICENSE deleted file mode 100644 index d64569567..000000000 --- a/vendor/github.com/pquerna/ffjson/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/vendor/github.com/pquerna/ffjson/NOTICE b/vendor/github.com/pquerna/ffjson/NOTICE deleted file mode 100644 index 405a49618..000000000 --- a/vendor/github.com/pquerna/ffjson/NOTICE +++ /dev/null @@ -1,8 +0,0 @@ -ffjson -Copyright (c) 2014, Paul Querna - -This product includes software developed by -Paul Querna (http://paul.querna.org/). - -Portions of this software were developed as -part of Go, Copyright (c) 2012 The Go Authors.
\ No newline at end of file diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/buffer.go b/vendor/github.com/pquerna/ffjson/fflib/v1/buffer.go deleted file mode 100644 index 7f63a8582..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/buffer.go +++ /dev/null @@ -1,421 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package v1 - -// Simple byte buffer for marshaling data. - -import ( - "bytes" - "encoding/json" - "errors" - "io" - "unicode/utf8" -) - -type grower interface { - Grow(n int) -} - -type truncater interface { - Truncate(n int) - Reset() -} - -type bytesReader interface { - Bytes() []byte - String() string -} - -type runeWriter interface { - WriteRune(r rune) (n int, err error) -} - -type stringWriter interface { - WriteString(s string) (n int, err error) -} - -type lener interface { - Len() int -} - -type rewinder interface { - Rewind(n int) (err error) -} - -type encoder interface { - Encode(interface{}) error -} - -// TODO(pquerna): continue to reduce these interfaces - -type EncodingBuffer interface { - io.Writer - io.WriterTo - io.ByteWriter - stringWriter - truncater - grower - rewinder - encoder -} - -type DecodingBuffer interface { - io.ReadWriter - io.ByteWriter - stringWriter - runeWriter - truncater - grower - bytesReader - lener -} - -// A Buffer is a variable-sized buffer of bytes with Read and Write methods. -// The zero value for Buffer is an empty buffer ready to use. -type Buffer struct { - buf []byte // contents are the bytes buf[off : len(buf)] - off int // read at &buf[off], write at &buf[len(buf)] - runeBytes [utf8.UTFMax]byte // avoid allocation of slice on each WriteByte or Rune - encoder *json.Encoder - skipTrailingByte bool -} - -// ErrTooLarge is passed to panic if memory cannot be allocated to store data in a buffer. -var ErrTooLarge = errors.New("fflib.v1.Buffer: too large") - -// Bytes returns a slice of the contents of the unread portion of the buffer; -// len(b.Bytes()) == b.Len(). If the caller changes the contents of the -// returned slice, the contents of the buffer will change provided there -// are no intervening method calls on the Buffer. -func (b *Buffer) Bytes() []byte { return b.buf[b.off:] } - -// String returns the contents of the unread portion of the buffer -// as a string. If the Buffer is a nil pointer, it returns "<nil>". -func (b *Buffer) String() string { - if b == nil { - // Special case, useful in debugging. - return "<nil>" - } - return string(b.buf[b.off:]) -} - -// Len returns the number of bytes of the unread portion of the buffer; -// b.Len() == len(b.Bytes()). -func (b *Buffer) Len() int { return len(b.buf) - b.off } - -// Truncate discards all but the first n unread bytes from the buffer. -// It panics if n is negative or greater than the length of the buffer. -func (b *Buffer) Truncate(n int) { - if n == 0 { - b.off = 0 - b.buf = b.buf[0:0] - } else { - b.buf = b.buf[0 : b.off+n] - } -} - -// Reset resets the buffer so it has no content. -// b.Reset() is the same as b.Truncate(0). -func (b *Buffer) Reset() { b.Truncate(0) } - -// grow grows the buffer to guarantee space for n more bytes. -// It returns the index where bytes should be written. -// If the buffer can't grow it will panic with ErrTooLarge. -func (b *Buffer) grow(n int) int { - // If we have no buffer, get one from the pool - m := b.Len() - if m == 0 { - if b.buf == nil { - b.buf = makeSlice(2 * n) - b.off = 0 - } else if b.off != 0 { - // If buffer is empty, reset to recover space. - b.Truncate(0) - } - } - if len(b.buf)+n > cap(b.buf) { - var buf []byte - if m+n <= cap(b.buf)/2 { - // We can slide things down instead of allocating a new - // slice. We only need m+n <= cap(b.buf) to slide, but - // we instead let capacity get twice as large so we - // don't spend all our time copying. - copy(b.buf[:], b.buf[b.off:]) - buf = b.buf[:m] - } else { - // not enough space anywhere - buf = makeSlice(2*cap(b.buf) + n) - copy(buf, b.buf[b.off:]) - Pool(b.buf) - b.buf = buf - } - b.off = 0 - } - b.buf = b.buf[0 : b.off+m+n] - return b.off + m -} - -// Grow grows the buffer's capacity, if necessary, to guarantee space for -// another n bytes. After Grow(n), at least n bytes can be written to the -// buffer without another allocation. -// If n is negative, Grow will panic. -// If the buffer can't grow it will panic with ErrTooLarge. -func (b *Buffer) Grow(n int) { - if n < 0 { - panic("bytes.Buffer.Grow: negative count") - } - m := b.grow(n) - b.buf = b.buf[0:m] -} - -// Write appends the contents of p to the buffer, growing the buffer as -// needed. The return value n is the length of p; err is always nil. If the -// buffer becomes too large, Write will panic with ErrTooLarge. -func (b *Buffer) Write(p []byte) (n int, err error) { - if b.skipTrailingByte { - p = p[:len(p)-1] - } - m := b.grow(len(p)) - return copy(b.buf[m:], p), nil -} - -// WriteString appends the contents of s to the buffer, growing the buffer as -// needed. The return value n is the length of s; err is always nil. If the -// buffer becomes too large, WriteString will panic with ErrTooLarge. -func (b *Buffer) WriteString(s string) (n int, err error) { - m := b.grow(len(s)) - return copy(b.buf[m:], s), nil -} - -// MinRead is the minimum slice size passed to a Read call by -// Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond -// what is required to hold the contents of r, ReadFrom will not grow the -// underlying buffer. -const minRead = 512 - -// ReadFrom reads data from r until EOF and appends it to the buffer, growing -// the buffer as needed. The return value n is the number of bytes read. Any -// error except io.EOF encountered during the read is also returned. If the -// buffer becomes too large, ReadFrom will panic with ErrTooLarge. -func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) { - // If buffer is empty, reset to recover space. - if b.off >= len(b.buf) { - b.Truncate(0) - } - for { - if free := cap(b.buf) - len(b.buf); free < minRead { - // not enough space at end - newBuf := b.buf - if b.off+free < minRead { - // not enough space using beginning of buffer; - // double buffer capacity - newBuf = makeSlice(2*cap(b.buf) + minRead) - } - copy(newBuf, b.buf[b.off:]) - Pool(b.buf) - b.buf = newBuf[:len(b.buf)-b.off] - b.off = 0 - } - m, e := r.Read(b.buf[len(b.buf):cap(b.buf)]) - b.buf = b.buf[0 : len(b.buf)+m] - n += int64(m) - if e == io.EOF { - break - } - if e != nil { - return n, e - } - } - return n, nil // err is EOF, so return nil explicitly -} - -// WriteTo writes data to w until the buffer is drained or an error occurs. -// The return value n is the number of bytes written; it always fits into an -// int, but it is int64 to match the io.WriterTo interface. Any error -// encountered during the write is also returned. -func (b *Buffer) WriteTo(w io.Writer) (n int64, err error) { - if b.off < len(b.buf) { - nBytes := b.Len() - m, e := w.Write(b.buf[b.off:]) - if m > nBytes { - panic("bytes.Buffer.WriteTo: invalid Write count") - } - b.off += m - n = int64(m) - if e != nil { - return n, e - } - // all bytes should have been written, by definition of - // Write method in io.Writer - if m != nBytes { - return n, io.ErrShortWrite - } - } - // Buffer is now empty; reset. - b.Truncate(0) - return -} - -// WriteByte appends the byte c to the buffer, growing the buffer as needed. -// The returned error is always nil, but is included to match bufio.Writer's -// WriteByte. If the buffer becomes too large, WriteByte will panic with -// ErrTooLarge. -func (b *Buffer) WriteByte(c byte) error { - m := b.grow(1) - b.buf[m] = c - return nil -} - -func (b *Buffer) Rewind(n int) error { - b.buf = b.buf[:len(b.buf)-n] - return nil -} - -func (b *Buffer) Encode(v interface{}) error { - if b.encoder == nil { - b.encoder = json.NewEncoder(b) - } - b.skipTrailingByte = true - err := b.encoder.Encode(v) - b.skipTrailingByte = false - return err -} - -// WriteRune appends the UTF-8 encoding of Unicode code point r to the -// buffer, returning its length and an error, which is always nil but is -// included to match bufio.Writer's WriteRune. The buffer is grown as needed; -// if it becomes too large, WriteRune will panic with ErrTooLarge. -func (b *Buffer) WriteRune(r rune) (n int, err error) { - if r < utf8.RuneSelf { - b.WriteByte(byte(r)) - return 1, nil - } - n = utf8.EncodeRune(b.runeBytes[0:], r) - b.Write(b.runeBytes[0:n]) - return n, nil -} - -// Read reads the next len(p) bytes from the buffer or until the buffer -// is drained. The return value n is the number of bytes read. If the -// buffer has no data to return, err is io.EOF (unless len(p) is zero); -// otherwise it is nil. -func (b *Buffer) Read(p []byte) (n int, err error) { - if b.off >= len(b.buf) { - // Buffer is empty, reset to recover space. - b.Truncate(0) - if len(p) == 0 { - return - } - return 0, io.EOF - } - n = copy(p, b.buf[b.off:]) - b.off += n - return -} - -// Next returns a slice containing the next n bytes from the buffer, -// advancing the buffer as if the bytes had been returned by Read. -// If there are fewer than n bytes in the buffer, Next returns the entire buffer. -// The slice is only valid until the next call to a read or write method. -func (b *Buffer) Next(n int) []byte { - m := b.Len() - if n > m { - n = m - } - data := b.buf[b.off : b.off+n] - b.off += n - return data -} - -// ReadByte reads and returns the next byte from the buffer. -// If no byte is available, it returns error io.EOF. -func (b *Buffer) ReadByte() (c byte, err error) { - if b.off >= len(b.buf) { - // Buffer is empty, reset to recover space. - b.Truncate(0) - return 0, io.EOF - } - c = b.buf[b.off] - b.off++ - return c, nil -} - -// ReadRune reads and returns the next UTF-8-encoded -// Unicode code point from the buffer. -// If no bytes are available, the error returned is io.EOF. -// If the bytes are an erroneous UTF-8 encoding, it -// consumes one byte and returns U+FFFD, 1. -func (b *Buffer) ReadRune() (r rune, size int, err error) { - if b.off >= len(b.buf) { - // Buffer is empty, reset to recover space. - b.Truncate(0) - return 0, 0, io.EOF - } - c := b.buf[b.off] - if c < utf8.RuneSelf { - b.off++ - return rune(c), 1, nil - } - r, n := utf8.DecodeRune(b.buf[b.off:]) - b.off += n - return r, n, nil -} - -// ReadBytes reads until the first occurrence of delim in the input, -// returning a slice containing the data up to and including the delimiter. -// If ReadBytes encounters an error before finding a delimiter, -// it returns the data read before the error and the error itself (often io.EOF). -// ReadBytes returns err != nil if and only if the returned data does not end in -// delim. -func (b *Buffer) ReadBytes(delim byte) (line []byte, err error) { - slice, err := b.readSlice(delim) - // return a copy of slice. The buffer's backing array may - // be overwritten by later calls. - line = append(line, slice...) - return -} - -// readSlice is like ReadBytes but returns a reference to internal buffer data. -func (b *Buffer) readSlice(delim byte) (line []byte, err error) { - i := bytes.IndexByte(b.buf[b.off:], delim) - end := b.off + i + 1 - if i < 0 { - end = len(b.buf) - err = io.EOF - } - line = b.buf[b.off:end] - b.off = end - return line, err -} - -// ReadString reads until the first occurrence of delim in the input, -// returning a string containing the data up to and including the delimiter. -// If ReadString encounters an error before finding a delimiter, -// it returns the data read before the error and the error itself (often io.EOF). -// ReadString returns err != nil if and only if the returned data does not end -// in delim. -func (b *Buffer) ReadString(delim byte) (line string, err error) { - slice, err := b.readSlice(delim) - return string(slice), err -} - -// NewBuffer creates and initializes a new Buffer using buf as its initial -// contents. It is intended to prepare a Buffer to read existing data. It -// can also be used to size the internal buffer for writing. To do that, -// buf should have the desired capacity but a length of zero. -// -// In most cases, new(Buffer) (or just declaring a Buffer variable) is -// sufficient to initialize a Buffer. -func NewBuffer(buf []byte) *Buffer { return &Buffer{buf: buf} } - -// NewBufferString creates and initializes a new Buffer using string s as its -// initial contents. It is intended to prepare a buffer to read an existing -// string. -// -// In most cases, new(Buffer) (or just declaring a Buffer variable) is -// sufficient to initialize a Buffer. -func NewBufferString(s string) *Buffer { - return &Buffer{buf: []byte(s)} -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/buffer_nopool.go b/vendor/github.com/pquerna/ffjson/fflib/v1/buffer_nopool.go deleted file mode 100644 index b84af6ff9..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/buffer_nopool.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !go1.3 - -package v1 - -// Stub version of buffer_pool.go for Go 1.2, which doesn't have sync.Pool. - -func Pool(b []byte) {} - -func makeSlice(n int) []byte { - return make([]byte, n) -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/buffer_pool.go b/vendor/github.com/pquerna/ffjson/fflib/v1/buffer_pool.go deleted file mode 100644 index a021c57cf..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/buffer_pool.go +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.3 - -package v1 - -// Allocation pools for Buffers. - -import "sync" - -var pools [14]sync.Pool -var pool64 *sync.Pool - -func init() { - var i uint - // TODO(pquerna): add science here around actual pool sizes. - for i = 6; i < 20; i++ { - n := 1 << i - pools[poolNum(n)].New = func() interface{} { return make([]byte, 0, n) } - } - pool64 = &pools[0] -} - -// This returns the pool number that will give a buffer of -// at least 'i' bytes. -func poolNum(i int) int { - // TODO(pquerna): convert to log2 w/ bsr asm instruction: - // <https://groups.google.com/forum/#!topic/golang-nuts/uAb5J1_y7ns> - if i <= 64 { - return 0 - } else if i <= 128 { - return 1 - } else if i <= 256 { - return 2 - } else if i <= 512 { - return 3 - } else if i <= 1024 { - return 4 - } else if i <= 2048 { - return 5 - } else if i <= 4096 { - return 6 - } else if i <= 8192 { - return 7 - } else if i <= 16384 { - return 8 - } else if i <= 32768 { - return 9 - } else if i <= 65536 { - return 10 - } else if i <= 131072 { - return 11 - } else if i <= 262144 { - return 12 - } else if i <= 524288 { - return 13 - } else { - return -1 - } -} - -// Send a buffer to the Pool to reuse for other instances. -// You may no longer utilize the content of the buffer, since it may be used -// by other goroutines. -func Pool(b []byte) { - if b == nil { - return - } - c := cap(b) - - // Our smallest buffer is 64 bytes, so we discard smaller buffers. - if c < 64 { - return - } - - // We need to put the incoming buffer into the NEXT buffer, - // since a buffer guarantees AT LEAST the number of bytes available - // that is the top of this buffer. - // That is the reason for dividing the cap by 2, so it gets into the NEXT bucket. - // We add 2 to avoid rounding down if size is exactly power of 2. - pn := poolNum((c + 2) >> 1) - if pn != -1 { - pools[pn].Put(b[0:0]) - } - // if we didn't have a slot for this []byte, we just drop it and let the GC - // take care of it. -} - -// makeSlice allocates a slice of size n -- it will attempt to use a pool'ed -// instance whenever possible. -func makeSlice(n int) []byte { - if n <= 64 { - return pool64.Get().([]byte)[0:n] - } - - pn := poolNum(n) - - if pn != -1 { - return pools[pn].Get().([]byte)[0:n] - } else { - return make([]byte, n) - } -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/bytenum.go b/vendor/github.com/pquerna/ffjson/fflib/v1/bytenum.go deleted file mode 100644 index 08477409a..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/bytenum.go +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on Go stdlib's strconv/iota.go */ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package v1 - -import ( - "github.com/pquerna/ffjson/fflib/v1/internal" -) - -func ParseFloat(s []byte, bitSize int) (f float64, err error) { - return internal.ParseFloat(s, bitSize) -} - -// ParseUint is like ParseInt but for unsigned numbers, and oeprating on []byte -func ParseUint(s []byte, base int, bitSize int) (n uint64, err error) { - if len(s) == 1 { - switch s[0] { - case '0': - return 0, nil - case '1': - return 1, nil - case '2': - return 2, nil - case '3': - return 3, nil - case '4': - return 4, nil - case '5': - return 5, nil - case '6': - return 6, nil - case '7': - return 7, nil - case '8': - return 8, nil - case '9': - return 9, nil - } - } - return internal.ParseUint(s, base, bitSize) -} - -func ParseInt(s []byte, base int, bitSize int) (i int64, err error) { - if len(s) == 1 { - switch s[0] { - case '0': - return 0, nil - case '1': - return 1, nil - case '2': - return 2, nil - case '3': - return 3, nil - case '4': - return 4, nil - case '5': - return 5, nil - case '6': - return 6, nil - case '7': - return 7, nil - case '8': - return 8, nil - case '9': - return 9, nil - } - } - return internal.ParseInt(s, base, bitSize) -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/decimal.go b/vendor/github.com/pquerna/ffjson/fflib/v1/decimal.go deleted file mode 100644 index 069df7a02..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/decimal.go +++ /dev/null @@ -1,378 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Multiprecision decimal numbers. -// For floating-point formatting only; not general purpose. -// Only operations are assign and (binary) left/right shift. -// Can do binary floating point in multiprecision decimal precisely -// because 2 divides 10; cannot do decimal floating point -// in multiprecision binary precisely. - -package v1 - -type decimal struct { - d [800]byte // digits - nd int // number of digits used - dp int // decimal point - neg bool - trunc bool // discarded nonzero digits beyond d[:nd] -} - -func (a *decimal) String() string { - n := 10 + a.nd - if a.dp > 0 { - n += a.dp - } - if a.dp < 0 { - n += -a.dp - } - - buf := make([]byte, n) - w := 0 - switch { - case a.nd == 0: - return "0" - - case a.dp <= 0: - // zeros fill space between decimal point and digits - buf[w] = '0' - w++ - buf[w] = '.' - w++ - w += digitZero(buf[w : w+-a.dp]) - w += copy(buf[w:], a.d[0:a.nd]) - - case a.dp < a.nd: - // decimal point in middle of digits - w += copy(buf[w:], a.d[0:a.dp]) - buf[w] = '.' - w++ - w += copy(buf[w:], a.d[a.dp:a.nd]) - - default: - // zeros fill space between digits and decimal point - w += copy(buf[w:], a.d[0:a.nd]) - w += digitZero(buf[w : w+a.dp-a.nd]) - } - return string(buf[0:w]) -} - -func digitZero(dst []byte) int { - for i := range dst { - dst[i] = '0' - } - return len(dst) -} - -// trim trailing zeros from number. -// (They are meaningless; the decimal point is tracked -// independent of the number of digits.) -func trim(a *decimal) { - for a.nd > 0 && a.d[a.nd-1] == '0' { - a.nd-- - } - if a.nd == 0 { - a.dp = 0 - } -} - -// Assign v to a. -func (a *decimal) Assign(v uint64) { - var buf [24]byte - - // Write reversed decimal in buf. - n := 0 - for v > 0 { - v1 := v / 10 - v -= 10 * v1 - buf[n] = byte(v + '0') - n++ - v = v1 - } - - // Reverse again to produce forward decimal in a.d. - a.nd = 0 - for n--; n >= 0; n-- { - a.d[a.nd] = buf[n] - a.nd++ - } - a.dp = a.nd - trim(a) -} - -// Maximum shift that we can do in one pass without overflow. -// Signed int has 31 bits, and we have to be able to accommodate 9<<k. -const maxShift = 27 - -// Binary shift right (* 2) by k bits. k <= maxShift to avoid overflow. -func rightShift(a *decimal, k uint) { - r := 0 // read pointer - w := 0 // write pointer - - // Pick up enough leading digits to cover first shift. - n := 0 - for ; n>>k == 0; r++ { - if r >= a.nd { - if n == 0 { - // a == 0; shouldn't get here, but handle anyway. - a.nd = 0 - return - } - for n>>k == 0 { - n = n * 10 - r++ - } - break - } - c := int(a.d[r]) - n = n*10 + c - '0' - } - a.dp -= r - 1 - - // Pick up a digit, put down a digit. - for ; r < a.nd; r++ { - c := int(a.d[r]) - dig := n >> k - n -= dig << k - a.d[w] = byte(dig + '0') - w++ - n = n*10 + c - '0' - } - - // Put down extra digits. - for n > 0 { - dig := n >> k - n -= dig << k - if w < len(a.d) { - a.d[w] = byte(dig + '0') - w++ - } else if dig > 0 { - a.trunc = true - } - n = n * 10 - } - - a.nd = w - trim(a) -} - -// Cheat sheet for left shift: table indexed by shift count giving -// number of new digits that will be introduced by that shift. -// -// For example, leftcheats[4] = {2, "625"}. That means that -// if we are shifting by 4 (multiplying by 16), it will add 2 digits -// when the string prefix is "625" through "999", and one fewer digit -// if the string prefix is "000" through "624". -// -// Credit for this trick goes to Ken. - -type leftCheat struct { - delta int // number of new digits - cutoff string // minus one digit if original < a. -} - -var leftcheats = []leftCheat{ - // Leading digits of 1/2^i = 5^i. - // 5^23 is not an exact 64-bit floating point number, - // so have to use bc for the math. - /* - seq 27 | sed 's/^/5^/' | bc | - awk 'BEGIN{ print "\tleftCheat{ 0, \"\" }," } - { - log2 = log(2)/log(10) - printf("\tleftCheat{ %d, \"%s\" },\t// * %d\n", - int(log2*NR+1), $0, 2**NR) - }' - */ - {0, ""}, - {1, "5"}, // * 2 - {1, "25"}, // * 4 - {1, "125"}, // * 8 - {2, "625"}, // * 16 - {2, "3125"}, // * 32 - {2, "15625"}, // * 64 - {3, "78125"}, // * 128 - {3, "390625"}, // * 256 - {3, "1953125"}, // * 512 - {4, "9765625"}, // * 1024 - {4, "48828125"}, // * 2048 - {4, "244140625"}, // * 4096 - {4, "1220703125"}, // * 8192 - {5, "6103515625"}, // * 16384 - {5, "30517578125"}, // * 32768 - {5, "152587890625"}, // * 65536 - {6, "762939453125"}, // * 131072 - {6, "3814697265625"}, // * 262144 - {6, "19073486328125"}, // * 524288 - {7, "95367431640625"}, // * 1048576 - {7, "476837158203125"}, // * 2097152 - {7, "2384185791015625"}, // * 4194304 - {7, "11920928955078125"}, // * 8388608 - {8, "59604644775390625"}, // * 16777216 - {8, "298023223876953125"}, // * 33554432 - {8, "1490116119384765625"}, // * 67108864 - {9, "7450580596923828125"}, // * 134217728 -} - -// Is the leading prefix of b lexicographically less than s? -func prefixIsLessThan(b []byte, s string) bool { - for i := 0; i < len(s); i++ { - if i >= len(b) { - return true - } - if b[i] != s[i] { - return b[i] < s[i] - } - } - return false -} - -// Binary shift left (/ 2) by k bits. k <= maxShift to avoid overflow. -func leftShift(a *decimal, k uint) { - delta := leftcheats[k].delta - if prefixIsLessThan(a.d[0:a.nd], leftcheats[k].cutoff) { - delta-- - } - - r := a.nd // read index - w := a.nd + delta // write index - n := 0 - - // Pick up a digit, put down a digit. - for r--; r >= 0; r-- { - n += (int(a.d[r]) - '0') << k - quo := n / 10 - rem := n - 10*quo - w-- - if w < len(a.d) { - a.d[w] = byte(rem + '0') - } else if rem != 0 { - a.trunc = true - } - n = quo - } - - // Put down extra digits. - for n > 0 { - quo := n / 10 - rem := n - 10*quo - w-- - if w < len(a.d) { - a.d[w] = byte(rem + '0') - } else if rem != 0 { - a.trunc = true - } - n = quo - } - - a.nd += delta - if a.nd >= len(a.d) { - a.nd = len(a.d) - } - a.dp += delta - trim(a) -} - -// Binary shift left (k > 0) or right (k < 0). -func (a *decimal) Shift(k int) { - switch { - case a.nd == 0: - // nothing to do: a == 0 - case k > 0: - for k > maxShift { - leftShift(a, maxShift) - k -= maxShift - } - leftShift(a, uint(k)) - case k < 0: - for k < -maxShift { - rightShift(a, maxShift) - k += maxShift - } - rightShift(a, uint(-k)) - } -} - -// If we chop a at nd digits, should we round up? -func shouldRoundUp(a *decimal, nd int) bool { - if nd < 0 || nd >= a.nd { - return false - } - if a.d[nd] == '5' && nd+1 == a.nd { // exactly halfway - round to even - // if we truncated, a little higher than what's recorded - always round up - if a.trunc { - return true - } - return nd > 0 && (a.d[nd-1]-'0')%2 != 0 - } - // not halfway - digit tells all - return a.d[nd] >= '5' -} - -// Round a to nd digits (or fewer). -// If nd is zero, it means we're rounding -// just to the left of the digits, as in -// 0.09 -> 0.1. -func (a *decimal) Round(nd int) { - if nd < 0 || nd >= a.nd { - return - } - if shouldRoundUp(a, nd) { - a.RoundUp(nd) - } else { - a.RoundDown(nd) - } -} - -// Round a down to nd digits (or fewer). -func (a *decimal) RoundDown(nd int) { - if nd < 0 || nd >= a.nd { - return - } - a.nd = nd - trim(a) -} - -// Round a up to nd digits (or fewer). -func (a *decimal) RoundUp(nd int) { - if nd < 0 || nd >= a.nd { - return - } - - // round up - for i := nd - 1; i >= 0; i-- { - c := a.d[i] - if c < '9' { // can stop after this digit - a.d[i]++ - a.nd = i + 1 - return - } - } - - // Number is all 9s. - // Change to single 1 with adjusted decimal point. - a.d[0] = '1' - a.nd = 1 - a.dp++ -} - -// Extract integer part, rounded appropriately. -// No guarantees about overflow. -func (a *decimal) RoundedInteger() uint64 { - if a.dp > 20 { - return 0xFFFFFFFFFFFFFFFF - } - var i int - n := uint64(0) - for i = 0; i < a.dp && i < a.nd; i++ { - n = n*10 + uint64(a.d[i]-'0') - } - for ; i < a.dp; i++ { - n *= 10 - } - if shouldRoundUp(a, a.dp) { - n++ - } - return n -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/extfloat.go b/vendor/github.com/pquerna/ffjson/fflib/v1/extfloat.go deleted file mode 100644 index 508ddc6be..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/extfloat.go +++ /dev/null @@ -1,668 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package v1 - -// An extFloat represents an extended floating-point number, with more -// precision than a float64. It does not try to save bits: the -// number represented by the structure is mant*(2^exp), with a negative -// sign if neg is true. -type extFloat struct { - mant uint64 - exp int - neg bool -} - -// Powers of ten taken from double-conversion library. -// http://code.google.com/p/double-conversion/ -const ( - firstPowerOfTen = -348 - stepPowerOfTen = 8 -) - -var smallPowersOfTen = [...]extFloat{ - {1 << 63, -63, false}, // 1 - {0xa << 60, -60, false}, // 1e1 - {0x64 << 57, -57, false}, // 1e2 - {0x3e8 << 54, -54, false}, // 1e3 - {0x2710 << 50, -50, false}, // 1e4 - {0x186a0 << 47, -47, false}, // 1e5 - {0xf4240 << 44, -44, false}, // 1e6 - {0x989680 << 40, -40, false}, // 1e7 -} - -var powersOfTen = [...]extFloat{ - {0xfa8fd5a0081c0288, -1220, false}, // 10^-348 - {0xbaaee17fa23ebf76, -1193, false}, // 10^-340 - {0x8b16fb203055ac76, -1166, false}, // 10^-332 - {0xcf42894a5dce35ea, -1140, false}, // 10^-324 - {0x9a6bb0aa55653b2d, -1113, false}, // 10^-316 - {0xe61acf033d1a45df, -1087, false}, // 10^-308 - {0xab70fe17c79ac6ca, -1060, false}, // 10^-300 - {0xff77b1fcbebcdc4f, -1034, false}, // 10^-292 - {0xbe5691ef416bd60c, -1007, false}, // 10^-284 - {0x8dd01fad907ffc3c, -980, false}, // 10^-276 - {0xd3515c2831559a83, -954, false}, // 10^-268 - {0x9d71ac8fada6c9b5, -927, false}, // 10^-260 - {0xea9c227723ee8bcb, -901, false}, // 10^-252 - {0xaecc49914078536d, -874, false}, // 10^-244 - {0x823c12795db6ce57, -847, false}, // 10^-236 - {0xc21094364dfb5637, -821, false}, // 10^-228 - {0x9096ea6f3848984f, -794, false}, // 10^-220 - {0xd77485cb25823ac7, -768, false}, // 10^-212 - {0xa086cfcd97bf97f4, -741, false}, // 10^-204 - {0xef340a98172aace5, -715, false}, // 10^-196 - {0xb23867fb2a35b28e, -688, false}, // 10^-188 - {0x84c8d4dfd2c63f3b, -661, false}, // 10^-180 - {0xc5dd44271ad3cdba, -635, false}, // 10^-172 - {0x936b9fcebb25c996, -608, false}, // 10^-164 - {0xdbac6c247d62a584, -582, false}, // 10^-156 - {0xa3ab66580d5fdaf6, -555, false}, // 10^-148 - {0xf3e2f893dec3f126, -529, false}, // 10^-140 - {0xb5b5ada8aaff80b8, -502, false}, // 10^-132 - {0x87625f056c7c4a8b, -475, false}, // 10^-124 - {0xc9bcff6034c13053, -449, false}, // 10^-116 - {0x964e858c91ba2655, -422, false}, // 10^-108 - {0xdff9772470297ebd, -396, false}, // 10^-100 - {0xa6dfbd9fb8e5b88f, -369, false}, // 10^-92 - {0xf8a95fcf88747d94, -343, false}, // 10^-84 - {0xb94470938fa89bcf, -316, false}, // 10^-76 - {0x8a08f0f8bf0f156b, -289, false}, // 10^-68 - {0xcdb02555653131b6, -263, false}, // 10^-60 - {0x993fe2c6d07b7fac, -236, false}, // 10^-52 - {0xe45c10c42a2b3b06, -210, false}, // 10^-44 - {0xaa242499697392d3, -183, false}, // 10^-36 - {0xfd87b5f28300ca0e, -157, false}, // 10^-28 - {0xbce5086492111aeb, -130, false}, // 10^-20 - {0x8cbccc096f5088cc, -103, false}, // 10^-12 - {0xd1b71758e219652c, -77, false}, // 10^-4 - {0x9c40000000000000, -50, false}, // 10^4 - {0xe8d4a51000000000, -24, false}, // 10^12 - {0xad78ebc5ac620000, 3, false}, // 10^20 - {0x813f3978f8940984, 30, false}, // 10^28 - {0xc097ce7bc90715b3, 56, false}, // 10^36 - {0x8f7e32ce7bea5c70, 83, false}, // 10^44 - {0xd5d238a4abe98068, 109, false}, // 10^52 - {0x9f4f2726179a2245, 136, false}, // 10^60 - {0xed63a231d4c4fb27, 162, false}, // 10^68 - {0xb0de65388cc8ada8, 189, false}, // 10^76 - {0x83c7088e1aab65db, 216, false}, // 10^84 - {0xc45d1df942711d9a, 242, false}, // 10^92 - {0x924d692ca61be758, 269, false}, // 10^100 - {0xda01ee641a708dea, 295, false}, // 10^108 - {0xa26da3999aef774a, 322, false}, // 10^116 - {0xf209787bb47d6b85, 348, false}, // 10^124 - {0xb454e4a179dd1877, 375, false}, // 10^132 - {0x865b86925b9bc5c2, 402, false}, // 10^140 - {0xc83553c5c8965d3d, 428, false}, // 10^148 - {0x952ab45cfa97a0b3, 455, false}, // 10^156 - {0xde469fbd99a05fe3, 481, false}, // 10^164 - {0xa59bc234db398c25, 508, false}, // 10^172 - {0xf6c69a72a3989f5c, 534, false}, // 10^180 - {0xb7dcbf5354e9bece, 561, false}, // 10^188 - {0x88fcf317f22241e2, 588, false}, // 10^196 - {0xcc20ce9bd35c78a5, 614, false}, // 10^204 - {0x98165af37b2153df, 641, false}, // 10^212 - {0xe2a0b5dc971f303a, 667, false}, // 10^220 - {0xa8d9d1535ce3b396, 694, false}, // 10^228 - {0xfb9b7cd9a4a7443c, 720, false}, // 10^236 - {0xbb764c4ca7a44410, 747, false}, // 10^244 - {0x8bab8eefb6409c1a, 774, false}, // 10^252 - {0xd01fef10a657842c, 800, false}, // 10^260 - {0x9b10a4e5e9913129, 827, false}, // 10^268 - {0xe7109bfba19c0c9d, 853, false}, // 10^276 - {0xac2820d9623bf429, 880, false}, // 10^284 - {0x80444b5e7aa7cf85, 907, false}, // 10^292 - {0xbf21e44003acdd2d, 933, false}, // 10^300 - {0x8e679c2f5e44ff8f, 960, false}, // 10^308 - {0xd433179d9c8cb841, 986, false}, // 10^316 - {0x9e19db92b4e31ba9, 1013, false}, // 10^324 - {0xeb96bf6ebadf77d9, 1039, false}, // 10^332 - {0xaf87023b9bf0ee6b, 1066, false}, // 10^340 -} - -// floatBits returns the bits of the float64 that best approximates -// the extFloat passed as receiver. Overflow is set to true if -// the resulting float64 is ±Inf. -func (f *extFloat) floatBits(flt *floatInfo) (bits uint64, overflow bool) { - f.Normalize() - - exp := f.exp + 63 - - // Exponent too small. - if exp < flt.bias+1 { - n := flt.bias + 1 - exp - f.mant >>= uint(n) - exp += n - } - - // Extract 1+flt.mantbits bits from the 64-bit mantissa. - mant := f.mant >> (63 - flt.mantbits) - if f.mant&(1<<(62-flt.mantbits)) != 0 { - // Round up. - mant += 1 - } - - // Rounding might have added a bit; shift down. - if mant == 2<<flt.mantbits { - mant >>= 1 - exp++ - } - - // Infinities. - if exp-flt.bias >= 1<<flt.expbits-1 { - // ±Inf - mant = 0 - exp = 1<<flt.expbits - 1 + flt.bias - overflow = true - } else if mant&(1<<flt.mantbits) == 0 { - // Denormalized? - exp = flt.bias - } - // Assemble bits. - bits = mant & (uint64(1)<<flt.mantbits - 1) - bits |= uint64((exp-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits - if f.neg { - bits |= 1 << (flt.mantbits + flt.expbits) - } - return -} - -// AssignComputeBounds sets f to the floating point value -// defined by mant, exp and precision given by flt. It returns -// lower, upper such that any number in the closed interval -// [lower, upper] is converted back to the same floating point number. -func (f *extFloat) AssignComputeBounds(mant uint64, exp int, neg bool, flt *floatInfo) (lower, upper extFloat) { - f.mant = mant - f.exp = exp - int(flt.mantbits) - f.neg = neg - if f.exp <= 0 && mant == (mant>>uint(-f.exp))<<uint(-f.exp) { - // An exact integer - f.mant >>= uint(-f.exp) - f.exp = 0 - return *f, *f - } - expBiased := exp - flt.bias - - upper = extFloat{mant: 2*f.mant + 1, exp: f.exp - 1, neg: f.neg} - if mant != 1<<flt.mantbits || expBiased == 1 { - lower = extFloat{mant: 2*f.mant - 1, exp: f.exp - 1, neg: f.neg} - } else { - lower = extFloat{mant: 4*f.mant - 1, exp: f.exp - 2, neg: f.neg} - } - return -} - -// Normalize normalizes f so that the highest bit of the mantissa is -// set, and returns the number by which the mantissa was left-shifted. -func (f *extFloat) Normalize() (shift uint) { - mant, exp := f.mant, f.exp - if mant == 0 { - return 0 - } - if mant>>(64-32) == 0 { - mant <<= 32 - exp -= 32 - } - if mant>>(64-16) == 0 { - mant <<= 16 - exp -= 16 - } - if mant>>(64-8) == 0 { - mant <<= 8 - exp -= 8 - } - if mant>>(64-4) == 0 { - mant <<= 4 - exp -= 4 - } - if mant>>(64-2) == 0 { - mant <<= 2 - exp -= 2 - } - if mant>>(64-1) == 0 { - mant <<= 1 - exp -= 1 - } - shift = uint(f.exp - exp) - f.mant, f.exp = mant, exp - return -} - -// Multiply sets f to the product f*g: the result is correctly rounded, -// but not normalized. -func (f *extFloat) Multiply(g extFloat) { - fhi, flo := f.mant>>32, uint64(uint32(f.mant)) - ghi, glo := g.mant>>32, uint64(uint32(g.mant)) - - // Cross products. - cross1 := fhi * glo - cross2 := flo * ghi - - // f.mant*g.mant is fhi*ghi << 64 + (cross1+cross2) << 32 + flo*glo - f.mant = fhi*ghi + (cross1 >> 32) + (cross2 >> 32) - rem := uint64(uint32(cross1)) + uint64(uint32(cross2)) + ((flo * glo) >> 32) - // Round up. - rem += (1 << 31) - - f.mant += (rem >> 32) - f.exp = f.exp + g.exp + 64 -} - -var uint64pow10 = [...]uint64{ - 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, -} - -// AssignDecimal sets f to an approximate value mantissa*10^exp. It -// returns true if the value represented by f is guaranteed to be the -// best approximation of d after being rounded to a float64 or -// float32 depending on flt. -func (f *extFloat) AssignDecimal(mantissa uint64, exp10 int, neg bool, trunc bool, flt *floatInfo) (ok bool) { - const uint64digits = 19 - const errorscale = 8 - errors := 0 // An upper bound for error, computed in errorscale*ulp. - if trunc { - // the decimal number was truncated. - errors += errorscale / 2 - } - - f.mant = mantissa - f.exp = 0 - f.neg = neg - - // Multiply by powers of ten. - i := (exp10 - firstPowerOfTen) / stepPowerOfTen - if exp10 < firstPowerOfTen || i >= len(powersOfTen) { - return false - } - adjExp := (exp10 - firstPowerOfTen) % stepPowerOfTen - - // We multiply by exp%step - if adjExp < uint64digits && mantissa < uint64pow10[uint64digits-adjExp] { - // We can multiply the mantissa exactly. - f.mant *= uint64pow10[adjExp] - f.Normalize() - } else { - f.Normalize() - f.Multiply(smallPowersOfTen[adjExp]) - errors += errorscale / 2 - } - - // We multiply by 10 to the exp - exp%step. - f.Multiply(powersOfTen[i]) - if errors > 0 { - errors += 1 - } - errors += errorscale / 2 - - // Normalize - shift := f.Normalize() - errors <<= shift - - // Now f is a good approximation of the decimal. - // Check whether the error is too large: that is, if the mantissa - // is perturbated by the error, the resulting float64 will change. - // The 64 bits mantissa is 1 + 52 bits for float64 + 11 extra bits. - // - // In many cases the approximation will be good enough. - denormalExp := flt.bias - 63 - var extrabits uint - if f.exp <= denormalExp { - // f.mant * 2^f.exp is smaller than 2^(flt.bias+1). - extrabits = uint(63 - flt.mantbits + 1 + uint(denormalExp-f.exp)) - } else { - extrabits = uint(63 - flt.mantbits) - } - - halfway := uint64(1) << (extrabits - 1) - mant_extra := f.mant & (1<<extrabits - 1) - - // Do a signed comparison here! If the error estimate could make - // the mantissa round differently for the conversion to double, - // then we can't give a definite answer. - if int64(halfway)-int64(errors) < int64(mant_extra) && - int64(mant_extra) < int64(halfway)+int64(errors) { - return false - } - return true -} - -// Frexp10 is an analogue of math.Frexp for decimal powers. It scales -// f by an approximate power of ten 10^-exp, and returns exp10, so -// that f*10^exp10 has the same value as the old f, up to an ulp, -// as well as the index of 10^-exp in the powersOfTen table. -func (f *extFloat) frexp10() (exp10, index int) { - // The constants expMin and expMax constrain the final value of the - // binary exponent of f. We want a small integral part in the result - // because finding digits of an integer requires divisions, whereas - // digits of the fractional part can be found by repeatedly multiplying - // by 10. - const expMin = -60 - const expMax = -32 - // Find power of ten such that x * 10^n has a binary exponent - // between expMin and expMax. - approxExp10 := ((expMin+expMax)/2 - f.exp) * 28 / 93 // log(10)/log(2) is close to 93/28. - i := (approxExp10 - firstPowerOfTen) / stepPowerOfTen -Loop: - for { - exp := f.exp + powersOfTen[i].exp + 64 - switch { - case exp < expMin: - i++ - case exp > expMax: - i-- - default: - break Loop - } - } - // Apply the desired decimal shift on f. It will have exponent - // in the desired range. This is multiplication by 10^-exp10. - f.Multiply(powersOfTen[i]) - - return -(firstPowerOfTen + i*stepPowerOfTen), i -} - -// frexp10Many applies a common shift by a power of ten to a, b, c. -func frexp10Many(a, b, c *extFloat) (exp10 int) { - exp10, i := c.frexp10() - a.Multiply(powersOfTen[i]) - b.Multiply(powersOfTen[i]) - return -} - -// FixedDecimal stores in d the first n significant digits -// of the decimal representation of f. It returns false -// if it cannot be sure of the answer. -func (f *extFloat) FixedDecimal(d *decimalSlice, n int) bool { - if f.mant == 0 { - d.nd = 0 - d.dp = 0 - d.neg = f.neg - return true - } - if n == 0 { - panic("strconv: internal error: extFloat.FixedDecimal called with n == 0") - } - // Multiply by an appropriate power of ten to have a reasonable - // number to process. - f.Normalize() - exp10, _ := f.frexp10() - - shift := uint(-f.exp) - integer := uint32(f.mant >> shift) - fraction := f.mant - (uint64(integer) << shift) - ε := uint64(1) // ε is the uncertainty we have on the mantissa of f. - - // Write exactly n digits to d. - needed := n // how many digits are left to write. - integerDigits := 0 // the number of decimal digits of integer. - pow10 := uint64(1) // the power of ten by which f was scaled. - for i, pow := 0, uint64(1); i < 20; i++ { - if pow > uint64(integer) { - integerDigits = i - break - } - pow *= 10 - } - rest := integer - if integerDigits > needed { - // the integral part is already large, trim the last digits. - pow10 = uint64pow10[integerDigits-needed] - integer /= uint32(pow10) - rest -= integer * uint32(pow10) - } else { - rest = 0 - } - - // Write the digits of integer: the digits of rest are omitted. - var buf [32]byte - pos := len(buf) - for v := integer; v > 0; { - v1 := v / 10 - v -= 10 * v1 - pos-- - buf[pos] = byte(v + '0') - v = v1 - } - for i := pos; i < len(buf); i++ { - d.d[i-pos] = buf[i] - } - nd := len(buf) - pos - d.nd = nd - d.dp = integerDigits + exp10 - needed -= nd - - if needed > 0 { - if rest != 0 || pow10 != 1 { - panic("strconv: internal error, rest != 0 but needed > 0") - } - // Emit digits for the fractional part. Each time, 10*fraction - // fits in a uint64 without overflow. - for needed > 0 { - fraction *= 10 - ε *= 10 // the uncertainty scales as we multiply by ten. - if 2*ε > 1<<shift { - // the error is so large it could modify which digit to write, abort. - return false - } - digit := fraction >> shift - d.d[nd] = byte(digit + '0') - fraction -= digit << shift - nd++ - needed-- - } - d.nd = nd - } - - // We have written a truncation of f (a numerator / 10^d.dp). The remaining part - // can be interpreted as a small number (< 1) to be added to the last digit of the - // numerator. - // - // If rest > 0, the amount is: - // (rest<<shift | fraction) / (pow10 << shift) - // fraction being known with a ±ε uncertainty. - // The fact that n > 0 guarantees that pow10 << shift does not overflow a uint64. - // - // If rest = 0, pow10 == 1 and the amount is - // fraction / (1 << shift) - // fraction being known with a ±ε uncertainty. - // - // We pass this information to the rounding routine for adjustment. - - ok := adjustLastDigitFixed(d, uint64(rest)<<shift|fraction, pow10, shift, ε) - if !ok { - return false - } - // Trim trailing zeros. - for i := d.nd - 1; i >= 0; i-- { - if d.d[i] != '0' { - d.nd = i + 1 - break - } - } - return true -} - -// adjustLastDigitFixed assumes d contains the representation of the integral part -// of some number, whose fractional part is num / (den << shift). The numerator -// num is only known up to an uncertainty of size ε, assumed to be less than -// (den << shift)/2. -// -// It will increase the last digit by one to account for correct rounding, typically -// when the fractional part is greater than 1/2, and will return false if ε is such -// that no correct answer can be given. -func adjustLastDigitFixed(d *decimalSlice, num, den uint64, shift uint, ε uint64) bool { - if num > den<<shift { - panic("strconv: num > den<<shift in adjustLastDigitFixed") - } - if 2*ε > den<<shift { - panic("strconv: ε > (den<<shift)/2") - } - if 2*(num+ε) < den<<shift { - return true - } - if 2*(num-ε) > den<<shift { - // increment d by 1. - i := d.nd - 1 - for ; i >= 0; i-- { - if d.d[i] == '9' { - d.nd-- - } else { - break - } - } - if i < 0 { - d.d[0] = '1' - d.nd = 1 - d.dp++ - } else { - d.d[i]++ - } - return true - } - return false -} - -// ShortestDecimal stores in d the shortest decimal representation of f -// which belongs to the open interval (lower, upper), where f is supposed -// to lie. It returns false whenever the result is unsure. The implementation -// uses the Grisu3 algorithm. -func (f *extFloat) ShortestDecimal(d *decimalSlice, lower, upper *extFloat) bool { - if f.mant == 0 { - d.nd = 0 - d.dp = 0 - d.neg = f.neg - return true - } - if f.exp == 0 && *lower == *f && *lower == *upper { - // an exact integer. - var buf [24]byte - n := len(buf) - 1 - for v := f.mant; v > 0; { - v1 := v / 10 - v -= 10 * v1 - buf[n] = byte(v + '0') - n-- - v = v1 - } - nd := len(buf) - n - 1 - for i := 0; i < nd; i++ { - d.d[i] = buf[n+1+i] - } - d.nd, d.dp = nd, nd - for d.nd > 0 && d.d[d.nd-1] == '0' { - d.nd-- - } - if d.nd == 0 { - d.dp = 0 - } - d.neg = f.neg - return true - } - upper.Normalize() - // Uniformize exponents. - if f.exp > upper.exp { - f.mant <<= uint(f.exp - upper.exp) - f.exp = upper.exp - } - if lower.exp > upper.exp { - lower.mant <<= uint(lower.exp - upper.exp) - lower.exp = upper.exp - } - - exp10 := frexp10Many(lower, f, upper) - // Take a safety margin due to rounding in frexp10Many, but we lose precision. - upper.mant++ - lower.mant-- - - // The shortest representation of f is either rounded up or down, but - // in any case, it is a truncation of upper. - shift := uint(-upper.exp) - integer := uint32(upper.mant >> shift) - fraction := upper.mant - (uint64(integer) << shift) - - // How far we can go down from upper until the result is wrong. - allowance := upper.mant - lower.mant - // How far we should go to get a very precise result. - targetDiff := upper.mant - f.mant - - // Count integral digits: there are at most 10. - var integerDigits int - for i, pow := 0, uint64(1); i < 20; i++ { - if pow > uint64(integer) { - integerDigits = i - break - } - pow *= 10 - } - for i := 0; i < integerDigits; i++ { - pow := uint64pow10[integerDigits-i-1] - digit := integer / uint32(pow) - d.d[i] = byte(digit + '0') - integer -= digit * uint32(pow) - // evaluate whether we should stop. - if currentDiff := uint64(integer)<<shift + fraction; currentDiff < allowance { - d.nd = i + 1 - d.dp = integerDigits + exp10 - d.neg = f.neg - // Sometimes allowance is so large the last digit might need to be - // decremented to get closer to f. - return adjustLastDigit(d, currentDiff, targetDiff, allowance, pow<<shift, 2) - } - } - d.nd = integerDigits - d.dp = d.nd + exp10 - d.neg = f.neg - - // Compute digits of the fractional part. At each step fraction does not - // overflow. The choice of minExp implies that fraction is less than 2^60. - var digit int - multiplier := uint64(1) - for { - fraction *= 10 - multiplier *= 10 - digit = int(fraction >> shift) - d.d[d.nd] = byte(digit + '0') - d.nd++ - fraction -= uint64(digit) << shift - if fraction < allowance*multiplier { - // We are in the admissible range. Note that if allowance is about to - // overflow, that is, allowance > 2^64/10, the condition is automatically - // true due to the limited range of fraction. - return adjustLastDigit(d, - fraction, targetDiff*multiplier, allowance*multiplier, - 1<<shift, multiplier*2) - } - } -} - -// adjustLastDigit modifies d = x-currentDiff*ε, to get closest to -// d = x-targetDiff*ε, without becoming smaller than x-maxDiff*ε. -// It assumes that a decimal digit is worth ulpDecimal*ε, and that -// all data is known with a error estimate of ulpBinary*ε. -func adjustLastDigit(d *decimalSlice, currentDiff, targetDiff, maxDiff, ulpDecimal, ulpBinary uint64) bool { - if ulpDecimal < 2*ulpBinary { - // Approximation is too wide. - return false - } - for currentDiff+ulpDecimal/2+ulpBinary < targetDiff { - d.d[d.nd-1]-- - currentDiff += ulpDecimal - } - if currentDiff+ulpDecimal <= targetDiff+ulpDecimal/2+ulpBinary { - // we have two choices, and don't know what to do. - return false - } - if currentDiff < ulpBinary || currentDiff > maxDiff-ulpBinary { - // we went too far - return false - } - if d.nd == 1 && d.d[0] == '0' { - // the number has actually reached zero. - d.nd = 0 - d.dp = 0 - } - return true -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/fold.go b/vendor/github.com/pquerna/ffjson/fflib/v1/fold.go deleted file mode 100644 index 4d33e6f77..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/fold.go +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on Go stdlib's encoding/json/fold.go */ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package v1 - -import ( - "unicode/utf8" -) - -const ( - caseMask = ^byte(0x20) // Mask to ignore case in ASCII. - kelvin = '\u212a' - smallLongEss = '\u017f' -) - -// equalFoldRight is a specialization of bytes.EqualFold when s is -// known to be all ASCII (including punctuation), but contains an 's', -// 'S', 'k', or 'K', requiring a Unicode fold on the bytes in t. -// See comments on foldFunc. -func EqualFoldRight(s, t []byte) bool { - for _, sb := range s { - if len(t) == 0 { - return false - } - tb := t[0] - if tb < utf8.RuneSelf { - if sb != tb { - sbUpper := sb & caseMask - if 'A' <= sbUpper && sbUpper <= 'Z' { - if sbUpper != tb&caseMask { - return false - } - } else { - return false - } - } - t = t[1:] - continue - } - // sb is ASCII and t is not. t must be either kelvin - // sign or long s; sb must be s, S, k, or K. - tr, size := utf8.DecodeRune(t) - switch sb { - case 's', 'S': - if tr != smallLongEss { - return false - } - case 'k', 'K': - if tr != kelvin { - return false - } - default: - return false - } - t = t[size:] - - } - if len(t) > 0 { - return false - } - return true -} - -// asciiEqualFold is a specialization of bytes.EqualFold for use when -// s is all ASCII (but may contain non-letters) and contains no -// special-folding letters. -// See comments on foldFunc. -func AsciiEqualFold(s, t []byte) bool { - if len(s) != len(t) { - return false - } - for i, sb := range s { - tb := t[i] - if sb == tb { - continue - } - if ('a' <= sb && sb <= 'z') || ('A' <= sb && sb <= 'Z') { - if sb&caseMask != tb&caseMask { - return false - } - } else { - return false - } - } - return true -} - -// simpleLetterEqualFold is a specialization of bytes.EqualFold for -// use when s is all ASCII letters (no underscores, etc) and also -// doesn't contain 'k', 'K', 's', or 'S'. -// See comments on foldFunc. -func SimpleLetterEqualFold(s, t []byte) bool { - if len(s) != len(t) { - return false - } - for i, b := range s { - if b&caseMask != t[i]&caseMask { - return false - } - } - return true -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/ftoa.go b/vendor/github.com/pquerna/ffjson/fflib/v1/ftoa.go deleted file mode 100644 index 360d6dbcf..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/ftoa.go +++ /dev/null @@ -1,542 +0,0 @@ -package v1 - -/** - * Copyright 2015 Paul Querna, Klaus Post - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Most of this file are on Go stdlib's strconv/ftoa.go */ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -import "math" - -// TODO: move elsewhere? -type floatInfo struct { - mantbits uint - expbits uint - bias int -} - -var optimize = true // can change for testing - -var float32info = floatInfo{23, 8, -127} -var float64info = floatInfo{52, 11, -1023} - -// AppendFloat appends the string form of the floating-point number f, -// as generated by FormatFloat -func AppendFloat(dst EncodingBuffer, val float64, fmt byte, prec, bitSize int) { - var bits uint64 - var flt *floatInfo - switch bitSize { - case 32: - bits = uint64(math.Float32bits(float32(val))) - flt = &float32info - case 64: - bits = math.Float64bits(val) - flt = &float64info - default: - panic("strconv: illegal AppendFloat/FormatFloat bitSize") - } - - neg := bits>>(flt.expbits+flt.mantbits) != 0 - exp := int(bits>>flt.mantbits) & (1<<flt.expbits - 1) - mant := bits & (uint64(1)<<flt.mantbits - 1) - - switch exp { - case 1<<flt.expbits - 1: - // Inf, NaN - var s string - switch { - case mant != 0: - s = "NaN" - case neg: - s = "-Inf" - default: - s = "+Inf" - } - dst.WriteString(s) - return - - case 0: - // denormalized - exp++ - - default: - // add implicit top bit - mant |= uint64(1) << flt.mantbits - } - exp += flt.bias - - // Pick off easy binary format. - if fmt == 'b' { - fmtB(dst, neg, mant, exp, flt) - return - } - - if !optimize { - bigFtoa(dst, prec, fmt, neg, mant, exp, flt) - return - } - - var digs decimalSlice - ok := false - // Negative precision means "only as much as needed to be exact." - shortest := prec < 0 - if shortest { - // Try Grisu3 algorithm. - f := new(extFloat) - lower, upper := f.AssignComputeBounds(mant, exp, neg, flt) - var buf [32]byte - digs.d = buf[:] - ok = f.ShortestDecimal(&digs, &lower, &upper) - if !ok { - bigFtoa(dst, prec, fmt, neg, mant, exp, flt) - return - } - // Precision for shortest representation mode. - switch fmt { - case 'e', 'E': - prec = max(digs.nd-1, 0) - case 'f': - prec = max(digs.nd-digs.dp, 0) - case 'g', 'G': - prec = digs.nd - } - } else if fmt != 'f' { - // Fixed number of digits. - digits := prec - switch fmt { - case 'e', 'E': - digits++ - case 'g', 'G': - if prec == 0 { - prec = 1 - } - digits = prec - } - if digits <= 15 { - // try fast algorithm when the number of digits is reasonable. - var buf [24]byte - digs.d = buf[:] - f := extFloat{mant, exp - int(flt.mantbits), neg} - ok = f.FixedDecimal(&digs, digits) - } - } - if !ok { - bigFtoa(dst, prec, fmt, neg, mant, exp, flt) - return - } - formatDigits(dst, shortest, neg, digs, prec, fmt) - return -} - -// bigFtoa uses multiprecision computations to format a float. -func bigFtoa(dst EncodingBuffer, prec int, fmt byte, neg bool, mant uint64, exp int, flt *floatInfo) { - d := new(decimal) - d.Assign(mant) - d.Shift(exp - int(flt.mantbits)) - var digs decimalSlice - shortest := prec < 0 - if shortest { - roundShortest(d, mant, exp, flt) - digs = decimalSlice{d: d.d[:], nd: d.nd, dp: d.dp} - // Precision for shortest representation mode. - switch fmt { - case 'e', 'E': - prec = digs.nd - 1 - case 'f': - prec = max(digs.nd-digs.dp, 0) - case 'g', 'G': - prec = digs.nd - } - } else { - // Round appropriately. - switch fmt { - case 'e', 'E': - d.Round(prec + 1) - case 'f': - d.Round(d.dp + prec) - case 'g', 'G': - if prec == 0 { - prec = 1 - } - d.Round(prec) - } - digs = decimalSlice{d: d.d[:], nd: d.nd, dp: d.dp} - } - formatDigits(dst, shortest, neg, digs, prec, fmt) - return -} - -func formatDigits(dst EncodingBuffer, shortest bool, neg bool, digs decimalSlice, prec int, fmt byte) { - switch fmt { - case 'e', 'E': - fmtE(dst, neg, digs, prec, fmt) - return - case 'f': - fmtF(dst, neg, digs, prec) - return - case 'g', 'G': - // trailing fractional zeros in 'e' form will be trimmed. - eprec := prec - if eprec > digs.nd && digs.nd >= digs.dp { - eprec = digs.nd - } - // %e is used if the exponent from the conversion - // is less than -4 or greater than or equal to the precision. - // if precision was the shortest possible, use precision 6 for this decision. - if shortest { - eprec = 6 - } - exp := digs.dp - 1 - if exp < -4 || exp >= eprec { - if prec > digs.nd { - prec = digs.nd - } - fmtE(dst, neg, digs, prec-1, fmt+'e'-'g') - return - } - if prec > digs.dp { - prec = digs.nd - } - fmtF(dst, neg, digs, max(prec-digs.dp, 0)) - return - } - - // unknown format - dst.Write([]byte{'%', fmt}) - return -} - -// Round d (= mant * 2^exp) to the shortest number of digits -// that will let the original floating point value be precisely -// reconstructed. Size is original floating point size (64 or 32). -func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo) { - // If mantissa is zero, the number is zero; stop now. - if mant == 0 { - d.nd = 0 - return - } - - // Compute upper and lower such that any decimal number - // between upper and lower (possibly inclusive) - // will round to the original floating point number. - - // We may see at once that the number is already shortest. - // - // Suppose d is not denormal, so that 2^exp <= d < 10^dp. - // The closest shorter number is at least 10^(dp-nd) away. - // The lower/upper bounds computed below are at distance - // at most 2^(exp-mantbits). - // - // So the number is already shortest if 10^(dp-nd) > 2^(exp-mantbits), - // or equivalently log2(10)*(dp-nd) > exp-mantbits. - // It is true if 332/100*(dp-nd) >= exp-mantbits (log2(10) > 3.32). - minexp := flt.bias + 1 // minimum possible exponent - if exp > minexp && 332*(d.dp-d.nd) >= 100*(exp-int(flt.mantbits)) { - // The number is already shortest. - return - } - - // d = mant << (exp - mantbits) - // Next highest floating point number is mant+1 << exp-mantbits. - // Our upper bound is halfway between, mant*2+1 << exp-mantbits-1. - upper := new(decimal) - upper.Assign(mant*2 + 1) - upper.Shift(exp - int(flt.mantbits) - 1) - - // d = mant << (exp - mantbits) - // Next lowest floating point number is mant-1 << exp-mantbits, - // unless mant-1 drops the significant bit and exp is not the minimum exp, - // in which case the next lowest is mant*2-1 << exp-mantbits-1. - // Either way, call it mantlo << explo-mantbits. - // Our lower bound is halfway between, mantlo*2+1 << explo-mantbits-1. - var mantlo uint64 - var explo int - if mant > 1<<flt.mantbits || exp == minexp { - mantlo = mant - 1 - explo = exp - } else { - mantlo = mant*2 - 1 - explo = exp - 1 - } - lower := new(decimal) - lower.Assign(mantlo*2 + 1) - lower.Shift(explo - int(flt.mantbits) - 1) - - // The upper and lower bounds are possible outputs only if - // the original mantissa is even, so that IEEE round-to-even - // would round to the original mantissa and not the neighbors. - inclusive := mant%2 == 0 - - // Now we can figure out the minimum number of digits required. - // Walk along until d has distinguished itself from upper and lower. - for i := 0; i < d.nd; i++ { - var l, m, u byte // lower, middle, upper digits - if i < lower.nd { - l = lower.d[i] - } else { - l = '0' - } - m = d.d[i] - if i < upper.nd { - u = upper.d[i] - } else { - u = '0' - } - - // Okay to round down (truncate) if lower has a different digit - // or if lower is inclusive and is exactly the result of rounding down. - okdown := l != m || (inclusive && l == m && i+1 == lower.nd) - - // Okay to round up if upper has a different digit and - // either upper is inclusive or upper is bigger than the result of rounding up. - okup := m != u && (inclusive || m+1 < u || i+1 < upper.nd) - - // If it's okay to do either, then round to the nearest one. - // If it's okay to do only one, do it. - switch { - case okdown && okup: - d.Round(i + 1) - return - case okdown: - d.RoundDown(i + 1) - return - case okup: - d.RoundUp(i + 1) - return - } - } -} - -type decimalSlice struct { - d []byte - nd, dp int - neg bool -} - -// %e: -d.ddddde±dd -func fmtE(dst EncodingBuffer, neg bool, d decimalSlice, prec int, fmt byte) { - // sign - if neg { - dst.WriteByte('-') - } - - // first digit - ch := byte('0') - if d.nd != 0 { - ch = d.d[0] - } - dst.WriteByte(ch) - - // .moredigits - if prec > 0 { - dst.WriteByte('.') - i := 1 - m := min(d.nd, prec+1) - if i < m { - dst.Write(d.d[i:m]) - i = m - } - for i <= prec { - dst.WriteByte('0') - i++ - } - } - - // e± - dst.WriteByte(fmt) - exp := d.dp - 1 - if d.nd == 0 { // special case: 0 has exponent 0 - exp = 0 - } - if exp < 0 { - ch = '-' - exp = -exp - } else { - ch = '+' - } - dst.WriteByte(ch) - - // dd or ddd - switch { - case exp < 10: - dst.WriteByte('0') - dst.WriteByte(byte(exp) + '0') - case exp < 100: - dst.WriteByte(byte(exp/10) + '0') - dst.WriteByte(byte(exp%10) + '0') - default: - dst.WriteByte(byte(exp/100) + '0') - dst.WriteByte(byte(exp/10)%10 + '0') - dst.WriteByte(byte(exp%10) + '0') - } - - return -} - -// %f: -ddddddd.ddddd -func fmtF(dst EncodingBuffer, neg bool, d decimalSlice, prec int) { - // sign - if neg { - dst.WriteByte('-') - } - - // integer, padded with zeros as needed. - if d.dp > 0 { - m := min(d.nd, d.dp) - dst.Write(d.d[:m]) - for ; m < d.dp; m++ { - dst.WriteByte('0') - } - } else { - dst.WriteByte('0') - } - - // fraction - if prec > 0 { - dst.WriteByte('.') - for i := 0; i < prec; i++ { - ch := byte('0') - if j := d.dp + i; 0 <= j && j < d.nd { - ch = d.d[j] - } - dst.WriteByte(ch) - } - } - - return -} - -// %b: -ddddddddp±ddd -func fmtB(dst EncodingBuffer, neg bool, mant uint64, exp int, flt *floatInfo) { - // sign - if neg { - dst.WriteByte('-') - } - - // mantissa - formatBits(dst, mant, 10, false) - - // p - dst.WriteByte('p') - - // ±exponent - exp -= int(flt.mantbits) - if exp >= 0 { - dst.WriteByte('+') - } - formatBits(dst, uint64(exp), 10, exp < 0) - - return -} - -func min(a, b int) int { - if a < b { - return a - } - return b -} - -func max(a, b int) int { - if a > b { - return a - } - return b -} - -// formatBits computes the string representation of u in the given base. -// If neg is set, u is treated as negative int64 value. -func formatBits(dst EncodingBuffer, u uint64, base int, neg bool) { - if base < 2 || base > len(digits) { - panic("strconv: illegal AppendInt/FormatInt base") - } - // 2 <= base && base <= len(digits) - - var a [64 + 1]byte // +1 for sign of 64bit value in base 2 - i := len(a) - - if neg { - u = -u - } - - // convert bits - if base == 10 { - // common case: use constants for / because - // the compiler can optimize it into a multiply+shift - - if ^uintptr(0)>>32 == 0 { - for u > uint64(^uintptr(0)) { - q := u / 1e9 - us := uintptr(u - q*1e9) // us % 1e9 fits into a uintptr - for j := 9; j > 0; j-- { - i-- - qs := us / 10 - a[i] = byte(us - qs*10 + '0') - us = qs - } - u = q - } - } - - // u guaranteed to fit into a uintptr - us := uintptr(u) - for us >= 10 { - i-- - q := us / 10 - a[i] = byte(us - q*10 + '0') - us = q - } - // u < 10 - i-- - a[i] = byte(us + '0') - - } else if s := shifts[base]; s > 0 { - // base is power of 2: use shifts and masks instead of / and % - b := uint64(base) - m := uintptr(b) - 1 // == 1<<s - 1 - for u >= b { - i-- - a[i] = digits[uintptr(u)&m] - u >>= s - } - // u < base - i-- - a[i] = digits[uintptr(u)] - - } else { - // general case - b := uint64(base) - for u >= b { - i-- - q := u / b - a[i] = digits[uintptr(u-q*b)] - u = q - } - // u < base - i-- - a[i] = digits[uintptr(u)] - } - - // add sign, if any - if neg { - i-- - a[i] = '-' - } - - dst.Write(a[i:]) -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/atof.go b/vendor/github.com/pquerna/ffjson/fflib/v1/internal/atof.go deleted file mode 100644 index 46c1289ec..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/atof.go +++ /dev/null @@ -1,936 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on Go stdlib's strconv/atof.go */ - -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package internal - -// decimal to binary floating point conversion. -// Algorithm: -// 1) Store input in multiprecision decimal. -// 2) Multiply/divide decimal by powers of two until in range [0.5, 1) -// 3) Multiply by 2^precision and round to get mantissa. - -import "math" - -var optimize = true // can change for testing - -func equalIgnoreCase(s1 []byte, s2 []byte) bool { - if len(s1) != len(s2) { - return false - } - for i := 0; i < len(s1); i++ { - c1 := s1[i] - if 'A' <= c1 && c1 <= 'Z' { - c1 += 'a' - 'A' - } - c2 := s2[i] - if 'A' <= c2 && c2 <= 'Z' { - c2 += 'a' - 'A' - } - if c1 != c2 { - return false - } - } - return true -} - -func special(s []byte) (f float64, ok bool) { - if len(s) == 0 { - return - } - switch s[0] { - default: - return - case '+': - if equalIgnoreCase(s, []byte("+inf")) || equalIgnoreCase(s, []byte("+infinity")) { - return math.Inf(1), true - } - case '-': - if equalIgnoreCase(s, []byte("-inf")) || equalIgnoreCase(s, []byte("-infinity")) { - return math.Inf(-1), true - } - case 'n', 'N': - if equalIgnoreCase(s, []byte("nan")) { - return math.NaN(), true - } - case 'i', 'I': - if equalIgnoreCase(s, []byte("inf")) || equalIgnoreCase(s, []byte("infinity")) { - return math.Inf(1), true - } - } - return -} - -func (b *decimal) set(s []byte) (ok bool) { - i := 0 - b.neg = false - b.trunc = false - - // optional sign - if i >= len(s) { - return - } - switch { - case s[i] == '+': - i++ - case s[i] == '-': - b.neg = true - i++ - } - - // digits - sawdot := false - sawdigits := false - for ; i < len(s); i++ { - switch { - case s[i] == '.': - if sawdot { - return - } - sawdot = true - b.dp = b.nd - continue - - case '0' <= s[i] && s[i] <= '9': - sawdigits = true - if s[i] == '0' && b.nd == 0 { // ignore leading zeros - b.dp-- - continue - } - if b.nd < len(b.d) { - b.d[b.nd] = s[i] - b.nd++ - } else if s[i] != '0' { - b.trunc = true - } - continue - } - break - } - if !sawdigits { - return - } - if !sawdot { - b.dp = b.nd - } - - // optional exponent moves decimal point. - // if we read a very large, very long number, - // just be sure to move the decimal point by - // a lot (say, 100000). it doesn't matter if it's - // not the exact number. - if i < len(s) && (s[i] == 'e' || s[i] == 'E') { - i++ - if i >= len(s) { - return - } - esign := 1 - if s[i] == '+' { - i++ - } else if s[i] == '-' { - i++ - esign = -1 - } - if i >= len(s) || s[i] < '0' || s[i] > '9' { - return - } - e := 0 - for ; i < len(s) && '0' <= s[i] && s[i] <= '9'; i++ { - if e < 10000 { - e = e*10 + int(s[i]) - '0' - } - } - b.dp += e * esign - } - - if i != len(s) { - return - } - - ok = true - return -} - -// readFloat reads a decimal mantissa and exponent from a float -// string representation. It sets ok to false if the number could -// not fit return types or is invalid. -func readFloat(s []byte) (mantissa uint64, exp int, neg, trunc, ok bool) { - const uint64digits = 19 - i := 0 - - // optional sign - if i >= len(s) { - return - } - switch { - case s[i] == '+': - i++ - case s[i] == '-': - neg = true - i++ - } - - // digits - sawdot := false - sawdigits := false - nd := 0 - ndMant := 0 - dp := 0 - for ; i < len(s); i++ { - switch c := s[i]; true { - case c == '.': - if sawdot { - return - } - sawdot = true - dp = nd - continue - - case '0' <= c && c <= '9': - sawdigits = true - if c == '0' && nd == 0 { // ignore leading zeros - dp-- - continue - } - nd++ - if ndMant < uint64digits { - mantissa *= 10 - mantissa += uint64(c - '0') - ndMant++ - } else if s[i] != '0' { - trunc = true - } - continue - } - break - } - if !sawdigits { - return - } - if !sawdot { - dp = nd - } - - // optional exponent moves decimal point. - // if we read a very large, very long number, - // just be sure to move the decimal point by - // a lot (say, 100000). it doesn't matter if it's - // not the exact number. - if i < len(s) && (s[i] == 'e' || s[i] == 'E') { - i++ - if i >= len(s) { - return - } - esign := 1 - if s[i] == '+' { - i++ - } else if s[i] == '-' { - i++ - esign = -1 - } - if i >= len(s) || s[i] < '0' || s[i] > '9' { - return - } - e := 0 - for ; i < len(s) && '0' <= s[i] && s[i] <= '9'; i++ { - if e < 10000 { - e = e*10 + int(s[i]) - '0' - } - } - dp += e * esign - } - - if i != len(s) { - return - } - - exp = dp - ndMant - ok = true - return - -} - -// decimal power of ten to binary power of two. -var powtab = []int{1, 3, 6, 9, 13, 16, 19, 23, 26} - -func (d *decimal) floatBits(flt *floatInfo) (b uint64, overflow bool) { - var exp int - var mant uint64 - - // Zero is always a special case. - if d.nd == 0 { - mant = 0 - exp = flt.bias - goto out - } - - // Obvious overflow/underflow. - // These bounds are for 64-bit floats. - // Will have to change if we want to support 80-bit floats in the future. - if d.dp > 310 { - goto overflow - } - if d.dp < -330 { - // zero - mant = 0 - exp = flt.bias - goto out - } - - // Scale by powers of two until in range [0.5, 1.0) - exp = 0 - for d.dp > 0 { - var n int - if d.dp >= len(powtab) { - n = 27 - } else { - n = powtab[d.dp] - } - d.Shift(-n) - exp += n - } - for d.dp < 0 || d.dp == 0 && d.d[0] < '5' { - var n int - if -d.dp >= len(powtab) { - n = 27 - } else { - n = powtab[-d.dp] - } - d.Shift(n) - exp -= n - } - - // Our range is [0.5,1) but floating point range is [1,2). - exp-- - - // Minimum representable exponent is flt.bias+1. - // If the exponent is smaller, move it up and - // adjust d accordingly. - if exp < flt.bias+1 { - n := flt.bias + 1 - exp - d.Shift(-n) - exp += n - } - - if exp-flt.bias >= 1<<flt.expbits-1 { - goto overflow - } - - // Extract 1+flt.mantbits bits. - d.Shift(int(1 + flt.mantbits)) - mant = d.RoundedInteger() - - // Rounding might have added a bit; shift down. - if mant == 2<<flt.mantbits { - mant >>= 1 - exp++ - if exp-flt.bias >= 1<<flt.expbits-1 { - goto overflow - } - } - - // Denormalized? - if mant&(1<<flt.mantbits) == 0 { - exp = flt.bias - } - goto out - -overflow: - // ±Inf - mant = 0 - exp = 1<<flt.expbits - 1 + flt.bias - overflow = true - -out: - // Assemble bits. - bits := mant & (uint64(1)<<flt.mantbits - 1) - bits |= uint64((exp-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits - if d.neg { - bits |= 1 << flt.mantbits << flt.expbits - } - return bits, overflow -} - -// Exact powers of 10. -var float64pow10 = []float64{ - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22, -} -var float32pow10 = []float32{1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10} - -// If possible to convert decimal representation to 64-bit float f exactly, -// entirely in floating-point math, do so, avoiding the expense of decimalToFloatBits. -// Three common cases: -// value is exact integer -// value is exact integer * exact power of ten -// value is exact integer / exact power of ten -// These all produce potentially inexact but correctly rounded answers. -func atof64exact(mantissa uint64, exp int, neg bool) (f float64, ok bool) { - if mantissa>>float64info.mantbits != 0 { - return - } - f = float64(mantissa) - if neg { - f = -f - } - switch { - case exp == 0: - // an integer. - return f, true - // Exact integers are <= 10^15. - // Exact powers of ten are <= 10^22. - case exp > 0 && exp <= 15+22: // int * 10^k - // If exponent is big but number of digits is not, - // can move a few zeros into the integer part. - if exp > 22 { - f *= float64pow10[exp-22] - exp = 22 - } - if f > 1e15 || f < -1e15 { - // the exponent was really too large. - return - } - return f * float64pow10[exp], true - case exp < 0 && exp >= -22: // int / 10^k - return f / float64pow10[-exp], true - } - return -} - -// If possible to compute mantissa*10^exp to 32-bit float f exactly, -// entirely in floating-point math, do so, avoiding the machinery above. -func atof32exact(mantissa uint64, exp int, neg bool) (f float32, ok bool) { - if mantissa>>float32info.mantbits != 0 { - return - } - f = float32(mantissa) - if neg { - f = -f - } - switch { - case exp == 0: - return f, true - // Exact integers are <= 10^7. - // Exact powers of ten are <= 10^10. - case exp > 0 && exp <= 7+10: // int * 10^k - // If exponent is big but number of digits is not, - // can move a few zeros into the integer part. - if exp > 10 { - f *= float32pow10[exp-10] - exp = 10 - } - if f > 1e7 || f < -1e7 { - // the exponent was really too large. - return - } - return f * float32pow10[exp], true - case exp < 0 && exp >= -10: // int / 10^k - return f / float32pow10[-exp], true - } - return -} - -const fnParseFloat = "ParseFloat" - -func atof32(s []byte) (f float32, err error) { - if val, ok := special(s); ok { - return float32(val), nil - } - - if optimize { - // Parse mantissa and exponent. - mantissa, exp, neg, trunc, ok := readFloat(s) - if ok { - // Try pure floating-point arithmetic conversion. - if !trunc { - if f, ok := atof32exact(mantissa, exp, neg); ok { - return f, nil - } - } - // Try another fast path. - ext := new(extFloat) - if ok := ext.AssignDecimal(mantissa, exp, neg, trunc, &float32info); ok { - b, ovf := ext.floatBits(&float32info) - f = math.Float32frombits(uint32(b)) - if ovf { - err = rangeError(fnParseFloat, string(s)) - } - return f, err - } - } - } - var d decimal - if !d.set(s) { - return 0, syntaxError(fnParseFloat, string(s)) - } - b, ovf := d.floatBits(&float32info) - f = math.Float32frombits(uint32(b)) - if ovf { - err = rangeError(fnParseFloat, string(s)) - } - return f, err -} - -func atof64(s []byte) (f float64, err error) { - if val, ok := special(s); ok { - return val, nil - } - - if optimize { - // Parse mantissa and exponent. - mantissa, exp, neg, trunc, ok := readFloat(s) - if ok { - // Try pure floating-point arithmetic conversion. - if !trunc { - if f, ok := atof64exact(mantissa, exp, neg); ok { - return f, nil - } - } - // Try another fast path. - ext := new(extFloat) - if ok := ext.AssignDecimal(mantissa, exp, neg, trunc, &float64info); ok { - b, ovf := ext.floatBits(&float64info) - f = math.Float64frombits(b) - if ovf { - err = rangeError(fnParseFloat, string(s)) - } - return f, err - } - } - } - var d decimal - if !d.set(s) { - return 0, syntaxError(fnParseFloat, string(s)) - } - b, ovf := d.floatBits(&float64info) - f = math.Float64frombits(b) - if ovf { - err = rangeError(fnParseFloat, string(s)) - } - return f, err -} - -// ParseFloat converts the string s to a floating-point number -// with the precision specified by bitSize: 32 for float32, or 64 for float64. -// When bitSize=32, the result still has type float64, but it will be -// convertible to float32 without changing its value. -// -// If s is well-formed and near a valid floating point number, -// ParseFloat returns the nearest floating point number rounded -// using IEEE754 unbiased rounding. -// -// The errors that ParseFloat returns have concrete type *NumError -// and include err.Num = s. -// -// If s is not syntactically well-formed, ParseFloat returns err.Err = ErrSyntax. -// -// If s is syntactically well-formed but is more than 1/2 ULP -// away from the largest floating point number of the given size, -// ParseFloat returns f = ±Inf, err.Err = ErrRange. -func ParseFloat(s []byte, bitSize int) (f float64, err error) { - if bitSize == 32 { - f1, err1 := atof32(s) - return float64(f1), err1 - } - f1, err1 := atof64(s) - return f1, err1 -} - -// oroginal: strconv/decimal.go, but not exported, and needed for PareFloat. - -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Multiprecision decimal numbers. -// For floating-point formatting only; not general purpose. -// Only operations are assign and (binary) left/right shift. -// Can do binary floating point in multiprecision decimal precisely -// because 2 divides 10; cannot do decimal floating point -// in multiprecision binary precisely. - -type decimal struct { - d [800]byte // digits - nd int // number of digits used - dp int // decimal point - neg bool - trunc bool // discarded nonzero digits beyond d[:nd] -} - -func (a *decimal) String() string { - n := 10 + a.nd - if a.dp > 0 { - n += a.dp - } - if a.dp < 0 { - n += -a.dp - } - - buf := make([]byte, n) - w := 0 - switch { - case a.nd == 0: - return "0" - - case a.dp <= 0: - // zeros fill space between decimal point and digits - buf[w] = '0' - w++ - buf[w] = '.' - w++ - w += digitZero(buf[w : w+-a.dp]) - w += copy(buf[w:], a.d[0:a.nd]) - - case a.dp < a.nd: - // decimal point in middle of digits - w += copy(buf[w:], a.d[0:a.dp]) - buf[w] = '.' - w++ - w += copy(buf[w:], a.d[a.dp:a.nd]) - - default: - // zeros fill space between digits and decimal point - w += copy(buf[w:], a.d[0:a.nd]) - w += digitZero(buf[w : w+a.dp-a.nd]) - } - return string(buf[0:w]) -} - -func digitZero(dst []byte) int { - for i := range dst { - dst[i] = '0' - } - return len(dst) -} - -// trim trailing zeros from number. -// (They are meaningless; the decimal point is tracked -// independent of the number of digits.) -func trim(a *decimal) { - for a.nd > 0 && a.d[a.nd-1] == '0' { - a.nd-- - } - if a.nd == 0 { - a.dp = 0 - } -} - -// Assign v to a. -func (a *decimal) Assign(v uint64) { - var buf [24]byte - - // Write reversed decimal in buf. - n := 0 - for v > 0 { - v1 := v / 10 - v -= 10 * v1 - buf[n] = byte(v + '0') - n++ - v = v1 - } - - // Reverse again to produce forward decimal in a.d. - a.nd = 0 - for n--; n >= 0; n-- { - a.d[a.nd] = buf[n] - a.nd++ - } - a.dp = a.nd - trim(a) -} - -// Maximum shift that we can do in one pass without overflow. -// Signed int has 31 bits, and we have to be able to accommodate 9<<k. -const maxShift = 27 - -// Binary shift right (* 2) by k bits. k <= maxShift to avoid overflow. -func rightShift(a *decimal, k uint) { - r := 0 // read pointer - w := 0 // write pointer - - // Pick up enough leading digits to cover first shift. - n := 0 - for ; n>>k == 0; r++ { - if r >= a.nd { - if n == 0 { - // a == 0; shouldn't get here, but handle anyway. - a.nd = 0 - return - } - for n>>k == 0 { - n = n * 10 - r++ - } - break - } - c := int(a.d[r]) - n = n*10 + c - '0' - } - a.dp -= r - 1 - - // Pick up a digit, put down a digit. - for ; r < a.nd; r++ { - c := int(a.d[r]) - dig := n >> k - n -= dig << k - a.d[w] = byte(dig + '0') - w++ - n = n*10 + c - '0' - } - - // Put down extra digits. - for n > 0 { - dig := n >> k - n -= dig << k - if w < len(a.d) { - a.d[w] = byte(dig + '0') - w++ - } else if dig > 0 { - a.trunc = true - } - n = n * 10 - } - - a.nd = w - trim(a) -} - -// Cheat sheet for left shift: table indexed by shift count giving -// number of new digits that will be introduced by that shift. -// -// For example, leftcheats[4] = {2, "625"}. That means that -// if we are shifting by 4 (multiplying by 16), it will add 2 digits -// when the string prefix is "625" through "999", and one fewer digit -// if the string prefix is "000" through "624". -// -// Credit for this trick goes to Ken. - -type leftCheat struct { - delta int // number of new digits - cutoff string // minus one digit if original < a. -} - -var leftcheats = []leftCheat{ - // Leading digits of 1/2^i = 5^i. - // 5^23 is not an exact 64-bit floating point number, - // so have to use bc for the math. - /* - seq 27 | sed 's/^/5^/' | bc | - awk 'BEGIN{ print "\tleftCheat{ 0, \"\" }," } - { - log2 = log(2)/log(10) - printf("\tleftCheat{ %d, \"%s\" },\t// * %d\n", - int(log2*NR+1), $0, 2**NR) - }' - */ - {0, ""}, - {1, "5"}, // * 2 - {1, "25"}, // * 4 - {1, "125"}, // * 8 - {2, "625"}, // * 16 - {2, "3125"}, // * 32 - {2, "15625"}, // * 64 - {3, "78125"}, // * 128 - {3, "390625"}, // * 256 - {3, "1953125"}, // * 512 - {4, "9765625"}, // * 1024 - {4, "48828125"}, // * 2048 - {4, "244140625"}, // * 4096 - {4, "1220703125"}, // * 8192 - {5, "6103515625"}, // * 16384 - {5, "30517578125"}, // * 32768 - {5, "152587890625"}, // * 65536 - {6, "762939453125"}, // * 131072 - {6, "3814697265625"}, // * 262144 - {6, "19073486328125"}, // * 524288 - {7, "95367431640625"}, // * 1048576 - {7, "476837158203125"}, // * 2097152 - {7, "2384185791015625"}, // * 4194304 - {7, "11920928955078125"}, // * 8388608 - {8, "59604644775390625"}, // * 16777216 - {8, "298023223876953125"}, // * 33554432 - {8, "1490116119384765625"}, // * 67108864 - {9, "7450580596923828125"}, // * 134217728 -} - -// Is the leading prefix of b lexicographically less than s? -func prefixIsLessThan(b []byte, s string) bool { - for i := 0; i < len(s); i++ { - if i >= len(b) { - return true - } - if b[i] != s[i] { - return b[i] < s[i] - } - } - return false -} - -// Binary shift left (/ 2) by k bits. k <= maxShift to avoid overflow. -func leftShift(a *decimal, k uint) { - delta := leftcheats[k].delta - if prefixIsLessThan(a.d[0:a.nd], leftcheats[k].cutoff) { - delta-- - } - - r := a.nd // read index - w := a.nd + delta // write index - n := 0 - - // Pick up a digit, put down a digit. - for r--; r >= 0; r-- { - n += (int(a.d[r]) - '0') << k - quo := n / 10 - rem := n - 10*quo - w-- - if w < len(a.d) { - a.d[w] = byte(rem + '0') - } else if rem != 0 { - a.trunc = true - } - n = quo - } - - // Put down extra digits. - for n > 0 { - quo := n / 10 - rem := n - 10*quo - w-- - if w < len(a.d) { - a.d[w] = byte(rem + '0') - } else if rem != 0 { - a.trunc = true - } - n = quo - } - - a.nd += delta - if a.nd >= len(a.d) { - a.nd = len(a.d) - } - a.dp += delta - trim(a) -} - -// Binary shift left (k > 0) or right (k < 0). -func (a *decimal) Shift(k int) { - switch { - case a.nd == 0: - // nothing to do: a == 0 - case k > 0: - for k > maxShift { - leftShift(a, maxShift) - k -= maxShift - } - leftShift(a, uint(k)) - case k < 0: - for k < -maxShift { - rightShift(a, maxShift) - k += maxShift - } - rightShift(a, uint(-k)) - } -} - -// If we chop a at nd digits, should we round up? -func shouldRoundUp(a *decimal, nd int) bool { - if nd < 0 || nd >= a.nd { - return false - } - if a.d[nd] == '5' && nd+1 == a.nd { // exactly halfway - round to even - // if we truncated, a little higher than what's recorded - always round up - if a.trunc { - return true - } - return nd > 0 && (a.d[nd-1]-'0')%2 != 0 - } - // not halfway - digit tells all - return a.d[nd] >= '5' -} - -// Round a to nd digits (or fewer). -// If nd is zero, it means we're rounding -// just to the left of the digits, as in -// 0.09 -> 0.1. -func (a *decimal) Round(nd int) { - if nd < 0 || nd >= a.nd { - return - } - if shouldRoundUp(a, nd) { - a.RoundUp(nd) - } else { - a.RoundDown(nd) - } -} - -// Round a down to nd digits (or fewer). -func (a *decimal) RoundDown(nd int) { - if nd < 0 || nd >= a.nd { - return - } - a.nd = nd - trim(a) -} - -// Round a up to nd digits (or fewer). -func (a *decimal) RoundUp(nd int) { - if nd < 0 || nd >= a.nd { - return - } - - // round up - for i := nd - 1; i >= 0; i-- { - c := a.d[i] - if c < '9' { // can stop after this digit - a.d[i]++ - a.nd = i + 1 - return - } - } - - // Number is all 9s. - // Change to single 1 with adjusted decimal point. - a.d[0] = '1' - a.nd = 1 - a.dp++ -} - -// Extract integer part, rounded appropriately. -// No guarantees about overflow. -func (a *decimal) RoundedInteger() uint64 { - if a.dp > 20 { - return 0xFFFFFFFFFFFFFFFF - } - var i int - n := uint64(0) - for i = 0; i < a.dp && i < a.nd; i++ { - n = n*10 + uint64(a.d[i]-'0') - } - for ; i < a.dp; i++ { - n *= 10 - } - if shouldRoundUp(a, a.dp) { - n++ - } - return n -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/atoi.go b/vendor/github.com/pquerna/ffjson/fflib/v1/internal/atoi.go deleted file mode 100644 index 06eb2ec29..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/atoi.go +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on Go stdlib's strconv/atoi.go */ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package internal - -import ( - "errors" - "strconv" -) - -// ErrRange indicates that a value is out of range for the target type. -var ErrRange = errors.New("value out of range") - -// ErrSyntax indicates that a value does not have the right syntax for the target type. -var ErrSyntax = errors.New("invalid syntax") - -// A NumError records a failed conversion. -type NumError struct { - Func string // the failing function (ParseBool, ParseInt, ParseUint, ParseFloat) - Num string // the input - Err error // the reason the conversion failed (ErrRange, ErrSyntax) -} - -func (e *NumError) Error() string { - return "strconv." + e.Func + ": " + "parsing " + strconv.Quote(e.Num) + ": " + e.Err.Error() -} - -func syntaxError(fn, str string) *NumError { - return &NumError{fn, str, ErrSyntax} -} - -func rangeError(fn, str string) *NumError { - return &NumError{fn, str, ErrRange} -} - -const intSize = 32 << uint(^uint(0)>>63) - -// IntSize is the size in bits of an int or uint value. -const IntSize = intSize - -// Return the first number n such that n*base >= 1<<64. -func cutoff64(base int) uint64 { - if base < 2 { - return 0 - } - return (1<<64-1)/uint64(base) + 1 -} - -// ParseUint is like ParseInt but for unsigned numbers, and oeprating on []byte -func ParseUint(s []byte, base int, bitSize int) (n uint64, err error) { - var cutoff, maxVal uint64 - - if bitSize == 0 { - bitSize = int(IntSize) - } - - s0 := s - switch { - case len(s) < 1: - err = ErrSyntax - goto Error - - case 2 <= base && base <= 36: - // valid base; nothing to do - - case base == 0: - // Look for octal, hex prefix. - switch { - case s[0] == '0' && len(s) > 1 && (s[1] == 'x' || s[1] == 'X'): - base = 16 - s = s[2:] - if len(s) < 1 { - err = ErrSyntax - goto Error - } - case s[0] == '0': - base = 8 - default: - base = 10 - } - - default: - err = errors.New("invalid base " + strconv.Itoa(base)) - goto Error - } - - n = 0 - cutoff = cutoff64(base) - maxVal = 1<<uint(bitSize) - 1 - - for i := 0; i < len(s); i++ { - var v byte - d := s[i] - switch { - case '0' <= d && d <= '9': - v = d - '0' - case 'a' <= d && d <= 'z': - v = d - 'a' + 10 - case 'A' <= d && d <= 'Z': - v = d - 'A' + 10 - default: - n = 0 - err = ErrSyntax - goto Error - } - if int(v) >= base { - n = 0 - err = ErrSyntax - goto Error - } - - if n >= cutoff { - // n*base overflows - n = 1<<64 - 1 - err = ErrRange - goto Error - } - n *= uint64(base) - - n1 := n + uint64(v) - if n1 < n || n1 > maxVal { - // n+v overflows - n = 1<<64 - 1 - err = ErrRange - goto Error - } - n = n1 - } - - return n, nil - -Error: - return n, &NumError{"ParseUint", string(s0), err} -} - -// ParseInt interprets a string s in the given base (2 to 36) and -// returns the corresponding value i. If base == 0, the base is -// implied by the string's prefix: base 16 for "0x", base 8 for -// "0", and base 10 otherwise. -// -// The bitSize argument specifies the integer type -// that the result must fit into. Bit sizes 0, 8, 16, 32, and 64 -// correspond to int, int8, int16, int32, and int64. -// -// The errors that ParseInt returns have concrete type *NumError -// and include err.Num = s. If s is empty or contains invalid -// digits, err.Err = ErrSyntax and the returned value is 0; -// if the value corresponding to s cannot be represented by a -// signed integer of the given size, err.Err = ErrRange and the -// returned value is the maximum magnitude integer of the -// appropriate bitSize and sign. -func ParseInt(s []byte, base int, bitSize int) (i int64, err error) { - const fnParseInt = "ParseInt" - - if bitSize == 0 { - bitSize = int(IntSize) - } - - // Empty string bad. - if len(s) == 0 { - return 0, syntaxError(fnParseInt, string(s)) - } - - // Pick off leading sign. - s0 := s - neg := false - if s[0] == '+' { - s = s[1:] - } else if s[0] == '-' { - neg = true - s = s[1:] - } - - // Convert unsigned and check range. - var un uint64 - un, err = ParseUint(s, base, bitSize) - if err != nil && err.(*NumError).Err != ErrRange { - err.(*NumError).Func = fnParseInt - err.(*NumError).Num = string(s0) - return 0, err - } - cutoff := uint64(1 << uint(bitSize-1)) - if !neg && un >= cutoff { - return int64(cutoff - 1), rangeError(fnParseInt, string(s0)) - } - if neg && un > cutoff { - return -int64(cutoff), rangeError(fnParseInt, string(s0)) - } - n := int64(un) - if neg { - n = -n - } - return n, nil -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/extfloat.go b/vendor/github.com/pquerna/ffjson/fflib/v1/internal/extfloat.go deleted file mode 100644 index ab791085a..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/extfloat.go +++ /dev/null @@ -1,668 +0,0 @@ -// Copyright 2011 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package internal - -// An extFloat represents an extended floating-point number, with more -// precision than a float64. It does not try to save bits: the -// number represented by the structure is mant*(2^exp), with a negative -// sign if neg is true. -type extFloat struct { - mant uint64 - exp int - neg bool -} - -// Powers of ten taken from double-conversion library. -// http://code.google.com/p/double-conversion/ -const ( - firstPowerOfTen = -348 - stepPowerOfTen = 8 -) - -var smallPowersOfTen = [...]extFloat{ - {1 << 63, -63, false}, // 1 - {0xa << 60, -60, false}, // 1e1 - {0x64 << 57, -57, false}, // 1e2 - {0x3e8 << 54, -54, false}, // 1e3 - {0x2710 << 50, -50, false}, // 1e4 - {0x186a0 << 47, -47, false}, // 1e5 - {0xf4240 << 44, -44, false}, // 1e6 - {0x989680 << 40, -40, false}, // 1e7 -} - -var powersOfTen = [...]extFloat{ - {0xfa8fd5a0081c0288, -1220, false}, // 10^-348 - {0xbaaee17fa23ebf76, -1193, false}, // 10^-340 - {0x8b16fb203055ac76, -1166, false}, // 10^-332 - {0xcf42894a5dce35ea, -1140, false}, // 10^-324 - {0x9a6bb0aa55653b2d, -1113, false}, // 10^-316 - {0xe61acf033d1a45df, -1087, false}, // 10^-308 - {0xab70fe17c79ac6ca, -1060, false}, // 10^-300 - {0xff77b1fcbebcdc4f, -1034, false}, // 10^-292 - {0xbe5691ef416bd60c, -1007, false}, // 10^-284 - {0x8dd01fad907ffc3c, -980, false}, // 10^-276 - {0xd3515c2831559a83, -954, false}, // 10^-268 - {0x9d71ac8fada6c9b5, -927, false}, // 10^-260 - {0xea9c227723ee8bcb, -901, false}, // 10^-252 - {0xaecc49914078536d, -874, false}, // 10^-244 - {0x823c12795db6ce57, -847, false}, // 10^-236 - {0xc21094364dfb5637, -821, false}, // 10^-228 - {0x9096ea6f3848984f, -794, false}, // 10^-220 - {0xd77485cb25823ac7, -768, false}, // 10^-212 - {0xa086cfcd97bf97f4, -741, false}, // 10^-204 - {0xef340a98172aace5, -715, false}, // 10^-196 - {0xb23867fb2a35b28e, -688, false}, // 10^-188 - {0x84c8d4dfd2c63f3b, -661, false}, // 10^-180 - {0xc5dd44271ad3cdba, -635, false}, // 10^-172 - {0x936b9fcebb25c996, -608, false}, // 10^-164 - {0xdbac6c247d62a584, -582, false}, // 10^-156 - {0xa3ab66580d5fdaf6, -555, false}, // 10^-148 - {0xf3e2f893dec3f126, -529, false}, // 10^-140 - {0xb5b5ada8aaff80b8, -502, false}, // 10^-132 - {0x87625f056c7c4a8b, -475, false}, // 10^-124 - {0xc9bcff6034c13053, -449, false}, // 10^-116 - {0x964e858c91ba2655, -422, false}, // 10^-108 - {0xdff9772470297ebd, -396, false}, // 10^-100 - {0xa6dfbd9fb8e5b88f, -369, false}, // 10^-92 - {0xf8a95fcf88747d94, -343, false}, // 10^-84 - {0xb94470938fa89bcf, -316, false}, // 10^-76 - {0x8a08f0f8bf0f156b, -289, false}, // 10^-68 - {0xcdb02555653131b6, -263, false}, // 10^-60 - {0x993fe2c6d07b7fac, -236, false}, // 10^-52 - {0xe45c10c42a2b3b06, -210, false}, // 10^-44 - {0xaa242499697392d3, -183, false}, // 10^-36 - {0xfd87b5f28300ca0e, -157, false}, // 10^-28 - {0xbce5086492111aeb, -130, false}, // 10^-20 - {0x8cbccc096f5088cc, -103, false}, // 10^-12 - {0xd1b71758e219652c, -77, false}, // 10^-4 - {0x9c40000000000000, -50, false}, // 10^4 - {0xe8d4a51000000000, -24, false}, // 10^12 - {0xad78ebc5ac620000, 3, false}, // 10^20 - {0x813f3978f8940984, 30, false}, // 10^28 - {0xc097ce7bc90715b3, 56, false}, // 10^36 - {0x8f7e32ce7bea5c70, 83, false}, // 10^44 - {0xd5d238a4abe98068, 109, false}, // 10^52 - {0x9f4f2726179a2245, 136, false}, // 10^60 - {0xed63a231d4c4fb27, 162, false}, // 10^68 - {0xb0de65388cc8ada8, 189, false}, // 10^76 - {0x83c7088e1aab65db, 216, false}, // 10^84 - {0xc45d1df942711d9a, 242, false}, // 10^92 - {0x924d692ca61be758, 269, false}, // 10^100 - {0xda01ee641a708dea, 295, false}, // 10^108 - {0xa26da3999aef774a, 322, false}, // 10^116 - {0xf209787bb47d6b85, 348, false}, // 10^124 - {0xb454e4a179dd1877, 375, false}, // 10^132 - {0x865b86925b9bc5c2, 402, false}, // 10^140 - {0xc83553c5c8965d3d, 428, false}, // 10^148 - {0x952ab45cfa97a0b3, 455, false}, // 10^156 - {0xde469fbd99a05fe3, 481, false}, // 10^164 - {0xa59bc234db398c25, 508, false}, // 10^172 - {0xf6c69a72a3989f5c, 534, false}, // 10^180 - {0xb7dcbf5354e9bece, 561, false}, // 10^188 - {0x88fcf317f22241e2, 588, false}, // 10^196 - {0xcc20ce9bd35c78a5, 614, false}, // 10^204 - {0x98165af37b2153df, 641, false}, // 10^212 - {0xe2a0b5dc971f303a, 667, false}, // 10^220 - {0xa8d9d1535ce3b396, 694, false}, // 10^228 - {0xfb9b7cd9a4a7443c, 720, false}, // 10^236 - {0xbb764c4ca7a44410, 747, false}, // 10^244 - {0x8bab8eefb6409c1a, 774, false}, // 10^252 - {0xd01fef10a657842c, 800, false}, // 10^260 - {0x9b10a4e5e9913129, 827, false}, // 10^268 - {0xe7109bfba19c0c9d, 853, false}, // 10^276 - {0xac2820d9623bf429, 880, false}, // 10^284 - {0x80444b5e7aa7cf85, 907, false}, // 10^292 - {0xbf21e44003acdd2d, 933, false}, // 10^300 - {0x8e679c2f5e44ff8f, 960, false}, // 10^308 - {0xd433179d9c8cb841, 986, false}, // 10^316 - {0x9e19db92b4e31ba9, 1013, false}, // 10^324 - {0xeb96bf6ebadf77d9, 1039, false}, // 10^332 - {0xaf87023b9bf0ee6b, 1066, false}, // 10^340 -} - -// floatBits returns the bits of the float64 that best approximates -// the extFloat passed as receiver. Overflow is set to true if -// the resulting float64 is ±Inf. -func (f *extFloat) floatBits(flt *floatInfo) (bits uint64, overflow bool) { - f.Normalize() - - exp := f.exp + 63 - - // Exponent too small. - if exp < flt.bias+1 { - n := flt.bias + 1 - exp - f.mant >>= uint(n) - exp += n - } - - // Extract 1+flt.mantbits bits from the 64-bit mantissa. - mant := f.mant >> (63 - flt.mantbits) - if f.mant&(1<<(62-flt.mantbits)) != 0 { - // Round up. - mant += 1 - } - - // Rounding might have added a bit; shift down. - if mant == 2<<flt.mantbits { - mant >>= 1 - exp++ - } - - // Infinities. - if exp-flt.bias >= 1<<flt.expbits-1 { - // ±Inf - mant = 0 - exp = 1<<flt.expbits - 1 + flt.bias - overflow = true - } else if mant&(1<<flt.mantbits) == 0 { - // Denormalized? - exp = flt.bias - } - // Assemble bits. - bits = mant & (uint64(1)<<flt.mantbits - 1) - bits |= uint64((exp-flt.bias)&(1<<flt.expbits-1)) << flt.mantbits - if f.neg { - bits |= 1 << (flt.mantbits + flt.expbits) - } - return -} - -// AssignComputeBounds sets f to the floating point value -// defined by mant, exp and precision given by flt. It returns -// lower, upper such that any number in the closed interval -// [lower, upper] is converted back to the same floating point number. -func (f *extFloat) AssignComputeBounds(mant uint64, exp int, neg bool, flt *floatInfo) (lower, upper extFloat) { - f.mant = mant - f.exp = exp - int(flt.mantbits) - f.neg = neg - if f.exp <= 0 && mant == (mant>>uint(-f.exp))<<uint(-f.exp) { - // An exact integer - f.mant >>= uint(-f.exp) - f.exp = 0 - return *f, *f - } - expBiased := exp - flt.bias - - upper = extFloat{mant: 2*f.mant + 1, exp: f.exp - 1, neg: f.neg} - if mant != 1<<flt.mantbits || expBiased == 1 { - lower = extFloat{mant: 2*f.mant - 1, exp: f.exp - 1, neg: f.neg} - } else { - lower = extFloat{mant: 4*f.mant - 1, exp: f.exp - 2, neg: f.neg} - } - return -} - -// Normalize normalizes f so that the highest bit of the mantissa is -// set, and returns the number by which the mantissa was left-shifted. -func (f *extFloat) Normalize() (shift uint) { - mant, exp := f.mant, f.exp - if mant == 0 { - return 0 - } - if mant>>(64-32) == 0 { - mant <<= 32 - exp -= 32 - } - if mant>>(64-16) == 0 { - mant <<= 16 - exp -= 16 - } - if mant>>(64-8) == 0 { - mant <<= 8 - exp -= 8 - } - if mant>>(64-4) == 0 { - mant <<= 4 - exp -= 4 - } - if mant>>(64-2) == 0 { - mant <<= 2 - exp -= 2 - } - if mant>>(64-1) == 0 { - mant <<= 1 - exp -= 1 - } - shift = uint(f.exp - exp) - f.mant, f.exp = mant, exp - return -} - -// Multiply sets f to the product f*g: the result is correctly rounded, -// but not normalized. -func (f *extFloat) Multiply(g extFloat) { - fhi, flo := f.mant>>32, uint64(uint32(f.mant)) - ghi, glo := g.mant>>32, uint64(uint32(g.mant)) - - // Cross products. - cross1 := fhi * glo - cross2 := flo * ghi - - // f.mant*g.mant is fhi*ghi << 64 + (cross1+cross2) << 32 + flo*glo - f.mant = fhi*ghi + (cross1 >> 32) + (cross2 >> 32) - rem := uint64(uint32(cross1)) + uint64(uint32(cross2)) + ((flo * glo) >> 32) - // Round up. - rem += (1 << 31) - - f.mant += (rem >> 32) - f.exp = f.exp + g.exp + 64 -} - -var uint64pow10 = [...]uint64{ - 1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, -} - -// AssignDecimal sets f to an approximate value mantissa*10^exp. It -// returns true if the value represented by f is guaranteed to be the -// best approximation of d after being rounded to a float64 or -// float32 depending on flt. -func (f *extFloat) AssignDecimal(mantissa uint64, exp10 int, neg bool, trunc bool, flt *floatInfo) (ok bool) { - const uint64digits = 19 - const errorscale = 8 - errors := 0 // An upper bound for error, computed in errorscale*ulp. - if trunc { - // the decimal number was truncated. - errors += errorscale / 2 - } - - f.mant = mantissa - f.exp = 0 - f.neg = neg - - // Multiply by powers of ten. - i := (exp10 - firstPowerOfTen) / stepPowerOfTen - if exp10 < firstPowerOfTen || i >= len(powersOfTen) { - return false - } - adjExp := (exp10 - firstPowerOfTen) % stepPowerOfTen - - // We multiply by exp%step - if adjExp < uint64digits && mantissa < uint64pow10[uint64digits-adjExp] { - // We can multiply the mantissa exactly. - f.mant *= uint64pow10[adjExp] - f.Normalize() - } else { - f.Normalize() - f.Multiply(smallPowersOfTen[adjExp]) - errors += errorscale / 2 - } - - // We multiply by 10 to the exp - exp%step. - f.Multiply(powersOfTen[i]) - if errors > 0 { - errors += 1 - } - errors += errorscale / 2 - - // Normalize - shift := f.Normalize() - errors <<= shift - - // Now f is a good approximation of the decimal. - // Check whether the error is too large: that is, if the mantissa - // is perturbated by the error, the resulting float64 will change. - // The 64 bits mantissa is 1 + 52 bits for float64 + 11 extra bits. - // - // In many cases the approximation will be good enough. - denormalExp := flt.bias - 63 - var extrabits uint - if f.exp <= denormalExp { - // f.mant * 2^f.exp is smaller than 2^(flt.bias+1). - extrabits = uint(63 - flt.mantbits + 1 + uint(denormalExp-f.exp)) - } else { - extrabits = uint(63 - flt.mantbits) - } - - halfway := uint64(1) << (extrabits - 1) - mant_extra := f.mant & (1<<extrabits - 1) - - // Do a signed comparison here! If the error estimate could make - // the mantissa round differently for the conversion to double, - // then we can't give a definite answer. - if int64(halfway)-int64(errors) < int64(mant_extra) && - int64(mant_extra) < int64(halfway)+int64(errors) { - return false - } - return true -} - -// Frexp10 is an analogue of math.Frexp for decimal powers. It scales -// f by an approximate power of ten 10^-exp, and returns exp10, so -// that f*10^exp10 has the same value as the old f, up to an ulp, -// as well as the index of 10^-exp in the powersOfTen table. -func (f *extFloat) frexp10() (exp10, index int) { - // The constants expMin and expMax constrain the final value of the - // binary exponent of f. We want a small integral part in the result - // because finding digits of an integer requires divisions, whereas - // digits of the fractional part can be found by repeatedly multiplying - // by 10. - const expMin = -60 - const expMax = -32 - // Find power of ten such that x * 10^n has a binary exponent - // between expMin and expMax. - approxExp10 := ((expMin+expMax)/2 - f.exp) * 28 / 93 // log(10)/log(2) is close to 93/28. - i := (approxExp10 - firstPowerOfTen) / stepPowerOfTen -Loop: - for { - exp := f.exp + powersOfTen[i].exp + 64 - switch { - case exp < expMin: - i++ - case exp > expMax: - i-- - default: - break Loop - } - } - // Apply the desired decimal shift on f. It will have exponent - // in the desired range. This is multiplication by 10^-exp10. - f.Multiply(powersOfTen[i]) - - return -(firstPowerOfTen + i*stepPowerOfTen), i -} - -// frexp10Many applies a common shift by a power of ten to a, b, c. -func frexp10Many(a, b, c *extFloat) (exp10 int) { - exp10, i := c.frexp10() - a.Multiply(powersOfTen[i]) - b.Multiply(powersOfTen[i]) - return -} - -// FixedDecimal stores in d the first n significant digits -// of the decimal representation of f. It returns false -// if it cannot be sure of the answer. -func (f *extFloat) FixedDecimal(d *decimalSlice, n int) bool { - if f.mant == 0 { - d.nd = 0 - d.dp = 0 - d.neg = f.neg - return true - } - if n == 0 { - panic("strconv: internal error: extFloat.FixedDecimal called with n == 0") - } - // Multiply by an appropriate power of ten to have a reasonable - // number to process. - f.Normalize() - exp10, _ := f.frexp10() - - shift := uint(-f.exp) - integer := uint32(f.mant >> shift) - fraction := f.mant - (uint64(integer) << shift) - ε := uint64(1) // ε is the uncertainty we have on the mantissa of f. - - // Write exactly n digits to d. - needed := n // how many digits are left to write. - integerDigits := 0 // the number of decimal digits of integer. - pow10 := uint64(1) // the power of ten by which f was scaled. - for i, pow := 0, uint64(1); i < 20; i++ { - if pow > uint64(integer) { - integerDigits = i - break - } - pow *= 10 - } - rest := integer - if integerDigits > needed { - // the integral part is already large, trim the last digits. - pow10 = uint64pow10[integerDigits-needed] - integer /= uint32(pow10) - rest -= integer * uint32(pow10) - } else { - rest = 0 - } - - // Write the digits of integer: the digits of rest are omitted. - var buf [32]byte - pos := len(buf) - for v := integer; v > 0; { - v1 := v / 10 - v -= 10 * v1 - pos-- - buf[pos] = byte(v + '0') - v = v1 - } - for i := pos; i < len(buf); i++ { - d.d[i-pos] = buf[i] - } - nd := len(buf) - pos - d.nd = nd - d.dp = integerDigits + exp10 - needed -= nd - - if needed > 0 { - if rest != 0 || pow10 != 1 { - panic("strconv: internal error, rest != 0 but needed > 0") - } - // Emit digits for the fractional part. Each time, 10*fraction - // fits in a uint64 without overflow. - for needed > 0 { - fraction *= 10 - ε *= 10 // the uncertainty scales as we multiply by ten. - if 2*ε > 1<<shift { - // the error is so large it could modify which digit to write, abort. - return false - } - digit := fraction >> shift - d.d[nd] = byte(digit + '0') - fraction -= digit << shift - nd++ - needed-- - } - d.nd = nd - } - - // We have written a truncation of f (a numerator / 10^d.dp). The remaining part - // can be interpreted as a small number (< 1) to be added to the last digit of the - // numerator. - // - // If rest > 0, the amount is: - // (rest<<shift | fraction) / (pow10 << shift) - // fraction being known with a ±ε uncertainty. - // The fact that n > 0 guarantees that pow10 << shift does not overflow a uint64. - // - // If rest = 0, pow10 == 1 and the amount is - // fraction / (1 << shift) - // fraction being known with a ±ε uncertainty. - // - // We pass this information to the rounding routine for adjustment. - - ok := adjustLastDigitFixed(d, uint64(rest)<<shift|fraction, pow10, shift, ε) - if !ok { - return false - } - // Trim trailing zeros. - for i := d.nd - 1; i >= 0; i-- { - if d.d[i] != '0' { - d.nd = i + 1 - break - } - } - return true -} - -// adjustLastDigitFixed assumes d contains the representation of the integral part -// of some number, whose fractional part is num / (den << shift). The numerator -// num is only known up to an uncertainty of size ε, assumed to be less than -// (den << shift)/2. -// -// It will increase the last digit by one to account for correct rounding, typically -// when the fractional part is greater than 1/2, and will return false if ε is such -// that no correct answer can be given. -func adjustLastDigitFixed(d *decimalSlice, num, den uint64, shift uint, ε uint64) bool { - if num > den<<shift { - panic("strconv: num > den<<shift in adjustLastDigitFixed") - } - if 2*ε > den<<shift { - panic("strconv: ε > (den<<shift)/2") - } - if 2*(num+ε) < den<<shift { - return true - } - if 2*(num-ε) > den<<shift { - // increment d by 1. - i := d.nd - 1 - for ; i >= 0; i-- { - if d.d[i] == '9' { - d.nd-- - } else { - break - } - } - if i < 0 { - d.d[0] = '1' - d.nd = 1 - d.dp++ - } else { - d.d[i]++ - } - return true - } - return false -} - -// ShortestDecimal stores in d the shortest decimal representation of f -// which belongs to the open interval (lower, upper), where f is supposed -// to lie. It returns false whenever the result is unsure. The implementation -// uses the Grisu3 algorithm. -func (f *extFloat) ShortestDecimal(d *decimalSlice, lower, upper *extFloat) bool { - if f.mant == 0 { - d.nd = 0 - d.dp = 0 - d.neg = f.neg - return true - } - if f.exp == 0 && *lower == *f && *lower == *upper { - // an exact integer. - var buf [24]byte - n := len(buf) - 1 - for v := f.mant; v > 0; { - v1 := v / 10 - v -= 10 * v1 - buf[n] = byte(v + '0') - n-- - v = v1 - } - nd := len(buf) - n - 1 - for i := 0; i < nd; i++ { - d.d[i] = buf[n+1+i] - } - d.nd, d.dp = nd, nd - for d.nd > 0 && d.d[d.nd-1] == '0' { - d.nd-- - } - if d.nd == 0 { - d.dp = 0 - } - d.neg = f.neg - return true - } - upper.Normalize() - // Uniformize exponents. - if f.exp > upper.exp { - f.mant <<= uint(f.exp - upper.exp) - f.exp = upper.exp - } - if lower.exp > upper.exp { - lower.mant <<= uint(lower.exp - upper.exp) - lower.exp = upper.exp - } - - exp10 := frexp10Many(lower, f, upper) - // Take a safety margin due to rounding in frexp10Many, but we lose precision. - upper.mant++ - lower.mant-- - - // The shortest representation of f is either rounded up or down, but - // in any case, it is a truncation of upper. - shift := uint(-upper.exp) - integer := uint32(upper.mant >> shift) - fraction := upper.mant - (uint64(integer) << shift) - - // How far we can go down from upper until the result is wrong. - allowance := upper.mant - lower.mant - // How far we should go to get a very precise result. - targetDiff := upper.mant - f.mant - - // Count integral digits: there are at most 10. - var integerDigits int - for i, pow := 0, uint64(1); i < 20; i++ { - if pow > uint64(integer) { - integerDigits = i - break - } - pow *= 10 - } - for i := 0; i < integerDigits; i++ { - pow := uint64pow10[integerDigits-i-1] - digit := integer / uint32(pow) - d.d[i] = byte(digit + '0') - integer -= digit * uint32(pow) - // evaluate whether we should stop. - if currentDiff := uint64(integer)<<shift + fraction; currentDiff < allowance { - d.nd = i + 1 - d.dp = integerDigits + exp10 - d.neg = f.neg - // Sometimes allowance is so large the last digit might need to be - // decremented to get closer to f. - return adjustLastDigit(d, currentDiff, targetDiff, allowance, pow<<shift, 2) - } - } - d.nd = integerDigits - d.dp = d.nd + exp10 - d.neg = f.neg - - // Compute digits of the fractional part. At each step fraction does not - // overflow. The choice of minExp implies that fraction is less than 2^60. - var digit int - multiplier := uint64(1) - for { - fraction *= 10 - multiplier *= 10 - digit = int(fraction >> shift) - d.d[d.nd] = byte(digit + '0') - d.nd++ - fraction -= uint64(digit) << shift - if fraction < allowance*multiplier { - // We are in the admissible range. Note that if allowance is about to - // overflow, that is, allowance > 2^64/10, the condition is automatically - // true due to the limited range of fraction. - return adjustLastDigit(d, - fraction, targetDiff*multiplier, allowance*multiplier, - 1<<shift, multiplier*2) - } - } -} - -// adjustLastDigit modifies d = x-currentDiff*ε, to get closest to -// d = x-targetDiff*ε, without becoming smaller than x-maxDiff*ε. -// It assumes that a decimal digit is worth ulpDecimal*ε, and that -// all data is known with a error estimate of ulpBinary*ε. -func adjustLastDigit(d *decimalSlice, currentDiff, targetDiff, maxDiff, ulpDecimal, ulpBinary uint64) bool { - if ulpDecimal < 2*ulpBinary { - // Approximation is too wide. - return false - } - for currentDiff+ulpDecimal/2+ulpBinary < targetDiff { - d.d[d.nd-1]-- - currentDiff += ulpDecimal - } - if currentDiff+ulpDecimal <= targetDiff+ulpDecimal/2+ulpBinary { - // we have two choices, and don't know what to do. - return false - } - if currentDiff < ulpBinary || currentDiff > maxDiff-ulpBinary { - // we went too far - return false - } - if d.nd == 1 && d.d[0] == '0' { - // the number has actually reached zero. - d.nd = 0 - d.dp = 0 - } - return true -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/ftoa.go b/vendor/github.com/pquerna/ffjson/fflib/v1/internal/ftoa.go deleted file mode 100644 index 253f83b45..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/internal/ftoa.go +++ /dev/null @@ -1,475 +0,0 @@ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// Binary to decimal floating point conversion. -// Algorithm: -// 1) store mantissa in multiprecision decimal -// 2) shift decimal by exponent -// 3) read digits out & format - -package internal - -import "math" - -// TODO: move elsewhere? -type floatInfo struct { - mantbits uint - expbits uint - bias int -} - -var float32info = floatInfo{23, 8, -127} -var float64info = floatInfo{52, 11, -1023} - -// FormatFloat converts the floating-point number f to a string, -// according to the format fmt and precision prec. It rounds the -// result assuming that the original was obtained from a floating-point -// value of bitSize bits (32 for float32, 64 for float64). -// -// The format fmt is one of -// 'b' (-ddddp±ddd, a binary exponent), -// 'e' (-d.dddde±dd, a decimal exponent), -// 'E' (-d.ddddE±dd, a decimal exponent), -// 'f' (-ddd.dddd, no exponent), -// 'g' ('e' for large exponents, 'f' otherwise), or -// 'G' ('E' for large exponents, 'f' otherwise). -// -// The precision prec controls the number of digits -// (excluding the exponent) printed by the 'e', 'E', 'f', 'g', and 'G' formats. -// For 'e', 'E', and 'f' it is the number of digits after the decimal point. -// For 'g' and 'G' it is the total number of digits. -// The special precision -1 uses the smallest number of digits -// necessary such that ParseFloat will return f exactly. -func formatFloat(f float64, fmt byte, prec, bitSize int) string { - return string(genericFtoa(make([]byte, 0, max(prec+4, 24)), f, fmt, prec, bitSize)) -} - -// AppendFloat appends the string form of the floating-point number f, -// as generated by FormatFloat, to dst and returns the extended buffer. -func appendFloat(dst []byte, f float64, fmt byte, prec int, bitSize int) []byte { - return genericFtoa(dst, f, fmt, prec, bitSize) -} - -func genericFtoa(dst []byte, val float64, fmt byte, prec, bitSize int) []byte { - var bits uint64 - var flt *floatInfo - switch bitSize { - case 32: - bits = uint64(math.Float32bits(float32(val))) - flt = &float32info - case 64: - bits = math.Float64bits(val) - flt = &float64info - default: - panic("strconv: illegal AppendFloat/FormatFloat bitSize") - } - - neg := bits>>(flt.expbits+flt.mantbits) != 0 - exp := int(bits>>flt.mantbits) & (1<<flt.expbits - 1) - mant := bits & (uint64(1)<<flt.mantbits - 1) - - switch exp { - case 1<<flt.expbits - 1: - // Inf, NaN - var s string - switch { - case mant != 0: - s = "NaN" - case neg: - s = "-Inf" - default: - s = "+Inf" - } - return append(dst, s...) - - case 0: - // denormalized - exp++ - - default: - // add implicit top bit - mant |= uint64(1) << flt.mantbits - } - exp += flt.bias - - // Pick off easy binary format. - if fmt == 'b' { - return fmtB(dst, neg, mant, exp, flt) - } - - if !optimize { - return bigFtoa(dst, prec, fmt, neg, mant, exp, flt) - } - - var digs decimalSlice - ok := false - // Negative precision means "only as much as needed to be exact." - shortest := prec < 0 - if shortest { - // Try Grisu3 algorithm. - f := new(extFloat) - lower, upper := f.AssignComputeBounds(mant, exp, neg, flt) - var buf [32]byte - digs.d = buf[:] - ok = f.ShortestDecimal(&digs, &lower, &upper) - if !ok { - return bigFtoa(dst, prec, fmt, neg, mant, exp, flt) - } - // Precision for shortest representation mode. - switch fmt { - case 'e', 'E': - prec = digs.nd - 1 - case 'f': - prec = max(digs.nd-digs.dp, 0) - case 'g', 'G': - prec = digs.nd - } - } else if fmt != 'f' { - // Fixed number of digits. - digits := prec - switch fmt { - case 'e', 'E': - digits++ - case 'g', 'G': - if prec == 0 { - prec = 1 - } - digits = prec - } - if digits <= 15 { - // try fast algorithm when the number of digits is reasonable. - var buf [24]byte - digs.d = buf[:] - f := extFloat{mant, exp - int(flt.mantbits), neg} - ok = f.FixedDecimal(&digs, digits) - } - } - if !ok { - return bigFtoa(dst, prec, fmt, neg, mant, exp, flt) - } - return formatDigits(dst, shortest, neg, digs, prec, fmt) -} - -// bigFtoa uses multiprecision computations to format a float. -func bigFtoa(dst []byte, prec int, fmt byte, neg bool, mant uint64, exp int, flt *floatInfo) []byte { - d := new(decimal) - d.Assign(mant) - d.Shift(exp - int(flt.mantbits)) - var digs decimalSlice - shortest := prec < 0 - if shortest { - roundShortest(d, mant, exp, flt) - digs = decimalSlice{d: d.d[:], nd: d.nd, dp: d.dp} - // Precision for shortest representation mode. - switch fmt { - case 'e', 'E': - prec = digs.nd - 1 - case 'f': - prec = max(digs.nd-digs.dp, 0) - case 'g', 'G': - prec = digs.nd - } - } else { - // Round appropriately. - switch fmt { - case 'e', 'E': - d.Round(prec + 1) - case 'f': - d.Round(d.dp + prec) - case 'g', 'G': - if prec == 0 { - prec = 1 - } - d.Round(prec) - } - digs = decimalSlice{d: d.d[:], nd: d.nd, dp: d.dp} - } - return formatDigits(dst, shortest, neg, digs, prec, fmt) -} - -func formatDigits(dst []byte, shortest bool, neg bool, digs decimalSlice, prec int, fmt byte) []byte { - switch fmt { - case 'e', 'E': - return fmtE(dst, neg, digs, prec, fmt) - case 'f': - return fmtF(dst, neg, digs, prec) - case 'g', 'G': - // trailing fractional zeros in 'e' form will be trimmed. - eprec := prec - if eprec > digs.nd && digs.nd >= digs.dp { - eprec = digs.nd - } - // %e is used if the exponent from the conversion - // is less than -4 or greater than or equal to the precision. - // if precision was the shortest possible, use precision 6 for this decision. - if shortest { - eprec = 6 - } - exp := digs.dp - 1 - if exp < -4 || exp >= eprec { - if prec > digs.nd { - prec = digs.nd - } - return fmtE(dst, neg, digs, prec-1, fmt+'e'-'g') - } - if prec > digs.dp { - prec = digs.nd - } - return fmtF(dst, neg, digs, max(prec-digs.dp, 0)) - } - - // unknown format - return append(dst, '%', fmt) -} - -// Round d (= mant * 2^exp) to the shortest number of digits -// that will let the original floating point value be precisely -// reconstructed. Size is original floating point size (64 or 32). -func roundShortest(d *decimal, mant uint64, exp int, flt *floatInfo) { - // If mantissa is zero, the number is zero; stop now. - if mant == 0 { - d.nd = 0 - return - } - - // Compute upper and lower such that any decimal number - // between upper and lower (possibly inclusive) - // will round to the original floating point number. - - // We may see at once that the number is already shortest. - // - // Suppose d is not denormal, so that 2^exp <= d < 10^dp. - // The closest shorter number is at least 10^(dp-nd) away. - // The lower/upper bounds computed below are at distance - // at most 2^(exp-mantbits). - // - // So the number is already shortest if 10^(dp-nd) > 2^(exp-mantbits), - // or equivalently log2(10)*(dp-nd) > exp-mantbits. - // It is true if 332/100*(dp-nd) >= exp-mantbits (log2(10) > 3.32). - minexp := flt.bias + 1 // minimum possible exponent - if exp > minexp && 332*(d.dp-d.nd) >= 100*(exp-int(flt.mantbits)) { - // The number is already shortest. - return - } - - // d = mant << (exp - mantbits) - // Next highest floating point number is mant+1 << exp-mantbits. - // Our upper bound is halfway between, mant*2+1 << exp-mantbits-1. - upper := new(decimal) - upper.Assign(mant*2 + 1) - upper.Shift(exp - int(flt.mantbits) - 1) - - // d = mant << (exp - mantbits) - // Next lowest floating point number is mant-1 << exp-mantbits, - // unless mant-1 drops the significant bit and exp is not the minimum exp, - // in which case the next lowest is mant*2-1 << exp-mantbits-1. - // Either way, call it mantlo << explo-mantbits. - // Our lower bound is halfway between, mantlo*2+1 << explo-mantbits-1. - var mantlo uint64 - var explo int - if mant > 1<<flt.mantbits || exp == minexp { - mantlo = mant - 1 - explo = exp - } else { - mantlo = mant*2 - 1 - explo = exp - 1 - } - lower := new(decimal) - lower.Assign(mantlo*2 + 1) - lower.Shift(explo - int(flt.mantbits) - 1) - - // The upper and lower bounds are possible outputs only if - // the original mantissa is even, so that IEEE round-to-even - // would round to the original mantissa and not the neighbors. - inclusive := mant%2 == 0 - - // Now we can figure out the minimum number of digits required. - // Walk along until d has distinguished itself from upper and lower. - for i := 0; i < d.nd; i++ { - var l, m, u byte // lower, middle, upper digits - if i < lower.nd { - l = lower.d[i] - } else { - l = '0' - } - m = d.d[i] - if i < upper.nd { - u = upper.d[i] - } else { - u = '0' - } - - // Okay to round down (truncate) if lower has a different digit - // or if lower is inclusive and is exactly the result of rounding down. - okdown := l != m || (inclusive && l == m && i+1 == lower.nd) - - // Okay to round up if upper has a different digit and - // either upper is inclusive or upper is bigger than the result of rounding up. - okup := m != u && (inclusive || m+1 < u || i+1 < upper.nd) - - // If it's okay to do either, then round to the nearest one. - // If it's okay to do only one, do it. - switch { - case okdown && okup: - d.Round(i + 1) - return - case okdown: - d.RoundDown(i + 1) - return - case okup: - d.RoundUp(i + 1) - return - } - } -} - -type decimalSlice struct { - d []byte - nd, dp int - neg bool -} - -// %e: -d.ddddde±dd -func fmtE(dst []byte, neg bool, d decimalSlice, prec int, fmt byte) []byte { - // sign - if neg { - dst = append(dst, '-') - } - - // first digit - ch := byte('0') - if d.nd != 0 { - ch = d.d[0] - } - dst = append(dst, ch) - - // .moredigits - if prec > 0 { - dst = append(dst, '.') - i := 1 - m := d.nd + prec + 1 - max(d.nd, prec+1) - for i < m { - dst = append(dst, d.d[i]) - i++ - } - for i <= prec { - dst = append(dst, '0') - i++ - } - } - - // e± - dst = append(dst, fmt) - exp := d.dp - 1 - if d.nd == 0 { // special case: 0 has exponent 0 - exp = 0 - } - if exp < 0 { - ch = '-' - exp = -exp - } else { - ch = '+' - } - dst = append(dst, ch) - - // dddd - var buf [3]byte - i := len(buf) - for exp >= 10 { - i-- - buf[i] = byte(exp%10 + '0') - exp /= 10 - } - // exp < 10 - i-- - buf[i] = byte(exp + '0') - - switch i { - case 0: - dst = append(dst, buf[0], buf[1], buf[2]) - case 1: - dst = append(dst, buf[1], buf[2]) - case 2: - // leading zeroes - dst = append(dst, '0', buf[2]) - } - return dst -} - -// %f: -ddddddd.ddddd -func fmtF(dst []byte, neg bool, d decimalSlice, prec int) []byte { - // sign - if neg { - dst = append(dst, '-') - } - - // integer, padded with zeros as needed. - if d.dp > 0 { - var i int - for i = 0; i < d.dp && i < d.nd; i++ { - dst = append(dst, d.d[i]) - } - for ; i < d.dp; i++ { - dst = append(dst, '0') - } - } else { - dst = append(dst, '0') - } - - // fraction - if prec > 0 { - dst = append(dst, '.') - for i := 0; i < prec; i++ { - ch := byte('0') - if j := d.dp + i; 0 <= j && j < d.nd { - ch = d.d[j] - } - dst = append(dst, ch) - } - } - - return dst -} - -// %b: -ddddddddp+ddd -func fmtB(dst []byte, neg bool, mant uint64, exp int, flt *floatInfo) []byte { - var buf [50]byte - w := len(buf) - exp -= int(flt.mantbits) - esign := byte('+') - if exp < 0 { - esign = '-' - exp = -exp - } - n := 0 - for exp > 0 || n < 1 { - n++ - w-- - buf[w] = byte(exp%10 + '0') - exp /= 10 - } - w-- - buf[w] = esign - w-- - buf[w] = 'p' - n = 0 - for mant > 0 || n < 1 { - n++ - w-- - buf[w] = byte(mant%10 + '0') - mant /= 10 - } - if neg { - w-- - buf[w] = '-' - } - return append(dst, buf[w:]...) -} - -func max(a, b int) int { - if a > b { - return a - } - return b -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/iota.go b/vendor/github.com/pquerna/ffjson/fflib/v1/iota.go deleted file mode 100644 index 3e50f0c41..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/iota.go +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on Go stdlib's strconv/iota.go */ -// Copyright 2009 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package v1 - -import ( - "io" -) - -const ( - digits = "0123456789abcdefghijklmnopqrstuvwxyz" - digits01 = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" - digits10 = "0000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999999999" -) - -var shifts = [len(digits) + 1]uint{ - 1 << 1: 1, - 1 << 2: 2, - 1 << 3: 3, - 1 << 4: 4, - 1 << 5: 5, -} - -var smallNumbers = [][]byte{ - []byte("0"), - []byte("1"), - []byte("2"), - []byte("3"), - []byte("4"), - []byte("5"), - []byte("6"), - []byte("7"), - []byte("8"), - []byte("9"), - []byte("10"), -} - -type FormatBitsWriter interface { - io.Writer - io.ByteWriter -} - -type FormatBitsScratch struct{} - -// -// DEPRECIATED: `scratch` is no longer used, FormatBits2 is available. -// -// FormatBits computes the string representation of u in the given base. -// If neg is set, u is treated as negative int64 value. If append_ is -// set, the string is appended to dst and the resulting byte slice is -// returned as the first result value; otherwise the string is returned -// as the second result value. -// -func FormatBits(scratch *FormatBitsScratch, dst FormatBitsWriter, u uint64, base int, neg bool) { - FormatBits2(dst, u, base, neg) -} - -// FormatBits2 computes the string representation of u in the given base. -// If neg is set, u is treated as negative int64 value. If append_ is -// set, the string is appended to dst and the resulting byte slice is -// returned as the first result value; otherwise the string is returned -// as the second result value. -// -func FormatBits2(dst FormatBitsWriter, u uint64, base int, neg bool) { - if base < 2 || base > len(digits) { - panic("strconv: illegal AppendInt/FormatInt base") - } - // fast path for small common numbers - if u <= 10 { - if neg { - dst.WriteByte('-') - } - dst.Write(smallNumbers[u]) - return - } - - // 2 <= base && base <= len(digits) - - var a = makeSlice(65) - // var a [64 + 1]byte // +1 for sign of 64bit value in base 2 - i := len(a) - - if neg { - u = -u - } - - // convert bits - if base == 10 { - // common case: use constants for / and % because - // the compiler can optimize it into a multiply+shift, - // and unroll loop - for u >= 100 { - i -= 2 - q := u / 100 - j := uintptr(u - q*100) - a[i+1] = digits01[j] - a[i+0] = digits10[j] - u = q - } - if u >= 10 { - i-- - q := u / 10 - a[i] = digits[uintptr(u-q*10)] - u = q - } - - } else if s := shifts[base]; s > 0 { - // base is power of 2: use shifts and masks instead of / and % - b := uint64(base) - m := uintptr(b) - 1 // == 1<<s - 1 - for u >= b { - i-- - a[i] = digits[uintptr(u)&m] - u >>= s - } - - } else { - // general case - b := uint64(base) - for u >= b { - i-- - a[i] = digits[uintptr(u%b)] - u /= b - } - } - - // u < base - i-- - a[i] = digits[uintptr(u)] - - // add sign, if any - if neg { - i-- - a[i] = '-' - } - - dst.Write(a[i:]) - - Pool(a) - - return -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/jsonstring.go b/vendor/github.com/pquerna/ffjson/fflib/v1/jsonstring.go deleted file mode 100644 index 513b45d57..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/jsonstring.go +++ /dev/null @@ -1,512 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on Go stdlib's encoding/json/encode.go */ -// Copyright 2010 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package v1 - -import ( - "io" - "unicode/utf8" - "strconv" - "unicode/utf16" - "unicode" -) - -const hex = "0123456789abcdef" - -type JsonStringWriter interface { - io.Writer - io.ByteWriter - stringWriter -} - -func WriteJsonString(buf JsonStringWriter, s string) { - WriteJson(buf, []byte(s)) -} - -/** - * Function ported from encoding/json: func (e *encodeState) string(s string) (int, error) - */ -func WriteJson(buf JsonStringWriter, s []byte) { - buf.WriteByte('"') - start := 0 - for i := 0; i < len(s); { - if b := s[i]; b < utf8.RuneSelf { - /* - if 0x20 <= b && b != '\\' && b != '"' && b != '<' && b != '>' && b != '&' { - i++ - continue - } - */ - if lt[b] == true { - i++ - continue - } - - if start < i { - buf.Write(s[start:i]) - } - switch b { - case '\\', '"': - buf.WriteByte('\\') - buf.WriteByte(b) - case '\n': - buf.WriteByte('\\') - buf.WriteByte('n') - case '\r': - buf.WriteByte('\\') - buf.WriteByte('r') - default: - // This encodes bytes < 0x20 except for \n and \r, - // as well as < and >. The latter are escaped because they - // can lead to security holes when user-controlled strings - // are rendered into JSON and served to some browsers. - buf.WriteString(`\u00`) - buf.WriteByte(hex[b>>4]) - buf.WriteByte(hex[b&0xF]) - } - i++ - start = i - continue - } - c, size := utf8.DecodeRune(s[i:]) - if c == utf8.RuneError && size == 1 { - if start < i { - buf.Write(s[start:i]) - } - buf.WriteString(`\ufffd`) - i += size - start = i - continue - } - // U+2028 is LINE SEPARATOR. - // U+2029 is PARAGRAPH SEPARATOR. - // They are both technically valid characters in JSON strings, - // but don't work in JSONP, which has to be evaluated as JavaScript, - // and can lead to security holes there. It is valid JSON to - // escape them, so we do so unconditionally. - // See http://timelessrepo.com/json-isnt-a-javascript-subset for discussion. - if c == '\u2028' || c == '\u2029' { - if start < i { - buf.Write(s[start:i]) - } - buf.WriteString(`\u202`) - buf.WriteByte(hex[c&0xF]) - i += size - start = i - continue - } - i += size - } - if start < len(s) { - buf.Write(s[start:]) - } - buf.WriteByte('"') -} - -// UnquoteBytes will decode []byte containing json string to go string -// ported from encoding/json/decode.go -func UnquoteBytes(s []byte) (t []byte, ok bool) { - if len(s) < 2 || s[0] != '"' || s[len(s)-1] != '"' { - return - } - s = s[1 : len(s)-1] - - // Check for unusual characters. If there are none, - // then no unquoting is needed, so return a slice of the - // original bytes. - r := 0 - for r < len(s) { - c := s[r] - if c == '\\' || c == '"' || c < ' ' { - break - } - if c < utf8.RuneSelf { - r++ - continue - } - rr, size := utf8.DecodeRune(s[r:]) - if rr == utf8.RuneError && size == 1 { - break - } - r += size - } - if r == len(s) { - return s, true - } - - b := make([]byte, len(s)+2*utf8.UTFMax) - w := copy(b, s[0:r]) - for r < len(s) { - // Out of room? Can only happen if s is full of - // malformed UTF-8 and we're replacing each - // byte with RuneError. - if w >= len(b)-2*utf8.UTFMax { - nb := make([]byte, (len(b)+utf8.UTFMax)*2) - copy(nb, b[0:w]) - b = nb - } - switch c := s[r]; { - case c == '\\': - r++ - if r >= len(s) { - return - } - switch s[r] { - default: - return - case '"', '\\', '/', '\'': - b[w] = s[r] - r++ - w++ - case 'b': - b[w] = '\b' - r++ - w++ - case 'f': - b[w] = '\f' - r++ - w++ - case 'n': - b[w] = '\n' - r++ - w++ - case 'r': - b[w] = '\r' - r++ - w++ - case 't': - b[w] = '\t' - r++ - w++ - case 'u': - r-- - rr := getu4(s[r:]) - if rr < 0 { - return - } - r += 6 - if utf16.IsSurrogate(rr) { - rr1 := getu4(s[r:]) - if dec := utf16.DecodeRune(rr, rr1); dec != unicode.ReplacementChar { - // A valid pair; consume. - r += 6 - w += utf8.EncodeRune(b[w:], dec) - break - } - // Invalid surrogate; fall back to replacement rune. - rr = unicode.ReplacementChar - } - w += utf8.EncodeRune(b[w:], rr) - } - - // Quote, control characters are invalid. - case c == '"', c < ' ': - return - - // ASCII - case c < utf8.RuneSelf: - b[w] = c - r++ - w++ - - // Coerce to well-formed UTF-8. - default: - rr, size := utf8.DecodeRune(s[r:]) - r += size - w += utf8.EncodeRune(b[w:], rr) - } - } - return b[0:w], true -} - -// getu4 decodes \uXXXX from the beginning of s, returning the hex value, -// or it returns -1. -func getu4(s []byte) rune { - if len(s) < 6 || s[0] != '\\' || s[1] != 'u' { - return -1 - } - r, err := strconv.ParseUint(string(s[2:6]), 16, 64) - if err != nil { - return -1 - } - return rune(r) -} - -// TODO(pquerna): consider combining wibth the normal byte mask. -var lt [256]bool = [256]bool{ - false, /* 0 */ - false, /* 1 */ - false, /* 2 */ - false, /* 3 */ - false, /* 4 */ - false, /* 5 */ - false, /* 6 */ - false, /* 7 */ - false, /* 8 */ - false, /* 9 */ - false, /* 10 */ - false, /* 11 */ - false, /* 12 */ - false, /* 13 */ - false, /* 14 */ - false, /* 15 */ - false, /* 16 */ - false, /* 17 */ - false, /* 18 */ - false, /* 19 */ - false, /* 20 */ - false, /* 21 */ - false, /* 22 */ - false, /* 23 */ - false, /* 24 */ - false, /* 25 */ - false, /* 26 */ - false, /* 27 */ - false, /* 28 */ - false, /* 29 */ - false, /* 30 */ - false, /* 31 */ - true, /* 32 */ - true, /* 33 */ - false, /* 34 */ - true, /* 35 */ - true, /* 36 */ - true, /* 37 */ - false, /* 38 */ - true, /* 39 */ - true, /* 40 */ - true, /* 41 */ - true, /* 42 */ - true, /* 43 */ - true, /* 44 */ - true, /* 45 */ - true, /* 46 */ - true, /* 47 */ - true, /* 48 */ - true, /* 49 */ - true, /* 50 */ - true, /* 51 */ - true, /* 52 */ - true, /* 53 */ - true, /* 54 */ - true, /* 55 */ - true, /* 56 */ - true, /* 57 */ - true, /* 58 */ - true, /* 59 */ - false, /* 60 */ - true, /* 61 */ - false, /* 62 */ - true, /* 63 */ - true, /* 64 */ - true, /* 65 */ - true, /* 66 */ - true, /* 67 */ - true, /* 68 */ - true, /* 69 */ - true, /* 70 */ - true, /* 71 */ - true, /* 72 */ - true, /* 73 */ - true, /* 74 */ - true, /* 75 */ - true, /* 76 */ - true, /* 77 */ - true, /* 78 */ - true, /* 79 */ - true, /* 80 */ - true, /* 81 */ - true, /* 82 */ - true, /* 83 */ - true, /* 84 */ - true, /* 85 */ - true, /* 86 */ - true, /* 87 */ - true, /* 88 */ - true, /* 89 */ - true, /* 90 */ - true, /* 91 */ - false, /* 92 */ - true, /* 93 */ - true, /* 94 */ - true, /* 95 */ - true, /* 96 */ - true, /* 97 */ - true, /* 98 */ - true, /* 99 */ - true, /* 100 */ - true, /* 101 */ - true, /* 102 */ - true, /* 103 */ - true, /* 104 */ - true, /* 105 */ - true, /* 106 */ - true, /* 107 */ - true, /* 108 */ - true, /* 109 */ - true, /* 110 */ - true, /* 111 */ - true, /* 112 */ - true, /* 113 */ - true, /* 114 */ - true, /* 115 */ - true, /* 116 */ - true, /* 117 */ - true, /* 118 */ - true, /* 119 */ - true, /* 120 */ - true, /* 121 */ - true, /* 122 */ - true, /* 123 */ - true, /* 124 */ - true, /* 125 */ - true, /* 126 */ - true, /* 127 */ - true, /* 128 */ - true, /* 129 */ - true, /* 130 */ - true, /* 131 */ - true, /* 132 */ - true, /* 133 */ - true, /* 134 */ - true, /* 135 */ - true, /* 136 */ - true, /* 137 */ - true, /* 138 */ - true, /* 139 */ - true, /* 140 */ - true, /* 141 */ - true, /* 142 */ - true, /* 143 */ - true, /* 144 */ - true, /* 145 */ - true, /* 146 */ - true, /* 147 */ - true, /* 148 */ - true, /* 149 */ - true, /* 150 */ - true, /* 151 */ - true, /* 152 */ - true, /* 153 */ - true, /* 154 */ - true, /* 155 */ - true, /* 156 */ - true, /* 157 */ - true, /* 158 */ - true, /* 159 */ - true, /* 160 */ - true, /* 161 */ - true, /* 162 */ - true, /* 163 */ - true, /* 164 */ - true, /* 165 */ - true, /* 166 */ - true, /* 167 */ - true, /* 168 */ - true, /* 169 */ - true, /* 170 */ - true, /* 171 */ - true, /* 172 */ - true, /* 173 */ - true, /* 174 */ - true, /* 175 */ - true, /* 176 */ - true, /* 177 */ - true, /* 178 */ - true, /* 179 */ - true, /* 180 */ - true, /* 181 */ - true, /* 182 */ - true, /* 183 */ - true, /* 184 */ - true, /* 185 */ - true, /* 186 */ - true, /* 187 */ - true, /* 188 */ - true, /* 189 */ - true, /* 190 */ - true, /* 191 */ - true, /* 192 */ - true, /* 193 */ - true, /* 194 */ - true, /* 195 */ - true, /* 196 */ - true, /* 197 */ - true, /* 198 */ - true, /* 199 */ - true, /* 200 */ - true, /* 201 */ - true, /* 202 */ - true, /* 203 */ - true, /* 204 */ - true, /* 205 */ - true, /* 206 */ - true, /* 207 */ - true, /* 208 */ - true, /* 209 */ - true, /* 210 */ - true, /* 211 */ - true, /* 212 */ - true, /* 213 */ - true, /* 214 */ - true, /* 215 */ - true, /* 216 */ - true, /* 217 */ - true, /* 218 */ - true, /* 219 */ - true, /* 220 */ - true, /* 221 */ - true, /* 222 */ - true, /* 223 */ - true, /* 224 */ - true, /* 225 */ - true, /* 226 */ - true, /* 227 */ - true, /* 228 */ - true, /* 229 */ - true, /* 230 */ - true, /* 231 */ - true, /* 232 */ - true, /* 233 */ - true, /* 234 */ - true, /* 235 */ - true, /* 236 */ - true, /* 237 */ - true, /* 238 */ - true, /* 239 */ - true, /* 240 */ - true, /* 241 */ - true, /* 242 */ - true, /* 243 */ - true, /* 244 */ - true, /* 245 */ - true, /* 246 */ - true, /* 247 */ - true, /* 248 */ - true, /* 249 */ - true, /* 250 */ - true, /* 251 */ - true, /* 252 */ - true, /* 253 */ - true, /* 254 */ - true, /* 255 */ -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/lexer.go b/vendor/github.com/pquerna/ffjson/fflib/v1/lexer.go deleted file mode 100644 index 5589292ff..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/lexer.go +++ /dev/null @@ -1,937 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -/* Portions of this file are on derived from yajl: <https://github.com/lloyd/yajl> */ -/* - * Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io> - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -package v1 - -import ( - "errors" - "fmt" - "io" -) - -type FFParseState int - -const ( - FFParse_map_start FFParseState = iota - FFParse_want_key - FFParse_want_colon - FFParse_want_value - FFParse_after_value -) - -type FFTok int - -const ( - FFTok_init FFTok = iota - FFTok_bool FFTok = iota - FFTok_colon FFTok = iota - FFTok_comma FFTok = iota - FFTok_eof FFTok = iota - FFTok_error FFTok = iota - FFTok_left_brace FFTok = iota - FFTok_left_bracket FFTok = iota - FFTok_null FFTok = iota - FFTok_right_brace FFTok = iota - FFTok_right_bracket FFTok = iota - - /* we differentiate between integers and doubles to allow the - * parser to interpret the number without re-scanning */ - FFTok_integer FFTok = iota - FFTok_double FFTok = iota - - FFTok_string FFTok = iota - - /* comment tokens are not currently returned to the parser, ever */ - FFTok_comment FFTok = iota -) - -type FFErr int - -const ( - FFErr_e_ok FFErr = iota - FFErr_io FFErr = iota - FFErr_string_invalid_utf8 FFErr = iota - FFErr_string_invalid_escaped_char FFErr = iota - FFErr_string_invalid_json_char FFErr = iota - FFErr_string_invalid_hex_char FFErr = iota - FFErr_invalid_char FFErr = iota - FFErr_invalid_string FFErr = iota - FFErr_missing_integer_after_decimal FFErr = iota - FFErr_missing_integer_after_exponent FFErr = iota - FFErr_missing_integer_after_minus FFErr = iota - FFErr_unallowed_comment FFErr = iota - FFErr_incomplete_comment FFErr = iota - FFErr_unexpected_token_type FFErr = iota // TODO: improve this error -) - -type FFLexer struct { - reader *ffReader - Output DecodingBuffer - Token FFTok - Error FFErr - BigError error - // TODO: convert all of this to an interface - lastCurrentChar int - captureAll bool - buf Buffer -} - -func NewFFLexer(input []byte) *FFLexer { - fl := &FFLexer{ - Token: FFTok_init, - Error: FFErr_e_ok, - reader: newffReader(input), - Output: &Buffer{}, - } - // TODO: guess size? - //fl.Output.Grow(64) - return fl -} - -type LexerError struct { - offset int - line int - char int - err error -} - -// Reset the Lexer and add new input. -func (ffl *FFLexer) Reset(input []byte) { - ffl.Token = FFTok_init - ffl.Error = FFErr_e_ok - ffl.BigError = nil - ffl.reader.Reset(input) - ffl.lastCurrentChar = 0 - ffl.Output.Reset() -} - -func (le *LexerError) Error() string { - return fmt.Sprintf(`ffjson error: (%T)%s offset=%d line=%d char=%d`, - le.err, le.err.Error(), - le.offset, le.line, le.char) -} - -func (ffl *FFLexer) WrapErr(err error) error { - line, char := ffl.reader.PosWithLine() - // TOOD: calcualte lines/characters based on offset - return &LexerError{ - offset: ffl.reader.Pos(), - line: line, - char: char, - err: err, - } -} - -func (ffl *FFLexer) scanReadByte() (byte, error) { - var c byte - var err error - if ffl.captureAll { - c, err = ffl.reader.ReadByte() - } else { - c, err = ffl.reader.ReadByteNoWS() - } - - if err != nil { - ffl.Error = FFErr_io - ffl.BigError = err - return 0, err - } - - return c, nil -} - -func (ffl *FFLexer) readByte() (byte, error) { - - c, err := ffl.reader.ReadByte() - if err != nil { - ffl.Error = FFErr_io - ffl.BigError = err - return 0, err - } - - return c, nil -} - -func (ffl *FFLexer) unreadByte() { - ffl.reader.UnreadByte() -} - -func (ffl *FFLexer) wantBytes(want []byte, iftrue FFTok) FFTok { - startPos := ffl.reader.Pos() - for _, b := range want { - c, err := ffl.readByte() - - if err != nil { - return FFTok_error - } - - if c != b { - ffl.unreadByte() - // fmt.Printf("wanted bytes: %s\n", string(want)) - // TODO(pquerna): thsi is a bad error message - ffl.Error = FFErr_invalid_string - return FFTok_error - } - } - - endPos := ffl.reader.Pos() - ffl.Output.Write(ffl.reader.Slice(startPos, endPos)) - return iftrue -} - -func (ffl *FFLexer) lexComment() FFTok { - c, err := ffl.readByte() - if err != nil { - return FFTok_error - } - - if c == '/' { - // a // comment, scan until line ends. - for { - c, err := ffl.readByte() - if err != nil { - return FFTok_error - } - - if c == '\n' { - return FFTok_comment - } - } - } else if c == '*' { - // a /* */ comment, scan */ - for { - c, err := ffl.readByte() - if err != nil { - return FFTok_error - } - - if c == '*' { - c, err := ffl.readByte() - - if err != nil { - return FFTok_error - } - - if c == '/' { - return FFTok_comment - } - - ffl.Error = FFErr_incomplete_comment - return FFTok_error - } - } - } else { - ffl.Error = FFErr_incomplete_comment - return FFTok_error - } -} - -func (ffl *FFLexer) lexString() FFTok { - if ffl.captureAll { - ffl.buf.Reset() - err := ffl.reader.SliceString(&ffl.buf) - - if err != nil { - ffl.BigError = err - return FFTok_error - } - - WriteJson(ffl.Output, ffl.buf.Bytes()) - - return FFTok_string - } else { - err := ffl.reader.SliceString(ffl.Output) - - if err != nil { - ffl.BigError = err - return FFTok_error - } - - return FFTok_string - } -} - -func (ffl *FFLexer) lexNumber() FFTok { - var numRead int = 0 - tok := FFTok_integer - startPos := ffl.reader.Pos() - - c, err := ffl.readByte() - if err != nil { - return FFTok_error - } - - /* optional leading minus */ - if c == '-' { - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - } - - /* a single zero, or a series of integers */ - if c == '0' { - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - } else if c >= '1' && c <= '9' { - for c >= '0' && c <= '9' { - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - } - } else { - ffl.unreadByte() - ffl.Error = FFErr_missing_integer_after_minus - return FFTok_error - } - - if c == '.' { - numRead = 0 - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - - for c >= '0' && c <= '9' { - numRead++ - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - } - - if numRead == 0 { - ffl.unreadByte() - - ffl.Error = FFErr_missing_integer_after_decimal - return FFTok_error - } - - tok = FFTok_double - } - - /* optional exponent (indicates this is floating point) */ - if c == 'e' || c == 'E' { - numRead = 0 - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - - /* optional sign */ - if c == '+' || c == '-' { - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - } - - for c >= '0' && c <= '9' { - numRead++ - c, err = ffl.readByte() - if err != nil { - return FFTok_error - } - } - - if numRead == 0 { - ffl.Error = FFErr_missing_integer_after_exponent - return FFTok_error - } - - tok = FFTok_double - } - - ffl.unreadByte() - - endPos := ffl.reader.Pos() - ffl.Output.Write(ffl.reader.Slice(startPos, endPos)) - return tok -} - -var true_bytes = []byte{'r', 'u', 'e'} -var false_bytes = []byte{'a', 'l', 's', 'e'} -var null_bytes = []byte{'u', 'l', 'l'} - -func (ffl *FFLexer) Scan() FFTok { - tok := FFTok_error - if ffl.captureAll == false { - ffl.Output.Reset() - } - ffl.Token = FFTok_init - - for { - c, err := ffl.scanReadByte() - if err != nil { - if err == io.EOF { - return FFTok_eof - } else { - return FFTok_error - } - } - - switch c { - case '{': - tok = FFTok_left_bracket - if ffl.captureAll { - ffl.Output.WriteByte('{') - } - goto lexed - case '}': - tok = FFTok_right_bracket - if ffl.captureAll { - ffl.Output.WriteByte('}') - } - goto lexed - case '[': - tok = FFTok_left_brace - if ffl.captureAll { - ffl.Output.WriteByte('[') - } - goto lexed - case ']': - tok = FFTok_right_brace - if ffl.captureAll { - ffl.Output.WriteByte(']') - } - goto lexed - case ',': - tok = FFTok_comma - if ffl.captureAll { - ffl.Output.WriteByte(',') - } - goto lexed - case ':': - tok = FFTok_colon - if ffl.captureAll { - ffl.Output.WriteByte(':') - } - goto lexed - case '\t', '\n', '\v', '\f', '\r', ' ': - if ffl.captureAll { - ffl.Output.WriteByte(c) - } - case 't': - ffl.Output.WriteByte('t') - tok = ffl.wantBytes(true_bytes, FFTok_bool) - goto lexed - case 'f': - ffl.Output.WriteByte('f') - tok = ffl.wantBytes(false_bytes, FFTok_bool) - goto lexed - case 'n': - ffl.Output.WriteByte('n') - tok = ffl.wantBytes(null_bytes, FFTok_null) - goto lexed - case '"': - tok = ffl.lexString() - goto lexed - case '-', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9': - ffl.unreadByte() - tok = ffl.lexNumber() - goto lexed - case '/': - tok = ffl.lexComment() - goto lexed - default: - tok = FFTok_error - ffl.Error = FFErr_invalid_char - goto lexed - } - } - -lexed: - ffl.Token = tok - return tok -} - -func (ffl *FFLexer) scanField(start FFTok, capture bool) ([]byte, error) { - switch start { - case FFTok_left_brace, - FFTok_left_bracket: - { - end := FFTok_right_brace - if start == FFTok_left_bracket { - end = FFTok_right_bracket - if capture { - ffl.Output.WriteByte('{') - } - } else { - if capture { - ffl.Output.WriteByte('[') - } - } - - depth := 1 - if capture { - ffl.captureAll = true - } - // TODO: work. - scanloop: - for { - tok := ffl.Scan() - //fmt.Printf("capture-token: %v end: %v depth: %v\n", tok, end, depth) - switch tok { - case FFTok_eof: - return nil, errors.New("ffjson: unexpected EOF") - case FFTok_error: - if ffl.BigError != nil { - return nil, ffl.BigError - } - return nil, ffl.Error.ToError() - case end: - depth-- - if depth == 0 { - break scanloop - } - case start: - depth++ - } - } - - if capture { - ffl.captureAll = false - } - - if capture { - return ffl.Output.Bytes(), nil - } else { - return nil, nil - } - } - case FFTok_bool, - FFTok_integer, - FFTok_null, - FFTok_double: - // simple value, return it. - if capture { - return ffl.Output.Bytes(), nil - } else { - return nil, nil - } - - case FFTok_string: - //TODO(pquerna): so, other users expect this to be a quoted string :( - if capture { - ffl.buf.Reset() - WriteJson(&ffl.buf, ffl.Output.Bytes()) - return ffl.buf.Bytes(), nil - } else { - return nil, nil - } - } - - return nil, fmt.Errorf("ffjson: invalid capture type: %v", start) -} - -// Captures an entire field value, including recursive objects, -// and converts them to a []byte suitable to pass to a sub-object's -// UnmarshalJSON -func (ffl *FFLexer) CaptureField(start FFTok) ([]byte, error) { - return ffl.scanField(start, true) -} - -func (ffl *FFLexer) SkipField(start FFTok) error { - _, err := ffl.scanField(start, false) - return err -} - -// TODO(pquerna): return line number and offset. -func (err FFErr) ToError() error { - switch err { - case FFErr_e_ok: - return nil - case FFErr_io: - return errors.New("ffjson: IO error") - case FFErr_string_invalid_utf8: - return errors.New("ffjson: string with invalid UTF-8 sequence") - case FFErr_string_invalid_escaped_char: - return errors.New("ffjson: string with invalid escaped character") - case FFErr_string_invalid_json_char: - return errors.New("ffjson: string with invalid JSON character") - case FFErr_string_invalid_hex_char: - return errors.New("ffjson: string with invalid hex character") - case FFErr_invalid_char: - return errors.New("ffjson: invalid character") - case FFErr_invalid_string: - return errors.New("ffjson: invalid string") - case FFErr_missing_integer_after_decimal: - return errors.New("ffjson: missing integer after decimal") - case FFErr_missing_integer_after_exponent: - return errors.New("ffjson: missing integer after exponent") - case FFErr_missing_integer_after_minus: - return errors.New("ffjson: missing integer after minus") - case FFErr_unallowed_comment: - return errors.New("ffjson: unallowed comment") - case FFErr_incomplete_comment: - return errors.New("ffjson: incomplete comment") - case FFErr_unexpected_token_type: - return errors.New("ffjson: unexpected token sequence") - } - - panic(fmt.Sprintf("unknown error type: %v ", err)) -} - -func (state FFParseState) String() string { - switch state { - case FFParse_map_start: - return "map:start" - case FFParse_want_key: - return "want_key" - case FFParse_want_colon: - return "want_colon" - case FFParse_want_value: - return "want_value" - case FFParse_after_value: - return "after_value" - } - - panic(fmt.Sprintf("unknown parse state: %d", int(state))) -} - -func (tok FFTok) String() string { - switch tok { - case FFTok_init: - return "tok:init" - case FFTok_bool: - return "tok:bool" - case FFTok_colon: - return "tok:colon" - case FFTok_comma: - return "tok:comma" - case FFTok_eof: - return "tok:eof" - case FFTok_error: - return "tok:error" - case FFTok_left_brace: - return "tok:left_brace" - case FFTok_left_bracket: - return "tok:left_bracket" - case FFTok_null: - return "tok:null" - case FFTok_right_brace: - return "tok:right_brace" - case FFTok_right_bracket: - return "tok:right_bracket" - case FFTok_integer: - return "tok:integer" - case FFTok_double: - return "tok:double" - case FFTok_string: - return "tok:string" - case FFTok_comment: - return "comment" - } - - panic(fmt.Sprintf("unknown token: %d", int(tok))) -} - -/* a lookup table which lets us quickly determine three things: - * cVEC - valid escaped control char - * note. the solidus '/' may be escaped or not. - * cIJC - invalid json char - * cVHC - valid hex char - * cNFP - needs further processing (from a string scanning perspective) - * cNUC - needs utf8 checking when enabled (from a string scanning perspective) - */ - -const ( - cVEC int8 = 0x01 - cIJC int8 = 0x02 - cVHC int8 = 0x04 - cNFP int8 = 0x08 - cNUC int8 = 0x10 -) - -var byteLookupTable [256]int8 = [256]int8{ - cIJC, /* 0 */ - cIJC, /* 1 */ - cIJC, /* 2 */ - cIJC, /* 3 */ - cIJC, /* 4 */ - cIJC, /* 5 */ - cIJC, /* 6 */ - cIJC, /* 7 */ - cIJC, /* 8 */ - cIJC, /* 9 */ - cIJC, /* 10 */ - cIJC, /* 11 */ - cIJC, /* 12 */ - cIJC, /* 13 */ - cIJC, /* 14 */ - cIJC, /* 15 */ - cIJC, /* 16 */ - cIJC, /* 17 */ - cIJC, /* 18 */ - cIJC, /* 19 */ - cIJC, /* 20 */ - cIJC, /* 21 */ - cIJC, /* 22 */ - cIJC, /* 23 */ - cIJC, /* 24 */ - cIJC, /* 25 */ - cIJC, /* 26 */ - cIJC, /* 27 */ - cIJC, /* 28 */ - cIJC, /* 29 */ - cIJC, /* 30 */ - cIJC, /* 31 */ - 0, /* 32 */ - 0, /* 33 */ - cVEC | cIJC | cNFP, /* 34 */ - 0, /* 35 */ - 0, /* 36 */ - 0, /* 37 */ - 0, /* 38 */ - 0, /* 39 */ - 0, /* 40 */ - 0, /* 41 */ - 0, /* 42 */ - 0, /* 43 */ - 0, /* 44 */ - 0, /* 45 */ - 0, /* 46 */ - cVEC, /* 47 */ - cVHC, /* 48 */ - cVHC, /* 49 */ - cVHC, /* 50 */ - cVHC, /* 51 */ - cVHC, /* 52 */ - cVHC, /* 53 */ - cVHC, /* 54 */ - cVHC, /* 55 */ - cVHC, /* 56 */ - cVHC, /* 57 */ - 0, /* 58 */ - 0, /* 59 */ - 0, /* 60 */ - 0, /* 61 */ - 0, /* 62 */ - 0, /* 63 */ - 0, /* 64 */ - cVHC, /* 65 */ - cVHC, /* 66 */ - cVHC, /* 67 */ - cVHC, /* 68 */ - cVHC, /* 69 */ - cVHC, /* 70 */ - 0, /* 71 */ - 0, /* 72 */ - 0, /* 73 */ - 0, /* 74 */ - 0, /* 75 */ - 0, /* 76 */ - 0, /* 77 */ - 0, /* 78 */ - 0, /* 79 */ - 0, /* 80 */ - 0, /* 81 */ - 0, /* 82 */ - 0, /* 83 */ - 0, /* 84 */ - 0, /* 85 */ - 0, /* 86 */ - 0, /* 87 */ - 0, /* 88 */ - 0, /* 89 */ - 0, /* 90 */ - 0, /* 91 */ - cVEC | cIJC | cNFP, /* 92 */ - 0, /* 93 */ - 0, /* 94 */ - 0, /* 95 */ - 0, /* 96 */ - cVHC, /* 97 */ - cVEC | cVHC, /* 98 */ - cVHC, /* 99 */ - cVHC, /* 100 */ - cVHC, /* 101 */ - cVEC | cVHC, /* 102 */ - 0, /* 103 */ - 0, /* 104 */ - 0, /* 105 */ - 0, /* 106 */ - 0, /* 107 */ - 0, /* 108 */ - 0, /* 109 */ - cVEC, /* 110 */ - 0, /* 111 */ - 0, /* 112 */ - 0, /* 113 */ - cVEC, /* 114 */ - 0, /* 115 */ - cVEC, /* 116 */ - 0, /* 117 */ - 0, /* 118 */ - 0, /* 119 */ - 0, /* 120 */ - 0, /* 121 */ - 0, /* 122 */ - 0, /* 123 */ - 0, /* 124 */ - 0, /* 125 */ - 0, /* 126 */ - 0, /* 127 */ - cNUC, /* 128 */ - cNUC, /* 129 */ - cNUC, /* 130 */ - cNUC, /* 131 */ - cNUC, /* 132 */ - cNUC, /* 133 */ - cNUC, /* 134 */ - cNUC, /* 135 */ - cNUC, /* 136 */ - cNUC, /* 137 */ - cNUC, /* 138 */ - cNUC, /* 139 */ - cNUC, /* 140 */ - cNUC, /* 141 */ - cNUC, /* 142 */ - cNUC, /* 143 */ - cNUC, /* 144 */ - cNUC, /* 145 */ - cNUC, /* 146 */ - cNUC, /* 147 */ - cNUC, /* 148 */ - cNUC, /* 149 */ - cNUC, /* 150 */ - cNUC, /* 151 */ - cNUC, /* 152 */ - cNUC, /* 153 */ - cNUC, /* 154 */ - cNUC, /* 155 */ - cNUC, /* 156 */ - cNUC, /* 157 */ - cNUC, /* 158 */ - cNUC, /* 159 */ - cNUC, /* 160 */ - cNUC, /* 161 */ - cNUC, /* 162 */ - cNUC, /* 163 */ - cNUC, /* 164 */ - cNUC, /* 165 */ - cNUC, /* 166 */ - cNUC, /* 167 */ - cNUC, /* 168 */ - cNUC, /* 169 */ - cNUC, /* 170 */ - cNUC, /* 171 */ - cNUC, /* 172 */ - cNUC, /* 173 */ - cNUC, /* 174 */ - cNUC, /* 175 */ - cNUC, /* 176 */ - cNUC, /* 177 */ - cNUC, /* 178 */ - cNUC, /* 179 */ - cNUC, /* 180 */ - cNUC, /* 181 */ - cNUC, /* 182 */ - cNUC, /* 183 */ - cNUC, /* 184 */ - cNUC, /* 185 */ - cNUC, /* 186 */ - cNUC, /* 187 */ - cNUC, /* 188 */ - cNUC, /* 189 */ - cNUC, /* 190 */ - cNUC, /* 191 */ - cNUC, /* 192 */ - cNUC, /* 193 */ - cNUC, /* 194 */ - cNUC, /* 195 */ - cNUC, /* 196 */ - cNUC, /* 197 */ - cNUC, /* 198 */ - cNUC, /* 199 */ - cNUC, /* 200 */ - cNUC, /* 201 */ - cNUC, /* 202 */ - cNUC, /* 203 */ - cNUC, /* 204 */ - cNUC, /* 205 */ - cNUC, /* 206 */ - cNUC, /* 207 */ - cNUC, /* 208 */ - cNUC, /* 209 */ - cNUC, /* 210 */ - cNUC, /* 211 */ - cNUC, /* 212 */ - cNUC, /* 213 */ - cNUC, /* 214 */ - cNUC, /* 215 */ - cNUC, /* 216 */ - cNUC, /* 217 */ - cNUC, /* 218 */ - cNUC, /* 219 */ - cNUC, /* 220 */ - cNUC, /* 221 */ - cNUC, /* 222 */ - cNUC, /* 223 */ - cNUC, /* 224 */ - cNUC, /* 225 */ - cNUC, /* 226 */ - cNUC, /* 227 */ - cNUC, /* 228 */ - cNUC, /* 229 */ - cNUC, /* 230 */ - cNUC, /* 231 */ - cNUC, /* 232 */ - cNUC, /* 233 */ - cNUC, /* 234 */ - cNUC, /* 235 */ - cNUC, /* 236 */ - cNUC, /* 237 */ - cNUC, /* 238 */ - cNUC, /* 239 */ - cNUC, /* 240 */ - cNUC, /* 241 */ - cNUC, /* 242 */ - cNUC, /* 243 */ - cNUC, /* 244 */ - cNUC, /* 245 */ - cNUC, /* 246 */ - cNUC, /* 247 */ - cNUC, /* 248 */ - cNUC, /* 249 */ - cNUC, /* 250 */ - cNUC, /* 251 */ - cNUC, /* 252 */ - cNUC, /* 253 */ - cNUC, /* 254 */ - cNUC, /* 255 */ -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/reader.go b/vendor/github.com/pquerna/ffjson/fflib/v1/reader.go deleted file mode 100644 index 96746b9d4..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/reader.go +++ /dev/null @@ -1,512 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1 - -import ( - "fmt" - "io" - "unicode" - "unicode/utf16" -) - -const sliceStringMask = cIJC | cNFP - -type ffReader struct { - s []byte - i int - l int -} - -func newffReader(d []byte) *ffReader { - return &ffReader{ - s: d, - i: 0, - l: len(d), - } -} - -func (r *ffReader) Slice(start, stop int) []byte { - return r.s[start:stop] -} - -func (r *ffReader) Pos() int { - return r.i -} - -// Reset the reader, and add new input. -func (r *ffReader) Reset(d []byte) { - r.s = d - r.i = 0 - r.l = len(d) -} - -// Calculates the Position with line and line offset, -// because this isn't counted for performance reasons, -// it will iterate the buffer from the beginning, and should -// only be used in error-paths. -func (r *ffReader) PosWithLine() (int, int) { - currentLine := 1 - currentChar := 0 - - for i := 0; i < r.i; i++ { - c := r.s[i] - currentChar++ - if c == '\n' { - currentLine++ - currentChar = 0 - } - } - - return currentLine, currentChar -} - -func (r *ffReader) ReadByteNoWS() (byte, error) { - if r.i >= r.l { - return 0, io.EOF - } - - j := r.i - - for { - c := r.s[j] - j++ - - // inline whitespace parsing gives another ~8% performance boost - // for many kinds of nicely indented JSON. - // ... and using a [255]bool instead of multiple ifs, gives another 2% - /* - if c != '\t' && - c != '\n' && - c != '\v' && - c != '\f' && - c != '\r' && - c != ' ' { - r.i = j - return c, nil - } - */ - if whitespaceLookupTable[c] == false { - r.i = j - return c, nil - } - - if j >= r.l { - return 0, io.EOF - } - } -} - -func (r *ffReader) ReadByte() (byte, error) { - if r.i >= r.l { - return 0, io.EOF - } - - r.i++ - - return r.s[r.i-1], nil -} - -func (r *ffReader) UnreadByte() error { - if r.i <= 0 { - panic("ffReader.UnreadByte: at beginning of slice") - } - r.i-- - return nil -} - -func (r *ffReader) readU4(j int) (rune, error) { - - var u4 [4]byte - for i := 0; i < 4; i++ { - if j >= r.l { - return -1, io.EOF - } - c := r.s[j] - if byteLookupTable[c]&cVHC != 0 { - u4[i] = c - j++ - continue - } else { - // TODO(pquerna): handle errors better. layering violation. - return -1, fmt.Errorf("lex_string_invalid_hex_char: %v %v", c, string(u4[:])) - } - } - - // TODO(pquerna): utf16.IsSurrogate - rr, err := ParseUint(u4[:], 16, 64) - if err != nil { - return -1, err - } - return rune(rr), nil -} - -func (r *ffReader) handleEscaped(c byte, j int, out DecodingBuffer) (int, error) { - if j >= r.l { - return 0, io.EOF - } - - c = r.s[j] - j++ - - if c == 'u' { - ru, err := r.readU4(j) - if err != nil { - return 0, err - } - - if utf16.IsSurrogate(ru) { - ru2, err := r.readU4(j + 6) - if err != nil { - return 0, err - } - out.Write(r.s[r.i : j-2]) - r.i = j + 10 - j = r.i - rval := utf16.DecodeRune(ru, ru2) - if rval != unicode.ReplacementChar { - out.WriteRune(rval) - } else { - return 0, fmt.Errorf("lex_string_invalid_unicode_surrogate: %v %v", ru, ru2) - } - } else { - out.Write(r.s[r.i : j-2]) - r.i = j + 4 - j = r.i - out.WriteRune(ru) - } - return j, nil - } else if byteLookupTable[c]&cVEC == 0 { - return 0, fmt.Errorf("lex_string_invalid_escaped_char: %v", c) - } else { - out.Write(r.s[r.i : j-2]) - r.i = j - j = r.i - - switch c { - case '"': - out.WriteByte('"') - case '\\': - out.WriteByte('\\') - case '/': - out.WriteByte('/') - case 'b': - out.WriteByte('\b') - case 'f': - out.WriteByte('\f') - case 'n': - out.WriteByte('\n') - case 'r': - out.WriteByte('\r') - case 't': - out.WriteByte('\t') - } - } - - return j, nil -} - -func (r *ffReader) SliceString(out DecodingBuffer) error { - var c byte - // TODO(pquerna): string_with_escapes? de-escape here? - j := r.i - - for { - if j >= r.l { - return io.EOF - } - - j, c = scanString(r.s, j) - - if c == '"' { - if j != r.i { - out.Write(r.s[r.i : j-1]) - r.i = j - } - return nil - } else if c == '\\' { - var err error - j, err = r.handleEscaped(c, j, out) - if err != nil { - return err - } - } else if byteLookupTable[c]&cIJC != 0 { - return fmt.Errorf("lex_string_invalid_json_char: %v", c) - } - continue - } -} - -// TODO(pquerna): consider combining wibth the normal byte mask. -var whitespaceLookupTable [256]bool = [256]bool{ - false, /* 0 */ - false, /* 1 */ - false, /* 2 */ - false, /* 3 */ - false, /* 4 */ - false, /* 5 */ - false, /* 6 */ - false, /* 7 */ - false, /* 8 */ - true, /* 9 */ - true, /* 10 */ - true, /* 11 */ - true, /* 12 */ - true, /* 13 */ - false, /* 14 */ - false, /* 15 */ - false, /* 16 */ - false, /* 17 */ - false, /* 18 */ - false, /* 19 */ - false, /* 20 */ - false, /* 21 */ - false, /* 22 */ - false, /* 23 */ - false, /* 24 */ - false, /* 25 */ - false, /* 26 */ - false, /* 27 */ - false, /* 28 */ - false, /* 29 */ - false, /* 30 */ - false, /* 31 */ - true, /* 32 */ - false, /* 33 */ - false, /* 34 */ - false, /* 35 */ - false, /* 36 */ - false, /* 37 */ - false, /* 38 */ - false, /* 39 */ - false, /* 40 */ - false, /* 41 */ - false, /* 42 */ - false, /* 43 */ - false, /* 44 */ - false, /* 45 */ - false, /* 46 */ - false, /* 47 */ - false, /* 48 */ - false, /* 49 */ - false, /* 50 */ - false, /* 51 */ - false, /* 52 */ - false, /* 53 */ - false, /* 54 */ - false, /* 55 */ - false, /* 56 */ - false, /* 57 */ - false, /* 58 */ - false, /* 59 */ - false, /* 60 */ - false, /* 61 */ - false, /* 62 */ - false, /* 63 */ - false, /* 64 */ - false, /* 65 */ - false, /* 66 */ - false, /* 67 */ - false, /* 68 */ - false, /* 69 */ - false, /* 70 */ - false, /* 71 */ - false, /* 72 */ - false, /* 73 */ - false, /* 74 */ - false, /* 75 */ - false, /* 76 */ - false, /* 77 */ - false, /* 78 */ - false, /* 79 */ - false, /* 80 */ - false, /* 81 */ - false, /* 82 */ - false, /* 83 */ - false, /* 84 */ - false, /* 85 */ - false, /* 86 */ - false, /* 87 */ - false, /* 88 */ - false, /* 89 */ - false, /* 90 */ - false, /* 91 */ - false, /* 92 */ - false, /* 93 */ - false, /* 94 */ - false, /* 95 */ - false, /* 96 */ - false, /* 97 */ - false, /* 98 */ - false, /* 99 */ - false, /* 100 */ - false, /* 101 */ - false, /* 102 */ - false, /* 103 */ - false, /* 104 */ - false, /* 105 */ - false, /* 106 */ - false, /* 107 */ - false, /* 108 */ - false, /* 109 */ - false, /* 110 */ - false, /* 111 */ - false, /* 112 */ - false, /* 113 */ - false, /* 114 */ - false, /* 115 */ - false, /* 116 */ - false, /* 117 */ - false, /* 118 */ - false, /* 119 */ - false, /* 120 */ - false, /* 121 */ - false, /* 122 */ - false, /* 123 */ - false, /* 124 */ - false, /* 125 */ - false, /* 126 */ - false, /* 127 */ - false, /* 128 */ - false, /* 129 */ - false, /* 130 */ - false, /* 131 */ - false, /* 132 */ - false, /* 133 */ - false, /* 134 */ - false, /* 135 */ - false, /* 136 */ - false, /* 137 */ - false, /* 138 */ - false, /* 139 */ - false, /* 140 */ - false, /* 141 */ - false, /* 142 */ - false, /* 143 */ - false, /* 144 */ - false, /* 145 */ - false, /* 146 */ - false, /* 147 */ - false, /* 148 */ - false, /* 149 */ - false, /* 150 */ - false, /* 151 */ - false, /* 152 */ - false, /* 153 */ - false, /* 154 */ - false, /* 155 */ - false, /* 156 */ - false, /* 157 */ - false, /* 158 */ - false, /* 159 */ - false, /* 160 */ - false, /* 161 */ - false, /* 162 */ - false, /* 163 */ - false, /* 164 */ - false, /* 165 */ - false, /* 166 */ - false, /* 167 */ - false, /* 168 */ - false, /* 169 */ - false, /* 170 */ - false, /* 171 */ - false, /* 172 */ - false, /* 173 */ - false, /* 174 */ - false, /* 175 */ - false, /* 176 */ - false, /* 177 */ - false, /* 178 */ - false, /* 179 */ - false, /* 180 */ - false, /* 181 */ - false, /* 182 */ - false, /* 183 */ - false, /* 184 */ - false, /* 185 */ - false, /* 186 */ - false, /* 187 */ - false, /* 188 */ - false, /* 189 */ - false, /* 190 */ - false, /* 191 */ - false, /* 192 */ - false, /* 193 */ - false, /* 194 */ - false, /* 195 */ - false, /* 196 */ - false, /* 197 */ - false, /* 198 */ - false, /* 199 */ - false, /* 200 */ - false, /* 201 */ - false, /* 202 */ - false, /* 203 */ - false, /* 204 */ - false, /* 205 */ - false, /* 206 */ - false, /* 207 */ - false, /* 208 */ - false, /* 209 */ - false, /* 210 */ - false, /* 211 */ - false, /* 212 */ - false, /* 213 */ - false, /* 214 */ - false, /* 215 */ - false, /* 216 */ - false, /* 217 */ - false, /* 218 */ - false, /* 219 */ - false, /* 220 */ - false, /* 221 */ - false, /* 222 */ - false, /* 223 */ - false, /* 224 */ - false, /* 225 */ - false, /* 226 */ - false, /* 227 */ - false, /* 228 */ - false, /* 229 */ - false, /* 230 */ - false, /* 231 */ - false, /* 232 */ - false, /* 233 */ - false, /* 234 */ - false, /* 235 */ - false, /* 236 */ - false, /* 237 */ - false, /* 238 */ - false, /* 239 */ - false, /* 240 */ - false, /* 241 */ - false, /* 242 */ - false, /* 243 */ - false, /* 244 */ - false, /* 245 */ - false, /* 246 */ - false, /* 247 */ - false, /* 248 */ - false, /* 249 */ - false, /* 250 */ - false, /* 251 */ - false, /* 252 */ - false, /* 253 */ - false, /* 254 */ - false, /* 255 */ -} diff --git a/vendor/github.com/pquerna/ffjson/fflib/v1/reader_scan_generic.go b/vendor/github.com/pquerna/ffjson/fflib/v1/reader_scan_generic.go deleted file mode 100644 index 47c260770..000000000 --- a/vendor/github.com/pquerna/ffjson/fflib/v1/reader_scan_generic.go +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package v1 - -func scanString(s []byte, j int) (int, byte) { - for { - if j >= len(s) { - return j, 0 - } - - c := s[j] - j++ - if byteLookupTable[c]&sliceStringMask == 0 { - continue - } - - return j, c - } -} diff --git a/vendor/github.com/pquerna/ffjson/inception/decoder.go b/vendor/github.com/pquerna/ffjson/inception/decoder.go deleted file mode 100644 index 908347a32..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/decoder.go +++ /dev/null @@ -1,323 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "fmt" - "reflect" - "strings" - - "github.com/pquerna/ffjson/shared" -) - -var validValues []string = []string{ - "FFTok_left_brace", - "FFTok_left_bracket", - "FFTok_integer", - "FFTok_double", - "FFTok_string", - "FFTok_bool", - "FFTok_null", -} - -func CreateUnmarshalJSON(ic *Inception, si *StructInfo) error { - out := "" - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - if len(si.Fields) > 0 { - ic.OutputImports[`"bytes"`] = true - } - ic.OutputImports[`"fmt"`] = true - - out += tplStr(decodeTpl["header"], header{ - IC: ic, - SI: si, - }) - - out += tplStr(decodeTpl["ujFunc"], ujFunc{ - SI: si, - IC: ic, - ValidValues: validValues, - ResetFields: ic.ResetFields, - }) - - ic.OutputFuncs = append(ic.OutputFuncs, out) - - return nil -} - -func handleField(ic *Inception, name string, typ reflect.Type, ptr bool, quoted bool) string { - return handleFieldAddr(ic, name, false, typ, ptr, quoted) -} - -func handleFieldAddr(ic *Inception, name string, takeAddr bool, typ reflect.Type, ptr bool, quoted bool) string { - out := fmt.Sprintf("/* handler: %s type=%v kind=%v quoted=%t*/\n", name, typ, typ.Kind(), quoted) - - umlx := typ.Implements(unmarshalFasterType) || typeInInception(ic, typ, shared.MustDecoder) - umlx = umlx || reflect.PtrTo(typ).Implements(unmarshalFasterType) - - umlstd := typ.Implements(unmarshalerType) || reflect.PtrTo(typ).Implements(unmarshalerType) - - out += tplStr(decodeTpl["handleUnmarshaler"], handleUnmarshaler{ - IC: ic, - Name: name, - Typ: typ, - Ptr: reflect.Ptr, - TakeAddr: takeAddr || ptr, - UnmarshalJSONFFLexer: umlx, - Unmarshaler: umlstd, - }) - - if umlx || umlstd { - return out - } - - // TODO(pquerna): generic handling of token type mismatching struct type - switch typ.Kind() { - case reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64: - - allowed := buildTokens(quoted, "FFTok_string", "FFTok_integer", "FFTok_null") - out += getAllowTokens(typ.Name(), allowed...) - - out += getNumberHandler(ic, name, takeAddr || ptr, typ, "ParseInt") - - case reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64: - - allowed := buildTokens(quoted, "FFTok_string", "FFTok_integer", "FFTok_null") - out += getAllowTokens(typ.Name(), allowed...) - - out += getNumberHandler(ic, name, takeAddr || ptr, typ, "ParseUint") - - case reflect.Float32, - reflect.Float64: - - allowed := buildTokens(quoted, "FFTok_string", "FFTok_double", "FFTok_integer", "FFTok_null") - out += getAllowTokens(typ.Name(), allowed...) - - out += getNumberHandler(ic, name, takeAddr || ptr, typ, "ParseFloat") - - case reflect.Bool: - ic.OutputImports[`"bytes"`] = true - ic.OutputImports[`"errors"`] = true - - allowed := buildTokens(quoted, "FFTok_string", "FFTok_bool", "FFTok_null") - out += getAllowTokens(typ.Name(), allowed...) - - out += tplStr(decodeTpl["handleBool"], handleBool{ - Name: name, - Typ: typ, - TakeAddr: takeAddr || ptr, - }) - - case reflect.Ptr: - out += tplStr(decodeTpl["handlePtr"], handlePtr{ - IC: ic, - Name: name, - Typ: typ, - Quoted: quoted, - }) - - case reflect.Array, - reflect.Slice: - out += getArrayHandler(ic, name, typ, ptr) - - case reflect.String: - // Is it a json.Number? - if typ.PkgPath() == "encoding/json" && typ.Name() == "Number" { - // Fall back to json package to rely on the valid number check. - // See: https://github.com/golang/go/blob/f05c3aa24d815cd3869153750c9875e35fc48a6e/src/encoding/json/decode.go#L897 - ic.OutputImports[`"encoding/json"`] = true - out += tplStr(decodeTpl["handleFallback"], handleFallback{ - Name: name, - Typ: typ, - Kind: typ.Kind(), - }) - } else { - out += tplStr(decodeTpl["handleString"], handleString{ - IC: ic, - Name: name, - Typ: typ, - TakeAddr: takeAddr || ptr, - Quoted: quoted, - }) - } - case reflect.Interface: - ic.OutputImports[`"encoding/json"`] = true - out += tplStr(decodeTpl["handleFallback"], handleFallback{ - Name: name, - Typ: typ, - Kind: typ.Kind(), - }) - case reflect.Map: - out += tplStr(decodeTpl["handleObject"], handleObject{ - IC: ic, - Name: name, - Typ: typ, - Ptr: reflect.Ptr, - TakeAddr: takeAddr || ptr, - }) - default: - ic.OutputImports[`"encoding/json"`] = true - out += tplStr(decodeTpl["handleFallback"], handleFallback{ - Name: name, - Typ: typ, - Kind: typ.Kind(), - }) - } - - return out -} - -func getArrayHandler(ic *Inception, name string, typ reflect.Type, ptr bool) string { - if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 { - ic.OutputImports[`"encoding/base64"`] = true - useReflectToSet := false - if typ.Elem().Name() != "byte" { - ic.OutputImports[`"reflect"`] = true - useReflectToSet = true - } - - return tplStr(decodeTpl["handleByteSlice"], handleArray{ - IC: ic, - Name: name, - Typ: typ, - Ptr: reflect.Ptr, - UseReflectToSet: useReflectToSet, - }) - } - - if typ.Elem().Kind() == reflect.Struct && typ.Elem().Name() != "" { - goto sliceOrArray - } - - if (typ.Elem().Kind() == reflect.Struct || typ.Elem().Kind() == reflect.Map) || - typ.Elem().Kind() == reflect.Array || typ.Elem().Kind() == reflect.Slice && - typ.Elem().Name() == "" { - ic.OutputImports[`"encoding/json"`] = true - - return tplStr(decodeTpl["handleFallback"], handleFallback{ - Name: name, - Typ: typ, - Kind: typ.Kind(), - }) - } - -sliceOrArray: - - if typ.Kind() == reflect.Array { - return tplStr(decodeTpl["handleArray"], handleArray{ - IC: ic, - Name: name, - Typ: typ, - IsPtr: ptr, - Ptr: reflect.Ptr, - }) - } - - return tplStr(decodeTpl["handleSlice"], handleArray{ - IC: ic, - Name: name, - Typ: typ, - IsPtr: ptr, - Ptr: reflect.Ptr, - }) -} - -func getAllowTokens(name string, tokens ...string) string { - return tplStr(decodeTpl["allowTokens"], allowTokens{ - Name: name, - Tokens: tokens, - }) -} - -func getNumberHandler(ic *Inception, name string, takeAddr bool, typ reflect.Type, parsefunc string) string { - return tplStr(decodeTpl["handlerNumeric"], handlerNumeric{ - IC: ic, - Name: name, - ParseFunc: parsefunc, - TakeAddr: takeAddr, - Typ: typ, - }) -} - -func getNumberSize(typ reflect.Type) string { - return fmt.Sprintf("%d", typ.Bits()) -} - -func getType(ic *Inception, name string, typ reflect.Type) string { - s := typ.Name() - - if typ.PkgPath() != "" && typ.PkgPath() != ic.PackagePath { - path := removeVendor(typ.PkgPath()) - ic.OutputImports[`"`+path+`"`] = true - s = typ.String() - } - - if s == "" { - return typ.String() - } - - return s -} - -// removeVendor removes everything before and including a '/vendor/' -// substring in the package path. -// This is needed becuase that full path can't be used in the -// import statement. -func removeVendor(path string) string { - i := strings.Index(path, "/vendor/") - if i == -1 { - return path - } - return path[i+8:] -} - -func buildTokens(containsOptional bool, optional string, required ...string) []string { - if containsOptional { - return append(required, optional) - } - - return required -} - -func unquoteField(quoted bool) string { - // The outer quote of a string is already stripped out by - // the lexer. We need to check if the inner string is also - // quoted. If so, we will decode it as json string. If decoding - // fails, we will use the original string - if quoted { - return ` - unquoted, ok := fflib.UnquoteBytes(outBuf) - if ok { - outBuf = unquoted - } - ` - } - return "" -} - -func getTmpVarFor(name string) string { - return "tmp" + strings.Replace(strings.Title(name), ".", "", -1) -} diff --git a/vendor/github.com/pquerna/ffjson/inception/decoder_tpl.go b/vendor/github.com/pquerna/ffjson/inception/decoder_tpl.go deleted file mode 100644 index 098506122..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/decoder_tpl.go +++ /dev/null @@ -1,773 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "reflect" - "strconv" - "text/template" -) - -var decodeTpl map[string]*template.Template - -func init() { - decodeTpl = make(map[string]*template.Template) - - funcs := map[string]string{ - "handlerNumeric": handlerNumericTxt, - "allowTokens": allowTokensTxt, - "handleFallback": handleFallbackTxt, - "handleString": handleStringTxt, - "handleObject": handleObjectTxt, - "handleArray": handleArrayTxt, - "handleSlice": handleSliceTxt, - "handleByteSlice": handleByteSliceTxt, - "handleBool": handleBoolTxt, - "handlePtr": handlePtrTxt, - "header": headerTxt, - "ujFunc": ujFuncTxt, - "handleUnmarshaler": handleUnmarshalerTxt, - } - - tplFuncs := template.FuncMap{ - "getAllowTokens": getAllowTokens, - "getNumberSize": getNumberSize, - "getType": getType, - "handleField": handleField, - "handleFieldAddr": handleFieldAddr, - "unquoteField": unquoteField, - "getTmpVarFor": getTmpVarFor, - } - - for k, v := range funcs { - decodeTpl[k] = template.Must(template.New(k).Funcs(tplFuncs).Parse(v)) - } -} - -type handlerNumeric struct { - IC *Inception - Name string - ParseFunc string - Typ reflect.Type - TakeAddr bool -} - -var handlerNumericTxt = ` -{ - {{$ic := .IC}} - - if tok == fflib.FFTok_null { - {{if eq .TakeAddr true}} - {{.Name}} = nil - {{end}} - } else { - {{if eq .ParseFunc "ParseFloat" }} - tval, err := fflib.{{ .ParseFunc}}(fs.Output.Bytes(), {{getNumberSize .Typ}}) - {{else}} - tval, err := fflib.{{ .ParseFunc}}(fs.Output.Bytes(), 10, {{getNumberSize .Typ}}) - {{end}} - - if err != nil { - return fs.WrapErr(err) - } - {{if eq .TakeAddr true}} - ttypval := {{getType $ic .Name .Typ}}(tval) - {{.Name}} = &ttypval - {{else}} - {{.Name}} = {{getType $ic .Name .Typ}}(tval) - {{end}} - } -} -` - -type allowTokens struct { - Name string - Tokens []string -} - -var allowTokensTxt = ` -{ - if {{range $index, $element := .Tokens}}{{if ne $index 0 }}&&{{end}} tok != fflib.{{$element}}{{end}} { - return fs.WrapErr(fmt.Errorf("cannot unmarshal %s into Go value for {{.Name}}", tok)) - } -} -` - -type handleFallback struct { - Name string - Typ reflect.Type - Kind reflect.Kind -} - -var handleFallbackTxt = ` -{ - /* Falling back. type={{printf "%v" .Typ}} kind={{printf "%v" .Kind}} */ - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - err = json.Unmarshal(tbuf, &{{.Name}}) - if err != nil { - return fs.WrapErr(err) - } -} -` - -type handleString struct { - IC *Inception - Name string - Typ reflect.Type - TakeAddr bool - Quoted bool -} - -var handleStringTxt = ` -{ - {{$ic := .IC}} - - {{getAllowTokens .Typ.Name "FFTok_string" "FFTok_null"}} - if tok == fflib.FFTok_null { - {{if eq .TakeAddr true}} - {{.Name}} = nil - {{end}} - } else { - {{if eq .TakeAddr true}} - var tval {{getType $ic .Name .Typ}} - outBuf := fs.Output.Bytes() - {{unquoteField .Quoted}} - tval = {{getType $ic .Name .Typ}}(string(outBuf)) - {{.Name}} = &tval - {{else}} - outBuf := fs.Output.Bytes() - {{unquoteField .Quoted}} - {{.Name}} = {{getType $ic .Name .Typ}}(string(outBuf)) - {{end}} - } -} -` - -type handleObject struct { - IC *Inception - Name string - Typ reflect.Type - Ptr reflect.Kind - TakeAddr bool -} - -var handleObjectTxt = ` -{ - {{$ic := .IC}} - {{getAllowTokens .Typ.Name "FFTok_left_bracket" "FFTok_null"}} - if tok == fflib.FFTok_null { - {{.Name}} = nil - } else { - - {{if eq .TakeAddr true}} - {{if eq .Typ.Elem.Kind .Ptr }} - {{if eq .Typ.Key.Kind .Ptr }} - var tval = make(map[*{{getType $ic .Name .Typ.Key.Elem}}]*{{getType $ic .Name .Typ.Elem.Elem}}, 0) - {{else}} - var tval = make(map[{{getType $ic .Name .Typ.Key}}]*{{getType $ic .Name .Typ.Elem.Elem}}, 0) - {{end}} - {{else}} - {{if eq .Typ.Key.Kind .Ptr }} - var tval = make(map[*{{getType $ic .Name .Typ.Key.Elem}}]{{getType $ic .Name .Typ.Elem}}, 0) - {{else}} - var tval = make(map[{{getType $ic .Name .Typ.Key}}]{{getType $ic .Name .Typ.Elem}}, 0) - {{end}} - {{end}} - {{else}} - {{if eq .Typ.Elem.Kind .Ptr }} - {{if eq .Typ.Key.Kind .Ptr }} - {{.Name}} = make(map[*{{getType $ic .Name .Typ.Key.Elem}}]*{{getType $ic .Name .Typ.Elem.Elem}}, 0) - {{else}} - {{.Name}} = make(map[{{getType $ic .Name .Typ.Key}}]*{{getType $ic .Name .Typ.Elem.Elem}}, 0) - {{end}} - {{else}} - {{if eq .Typ.Key.Kind .Ptr }} - {{.Name}} = make(map[*{{getType $ic .Name .Typ.Key.Elem}}]{{getType $ic .Name .Typ.Elem}}, 0) - {{else}} - {{.Name}} = make(map[{{getType $ic .Name .Typ.Key}}]{{getType $ic .Name .Typ.Elem}}, 0) - {{end}} - {{end}} - {{end}} - - wantVal := true - - for { - {{$keyPtr := false}} - {{if eq .Typ.Key.Kind .Ptr }} - {{$keyPtr := true}} - var k *{{getType $ic .Name .Typ.Key.Elem}} - {{else}} - var k {{getType $ic .Name .Typ.Key}} - {{end}} - - {{$valPtr := false}} - {{$tmpVar := getTmpVarFor .Name}} - {{if eq .Typ.Elem.Kind .Ptr }} - {{$valPtr := true}} - var {{$tmpVar}} *{{getType $ic .Name .Typ.Elem.Elem}} - {{else}} - var {{$tmpVar}} {{getType $ic .Name .Typ.Elem}} - {{end}} - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_bracket { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - {{handleField .IC "k" .Typ.Key $keyPtr false}} - - // Expect ':' after key - tok = fs.Scan() - if tok != fflib.FFTok_colon { - return fs.WrapErr(fmt.Errorf("wanted colon token, but got token: %v", tok)) - } - - tok = fs.Scan() - {{handleField .IC $tmpVar .Typ.Elem $valPtr false}} - - {{if eq .TakeAddr true}} - tval[k] = {{$tmpVar}} - {{else}} - {{.Name}}[k] = {{$tmpVar}} - {{end}} - wantVal = false - } - - {{if eq .TakeAddr true}} - {{.Name}} = &tval - {{end}} - } -} -` - -type handleArray struct { - IC *Inception - Name string - Typ reflect.Type - Ptr reflect.Kind - UseReflectToSet bool - IsPtr bool -} - -var handleArrayTxt = ` -{ - {{$ic := .IC}} - {{getAllowTokens .Typ.Name "FFTok_left_brace" "FFTok_null"}} - {{if eq .Typ.Elem.Kind .Ptr}} - {{.Name}} = [{{.Typ.Len}}]*{{getType $ic .Name .Typ.Elem.Elem}}{} - {{else}} - {{.Name}} = [{{.Typ.Len}}]{{getType $ic .Name .Typ.Elem}}{} - {{end}} - if tok != fflib.FFTok_null { - wantVal := true - - idx := 0 - for { - {{$ptr := false}} - {{$tmpVar := getTmpVarFor .Name}} - {{if eq .Typ.Elem.Kind .Ptr }} - {{$ptr := true}} - var {{$tmpVar}} *{{getType $ic .Name .Typ.Elem.Elem}} - {{else}} - var {{$tmpVar}} {{getType $ic .Name .Typ.Elem}} - {{end}} - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - {{handleField .IC $tmpVar .Typ.Elem $ptr false}} - - // Standard json.Unmarshal ignores elements out of array bounds, - // that what we do as well. - if idx < {{.Typ.Len}} { - {{.Name}}[idx] = {{$tmpVar}} - idx++ - } - - wantVal = false - } - } -} -` - -var handleSliceTxt = ` -{ - {{$ic := .IC}} - {{getAllowTokens .Typ.Name "FFTok_left_brace" "FFTok_null"}} - if tok == fflib.FFTok_null { - {{.Name}} = nil - } else { - {{if eq .Typ.Elem.Kind .Ptr }} - {{if eq .IsPtr true}} - {{.Name}} = &[]*{{getType $ic .Name .Typ.Elem.Elem}}{} - {{else}} - {{.Name}} = []*{{getType $ic .Name .Typ.Elem.Elem}}{} - {{end}} - {{else}} - {{if eq .IsPtr true}} - {{.Name}} = &[]{{getType $ic .Name .Typ.Elem}}{} - {{else}} - {{.Name}} = []{{getType $ic .Name .Typ.Elem}}{} - {{end}} - {{end}} - - wantVal := true - - for { - {{$ptr := false}} - {{$tmpVar := getTmpVarFor .Name}} - {{if eq .Typ.Elem.Kind .Ptr }} - {{$ptr := true}} - var {{$tmpVar}} *{{getType $ic .Name .Typ.Elem.Elem}} - {{else}} - var {{$tmpVar}} {{getType $ic .Name .Typ.Elem}} - {{end}} - - tok = fs.Scan() - if tok == fflib.FFTok_error { - goto tokerror - } - if tok == fflib.FFTok_right_brace { - break - } - - if tok == fflib.FFTok_comma { - if wantVal == true { - // TODO(pquerna): this isn't an ideal error message, this handles - // things like [,,,] as an array value. - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) - } - continue - } else { - wantVal = true - } - - {{handleField .IC $tmpVar .Typ.Elem $ptr false}} - {{if eq .IsPtr true}} - *{{.Name}} = append(*{{.Name}}, {{$tmpVar}}) - {{else}} - {{.Name}} = append({{.Name}}, {{$tmpVar}}) - {{end}} - wantVal = false - } - } -} -` - -var handleByteSliceTxt = ` -{ - {{getAllowTokens .Typ.Name "FFTok_string" "FFTok_null"}} - if tok == fflib.FFTok_null { - {{.Name}} = nil - } else { - b := make([]byte, base64.StdEncoding.DecodedLen(fs.Output.Len())) - n, err := base64.StdEncoding.Decode(b, fs.Output.Bytes()) - if err != nil { - return fs.WrapErr(err) - } - {{if eq .UseReflectToSet true}} - v := reflect.ValueOf(&{{.Name}}).Elem() - v.SetBytes(b[0:n]) - {{else}} - {{.Name}} = append([]byte(), b[0:n]...) - {{end}} - } -} -` - -type handleBool struct { - Name string - Typ reflect.Type - TakeAddr bool -} - -var handleBoolTxt = ` -{ - if tok == fflib.FFTok_null { - {{if eq .TakeAddr true}} - {{.Name}} = nil - {{end}} - } else { - tmpb := fs.Output.Bytes() - - {{if eq .TakeAddr true}} - var tval bool - {{end}} - - if bytes.Compare([]byte{'t', 'r', 'u', 'e'}, tmpb) == 0 { - {{if eq .TakeAddr true}} - tval = true - {{else}} - {{.Name}} = true - {{end}} - } else if bytes.Compare([]byte{'f', 'a', 'l', 's', 'e'}, tmpb) == 0 { - {{if eq .TakeAddr true}} - tval = false - {{else}} - {{.Name}} = false - {{end}} - } else { - err = errors.New("unexpected bytes for true/false value") - return fs.WrapErr(err) - } - - {{if eq .TakeAddr true}} - {{.Name}} = &tval - {{end}} - } -} -` - -type handlePtr struct { - IC *Inception - Name string - Typ reflect.Type - Quoted bool -} - -var handlePtrTxt = ` -{ - {{$ic := .IC}} - - if tok == fflib.FFTok_null { - {{.Name}} = nil - } else { - if {{.Name}} == nil { - {{.Name}} = new({{getType $ic .Typ.Elem.Name .Typ.Elem}}) - } - - {{handleFieldAddr .IC .Name true .Typ.Elem false .Quoted}} - } -} -` - -type header struct { - IC *Inception - SI *StructInfo -} - -var headerTxt = ` -const ( - ffjt{{.SI.Name}}base = iota - ffjt{{.SI.Name}}nosuchkey - {{with $si := .SI}} - {{range $index, $field := $si.Fields}} - {{if ne $field.JsonName "-"}} - ffjt{{$si.Name}}{{$field.Name}} - {{end}} - {{end}} - {{end}} -) - -{{with $si := .SI}} - {{range $index, $field := $si.Fields}} - {{if ne $field.JsonName "-"}} -var ffjKey{{$si.Name}}{{$field.Name}} = []byte({{$field.JsonName}}) - {{end}} - {{end}} -{{end}} - -` - -type ujFunc struct { - IC *Inception - SI *StructInfo - ValidValues []string - ResetFields bool -} - -var ujFuncTxt = ` -{{$si := .SI}} -{{$ic := .IC}} - -// UnmarshalJSON umarshall json - template of ffjson -func (j *{{.SI.Name}}) UnmarshalJSON(input []byte) error { - fs := fflib.NewFFLexer(input) - return j.UnmarshalJSONFFLexer(fs, fflib.FFParse_map_start) -} - -// UnmarshalJSONFFLexer fast json unmarshall - template ffjson -func (j *{{.SI.Name}}) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error { - var err error - currentKey := ffjt{{.SI.Name}}base - _ = currentKey - tok := fflib.FFTok_init - wantedTok := fflib.FFTok_init - - {{if eq .ResetFields true}} - {{range $index, $field := $si.Fields}} - var ffjSet{{$si.Name}}{{$field.Name}} = false - {{end}} - {{end}} - -mainparse: - for { - tok = fs.Scan() - // println(fmt.Sprintf("debug: tok: %v state: %v", tok, state)) - if tok == fflib.FFTok_error { - goto tokerror - } - - switch state { - - case fflib.FFParse_map_start: - if tok != fflib.FFTok_left_bracket { - wantedTok = fflib.FFTok_left_bracket - goto wrongtokenerror - } - state = fflib.FFParse_want_key - continue - - case fflib.FFParse_after_value: - if tok == fflib.FFTok_comma { - state = fflib.FFParse_want_key - } else if tok == fflib.FFTok_right_bracket { - goto done - } else { - wantedTok = fflib.FFTok_comma - goto wrongtokenerror - } - - case fflib.FFParse_want_key: - // json {} ended. goto exit. woo. - if tok == fflib.FFTok_right_bracket { - goto done - } - if tok != fflib.FFTok_string { - wantedTok = fflib.FFTok_string - goto wrongtokenerror - } - - kn := fs.Output.Bytes() - if len(kn) <= 0 { - // "" case. hrm. - currentKey = ffjt{{.SI.Name}}nosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } else { - switch kn[0] { - {{range $byte, $fields := $si.FieldsByFirstByte}} - case '{{$byte}}': - {{range $index, $field := $fields}} - {{if ne $index 0 }}} else if {{else}}if {{end}} bytes.Equal(ffjKey{{$si.Name}}{{$field.Name}}, kn) { - currentKey = ffjt{{$si.Name}}{{$field.Name}} - state = fflib.FFParse_want_colon - goto mainparse - {{end}} } - {{end}} - } - {{range $index, $field := $si.ReverseFields}} - if {{$field.FoldFuncName}}(ffjKey{{$si.Name}}{{$field.Name}}, kn) { - currentKey = ffjt{{$si.Name}}{{$field.Name}} - state = fflib.FFParse_want_colon - goto mainparse - } - {{end}} - currentKey = ffjt{{.SI.Name}}nosuchkey - state = fflib.FFParse_want_colon - goto mainparse - } - - case fflib.FFParse_want_colon: - if tok != fflib.FFTok_colon { - wantedTok = fflib.FFTok_colon - goto wrongtokenerror - } - state = fflib.FFParse_want_value - continue - case fflib.FFParse_want_value: - - if {{range $index, $v := .ValidValues}}{{if ne $index 0 }}||{{end}}tok == fflib.{{$v}}{{end}} { - switch currentKey { - {{range $index, $field := $si.Fields}} - case ffjt{{$si.Name}}{{$field.Name}}: - goto handle_{{$field.Name}} - {{end}} - case ffjt{{$si.Name}}nosuchkey: - err = fs.SkipField(tok) - if err != nil { - return fs.WrapErr(err) - } - state = fflib.FFParse_after_value - goto mainparse - } - } else { - goto wantedvalue - } - } - } -{{range $index, $field := $si.Fields}} -handle_{{$field.Name}}: - {{with $fieldName := $field.Name | printf "j.%s"}} - {{handleField $ic $fieldName $field.Typ $field.Pointer $field.ForceString}} - {{if eq $.ResetFields true}} - ffjSet{{$si.Name}}{{$field.Name}} = true - {{end}} - state = fflib.FFParse_after_value - goto mainparse - {{end}} -{{end}} - -wantedvalue: - return fs.WrapErr(fmt.Errorf("wanted value token, but got token: %v", tok)) -wrongtokenerror: - return fs.WrapErr(fmt.Errorf("ffjson: wanted token: %v, but got token: %v output=%s", wantedTok, tok, fs.Output.String())) -tokerror: - if fs.BigError != nil { - return fs.WrapErr(fs.BigError) - } - err = fs.Error.ToError() - if err != nil { - return fs.WrapErr(err) - } - panic("ffjson-generated: unreachable, please report bug.") -done: -{{if eq .ResetFields true}} -{{range $index, $field := $si.Fields}} - if !ffjSet{{$si.Name}}{{$field.Name}} { - {{with $fieldName := $field.Name | printf "j.%s"}} - {{if eq $field.Pointer true}} - {{$fieldName}} = nil - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.Interface), 10) + `}} - {{$fieldName}} = nil - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.Slice), 10) + `}} - {{$fieldName}} = nil - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.Array), 10) + `}} - {{$fieldName}} = [{{$field.Typ.Len}}]{{getType $ic $fieldName $field.Typ.Elem}}{} - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.Map), 10) + `}} - {{$fieldName}} = nil - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.Bool), 10) + `}} - {{$fieldName}} = false - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.String), 10) + `}} - {{$fieldName}} = "" - {{else if eq $field.Typ.Kind ` + strconv.FormatUint(uint64(reflect.Struct), 10) + `}} - {{$fieldName}} = {{getType $ic $fieldName $field.Typ}}{} - {{else}} - {{$fieldName}} = {{getType $ic $fieldName $field.Typ}}(0) - {{end}} - {{end}} - } -{{end}} -{{end}} - return nil -} -` - -type handleUnmarshaler struct { - IC *Inception - Name string - Typ reflect.Type - Ptr reflect.Kind - TakeAddr bool - UnmarshalJSONFFLexer bool - Unmarshaler bool -} - -var handleUnmarshalerTxt = ` - {{$ic := .IC}} - - {{if eq .UnmarshalJSONFFLexer true}} - { - if tok == fflib.FFTok_null { - {{if eq .Typ.Kind .Ptr }} - {{.Name}} = nil - {{end}} - {{if eq .TakeAddr true }} - {{.Name}} = nil - {{end}} - } else { - {{if eq .Typ.Kind .Ptr }} - if {{.Name}} == nil { - {{.Name}} = new({{getType $ic .Typ.Elem.Name .Typ.Elem}}) - } - {{end}} - {{if eq .TakeAddr true }} - if {{.Name}} == nil { - {{.Name}} = new({{getType $ic .Typ.Name .Typ}}) - } - {{end}} - err = {{.Name}}.UnmarshalJSONFFLexer(fs, fflib.FFParse_want_key) - if err != nil { - return err - } - } - state = fflib.FFParse_after_value - } - {{else}} - {{if eq .Unmarshaler true}} - { - if tok == fflib.FFTok_null { - {{if eq .TakeAddr true }} - {{.Name}} = nil - {{end}} - } else { - - tbuf, err := fs.CaptureField(tok) - if err != nil { - return fs.WrapErr(err) - } - - {{if eq .TakeAddr true }} - if {{.Name}} == nil { - {{.Name}} = new({{getType $ic .Typ.Name .Typ}}) - } - {{end}} - err = {{.Name}}.UnmarshalJSON(tbuf) - if err != nil { - return fs.WrapErr(err) - } - } - state = fflib.FFParse_after_value - } - {{end}} - {{end}} -` diff --git a/vendor/github.com/pquerna/ffjson/inception/encoder.go b/vendor/github.com/pquerna/ffjson/inception/encoder.go deleted file mode 100644 index 3e37a2814..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/encoder.go +++ /dev/null @@ -1,544 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "fmt" - "reflect" - - "github.com/pquerna/ffjson/shared" -) - -func typeInInception(ic *Inception, typ reflect.Type, f shared.Feature) bool { - for _, v := range ic.objs { - if v.Typ == typ { - return v.Options.HasFeature(f) - } - if typ.Kind() == reflect.Ptr { - if v.Typ == typ.Elem() { - return v.Options.HasFeature(f) - } - } - } - - return false -} - -func getOmitEmpty(ic *Inception, sf *StructField) string { - ptname := "j." + sf.Name - if sf.Pointer { - ptname = "*" + ptname - return "if true {\n" - } - switch sf.Typ.Kind() { - - case reflect.Array, reflect.Map, reflect.Slice, reflect.String: - return "if len(" + ptname + ") != 0 {" + "\n" - - case reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64, - reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64, - reflect.Uintptr, - reflect.Float32, - reflect.Float64: - return "if " + ptname + " != 0 {" + "\n" - - case reflect.Bool: - return "if " + ptname + " != false {" + "\n" - - case reflect.Interface, reflect.Ptr: - return "if " + ptname + " != nil {" + "\n" - - default: - // TODO(pquerna): fix types - return "if true {" + "\n" - } -} - -func getMapValue(ic *Inception, name string, typ reflect.Type, ptr bool, forceString bool) string { - var out = "" - - if typ.Key().Kind() != reflect.String { - out += fmt.Sprintf("/* Falling back. type=%v kind=%v */\n", typ, typ.Kind()) - out += ic.q.Flush() - out += "err = buf.Encode(" + name + ")" + "\n" - out += "if err != nil {" + "\n" - out += " return err" + "\n" - out += "}" + "\n" - return out - } - - var elemKind reflect.Kind - elemKind = typ.Elem().Kind() - - switch elemKind { - case reflect.String, - reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr, - reflect.Float32, - reflect.Float64, - reflect.Bool: - - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - - out += "if " + name + " == nil {" + "\n" - ic.q.Write("null") - out += ic.q.GetQueued() - ic.q.DeleteLast() - out += "} else {" + "\n" - out += ic.q.WriteFlush("{ ") - out += " for key, value := range " + name + " {" + "\n" - out += " fflib.WriteJsonString(buf, key)" + "\n" - out += " buf.WriteString(`:`)" + "\n" - out += getGetInnerValue(ic, "value", typ.Elem(), false, forceString) - out += " buf.WriteByte(',')" + "\n" - out += " }" + "\n" - out += "buf.Rewind(1)" + "\n" - out += ic.q.WriteFlush("}") - out += "}" + "\n" - - default: - out += ic.q.Flush() - out += fmt.Sprintf("/* Falling back. type=%v kind=%v */\n", typ, typ.Kind()) - out += "err = buf.Encode(" + name + ")" + "\n" - out += "if err != nil {" + "\n" - out += " return err" + "\n" - out += "}" + "\n" - } - return out -} - -func getGetInnerValue(ic *Inception, name string, typ reflect.Type, ptr bool, forceString bool) string { - var out = "" - - // Flush if not bool or maps - if typ.Kind() != reflect.Bool && typ.Kind() != reflect.Map && typ.Kind() != reflect.Struct { - out += ic.q.Flush() - } - - if typ.Implements(marshalerFasterType) || - reflect.PtrTo(typ).Implements(marshalerFasterType) || - typeInInception(ic, typ, shared.MustEncoder) || - typ.Implements(marshalerType) || - reflect.PtrTo(typ).Implements(marshalerType) { - - out += ic.q.Flush() - out += tplStr(encodeTpl["handleMarshaler"], handleMarshaler{ - IC: ic, - Name: name, - Typ: typ, - Ptr: reflect.Ptr, - MarshalJSONBuf: typ.Implements(marshalerFasterType) || reflect.PtrTo(typ).Implements(marshalerFasterType) || typeInInception(ic, typ, shared.MustEncoder), - Marshaler: typ.Implements(marshalerType) || reflect.PtrTo(typ).Implements(marshalerType), - }) - return out - } - - ptname := name - if ptr { - ptname = "*" + name - } - - switch typ.Kind() { - case reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64: - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - out += "fflib.FormatBits2(buf, uint64(" + ptname + "), 10, " + ptname + " < 0)" + "\n" - case reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64, - reflect.Uintptr: - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - out += "fflib.FormatBits2(buf, uint64(" + ptname + "), 10, false)" + "\n" - case reflect.Float32: - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - out += "fflib.AppendFloat(buf, float64(" + ptname + "), 'g', -1, 32)" + "\n" - case reflect.Float64: - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - out += "fflib.AppendFloat(buf, float64(" + ptname + "), 'g', -1, 64)" + "\n" - case reflect.Array, - reflect.Slice: - - // Arrays cannot be nil - if typ.Kind() != reflect.Array { - out += "if " + name + "!= nil {" + "\n" - } - // Array and slice values encode as JSON arrays, except that - // []byte encodes as a base64-encoded string, and a nil slice - // encodes as the null JSON object. - if typ.Kind() == reflect.Slice && typ.Elem().Kind() == reflect.Uint8 { - ic.OutputImports[`"encoding/base64"`] = true - - out += "buf.WriteString(`\"`)" + "\n" - out += `{` + "\n" - out += `enc := base64.NewEncoder(base64.StdEncoding, buf)` + "\n" - if typ.Elem().Name() != "byte" { - ic.OutputImports[`"reflect"`] = true - out += `enc.Write(reflect.Indirect(reflect.ValueOf(` + ptname + `)).Bytes())` + "\n" - - } else { - out += `enc.Write(` + ptname + `)` + "\n" - } - out += `enc.Close()` + "\n" - out += `}` + "\n" - out += "buf.WriteString(`\"`)" + "\n" - } else { - out += "buf.WriteString(`[`)" + "\n" - out += "for i, v := range " + ptname + "{" + "\n" - out += "if i != 0 {" + "\n" - out += "buf.WriteString(`,`)" + "\n" - out += "}" + "\n" - out += getGetInnerValue(ic, "v", typ.Elem(), false, false) - out += "}" + "\n" - out += "buf.WriteString(`]`)" + "\n" - } - if typ.Kind() != reflect.Array { - out += "} else {" + "\n" - out += "buf.WriteString(`null`)" + "\n" - out += "}" + "\n" - } - case reflect.String: - // Is it a json.Number? - if typ.PkgPath() == "encoding/json" && typ.Name() == "Number" { - // Fall back to json package to rely on the valid number check. - // See: https://github.com/golang/go/blob/92cd6e3af9f423ab4d8ac78f24e7fd81c31a8ce6/src/encoding/json/encode.go#L550 - out += fmt.Sprintf("/* json.Number */\n") - out += "err = buf.Encode(" + name + ")" + "\n" - out += "if err != nil {" + "\n" - out += " return err" + "\n" - out += "}" + "\n" - } else { - ic.OutputImports[`fflib "github.com/pquerna/ffjson/fflib/v1"`] = true - if forceString { - // Forcestring on strings does double-escaping of the entire value. - // We create a temporary buffer, encode to that an re-encode it. - out += "{" + "\n" - out += "tmpbuf := fflib.Buffer{}" + "\n" - out += "tmpbuf.Grow(len(" + ptname + ") + 16)" + "\n" - out += "fflib.WriteJsonString(&tmpbuf, string(" + ptname + "))" + "\n" - out += "fflib.WriteJsonString(buf, string( tmpbuf.Bytes() " + `))` + "\n" - out += "}" + "\n" - } else { - out += "fflib.WriteJsonString(buf, string(" + ptname + "))" + "\n" - } - } - case reflect.Ptr: - out += "if " + name + "!= nil {" + "\n" - switch typ.Elem().Kind() { - case reflect.Struct: - out += getGetInnerValue(ic, name, typ.Elem(), false, false) - default: - out += getGetInnerValue(ic, "*"+name, typ.Elem(), false, false) - } - out += "} else {" + "\n" - out += "buf.WriteString(`null`)" + "\n" - out += "}" + "\n" - case reflect.Bool: - out += "if " + ptname + " {" + "\n" - ic.q.Write("true") - out += ic.q.GetQueued() - out += "} else {" + "\n" - // Delete 'true' - ic.q.DeleteLast() - out += ic.q.WriteFlush("false") - out += "}" + "\n" - case reflect.Interface: - out += fmt.Sprintf("/* Interface types must use runtime reflection. type=%v kind=%v */\n", typ, typ.Kind()) - out += "err = buf.Encode(" + name + ")" + "\n" - out += "if err != nil {" + "\n" - out += " return err" + "\n" - out += "}" + "\n" - case reflect.Map: - out += getMapValue(ic, ptname, typ, ptr, forceString) - case reflect.Struct: - if typ.Name() == "" { - ic.q.Write("{") - ic.q.Write(" ") - out += fmt.Sprintf("/* Inline struct. type=%v kind=%v */\n", typ, typ.Kind()) - newV := reflect.Indirect(reflect.New(typ)).Interface() - fields := extractFields(newV) - - // Output all fields - for _, field := range fields { - // Adjust field name - field.Name = name + "." + field.Name - out += getField(ic, field, "") - } - - if lastConditional(fields) { - out += ic.q.Flush() - out += `buf.Rewind(1)` + "\n" - } else { - ic.q.DeleteLast() - } - out += ic.q.WriteFlush("}") - } else { - out += fmt.Sprintf("/* Struct fall back. type=%v kind=%v */\n", typ, typ.Kind()) - out += ic.q.Flush() - if ptr { - out += "err = buf.Encode(" + name + ")" + "\n" - } else { - // We send pointer to avoid copying entire struct - out += "err = buf.Encode(&" + name + ")" + "\n" - } - out += "if err != nil {" + "\n" - out += " return err" + "\n" - out += "}" + "\n" - } - default: - out += fmt.Sprintf("/* Falling back. type=%v kind=%v */\n", typ, typ.Kind()) - out += "err = buf.Encode(" + name + ")" + "\n" - out += "if err != nil {" + "\n" - out += " return err" + "\n" - out += "}" + "\n" - } - - return out -} - -func getValue(ic *Inception, sf *StructField, prefix string) string { - closequote := false - if sf.ForceString { - switch sf.Typ.Kind() { - case reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Int64, - reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32, - reflect.Uint64, - reflect.Uintptr, - reflect.Float32, - reflect.Float64, - reflect.Bool: - ic.q.Write(`"`) - closequote = true - } - } - out := getGetInnerValue(ic, prefix+sf.Name, sf.Typ, sf.Pointer, sf.ForceString) - if closequote { - if sf.Pointer { - out += ic.q.WriteFlush(`"`) - } else { - ic.q.Write(`"`) - } - } - - return out -} - -func p2(v uint32) uint32 { - v-- - v |= v >> 1 - v |= v >> 2 - v |= v >> 4 - v |= v >> 8 - v |= v >> 16 - v++ - return v -} - -func getTypeSize(t reflect.Type) uint32 { - switch t.Kind() { - case reflect.String: - // TODO: consider runtime analysis. - return 32 - case reflect.Array, reflect.Map, reflect.Slice: - // TODO: consider runtime analysis. - return 4 * getTypeSize(t.Elem()) - case reflect.Int, - reflect.Int8, - reflect.Int16, - reflect.Int32, - reflect.Uint, - reflect.Uint8, - reflect.Uint16, - reflect.Uint32: - return 8 - case reflect.Int64, - reflect.Uint64, - reflect.Uintptr: - return 16 - case reflect.Float32, - reflect.Float64: - return 16 - case reflect.Bool: - return 4 - case reflect.Ptr: - return getTypeSize(t.Elem()) - default: - return 16 - } -} - -func getTotalSize(si *StructInfo) uint32 { - rv := uint32(si.Typ.Size()) - for _, f := range si.Fields { - rv += getTypeSize(f.Typ) - } - return rv -} - -func getBufGrowSize(si *StructInfo) uint32 { - - // TOOD(pquerna): automatically calc a better grow size based on history - // of a struct. - return p2(getTotalSize(si)) -} - -func isIntish(t reflect.Type) bool { - if t.Kind() >= reflect.Int && t.Kind() <= reflect.Uintptr { - return true - } - if t.Kind() == reflect.Array || t.Kind() == reflect.Slice || t.Kind() == reflect.Ptr { - if t.Kind() == reflect.Slice && t.Elem().Kind() == reflect.Uint8 { - // base64 special case. - return false - } else { - return isIntish(t.Elem()) - } - } - return false -} - -func getField(ic *Inception, f *StructField, prefix string) string { - out := "" - if f.OmitEmpty { - out += ic.q.Flush() - if f.Pointer { - out += "if " + prefix + f.Name + " != nil {" + "\n" - } - out += getOmitEmpty(ic, f) - } - - if f.Pointer && !f.OmitEmpty { - // Pointer values encode as the value pointed to. A nil pointer encodes as the null JSON object. - out += "if " + prefix + f.Name + " != nil {" + "\n" - } - - // JsonName is already escaped and quoted. - // getInnervalue should flush - ic.q.Write(f.JsonName + ":") - // We save a copy in case we need it - t := ic.q - - out += getValue(ic, f, prefix) - ic.q.Write(",") - - if f.Pointer && !f.OmitEmpty { - out += "} else {" + "\n" - out += t.WriteFlush("null") - out += "}" + "\n" - } - - if f.OmitEmpty { - out += ic.q.Flush() - if f.Pointer { - out += "}" + "\n" - } - out += "}" + "\n" - } - return out -} - -// We check if the last field is conditional. -func lastConditional(fields []*StructField) bool { - if len(fields) > 0 { - f := fields[len(fields)-1] - return f.OmitEmpty - } - return false -} - -func CreateMarshalJSON(ic *Inception, si *StructInfo) error { - conditionalWrites := lastConditional(si.Fields) - out := "" - - out += "// MarshalJSON marshal bytes to json - template\n" - out += `func (j *` + si.Name + `) MarshalJSON() ([]byte, error) {` + "\n" - out += `var buf fflib.Buffer` + "\n" - - out += `if j == nil {` + "\n" - out += ` buf.WriteString("null")` + "\n" - out += " return buf.Bytes(), nil" + "\n" - out += `}` + "\n" - - out += `err := j.MarshalJSONBuf(&buf)` + "\n" - out += `if err != nil {` + "\n" - out += " return nil, err" + "\n" - out += `}` + "\n" - out += `return buf.Bytes(), nil` + "\n" - out += `}` + "\n" - - out += "// MarshalJSONBuf marshal buff to json - template\n" - out += `func (j *` + si.Name + `) MarshalJSONBuf(buf fflib.EncodingBuffer) (error) {` + "\n" - out += ` if j == nil {` + "\n" - out += ` buf.WriteString("null")` + "\n" - out += " return nil" + "\n" - out += ` }` + "\n" - - out += `var err error` + "\n" - out += `var obj []byte` + "\n" - out += `_ = obj` + "\n" - out += `_ = err` + "\n" - - ic.q.Write("{") - - // The extra space is inserted here. - // If nothing is written to the field this will be deleted - // instead of the last comma. - if conditionalWrites || len(si.Fields) == 0 { - ic.q.Write(" ") - } - - for _, f := range si.Fields { - out += getField(ic, f, "j.") - } - - // Handling the last comma is tricky. - // If the last field has omitempty, conditionalWrites is set. - // If something has been written, we delete the last comma, - // by backing up the buffer, otherwise it will delete a space. - if conditionalWrites { - out += ic.q.Flush() - out += `buf.Rewind(1)` + "\n" - } else { - ic.q.DeleteLast() - } - - out += ic.q.WriteFlush("}") - out += `return nil` + "\n" - out += `}` + "\n" - ic.OutputFuncs = append(ic.OutputFuncs, out) - return nil -} diff --git a/vendor/github.com/pquerna/ffjson/inception/encoder_tpl.go b/vendor/github.com/pquerna/ffjson/inception/encoder_tpl.go deleted file mode 100644 index 22ab5292e..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/encoder_tpl.go +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "reflect" - "text/template" -) - -var encodeTpl map[string]*template.Template - -func init() { - encodeTpl = make(map[string]*template.Template) - - funcs := map[string]string{ - "handleMarshaler": handleMarshalerTxt, - } - tplFuncs := template.FuncMap{} - - for k, v := range funcs { - encodeTpl[k] = template.Must(template.New(k).Funcs(tplFuncs).Parse(v)) - } -} - -type handleMarshaler struct { - IC *Inception - Name string - Typ reflect.Type - Ptr reflect.Kind - MarshalJSONBuf bool - Marshaler bool -} - -var handleMarshalerTxt = ` - { - {{if eq .Typ.Kind .Ptr}} - if {{.Name}} == nil { - buf.WriteString("null") - } else { - {{end}} - - {{if eq .MarshalJSONBuf true}} - err = {{.Name}}.MarshalJSONBuf(buf) - if err != nil { - return err - } - {{else if eq .Marshaler true}} - obj, err = {{.Name}}.MarshalJSON() - if err != nil { - return err - } - buf.Write(obj) - {{end}} - {{if eq .Typ.Kind .Ptr}} - } - {{end}} - } -` diff --git a/vendor/github.com/pquerna/ffjson/inception/inception.go b/vendor/github.com/pquerna/ffjson/inception/inception.go deleted file mode 100644 index 10cb2712c..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/inception.go +++ /dev/null @@ -1,160 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "errors" - "fmt" - "github.com/pquerna/ffjson/shared" - "io/ioutil" - "os" - "reflect" - "sort" -) - -type Inception struct { - objs []*StructInfo - InputPath string - OutputPath string - PackageName string - PackagePath string - OutputImports map[string]bool - OutputFuncs []string - q ConditionalWrite - ResetFields bool -} - -func NewInception(inputPath string, packageName string, outputPath string, resetFields bool) *Inception { - return &Inception{ - objs: make([]*StructInfo, 0), - InputPath: inputPath, - OutputPath: outputPath, - PackageName: packageName, - OutputFuncs: make([]string, 0), - OutputImports: make(map[string]bool), - ResetFields: resetFields, - } -} - -func (i *Inception) AddMany(objs []shared.InceptionType) { - for _, obj := range objs { - i.Add(obj) - } -} - -func (i *Inception) Add(obj shared.InceptionType) { - i.objs = append(i.objs, NewStructInfo(obj)) - i.PackagePath = i.objs[0].Typ.PkgPath() -} - -func (i *Inception) wantUnmarshal(si *StructInfo) bool { - if si.Options.SkipDecoder { - return false - } - typ := si.Typ - umlx := typ.Implements(unmarshalFasterType) || reflect.PtrTo(typ).Implements(unmarshalFasterType) - umlstd := typ.Implements(unmarshalerType) || reflect.PtrTo(typ).Implements(unmarshalerType) - if umlstd && !umlx { - // structure has UnmarshalJSON, but not our faster version -- skip it. - return false - } - return true -} - -func (i *Inception) wantMarshal(si *StructInfo) bool { - if si.Options.SkipEncoder { - return false - } - typ := si.Typ - mlx := typ.Implements(marshalerFasterType) || reflect.PtrTo(typ).Implements(marshalerFasterType) - mlstd := typ.Implements(marshalerType) || reflect.PtrTo(typ).Implements(marshalerType) - if mlstd && !mlx { - // structure has MarshalJSON, but not our faster version -- skip it. - return false - } - return true -} - -type sortedStructs []*StructInfo - -func (p sortedStructs) Len() int { return len(p) } -func (p sortedStructs) Less(i, j int) bool { return p[i].Name < p[j].Name } -func (p sortedStructs) Swap(i, j int) { p[i], p[j] = p[j], p[i] } -func (p sortedStructs) Sort() { sort.Sort(p) } - -func (i *Inception) generateCode() error { - // We sort the structs by name, so output if predictable. - sorted := sortedStructs(i.objs) - sorted.Sort() - - for _, si := range sorted { - if i.wantMarshal(si) { - err := CreateMarshalJSON(i, si) - if err != nil { - return err - } - } - - if i.wantUnmarshal(si) { - err := CreateUnmarshalJSON(i, si) - if err != nil { - return err - } - } - } - return nil -} - -func (i *Inception) handleError(err error) { - fmt.Fprintf(os.Stderr, "Error: %s:\n\n", err) - os.Exit(1) -} - -func (i *Inception) Execute() { - if len(os.Args) != 1 { - i.handleError(errors.New(fmt.Sprintf("Internal ffjson error: inception executable takes no args: %v", os.Args))) - return - } - - err := i.generateCode() - if err != nil { - i.handleError(err) - return - } - - data, err := RenderTemplate(i) - if err != nil { - i.handleError(err) - return - } - - stat, err := os.Stat(i.InputPath) - - if err != nil { - i.handleError(err) - return - } - - err = ioutil.WriteFile(i.OutputPath, data, stat.Mode()) - - if err != nil { - i.handleError(err) - return - } - -} diff --git a/vendor/github.com/pquerna/ffjson/inception/reflect.go b/vendor/github.com/pquerna/ffjson/inception/reflect.go deleted file mode 100644 index 8fb0bd5cb..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/reflect.go +++ /dev/null @@ -1,290 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - fflib "github.com/pquerna/ffjson/fflib/v1" - "github.com/pquerna/ffjson/shared" - - "bytes" - "encoding/json" - "reflect" - "unicode/utf8" -) - -type StructField struct { - Name string - JsonName string - FoldFuncName string - Typ reflect.Type - OmitEmpty bool - ForceString bool - HasMarshalJSON bool - HasUnmarshalJSON bool - Pointer bool - Tagged bool -} - -type FieldByJsonName []*StructField - -func (a FieldByJsonName) Len() int { return len(a) } -func (a FieldByJsonName) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -func (a FieldByJsonName) Less(i, j int) bool { return a[i].JsonName < a[j].JsonName } - -type StructInfo struct { - Name string - Obj interface{} - Typ reflect.Type - Fields []*StructField - Options shared.StructOptions -} - -func NewStructInfo(obj shared.InceptionType) *StructInfo { - t := reflect.TypeOf(obj.Obj) - return &StructInfo{ - Obj: obj.Obj, - Name: t.Name(), - Typ: t, - Fields: extractFields(obj.Obj), - Options: obj.Options, - } -} - -func (si *StructInfo) FieldsByFirstByte() map[string][]*StructField { - rv := make(map[string][]*StructField) - for _, f := range si.Fields { - b := string(f.JsonName[1]) - rv[b] = append(rv[b], f) - } - return rv -} - -func (si *StructInfo) ReverseFields() []*StructField { - var i int - rv := make([]*StructField, 0) - for i = len(si.Fields) - 1; i >= 0; i-- { - rv = append(rv, si.Fields[i]) - } - return rv -} - -const ( - caseMask = ^byte(0x20) // Mask to ignore case in ASCII. -) - -func foldFunc(key []byte) string { - nonLetter := false - special := false // special letter - for _, b := range key { - if b >= utf8.RuneSelf { - return "bytes.EqualFold" - } - upper := b & caseMask - if upper < 'A' || upper > 'Z' { - nonLetter = true - } else if upper == 'K' || upper == 'S' { - // See above for why these letters are special. - special = true - } - } - if special { - return "fflib.EqualFoldRight" - } - if nonLetter { - return "fflib.AsciiEqualFold" - } - return "fflib.SimpleLetterEqualFold" -} - -type MarshalerFaster interface { - MarshalJSONBuf(buf fflib.EncodingBuffer) error -} - -type UnmarshalFaster interface { - UnmarshalJSONFFLexer(l *fflib.FFLexer, state fflib.FFParseState) error -} - -var marshalerType = reflect.TypeOf(new(json.Marshaler)).Elem() -var marshalerFasterType = reflect.TypeOf(new(MarshalerFaster)).Elem() -var unmarshalerType = reflect.TypeOf(new(json.Unmarshaler)).Elem() -var unmarshalFasterType = reflect.TypeOf(new(UnmarshalFaster)).Elem() - -// extractFields returns a list of fields that JSON should recognize for the given type. -// The algorithm is breadth-first search over the set of structs to include - the top struct -// and then any reachable anonymous structs. -func extractFields(obj interface{}) []*StructField { - t := reflect.TypeOf(obj) - // Anonymous fields to explore at the current level and the next. - current := []StructField{} - next := []StructField{{Typ: t}} - - // Count of queued names for current level and the next. - count := map[reflect.Type]int{} - nextCount := map[reflect.Type]int{} - - // Types already visited at an earlier level. - visited := map[reflect.Type]bool{} - - // Fields found. - var fields []*StructField - - for len(next) > 0 { - current, next = next, current[:0] - count, nextCount = nextCount, map[reflect.Type]int{} - - for _, f := range current { - if visited[f.Typ] { - continue - } - visited[f.Typ] = true - - // Scan f.typ for fields to include. - for i := 0; i < f.Typ.NumField(); i++ { - sf := f.Typ.Field(i) - if sf.PkgPath != "" { // unexported - continue - } - tag := sf.Tag.Get("json") - if tag == "-" { - continue - } - name, opts := parseTag(tag) - if !isValidTag(name) { - name = "" - } - - ft := sf.Type - ptr := false - if ft.Kind() == reflect.Ptr { - ptr = true - } - - if ft.Name() == "" && ft.Kind() == reflect.Ptr { - // Follow pointer. - ft = ft.Elem() - } - - // Record found field and index sequence. - if name != "" || !sf.Anonymous || ft.Kind() != reflect.Struct { - tagged := name != "" - if name == "" { - name = sf.Name - } - - var buf bytes.Buffer - fflib.WriteJsonString(&buf, name) - - field := &StructField{ - Name: sf.Name, - JsonName: string(buf.Bytes()), - FoldFuncName: foldFunc([]byte(name)), - Typ: ft, - HasMarshalJSON: ft.Implements(marshalerType), - HasUnmarshalJSON: ft.Implements(unmarshalerType), - OmitEmpty: opts.Contains("omitempty"), - ForceString: opts.Contains("string"), - Pointer: ptr, - Tagged: tagged, - } - - fields = append(fields, field) - - if count[f.Typ] > 1 { - // If there were multiple instances, add a second, - // so that the annihilation code will see a duplicate. - // It only cares about the distinction between 1 or 2, - // so don't bother generating any more copies. - fields = append(fields, fields[len(fields)-1]) - } - continue - } - - // Record new anonymous struct to explore in next round. - nextCount[ft]++ - if nextCount[ft] == 1 { - next = append(next, StructField{ - Name: ft.Name(), - Typ: ft, - }) - } - } - } - } - - // Delete all fields that are hidden by the Go rules for embedded fields, - // except that fields with JSON tags are promoted. - - // The fields are sorted in primary order of name, secondary order - // of field index length. Loop over names; for each name, delete - // hidden fields by choosing the one dominant field that survives. - out := fields[:0] - for advance, i := 0, 0; i < len(fields); i += advance { - // One iteration per name. - // Find the sequence of fields with the name of this first field. - fi := fields[i] - name := fi.JsonName - for advance = 1; i+advance < len(fields); advance++ { - fj := fields[i+advance] - if fj.JsonName != name { - break - } - } - if advance == 1 { // Only one field with this name - out = append(out, fi) - continue - } - dominant, ok := dominantField(fields[i : i+advance]) - if ok { - out = append(out, dominant) - } - } - - fields = out - - return fields -} - -// dominantField looks through the fields, all of which are known to -// have the same name, to find the single field that dominates the -// others using Go's embedding rules, modified by the presence of -// JSON tags. If there are multiple top-level fields, the boolean -// will be false: This condition is an error in Go and we skip all -// the fields. -func dominantField(fields []*StructField) (*StructField, bool) { - tagged := -1 // Index of first tagged field. - for i, f := range fields { - if f.Tagged { - if tagged >= 0 { - // Multiple tagged fields at the same level: conflict. - // Return no field. - return nil, false - } - tagged = i - } - } - if tagged >= 0 { - return fields[tagged], true - } - // All remaining fields have the same length. If there's more than one, - // we have a conflict (two fields named "X" at the same level) and we - // return no field. - if len(fields) > 1 { - return nil, false - } - return fields[0], true -} diff --git a/vendor/github.com/pquerna/ffjson/inception/tags.go b/vendor/github.com/pquerna/ffjson/inception/tags.go deleted file mode 100644 index ccce101b8..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/tags.go +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "strings" - "unicode" -) - -// from: http://golang.org/src/pkg/encoding/json/tags.go - -// tagOptions is the string following a comma in a struct field's "json" -// tag, or the empty string. It does not include the leading comma. -type tagOptions string - -// parseTag splits a struct field's json tag into its name and -// comma-separated options. -func parseTag(tag string) (string, tagOptions) { - if idx := strings.Index(tag, ","); idx != -1 { - return tag[:idx], tagOptions(tag[idx+1:]) - } - return tag, tagOptions("") -} - -// Contains reports whether a comma-separated list of options -// contains a particular substr flag. substr must be surrounded by a -// string boundary or commas. -func (o tagOptions) Contains(optionName string) bool { - if len(o) == 0 { - return false - } - s := string(o) - for s != "" { - var next string - i := strings.Index(s, ",") - if i >= 0 { - s, next = s[:i], s[i+1:] - } - if s == optionName { - return true - } - s = next - } - return false -} - -func isValidTag(s string) bool { - if s == "" { - return false - } - for _, c := range s { - switch { - case strings.ContainsRune("!#$%&()*+-./:<=>?@[]^_{|}~ ", c): - // Backslash and quote chars are reserved, but - // otherwise any punctuation chars are allowed - // in a tag name. - default: - if !unicode.IsLetter(c) && !unicode.IsDigit(c) { - return false - } - } - } - return true -} diff --git a/vendor/github.com/pquerna/ffjson/inception/template.go b/vendor/github.com/pquerna/ffjson/inception/template.go deleted file mode 100644 index 121a23dd8..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/template.go +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2014 Paul Querna - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package ffjsoninception - -import ( - "bytes" - "go/format" - "text/template" -) - -const ffjsonTemplate = ` -// Code generated by ffjson <https://github.com/pquerna/ffjson>. DO NOT EDIT. -// source: {{.InputPath}} - -package {{.PackageName}} - -import ( -{{range $k, $v := .OutputImports}}{{$k}} -{{end}} -) - -{{range .OutputFuncs}} -{{.}} -{{end}} - -` - -func RenderTemplate(ic *Inception) ([]byte, error) { - t := template.Must(template.New("ffjson.go").Parse(ffjsonTemplate)) - buf := new(bytes.Buffer) - err := t.Execute(buf, ic) - if err != nil { - return nil, err - } - return format.Source(buf.Bytes()) -} - -func tplStr(t *template.Template, data interface{}) string { - buf := bytes.Buffer{} - err := t.Execute(&buf, data) - if err != nil { - panic(err) - } - return buf.String() -} diff --git a/vendor/github.com/pquerna/ffjson/inception/writerstack.go b/vendor/github.com/pquerna/ffjson/inception/writerstack.go deleted file mode 100644 index 1521961c9..000000000 --- a/vendor/github.com/pquerna/ffjson/inception/writerstack.go +++ /dev/null @@ -1,65 +0,0 @@ -package ffjsoninception - -import "strings" - -// ConditionalWrite is a stack containing a number of pending writes -type ConditionalWrite struct { - Queued []string -} - -// Write will add a string to be written -func (w *ConditionalWrite) Write(s string) { - w.Queued = append(w.Queued, s) -} - -// DeleteLast will delete the last added write -func (w *ConditionalWrite) DeleteLast() { - if len(w.Queued) == 0 { - return - } - w.Queued = w.Queued[:len(w.Queued)-1] -} - -// Last will return the last added write -func (w *ConditionalWrite) Last() string { - if len(w.Queued) == 0 { - return "" - } - return w.Queued[len(w.Queued)-1] -} - -// Flush will return all queued writes, and return -// "" (empty string) in nothing has been queued -// "buf.WriteByte('" + byte + "')" + '\n' if one bute has been queued. -// "buf.WriteString(`" + string + "`)" + "\n" if more than one byte has been queued. -func (w *ConditionalWrite) Flush() string { - combined := strings.Join(w.Queued, "") - if len(combined) == 0 { - return "" - } - - w.Queued = nil - if len(combined) == 1 { - return "buf.WriteByte('" + combined + "')" + "\n" - } - return "buf.WriteString(`" + combined + "`)" + "\n" -} - -func (w *ConditionalWrite) FlushTo(out string) string { - out += w.Flush() - return out -} - -// WriteFlush will add a string and return the Flush result for the queue -func (w *ConditionalWrite) WriteFlush(s string) string { - w.Write(s) - return w.Flush() -} - -// GetQueued will return the current queued content without flushing. -func (w *ConditionalWrite) GetQueued() string { - t := w.Queued - s := w.Flush() - w.Queued = t - return s -} diff --git a/vendor/github.com/pquerna/ffjson/shared/options.go b/vendor/github.com/pquerna/ffjson/shared/options.go deleted file mode 100644 index d74edc135..000000000 --- a/vendor/github.com/pquerna/ffjson/shared/options.go +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright 2014 Paul Querna, Klaus Post - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -package shared - -type StructOptions struct { - SkipDecoder bool - SkipEncoder bool -} - -type InceptionType struct { - Obj interface{} - Options StructOptions -} -type Feature int - -const ( - Nothing Feature = 0 - MustDecoder = 1 << 1 - MustEncoder = 1 << 2 - MustEncDec = MustDecoder | MustEncoder -) - -func (i InceptionType) HasFeature(f Feature) bool { - return i.HasFeature(f) -} - -func (s StructOptions) HasFeature(f Feature) bool { - hasNeeded := true - if f&MustDecoder != 0 && s.SkipDecoder { - hasNeeded = false - } - if f&MustEncoder != 0 && s.SkipEncoder { - hasNeeded = false - } - return hasNeeded -} diff --git a/vendor/modules.txt b/vendor/modules.txt index c706ee16e..50e97b66c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -191,7 +191,7 @@ github.com/containers/psgo/internal/dev github.com/containers/psgo/internal/host github.com/containers/psgo/internal/proc github.com/containers/psgo/internal/process -# github.com/containers/storage v1.30.1 +# github.com/containers/storage v1.30.2 github.com/containers/storage github.com/containers/storage/drivers github.com/containers/storage/drivers/aufs @@ -529,11 +529,6 @@ github.com/ostreedev/ostree-go/pkg/otbuiltin github.com/pkg/errors # github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib/difflib -# github.com/pquerna/ffjson v0.0.0-20190813045741-dac163c6c0a9 -github.com/pquerna/ffjson/fflib/v1 -github.com/pquerna/ffjson/fflib/v1/internal -github.com/pquerna/ffjson/inception -github.com/pquerna/ffjson/shared # github.com/prometheus/client_golang v1.7.1 github.com/prometheus/client_golang/prometheus github.com/prometheus/client_golang/prometheus/internal |