From 55e2cd8e811cb21311b2b81080c0c206442a841f Mon Sep 17 00:00:00 2001 From: Felix Furrer Date: Fri, 20 Jan 2023 14:15:05 +0100 Subject: [PATCH] Extend format command with slim-sprig --- .../go/github.com/go-task/slim-sprig.dep.yml | 30 +++++++++++++++++++ CHANGELOG.md | 11 +++++++ cmd/semver/format.go | 3 +- go.mod | 2 +- 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .licenses/go/github.com/go-task/slim-sprig.dep.yml diff --git a/.licenses/go/github.com/go-task/slim-sprig.dep.yml b/.licenses/go/github.com/go-task/slim-sprig.dep.yml new file mode 100644 index 0000000..ea2c23d --- /dev/null +++ b/.licenses/go/github.com/go-task/slim-sprig.dep.yml @@ -0,0 +1,30 @@ +--- +name: github.com/go-task/slim-sprig +version: v0.0.0-20230315185526-52ccab3ef572 +type: go +summary: Package sprig provides template functions for Go. +homepage: https://pkg.go.dev/github.com/go-task/slim-sprig +license: mit +licenses: +- sources: LICENSE.txt + text: | + Copyright (C) 2013-2020 Masterminds + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +notices: [] diff --git a/CHANGELOG.md b/CHANGELOG.md index f1d07b6..8a174da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Security +## [2.3.0] - 2023-12-29 + +### Added + +- Extend format command with the [slim-sprig](https://go-task.github.io/slim-sprig/) library + +### Changed + +- Bumped `alpine` base image from 3.18.4 to 3.19.0 +- Updated dependencies + ## [2.2.0] - 2023-09-25 ### Added diff --git a/cmd/semver/format.go b/cmd/semver/format.go index 3bc9588..1b44912 100644 --- a/cmd/semver/format.go +++ b/cmd/semver/format.go @@ -6,6 +6,7 @@ import ( "os" "text/template" + sprig "github.com/go-task/slim-sprig" "github.com/spf13/cobra" "github.com/ffurrer2/semver/v2/internal/pkg/cli" @@ -40,7 +41,7 @@ type SemVer struct { DisableFlagsInUseLine: true, Run: func(cmd *cobra.Command, args []string) { text := args[0] - tpl, err := template.New("semver").Parse(text) + tpl, err := template.New("semver").Funcs(sprig.FuncMap()).Parse(text) if err != nil { cmd.PrintErrf("error: %v\n", err) os.Exit(1) diff --git a/go.mod b/go.mod index 4b4912e..c4fd7b4 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.21 require ( github.com/go-playground/pkg/v5 v5.22.0 + github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 github.com/onsi/ginkgo/v2 v2.13.2 github.com/onsi/gomega v1.30.0 github.com/samber/lo v1.39.0 @@ -13,7 +14,6 @@ require ( require ( github.com/go-logr/logr v1.4.1 // indirect - github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/pprof v0.0.0-20231229022155-5aaadb5f27d9 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect