summaryrefslogtreecommitdiff
path: root/docs-src/content/functions/semver.yml
blob: 1eb49e91dc6efba2d16a19c2bd72c25fd826ae09 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
ns: semver
preamble: |
  These functions allow user you to parse a [semantic version](http://semver.org/) string or test it with constraint.
  
  It's implemented with the https://github.com/Masterminds/semver library.
funcs:
  - name: semver.Semver
    description: |
      Returns a semantic version struct holding the `input` version string.
      
      The returned struct are defined at: [`semver.Version`](https://pkg.go.dev/github.com/Masterminds/semver/v3#Version).
    pipeline: true
    arguments:
      - name: input
        required: true
        description: The input to parse
    examples:
      - |
        $ gomplate -i '{{ semver.Semver "v1.1.1"}}'
        1.1.1
      - |
        $ gomplate -i '{{ (semver.Semver "v1.1.1").Major }}'
        1
      - |
        $ gomplate -i 'the pre release version is {{ ("v1.1.1" | semver.Semver).SetPrerelease "beta.1" }}'
        the pre release version is 1.1.1-beta.1
  - name: semver.CheckConstraint
    description: |
      Test whether the input version matches the constraint.

      Ref: https://github.com/Masterminds/semver#checking-version-constraints
    pipeline: true
    arguments:
      - name: constraint
        required: true
        description: The constraints expression to test.
      - name: input
        required: true
        description: The input semantic version string to test.
    examples:
      - |
        $ gomplate -i '{{ semver.CheckConstraint "> 1.0" "v1.1.1" }}'
        true
      - |
        $ gomplate -i '{{ semver.CheckConstraint "> 1.0, <1.1" "v1.1.1" }}'
        false        
      - |
        $ gomplate -i '{{ "v1.1.1" | semver.CheckConstraint "> 1.0" }}'
        true