sourceconditiontarget

Description

The golang/module resource queries a Go module proxy for the published versions of a module.

source

Returns the version matching versionfilter.

condition

Checks that version is published for the module.

target

Not supported - a target fails with Target not supported for the plugin GO module. To write the version into a go.mod, use golang/gomod.

Parameters

NameTypeDescriptionRequired
ageobject

Age defines the minimum or maximum age of a release to be considered valid. It accepts a duration string (e.g., “24h”, “7d”).

Compatible:

  • source
  • condition
    maximumstringMaximum defines the maximum age of a release to be considered valid. It accepts a duration string (e.g., “24h”, “7d”, “3w”, “1y”). Accepted time units are “h” for hours, “d” for days, “w” for weeks, “mo” for months, and “y” for years. If no unit is provided, hours are assumed.
    minimumstringMinimum defines the minimum age of a release to be considered valid. It accepts a duration string (e.g., “24h”, “7d”, “3w”, “1y”). Accepted time units are “h” for hours, “d” for days, “w” for weeks, “mo” for months, and “y” for years. If no unit is provided, hours are assumed.
modulestring

module specifies the name of the Golang module

Compatible:

  • source
  • condition
proxystring

Proxy allows to override GO proxy similarly to GOPROXY environment variable. Proxy may have the schemes https, http. file is not supported at this time. If a URL has no scheme, https is assumed Compatible:

  • source
  • condition
versionstring

version defines a specific package version to check

Compatible:

  • condition
versionfilterobject

VersionFilter provides parameters to specify version pattern and its type like regex, semver, or just latest.

Compatible:

  • source
    kindstringspecifies the version kind such as semver, regex, or latest
    patternstringspecifies the version pattern according the version kind for semver, it is a semver constraint for regex, it is a regex pattern for time, it is a date format
    regexstringspecifies the regex pattern, used for regex/semver and regex/time. Output of the first capture group will be used.
    replaceallobjectreplaceAll applies a regex replacement to version strings before filtering. This is useful for transforming versions (e.g., curl-8_15_0 to curl-8.15.0) before regex extraction.
    strictbooleanstrict enforce strict versioning rule. Only used for semantic versioning at this time
module

Mandatory - the full module path, e.g. github.com/updatecli/updatecli.

proxy

Overrides the proxy, the same way GOPROXY does. https and http schemes are accepted, and a URL without a scheme is assumed to be https. file:// proxies are not supported.

version

Condition only.

Pseudo-versions (the v0.0.0-20230101120000-abcdef123456 form Go generates for untagged commits) are understood.

Filtering by release age

age restricts which releases count as valid, which is the usual way to let a release settle before adopting it:

spec:
  module: github.com/sirupsen/logrus
  age:
    minimum: "7d"

minimum and maximum accept h, d, w, mo and y; a bare number means hours. An unparsable value fails with invalid MinimumReleaseAge "<value>".

Warning

age is not free here either. The proxy returns the version list without dates, so Updatecli issues one additional request per version to fetch each release date. On a module with a long history that is a lot of round trips, and the whole list is walked before any filtering happens.

Versions whose date cannot be fetched or parsed are skipped silently - visible only with --debug, as ignoring version "x" from proxy "y" due to …​. A proxy that rate-limits you therefore shows up as versions quietly disappearing rather than as an error.

Example

# updatecli.yaml
name: "Golang module example"

sources:
  default:
    kind: golang/module
    name: Get the latest Golang module version for github.com/Masterminds/semver/v3
    spec:
      module: "github.com/Masterminds/semver/v3"
      
  semver:
    kind: golang/module
    name: Get Golang module version for github.com/Masterminds/semver/v3 matching version 3.2
    spec:
      module: "github.com/Masterminds/semver/v3"
      versionfilter:
        kind: semver
        pattern: "3.2"

conditions:
  default:
    # The version is set by the sourceid "default"
    kind: golang/module
    name: Checks if version v3.2.0 exists for Golang module github.com/Masterminds/semver/v3
    sourceid: default
    spec:
      module: "github.com/Masterminds/semver/v3"

  noSourceInput:
    disablesourceinput: true
    kind: golang/module
    name: Checks if version v3.2.0 exists for Golang module github.com/Masterminds/semver/v3
    spec:
      module: "github.com/Masterminds/semver/v3"
      version: "v3.2.0"