automation-tests/cmd/podman
OpenShift Merge Robot f6f7172494
Merge pull request #6000 from mheon/volume_backend_flags
Add support for volumes-from, image volumes, init
2020-04-27 21:53:37 +02:00
..
common Merge pull request #6000 from mheon/volume_backend_flags 2020-04-27 21:53:37 +02:00
containers Merge pull request #5978 from rhatdan/ports 2020-04-27 21:27:49 +02:00
healthcheck Podman V2 birth 2020-04-16 15:53:58 -05:00
images enable load integration tests 2020-04-27 10:20:53 -05:00
manifest Add --os to manifest add 2020-04-24 14:57:56 -04:00
networks Podman V2 birth 2020-04-16 15:53:58 -05:00
parse Podman V2 birth 2020-04-16 15:53:58 -05:00
pods implement pod stats 2020-04-27 12:00:35 +02:00
registry Provide a json variable pointing to a configured json API 2020-04-21 07:56:10 -07:00
report Provide a json variable pointing to a configured json API 2020-04-21 07:56:10 -07:00
system Instrumentation to answer #5765 2020-04-22 11:07:28 -07:00
utils podmanV2: implement build 2020-04-17 10:26:50 +02:00
volumes Provide a json variable pointing to a configured json API 2020-04-21 07:56:10 -07:00
README.md Podman V2 birth 2020-04-16 15:53:58 -05:00
build.go podmanV2: implement build 2020-04-17 10:26:50 +02:00
diff.go V2 Fix --latest for podman diff commands 2020-04-20 09:27:54 -07:00
inspect.go Fix podman inspect to accept -l and -s fields 2020-04-20 15:52:46 -04:00
login.go v2: implement log{in,out} 2020-04-21 15:10:31 +02:00
logout.go v2: implement log{in,out} 2020-04-21 15:10:31 +02:00
main.go manifest create,add,inspect 2020-04-22 20:05:21 -04:00
root.go V2 restore libpod.Shutdown() when exiting podman commands 2020-04-22 14:25:40 -07:00

README.md

Adding a podman V2 commands

Build podman V2

$ cd $GOPATH/src/github.com/containers/libpod/cmd/podmanV2

If you wish to include the libpod library in your program,

$ go build -tags 'ABISupport' .

The --remote flag may be used to connect to the Podman service using the API. Otherwise, direct calls will be made to the Libpod library.

$ go build -tags '!ABISupport' .

The Libpod library is not linked into the executable. All calls are made via the API and --remote=False is an error condition.

Adding a new command podman manifests

$ mkdir -p $GOPATH/src/github.com/containers/libpod/cmd/podmanV2/manifests

Create the file $GOPATH/src/github.com/containers/libpod/cmd/podmanV2/manifests/manifest.go

package manifests

import (
    "github.com/containers/libpod/cmd/podman/registry"
    "github.com/containers/libpod/pkg/domain/entities"
    "github.com/spf13/cobra"
)

var (
    // podman _manifests_
    manifestCmd = &cobra.Command{
        Use:               "manifest",
        Short:             "Manage manifests",
        Long:              "Manage manifests",
        Example:           "podman manifests IMAGE",
        TraverseChildren:  true,
        PersistentPreRunE: preRunE,
        RunE:              registry.SubCommandExists, // Report error if there is no sub command given
    }
)
func init() {
    // Subscribe command to podman
    registry.Commands = append(registry.Commands, registry.CliCommand{
        // _podman manifest_ will support both ABIMode and TunnelMode
        Mode:    []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
        // The definition for this command
        Command: manifestCmd,
    })
    // Setup cobra templates, sub commands will inherit
    manifestCmd.SetHelpTemplate(registry.HelpTemplate())
    manifestCmd.SetUsageTemplate(registry.UsageTemplate())
}

// preRunE populates the image engine for sub commands
func preRunE(cmd *cobra.Command, args []string) error {
    _, err := registry.NewImageEngine(cmd, args)
    return err
}

To "wire" in the manifest command, edit the file $GOPATH/src/github.com/containers/libpod/cmd/podmanV2/main.go to add:

package main

import	_ "github.com/containers/libpod/cmd/podman/manifests"

Adding a new sub command podman manifests list

Create the file $GOPATH/src/github.com/containers/libpod/cmd/podmanV2/manifests/inspect.go

package manifests

import (
    "github.com/containers/libpod/cmd/podman/registry"
    "github.com/containers/libpod/pkg/domain/entities"
    "github.com/spf13/cobra"
)

var (
    // podman manifests _inspect_
    inspectCmd = &cobra.Command{
        Use:     "inspect IMAGE",
        Short:   "Display manifest from image",
        Long:    "Displays the low-level information on a manifest identified by image name or ID",
        RunE:    inspect,
        Example: "podman manifest DEADBEEF",
    }
)

func init() {
    // Subscribe inspect sub command to manifest command
    registry.Commands = append(registry.Commands, registry.CliCommand{
        // _podman manifest inspect_ will support both ABIMode and TunnelMode
        Mode:    []entities.EngineMode{entities.ABIMode, entities.TunnelMode},
        // The definition for this command
        Command: inspectCmd,
        Parent:  manifestCmd,
    })

    // This is where you would configure the cobra flags using inspectCmd.Flags()
}

// Business logic: cmd is inspectCmd, args is the positional arguments from os.Args
func inspect(cmd *cobra.Command, args []string) error {
    // Business logic using registry.ImageEngine
    // Do not pull from libpod directly use the domain objects and types
    return nil
}