diff options
Diffstat (limited to 'libpod/define')
-rw-r--r-- | libpod/define/config.go | 10 | ||||
-rw-r--r-- | libpod/define/healthchecks.go | 36 | ||||
-rw-r--r-- | libpod/define/version.go | 27 |
3 files changed, 61 insertions, 12 deletions
diff --git a/libpod/define/config.go b/libpod/define/config.go index 692eafb04..5ca4da4af 100644 --- a/libpod/define/config.go +++ b/libpod/define/config.go @@ -3,6 +3,9 @@ package define import ( "bufio" "io" + "regexp" + + "github.com/pkg/errors" ) var ( @@ -10,6 +13,13 @@ var ( DefaultSHMLockPath = "/libpod_lock" // DefaultRootlessSHMLockPath is the default path for rootless SHM locks DefaultRootlessSHMLockPath = "/libpod_rootless_lock" + + // NameRegex is a regular expression to validate container/pod names. + // This must NOT be changed from outside of Libpod. It should be a + // constant, but Go won't let us do that. + NameRegex = regexp.MustCompile("^[a-zA-Z0-9][a-zA-Z0-9_.-]*$") + // RegexError is thrown in presence of an invalid container/pod name. + RegexError = errors.Wrapf(ErrInvalidArg, "names must match [a-zA-Z0-9][a-zA-Z0-9_.-]*") ) const ( diff --git a/libpod/define/healthchecks.go b/libpod/define/healthchecks.go new file mode 100644 index 000000000..4114262b6 --- /dev/null +++ b/libpod/define/healthchecks.go @@ -0,0 +1,36 @@ +package define + +const ( + // HealthCheckHealthy describes a healthy container + HealthCheckHealthy string = "healthy" + // HealthCheckUnhealthy describes an unhealthy container + HealthCheckUnhealthy string = "unhealthy" + // HealthCheckStarting describes the time between when the container starts + // and the start-period (time allowed for the container to start and application + // to be running) expires. + HealthCheckStarting string = "starting" +) + +// HealthCheckStatus represents the current state of a container +type HealthCheckStatus int + +const ( + // HealthCheckSuccess means the health worked + HealthCheckSuccess HealthCheckStatus = iota + // HealthCheckFailure means the health ran and failed + HealthCheckFailure HealthCheckStatus = iota + // HealthCheckContainerStopped means the health check cannot + // be run because the container is stopped + HealthCheckContainerStopped HealthCheckStatus = iota + // HealthCheckContainerNotFound means the container could + // not be found in local store + HealthCheckContainerNotFound HealthCheckStatus = iota + // HealthCheckNotDefined means the container has no health + // check defined in it + HealthCheckNotDefined HealthCheckStatus = iota + // HealthCheckInternalError means some something failed obtaining or running + // a given health check + HealthCheckInternalError HealthCheckStatus = iota + // HealthCheckDefined means the healthcheck was found on the container + HealthCheckDefined HealthCheckStatus = iota +) diff --git a/libpod/define/version.go b/libpod/define/version.go index 954cd00f1..3eb016264 100644 --- a/libpod/define/version.go +++ b/libpod/define/version.go @@ -3,6 +3,7 @@ package define import ( "runtime" "strconv" + "time" podmanVersion "github.com/containers/libpod/version" ) @@ -19,12 +20,13 @@ var ( // Version is an output struct for varlink type Version struct { - RemoteAPIVersion int64 - Version string - GoVersion string - GitCommit string - Built int64 - OsArch string + APIVersion int64 + Version string + GoVersion string + GitCommit string + BuiltTime string + Built int64 + OsArch string } // GetVersion returns a VersionOutput struct for varlink and podman @@ -40,11 +42,12 @@ func GetVersion() (Version, error) { } } return Version{ - RemoteAPIVersion: podmanVersion.RemoteAPIVersion, - Version: podmanVersion.Version, - GoVersion: runtime.Version(), - GitCommit: gitCommit, - Built: buildTime, - OsArch: runtime.GOOS + "/" + runtime.GOARCH, + APIVersion: podmanVersion.APIVersion, + Version: podmanVersion.Version, + GoVersion: runtime.Version(), + GitCommit: gitCommit, + BuiltTime: time.Unix(buildTime, 0).Format(time.ANSIC), + Built: buildTime, + OsArch: runtime.GOOS + "/" + runtime.GOARCH, }, nil } |