version

package
Version: v0.0.0-...-774c3c8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 2, 2021 License: Apache-2.0 Imports: 4 Imported by: 10

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVersionFile

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.

Types

type Info

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

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

func GetStartupVersion() (Info, error)

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

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL