From 562bcd95dfb6fb14af7e0b5829beccff3636d2f1 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Thu, 25 Jan 2024 21:13:05 -0500 Subject: Remove deprecated functions (#1978) Signed-off-by: Dave Henderson --- internal/funcs/aws.go | 19 ------------------- internal/funcs/base64.go | 16 ---------------- internal/funcs/coll.go | 16 ---------------- internal/funcs/conv.go | 41 ----------------------------------------- internal/funcs/crypto.go | 16 ---------------- internal/funcs/data.go | 16 ---------------- internal/funcs/env.go | 16 ---------------- internal/funcs/file.go | 16 ---------------- internal/funcs/filepath.go | 16 ---------------- internal/funcs/gcp.go | 16 ---------------- internal/funcs/math.go | 16 ---------------- internal/funcs/net.go | 16 ---------------- internal/funcs/path.go | 16 ---------------- internal/funcs/random.go | 16 ---------------- internal/funcs/regexp.go | 16 ---------------- internal/funcs/sockaddr.go | 14 -------------- internal/funcs/strings.go | 16 ---------------- internal/funcs/test.go | 16 ---------------- internal/funcs/test_test.go | 10 +++++----- internal/funcs/time.go | 32 -------------------------------- internal/funcs/uuid.go | 16 ---------------- internal/funcs/uuid_test.go | 10 +++++----- 22 files changed, 10 insertions(+), 372 deletions(-) (limited to 'internal') diff --git a/internal/funcs/aws.go b/internal/funcs/aws.go index ef95d612..01e225ca 100644 --- a/internal/funcs/aws.go +++ b/internal/funcs/aws.go @@ -8,25 +8,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/conv" ) -// AWSNS - the aws namespace -// -// Deprecated: don't use -// -//nolint:golint -func AWSNS() *Funcs { - return &Funcs{} -} - -// AWSFuncs - -// -// Deprecated: use [CreateAWSFuncs] instead -func AWSFuncs(f map[string]interface{}) { - f2 := CreateAWSFuncs(context.Background()) - for k, v := range f2 { - f[k] = v - } -} - // CreateAWSFuncs - func CreateAWSFuncs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/base64.go b/internal/funcs/base64.go index b25a9091..ba79a1d1 100644 --- a/internal/funcs/base64.go +++ b/internal/funcs/base64.go @@ -7,22 +7,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/conv" ) -// Base64NS - the base64 namespace -// -// Deprecated: don't use -func Base64NS() *Base64Funcs { - return &Base64Funcs{} -} - -// AddBase64Funcs - -// -// Deprecated: use [CreateBase64Funcs] instead -func AddBase64Funcs(f map[string]interface{}) { - for k, v := range CreateBase64Funcs(context.Background()) { - f[k] = v - } -} - // CreateBase64Funcs - func CreateBase64Funcs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/coll.go b/internal/funcs/coll.go index c8cb4dcc..a9431f9d 100644 --- a/internal/funcs/coll.go +++ b/internal/funcs/coll.go @@ -12,22 +12,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/coll" ) -// CollNS - -// -// Deprecated: don't use -func CollNS() *CollFuncs { - return &CollFuncs{} -} - -// AddCollFuncs - -// -// Deprecated: use CreateCollFuncs instead -func AddCollFuncs(f map[string]interface{}) { - for k, v := range CreateCollFuncs(context.Background()) { - f[k] = v - } -} - // CreateCollFuncs - func CreateCollFuncs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/conv.go b/internal/funcs/conv.go index 3361879d..5bc5cab9 100644 --- a/internal/funcs/conv.go +++ b/internal/funcs/conv.go @@ -5,27 +5,10 @@ import ( "net/url" "text/template" - "github.com/hairyhenderson/gomplate/v4/coll" "github.com/hairyhenderson/gomplate/v4/conv" "github.com/hairyhenderson/gomplate/v4/internal/deprecated" ) -// ConvNS - -// -// Deprecated: don't use -func ConvNS() *ConvFuncs { - return &ConvFuncs{} -} - -// AddConvFuncs - -// -// Deprecated: use [CreateConvFuncs] instead -func AddConvFuncs(f map[string]interface{}) { - for k, v := range CreateConvFuncs(context.Background()) { - f[k] = v - } -} - // CreateConvFuncs - func CreateConvFuncs(ctx context.Context) map[string]interface{} { ns := &ConvFuncs{ctx} @@ -63,27 +46,11 @@ func (ConvFuncs) ToBools(in ...interface{}) []bool { return conv.ToBools(in...) } -// Slice - -// -// Deprecated: use [CollFuncs.Slice] instead -func (f *ConvFuncs) Slice(args ...interface{}) []interface{} { - deprecated.WarnDeprecated(f.ctx, "conv.Slice is deprecated - use coll.Slice instead") - return coll.Slice(args...) -} - // Join - func (ConvFuncs) Join(in interface{}, sep string) (string, error) { return conv.Join(in, sep) } -// Has - -// -// Deprecated: use [CollFuncs.Has] instead -func (f *ConvFuncs) Has(in interface{}, key string) bool { - deprecated.WarnDeprecated(f.ctx, "conv.Has is deprecated - use coll.Has instead") - return coll.Has(in, key) -} - // ParseInt - func (ConvFuncs) ParseInt(s interface{}, base, bitSize int) int64 { return conv.MustParseInt(conv.ToString(s), base, bitSize) @@ -156,11 +123,3 @@ func (ConvFuncs) Default(def, in interface{}) interface{} { } return def } - -// Dict - -// -// Deprecated: use [CollFuncs.Dict] instead -func (f *ConvFuncs) Dict(in ...interface{}) (map[string]interface{}, error) { - deprecated.WarnDeprecated(f.ctx, "conv.Dict is deprecated - use coll.Dict instead") - return coll.Dict(in...) -} diff --git a/internal/funcs/crypto.go b/internal/funcs/crypto.go index e3628fad..fab02a7a 100644 --- a/internal/funcs/crypto.go +++ b/internal/funcs/crypto.go @@ -19,22 +19,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/crypto" ) -// CryptoNS - the crypto namespace -// -// Deprecated: don't use -func CryptoNS() *CryptoFuncs { - return &CryptoFuncs{} -} - -// AddCryptoFuncs - -// -// Deprecated: use [CreateCryptoFuncs] instead -func AddCryptoFuncs(f map[string]interface{}) { - for k, v := range CreateCryptoFuncs(context.Background()) { - f[k] = v - } -} - // CreateCryptoFuncs - func CreateCryptoFuncs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/data.go b/internal/funcs/data.go index 32f5b2da..1adb90aa 100644 --- a/internal/funcs/data.go +++ b/internal/funcs/data.go @@ -8,22 +8,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/internal/parsers" ) -// DataNS - -// -// Deprecated: don't use -func DataNS() *DataFuncs { - return &DataFuncs{} -} - -// AddDataFuncs - -// -// Deprecated: use [CreateDataFuncs] instead -func AddDataFuncs(f map[string]interface{}, d *data.Data) { - for k, v := range CreateDataFuncs(context.Background(), d) { - f[k] = v - } -} - // CreateDataFuncs - // //nolint:staticcheck diff --git a/internal/funcs/env.go b/internal/funcs/env.go index 0df63b3e..61ed9be4 100644 --- a/internal/funcs/env.go +++ b/internal/funcs/env.go @@ -7,22 +7,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/env" ) -// EnvNS - the Env namespace -// -// Deprecated: don't use -func EnvNS() *EnvFuncs { - return &EnvFuncs{} -} - -// AddEnvFuncs - -// -// Deprecated: use [CreateEnvFuncs] instead -func AddEnvFuncs(f map[string]interface{}) { - for k, v := range CreateEnvFuncs(context.Background()) { - f[k] = v - } -} - // CreateEnvFuncs - func CreateEnvFuncs(ctx context.Context) map[string]interface{} { ns := &EnvFuncs{ctx} diff --git a/internal/funcs/file.go b/internal/funcs/file.go index 32af47cf..82d9be09 100644 --- a/internal/funcs/file.go +++ b/internal/funcs/file.go @@ -11,22 +11,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/internal/iohelpers" ) -// FileNS - the File namespace -// -// Deprecated: don't use -func FileNS() *FileFuncs { - return &FileFuncs{} -} - -// AddFileFuncs - -// -// Deprecated: use [CreateFileFuncs] instead -func AddFileFuncs(f map[string]interface{}) { - for k, v := range CreateFileFuncs(context.Background()) { - f[k] = v - } -} - // CreateFileFuncs - func CreateFileFuncs(ctx context.Context) map[string]interface{} { fsys, err := datafs.FSysForPath(ctx, "/") diff --git a/internal/funcs/filepath.go b/internal/funcs/filepath.go index 726a1d7c..ffbd5699 100644 --- a/internal/funcs/filepath.go +++ b/internal/funcs/filepath.go @@ -7,22 +7,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/conv" ) -// FilePathNS - the Path namespace -// -// Deprecated: don't use -func FilePathNS() *FilePathFuncs { - return &FilePathFuncs{} -} - -// AddFilePathFuncs - -// -// Deprecated: use [CreateFilePathFuncs] instead -func AddFilePathFuncs(f map[string]interface{}) { - for k, v := range CreateFilePathFuncs(context.Background()) { - f[k] = v - } -} - // CreateFilePathFuncs - func CreateFilePathFuncs(ctx context.Context) map[string]interface{} { ns := &FilePathFuncs{ctx} diff --git a/internal/funcs/gcp.go b/internal/funcs/gcp.go index 040a451b..b87bd54b 100644 --- a/internal/funcs/gcp.go +++ b/internal/funcs/gcp.go @@ -7,22 +7,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/gcp" ) -// GCPNS - the gcp namespace -// -// Deprecated: don't use -func GCPNS() *GcpFuncs { - return &GcpFuncs{gcpopts: gcp.GetClientOptions()} -} - -// AddGCPFuncs - -// -// Deprecated: use [CreateGCPFuncs] instead -func AddGCPFuncs(f map[string]interface{}) { - for k, v := range CreateGCPFuncs(context.Background()) { - f[k] = v - } -} - // CreateGCPFuncs - func CreateGCPFuncs(ctx context.Context) map[string]interface{} { ns := &GcpFuncs{ diff --git a/internal/funcs/math.go b/internal/funcs/math.go index 68316101..3881e057 100644 --- a/internal/funcs/math.go +++ b/internal/funcs/math.go @@ -11,22 +11,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/math" ) -// MathNS - the math namespace -// -// Deprecated: don't use -func MathNS() *MathFuncs { - return &MathFuncs{} -} - -// AddMathFuncs - -// -// Deprecated: use [CreateMathFuncs] instead -func AddMathFuncs(f map[string]interface{}) { - for k, v := range CreateMathFuncs(context.Background()) { - f[k] = v - } -} - // CreateMathFuncs - func CreateMathFuncs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/net.go b/internal/funcs/net.go index 3342bd27..e06b996a 100644 --- a/internal/funcs/net.go +++ b/internal/funcs/net.go @@ -15,22 +15,6 @@ import ( "inet.af/netaddr" ) -// NetNS - the net namespace -// -// Deprecated: don't use -func NetNS() *NetFuncs { - return &NetFuncs{} -} - -// AddNetFuncs - -// -// Deprecated: use [CreateNetFuncs] instead -func AddNetFuncs(f map[string]interface{}) { - for k, v := range CreateNetFuncs(context.Background()) { - f[k] = v - } -} - // CreateNetFuncs - func CreateNetFuncs(ctx context.Context) map[string]interface{} { ns := &NetFuncs{ctx} diff --git a/internal/funcs/path.go b/internal/funcs/path.go index 324f188a..3831ed5f 100644 --- a/internal/funcs/path.go +++ b/internal/funcs/path.go @@ -7,22 +7,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/conv" ) -// PathNS - the Path namespace -// -// Deprecated: don't use -func PathNS() *PathFuncs { - return &PathFuncs{} -} - -// AddPathFuncs - -// -// Deprecated: use [CreatePathFuncs] instead -func AddPathFuncs(f map[string]interface{}) { - for k, v := range CreatePathFuncs(context.Background()) { - f[k] = v - } -} - // CreatePathFuncs - func CreatePathFuncs(ctx context.Context) map[string]interface{} { ns := &PathFuncs{ctx} diff --git a/internal/funcs/random.go b/internal/funcs/random.go index 6aa863be..84bad8d7 100644 --- a/internal/funcs/random.go +++ b/internal/funcs/random.go @@ -11,22 +11,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/random" ) -// RandomNS - -// -// Deprecated: don't use -func RandomNS() *RandomFuncs { - return &RandomFuncs{} -} - -// AddRandomFuncs - -// -// Deprecated: use [CreateRandomFuncs] instead -func AddRandomFuncs(f map[string]interface{}) { - for k, v := range CreateRandomFuncs(context.Background()) { - f[k] = v - } -} - // CreateRandomFuncs - func CreateRandomFuncs(ctx context.Context) map[string]interface{} { ns := &RandomFuncs{ctx} diff --git a/internal/funcs/regexp.go b/internal/funcs/regexp.go index 66cbe4c4..6da1190c 100644 --- a/internal/funcs/regexp.go +++ b/internal/funcs/regexp.go @@ -8,22 +8,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/regexp" ) -// ReNS - -// -// Deprecated: don't use -func ReNS() *ReFuncs { - return &ReFuncs{} -} - -// AddReFuncs - -// -// Deprecated: use [CreateReFuncs] instead -func AddReFuncs(f map[string]interface{}) { - for k, v := range CreateReFuncs(context.Background()) { - f[k] = v - } -} - // CreateReFuncs - func CreateReFuncs(ctx context.Context) map[string]interface{} { ns := &ReFuncs{ctx} diff --git a/internal/funcs/sockaddr.go b/internal/funcs/sockaddr.go index e41fb162..a1e607ec 100644 --- a/internal/funcs/sockaddr.go +++ b/internal/funcs/sockaddr.go @@ -7,20 +7,6 @@ import ( "github.com/hashicorp/go-sockaddr/template" ) -// SockaddrNS - the sockaddr namespace -// -// Deprecated: don't use -func SockaddrNS() *SockaddrFuncs { - return &SockaddrFuncs{} -} - -// AddSockaddrFuncs - -// -// Deprecated: use [CreateSockaddrFuncs] instead -func AddSockaddrFuncs(f map[string]interface{}) { - f["sockaddr"] = SockaddrNS -} - // CreateSockaddrFuncs - func CreateSockaddrFuncs(ctx context.Context) map[string]interface{} { ns := &SockaddrFuncs{ctx} diff --git a/internal/funcs/strings.go b/internal/funcs/strings.go index f95e6bf5..c648ab0d 100644 --- a/internal/funcs/strings.go +++ b/internal/funcs/strings.go @@ -22,22 +22,6 @@ import ( "golang.org/x/text/language" ) -// StrNS - -// -// Deprecated: don't use -func StrNS() *StringFuncs { - return &StringFuncs{} -} - -// AddStringFuncs - -// -// Deprecated: use [CreateStringFuncs] instead -func AddStringFuncs(f map[string]interface{}) { - for k, v := range CreateStringFuncs(context.Background()) { - f[k] = v - } -} - // CreateStringFuncs - func CreateStringFuncs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/test.go b/internal/funcs/test.go index 875cf631..9dd780e5 100644 --- a/internal/funcs/test.go +++ b/internal/funcs/test.go @@ -9,22 +9,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/test" ) -// TestNS - -// -// Deprecated: don't use -func TestNS() *TestFuncs { - return &TestFuncs{} -} - -// AddTestFuncs - -// -// Deprecated: use [CreateTestFuncs] instead -func AddTestFuncs(f map[string]interface{}) { - for k, v := range CreateTestFuncs(context.Background()) { - f[k] = v - } -} - // CreateTestFuncs - func CreateTestFuncs(ctx context.Context) map[string]interface{} { f := map[string]interface{}{} diff --git a/internal/funcs/test_test.go b/internal/funcs/test_test.go index 26909813..397e9698 100644 --- a/internal/funcs/test_test.go +++ b/internal/funcs/test_test.go @@ -29,7 +29,7 @@ func TestCreateTestFuncs(t *testing.T) { func TestAssert(t *testing.T) { t.Parallel() - f := TestNS() + f := TestFuncs{ctx: context.Background()} _, err := f.Assert(false) assert.Error(t, err) @@ -46,7 +46,7 @@ func TestAssert(t *testing.T) { func TestRequired(t *testing.T) { t.Parallel() - f := TestNS() + f := TestFuncs{ctx: context.Background()} errMsg := "can not render template: a required value was not set" v, err := f.Required("") assert.Error(t, err) @@ -91,7 +91,7 @@ func TestRequired(t *testing.T) { func TestTernary(t *testing.T) { t.Parallel() - f := TestNS() + f := TestFuncs{ctx: context.Background()} testdata := []struct { tval, fval, b interface{} expected interface{} @@ -108,7 +108,7 @@ func TestTernary(t *testing.T) { func TestKind(t *testing.T) { t.Parallel() - f := TestNS() + f := TestFuncs{ctx: context.Background()} testdata := []struct { arg interface{} expected string @@ -131,7 +131,7 @@ func TestKind(t *testing.T) { func TestIsKind(t *testing.T) { t.Parallel() - f := TestNS() + f := TestFuncs{ctx: context.Background()} truedata := []struct { arg interface{} kind string diff --git a/internal/funcs/time.go b/internal/funcs/time.go index ca02a35a..deaddc2e 100644 --- a/internal/funcs/time.go +++ b/internal/funcs/time.go @@ -12,38 +12,6 @@ import ( "github.com/hairyhenderson/gomplate/v4/time" ) -// TimeNS - -// -// Deprecated: don't use -func TimeNS() *TimeFuncs { - return &TimeFuncs{ - ANSIC: gotime.ANSIC, - UnixDate: gotime.UnixDate, - RubyDate: gotime.RubyDate, - RFC822: gotime.RFC822, - RFC822Z: gotime.RFC822Z, - RFC850: gotime.RFC850, - RFC1123: gotime.RFC1123, - RFC1123Z: gotime.RFC1123Z, - RFC3339: gotime.RFC3339, - RFC3339Nano: gotime.RFC3339Nano, - Kitchen: gotime.Kitchen, - Stamp: gotime.Stamp, - StampMilli: gotime.StampMilli, - StampMicro: gotime.StampMicro, - StampNano: gotime.StampNano, - } -} - -// AddTimeFuncs - -// -// Deprecated: use [CreateTimeFuncs] instead -func AddTimeFuncs(f map[string]interface{}) { - for k, v := range CreateTimeFuncs(context.Background()) { - f[k] = v - } -} - // CreateTimeFuncs - func CreateTimeFuncs(ctx context.Context) map[string]interface{} { ns := &TimeFuncs{ diff --git a/internal/funcs/uuid.go b/internal/funcs/uuid.go index 2ad9d874..6831dbf7 100644 --- a/internal/funcs/uuid.go +++ b/internal/funcs/uuid.go @@ -8,22 +8,6 @@ import ( "github.com/google/uuid" ) -// UUIDNS - -// -// Deprecated: don't use -func UUIDNS() *UUIDFuncs { - return &UUIDFuncs{} -} - -// AddUUIDFuncs - -// -// Deprecated: use [CreateUUIDFuncs] instead -func AddUUIDFuncs(f map[string]interface{}) { - for k, v := range CreateUUIDFuncs(context.Background()) { - f[k] = v - } -} - // CreateUUIDFuncs - func CreateUUIDFuncs(ctx context.Context) map[string]interface{} { ns := &UUIDFuncs{ctx} diff --git a/internal/funcs/uuid_test.go b/internal/funcs/uuid_test.go index c21981ea..0f586d5e 100644 --- a/internal/funcs/uuid_test.go +++ b/internal/funcs/uuid_test.go @@ -35,7 +35,7 @@ const ( func TestV1(t *testing.T) { t.Parallel() - u := UUIDNS() + u := UUIDFuncs{ctx: context.Background()} i, err := u.V1() require.NoError(t, err) assert.Regexp(t, uuidV1Pattern, i) @@ -44,7 +44,7 @@ func TestV1(t *testing.T) { func TestV4(t *testing.T) { t.Parallel() - u := UUIDNS() + u := UUIDFuncs{ctx: context.Background()} i, err := u.V4() require.NoError(t, err) assert.Regexp(t, uuidV4Pattern, i) @@ -53,7 +53,7 @@ func TestV4(t *testing.T) { func TestNil(t *testing.T) { t.Parallel() - u := UUIDNS() + u := UUIDFuncs{ctx: context.Background()} i, err := u.Nil() require.NoError(t, err) assert.Equal(t, "00000000-0000-0000-0000-000000000000", i) @@ -62,7 +62,7 @@ func TestNil(t *testing.T) { func TestIsValid(t *testing.T) { t.Parallel() - u := UUIDNS() + u := UUIDFuncs{ctx: context.Background()} in := interface{}(false) i, err := u.IsValid(in) require.NoError(t, err) @@ -90,7 +90,7 @@ func TestIsValid(t *testing.T) { func TestParse(t *testing.T) { t.Parallel() - u := UUIDNS() + u := UUIDFuncs{ctx: context.Background()} in := interface{}(false) _, err := u.Parse(in) assert.Error(t, err) -- cgit v1.2.3