Add containerdVersion flag

Add version flag that only prints the static version for the binary.

This commit does not include build details for containers since
Makefile does not build them.

Closes #8

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
This commit is contained in:
Christopher M. Luciano
2017-04-18 15:07:00 -04:00
parent d6978e3b7f
commit 683fd7f0e5
5 changed files with 98 additions and 2 deletions

View File

@@ -17,11 +17,14 @@ limitations under the License.
package main
import (
"os"
"github.com/golang/glog"
"github.com/spf13/pflag"
"github.com/kubernetes-incubator/cri-containerd/cmd/cri-containerd/options"
"github.com/kubernetes-incubator/cri-containerd/pkg/server"
"github.com/kubernetes-incubator/cri-containerd/pkg/version"
)
func main() {
@@ -29,6 +32,11 @@ func main() {
o.AddFlags(pflag.CommandLine)
options.InitFlags()
if o.CRIContainerdVersion {
version.PrintVersion()
os.Exit(0)
}
glog.V(2).Infof("Connect to containerd socket %q with timeout %v", o.ContainerdSocketPath, o.ContainerdConnectionTimeout)
conn, err := server.ConnectToContainerd(o.ContainerdSocketPath, o.ContainerdConnectionTimeout)
if err != nil {

View File

@@ -27,6 +27,8 @@ import (
type CRIContainerdOptions struct {
// CRIContainerdSocketPath is the path to the socket which cri-containerd serves on.
CRIContainerdSocketPath string
// CRIContainerdVersion is the git release version of cri-containerd
CRIContainerdVersion bool
// ContainerdSocketPath is the path to the containerd socket.
ContainerdSocketPath string
// ContainerdConnectionTimeout is the connection timeout for containerd client.
@@ -46,6 +48,8 @@ func (c *CRIContainerdOptions) AddFlags(fs *pflag.FlagSet) {
"/run/containerd/containerd.sock", "Path to the containerd socket.")
fs.DurationVar(&c.ContainerdConnectionTimeout, "containerd-connection-timeout",
2*time.Minute, "Connection timeout for containerd client.")
fs.BoolVar(&c.CRIContainerdVersion, "version",
false, "Print cri-containerd version information and quit.")
}
// InitFlags must be called after adding all cli options flags are defined and