luci: go.chromium.org/luci/cipd/version Index | Files

package version

import "go.chromium.org/luci/cipd/version"

Package version provides a way for CIPD packaged Go binaries to discover their current package instance ID.

It's safe to link this library into arbitrary executables. It is small and doesn't pull in rest of CIPD client code.

Index

Package Files

cli.go version.go

Variables

var SubcommandVersion = &subcommands.Command{
    UsageLine:  "version",
    ShortDesc:  "prints version of CIPD package this exe was installed from",
    LongDesc:   "Prints version of CIPD package this exe was installed from.",
    CommandRun: func() subcommands.CommandRun { return &versionRun{} },
}

SubcommandVersion implement subcommand that prints version of CIPD package that contains the executable.

func GetVersionFile Uses

func GetVersionFile(exePath string) string

GetVersionFile returns the path to the version file corresponding to the provided exe. This isn't typically needed, but can be useful for debugging.

type Info Uses

type Info struct {
    PackageName string `json:"package_name"`
    InstanceID  string `json:"instance_id"`
}

Info describes JSON file with package version information that's deployed to a path specified in 'version_file' attribute of the manifest.

func GetCurrentVersion Uses

func GetCurrentVersion() (Info, error)

GetCurrentVersion reads version file from disk.

Note that it may have been updated since the process started. This function always reads the latest values. Version file is expected to be found at <exe-path>.cipd_version.

Add following lines to package definition yaml to to set this up:

data:
  - version_file: .versions/<exe-name>${exe_suffix}.cipd_version

Replace <exe-name> with name of the binary file.

If the version file is missing, returns empty Info{} and no error.

func GetStartupVersion Uses

func GetStartupVersion() (Info, error)

GetStartupVersion returns value of version file as it was when the process has just started.

Package version imports 6 packages (graph) and is imported by 9 packages. Updated 2018-08-21. Refresh now. Tools for package owners.