Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
/test/checkseccomp/checkseccomp
/test/copyimg/copyimg
/build/
cmd/podman/ioprojectatomicpodman/ioprojectatomicpodman.go
2 changes: 2 additions & 0 deletions Dockerfile.Fedora
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ RUN mkdir -p /etc/containers
COPY test/policy.json /etc/containers/policy.json
COPY test/redhat_sigstore.yaml /etc/containers/registries.d/registry.access.redhat.com.yaml

# Install varlink stuff
RUN pip3 install varlink
WORKDIR /go/src/github.com/projectatomic/libpod
26 changes: 21 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ MANDIR ?= ${PREFIX}/share/man
SHAREDIR_CONTAINERS ?= ${PREFIX}/share/containers
ETCDIR ?= ${DESTDIR}/etc
ETCDIR_LIBPOD ?= ${ETCDIR}/crio
SYSTEMDDIR ?= ${PREFIX}/lib/systemd/system
BUILDTAGS ?= seccomp $(shell hack/btrfs_tag.sh) $(shell hack/libdm_tag.sh) $(shell hack/btrfs_installed_tag.sh) $(shell hack/ostree_tag.sh) $(shell hack/selinux_tag.sh)
PYTHON ?= /usr/bin/python3

BASHINSTALLDIR=${PREFIX}/share/bash-completion/completions
OCIUMOUNTINSTALLDIR=$(PREFIX)/share/oci-umount/oci-umount.d
Expand Down Expand Up @@ -65,7 +67,7 @@ ifeq ("$(wildcard $(GOPKGDIR))","")
endif
touch "$(GOPATH)/.gopathok"

lint: .gopathok
lint: .gopathok varlink_generate
@echo "checking lint"
@./.tool/lint

Expand Down Expand Up @@ -101,6 +103,7 @@ endif
rm -f test/copyimg/copyimg
rm -f test/checkseccomp/checkseccomp
rm -fr build/
rm -f cmd/podman/ioprojectatomicpodman/ioprojectatomicpodman.go

libpodimage:
docker build -t ${LIBPOD_IMAGE} .
Expand All @@ -126,19 +129,20 @@ shell: libpodimage
testunit: libpodimage
docker run -e STORAGE_OPTIONS="--storage-driver=vfs" -e TESTFLAGS -e TRAVIS -t --privileged --rm -v ${CURDIR}:/go/src/${PROJECT} ${LIBPOD_IMAGE} make localunit

localunit:
localunit: varlink_generate
$(GO) test -tags "$(BUILDTAGS)" -cover $(PACKAGES)

ginkgo:
ginkgo -v test/e2e/

localintegration: test-binaries
localintegration: varlink_generate test-binaries
ginkgo -v -cover -flakeAttempts 3 -progress -trace -noColor test/e2e/.
sh test/varlink/run_varlink_tests.sh

vagrant-check:
BOX=$(BOX) sh ./vagrant.sh

binaries: podman
binaries: varlink_generate podman

test-binaries: test/bin2img/bin2img test/copyimg/copyimg test/checkseccomp/checkseccomp

Expand All @@ -163,7 +167,7 @@ changelog:
$(shell cat $(TMPFILE) >> changelog.txt)
$(shell rm $(TMPFILE))

install: .gopathok install.bin install.man install.cni
install: .gopathok install.bin install.man install.cni install.systemd

install.bin:
install ${SELINUXOPT} -D -m 755 bin/podman $(BINDIR)/podman
Expand All @@ -189,6 +193,10 @@ install.docker: docker-docs
install ${SELINUXOPT} -d -m 755 $(MANDIR)/man1
install ${SELINUXOPT} -m 644 docs/docker*.1 -t $(MANDIR)/man1

install.systemd:
install ${SELINUXOPT} -m 644 contrib/varlink/io.projectatomic.podman.socket ${SYSTEMDDIR}/io.projectatomic.podman.socket
install ${SELINUXOPT} -m 644 contrib/varlink/io.projectatomic.podman.service ${SYSTEMDDIR}/io.projectatomic.podman.service

uninstall:
for i in $(filter %.1,$(MANPAGES)); do \
rm -f $(MANDIR)/man1/$$(basename $${i}); \
Expand Down Expand Up @@ -229,6 +237,14 @@ install.tools: .install.gitvalidation .install.gometalinter .install.md2man
make all install; \
fi

.install.varlink: .gopathok
$(GO) get -u github.com/varlink/go/varlink
$(GO) get -u github.com/varlink/go/cmd/varlink-go-interface-generator

varlink_generate: .gopathok .install.varlink
rm -f cmd/podman/ioprojectatomicpodman/ioprojectatomicpodman.go
$(GO) generate ./cmd/podman/ioprojectatomicpodman/...

validate: gofmt .gitvalidation

.PHONY: \
Expand Down
2 changes: 1 addition & 1 deletion cmd/podman/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ func debugInfo(c *cli.Context) map[string]interface{} {
info["compiler"] = runtime.Compiler
info["go version"] = runtime.Version()
info["podman version"] = c.App.Version
info["git commit"] = gitCommit
info["git commit"] = libpod.GitCommit
return info
}
3 changes: 3 additions & 0 deletions cmd/podman/ioprojectatomicpodman/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package ioprojectatomicpodman

//go:generate $GOPATH/bin/varlink-go-interface-generator io.projectatomic.podman.varlink
65 changes: 65 additions & 0 deletions cmd/podman/ioprojectatomicpodman/io.projectatomic.podman.varlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Podman Service Interface
interface io.projectatomic.podman

type Version (
version: string,
go_version: string,
git_commit: string,
built: int,
os_arch: string
)

type NotImplemented (
comment: string
)

type StringResponse (
message: string
)

# System
method Ping() -> (ping: StringResponse)
method GetVersion() -> (version: Version)

# Containers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing CommitContainer()

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is under the image side of things ...

method ListContainers() -> (notimplemented: NotImplemented)
method CreateContainer() -> (notimplemented: NotImplemented)
method InspectContainer() -> (notimplemented: NotImplemented)
method ListContainerProcesses() -> (notimplemented: NotImplemented)
method GetContainerLogs() -> (notimplemented: NotImplemented)
method ListContainerChanges() -> (notimplemented: NotImplemented)
method ExportContainer() -> (notimplemented: NotImplemented)
method GetContainerStats() -> (notimplemented: NotImplemented)
method ResizeContainerTty() -> (notimplemented: NotImplemented)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be baked into attach. We don't do separate TTY resize.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our IRC conversation, it will stay not implemented and culled later.

method StartContainer() -> (notimplemented: NotImplemented)
method StopContainer() -> (notimplemented: NotImplemented)
method RestartContainer() -> (notimplemented: NotImplemented)
method KillContainer() -> (notimplemented: NotImplemented)
method UpdateContainer() -> (notimplemented: NotImplemented)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't want this. We never implemented podman update so no reason to have a Varlink target for a nonexistant API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our IRC conversation, it will stay not implemented and culled later.

method RenameContainer() -> (notimplemented: NotImplemented)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - no podman command, so no need for an API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per our IRC conversation, it will stay not implemented and culled later.

method PauseContainer() -> (notimplemented: NotImplemented)
method UnpauseContainer() -> (notimplemented: NotImplemented)
method AttachToContainer() -> (notimplemented: NotImplemented)
method WaitContainer() -> (notimplemented: NotImplemented)
method RemoveContainer() -> (notimplemented: NotImplemented)
method DeleteStoppedContainers() -> (notimplemented: NotImplemented)

# Images
method ListImages() -> (notimplemented: NotImplemented)
method BuildImage() -> (notimplemented: NotImplemented)
method CreateImage() -> (notimplemented: NotImplemented)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this pull? If not, what does pull images, I don't see a pull target?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find @mheon . It does do a pull and that API has no outright Pull target. I can understand why, given most everything will pull if it isnt local. That said, I would have zero objection to adding a Pull target. WDYT?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's probably a good idea. If nothing else, it's a lot more clear what it will do vs CreateImage, which sounds like it could potentially be related to build? API docs will help this, but familiar names are always good

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

method InspectImage() -> (notimplemented: NotImplemented)
method HistoryImage() -> (notimplemented: NotImplemented)
method PushImage() -> (notimplemented: NotImplemented)
method TagImage() -> (notimplemented: NotImplemented)
method RemoveImage() -> (notimplemented: NotImplemented)
method SearchImage() -> (notimplemented: NotImplemented)
method DeleteUnusedImages() -> (notimplemented: NotImplemented)
method CreateFromContainer() -> (notimplemented: NotImplemented)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move this over to the Container commands and call it Commit

method ImportImage() -> (notimplemented: NotImplemented)
method ExportImage() -> (notimplemented: NotImplemented)
method PullImage() -> (notimplemented: NotImplemented)


# Something failed
error ActionFailed (reason: string)
1 change: 1 addition & 0 deletions cmd/podman/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ func main() {
topCommand,
umountCommand,
unpauseCommand,
varlinkCommand,
versionCommand,
waitCommand,
}
Expand Down
60 changes: 60 additions & 0 deletions cmd/podman/varlink.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package main

import (
"github.com/pkg/errors"
"github.com/projectatomic/libpod/cmd/podman/ioprojectatomicpodman"
"github.com/projectatomic/libpod/pkg/varlinkapi"
"github.com/projectatomic/libpod/version"
"github.com/urfave/cli"
"github.com/varlink/go/varlink"
)

var (
varlinkDescription = `
podman varlink

run varlink interface
`
varlinkFlags = []cli.Flag{}
varlinkCommand = cli.Command{
Name: "varlink",
Usage: "Run varlink interface",
Description: varlinkDescription,
Flags: varlinkFlags,
Action: varlinkCmd,
ArgsUsage: "VARLINK_URI",
}
)

func varlinkCmd(c *cli.Context) error {
args := c.Args()
if len(args) < 1 {
return errors.Errorf("you must provide a varlink URI")
}

var varlinkInterfaces = []*ioprojectatomicpodman.VarlinkInterface{varlinkapi.VarlinkLibpod}
// Register varlink service. The metadata can be retrieved with:
// $ varlink info [varlink address URI]
service, err := varlink.NewService(
"Atomic",
"podman",
version.Version,
"https://github.com/projectatomic/libpod",
)
if err != nil {
return errors.Wrapf(err, "unable to create new varlink service")
}

for _, i := range varlinkInterfaces {
if err := service.RegisterInterface(i); err != nil {
return errors.Errorf("unable to register varlink interface %v", i)
}
}

// Run the varlink server at the given address
if err = service.Listen(args[0], 0); err != nil {
return errors.Errorf("unable to start varlink service")
}

return nil
}
39 changes: 14 additions & 25 deletions cmd/podman/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,30 @@ package main

import (
"fmt"
"runtime"
"strconv"
"time"

"github.com/pkg/errors"
"github.com/projectatomic/libpod/libpod"
"github.com/urfave/cli"
)

// Overwritten at build time
var (
// gitCommit is the commit that the binary is being built from.
// It will be populated by the Makefile.
gitCommit string
// buildInfo is the time at which the binary was built
// It will be populated by the Makefile.
buildInfo string
)

// versionCmd gets and prints version info for version command
func versionCmd(c *cli.Context) error {
fmt.Println("Version: ", c.App.Version)
fmt.Println("Go Version: ", runtime.Version())
if gitCommit != "" {
fmt.Println("Git Commit: ", gitCommit)
output, err := libpod.GetVersion()
if err != nil {
errors.Wrapf(err, "unable to determine version")
}
fmt.Println("Version: ", output.Version)
fmt.Println("Go Version: ", output.GoVersion)
if output.GitCommit != "" {
fmt.Println("Git Commit: ", output.GitCommit)
}
if buildInfo != "" {
// Converts unix time from string to int64
buildTime, err := strconv.ParseInt(buildInfo, 10, 64)
if err != nil {
return err
}
// Prints out the build time in readable format
fmt.Println("Built: ", time.Unix(buildTime, 0).Format(time.ANSIC))
// Prints out the build time in readable format
if libpod.BuildInfo != "" {
fmt.Println("Built: ", time.Unix(output.Built, 0).Format(time.ANSIC))
}
fmt.Println("OS/Arch: ", runtime.GOOS+"/"+runtime.GOARCH)

fmt.Println("OS/Arch: ", output.OsArch)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@
| [podman-top(1)](/docs/podman-top.1.md) | Display the running processes of a container |[![...](/docs/play.png)](https://asciinema.org/a/5WCCi1LXwSuRbvaO9cBUYf3fk)|
| [podman-umount(1)](/docs/podman-umount.1.md) | Unmount a working container's root filesystem |[![...](/docs/play.png)](https://asciinema.org/a/MZPTWD5CVs3dMREkBxQBY9C5z)|
| [podman-unpause(1)](/docs/podman-unpause.1.md) | Unpause one or more running containers |[![...](/docs/play.png)](https://asciinema.org/a/141292)|
| [podman-varlink(1)](/docs/podman-varlink.1.md) | Run the varlink backend ||
| [podman-version(1)](/docs/podman-version.1.md) | Display the version information |[![...](/docs/play.png)](https://asciinema.org/a/mfrn61pjZT9Fc8L4NbfdSqfgu)|
| [podman-wait(1)](/docs/podman-wait.1.md) | Wait on one or more containers to stop and print their exit codes |[![...](/docs/play.png)](https://asciinema.org/a/QNPGKdjWuPgI96GcfkycQtah0)|
9 changes: 9 additions & 0 deletions completions/bash/podman
Original file line number Diff line number Diff line change
Expand Up @@ -1514,6 +1514,14 @@ _podman_unpause() {
_complete_ "$options_with_args" "$boolean_options"
}

_podman_varlink() {
local options_with_args="
--help -h
"
local boolean_options=""
_complete_ "$options_with_args" "$boolean_options"
}

_podman_wait() {
local options_with_args=""
local boolean_options="
Expand Down Expand Up @@ -1633,6 +1641,7 @@ _podman_podman() {
umount
unmount
unpause
varlink
version
wait
"
Expand Down
12 changes: 12 additions & 0 deletions contrib/varlink/io.projectatomic.podman.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Pod Manager
Requires=io.projectatomic.podman.socket
After=io.projectatomic.podman.socket

[Service]
Type=simple
ExecStart=/usr/bin/podman --varlink=unix:/run/io.projectatomic.podman

[Install]
WantedBy=multi-user.target
Also=io.projectatomic.podman.socket
8 changes: 8 additions & 0 deletions contrib/varlink/io.projectatomic.podman.socket
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Unit]
Description=Pod Manager Socket

[Socket]
ListenStream=/run/io.projectatomic.podman

[Install]
WantedBy=sockets.target
38 changes: 38 additions & 0 deletions docs/podman-varlink.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
% podman(1) podman-varlink - Waits on a container
% Brent Baude
# podman-varlink "1" "April 2018" "podman"

## NAME
podman varlink - Runs the varlink backend interface

## SYNOPSIS
**podman varlink**
[**--help**|**-h**]
VARLINK_URI

## DESCRIPTION
Starts the varlink service that allows varlink clients to interact with podman.
<!--
More will go here as the docs and api firm up.
-->

**podman [GLOBAL OPTIONS] varlink **

## GLOBAL OPTIONS

**--help, -h**
Print usage statement

## EXAMPLES

podman varlink unix:/run/io.projectatomic.podman
<!--
TODO: More examples with TCP can be added when that works
as well.
-->

## SEE ALSO
podman(1)

## HISTORY
April 2018, Originally compiled by Brent Baude<bbaude@redhat.com>
Loading