diff --git a/README.md b/README.md index 729257c..c4c4290 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,42 @@ If you are still interested, please go through [docs](/docs/build_and_run.md) to combine `tcli` for meaningful tests. To find even more sophisticated uses of `tcli`, see [stress test with tcli](/docs/stress_test.md) +### Using tcli as a library + +`tcli`'s reusable packages (spec parsing, config/module loading, and command +execution) live under `pkg/` and can be imported directly by other Go +modules — no need to copy source files into your own repository: + +```go +import ( + "github.com/hpinc/tcli/pkg/cmd" + "github.com/hpinc/tcli/pkg/config" + "github.com/hpinc/tcli/pkg/env" + "github.com/hpinc/tcli/pkg/parser" +) +``` + +Custom extension commands (like the `sqs`/`sns` example under +[`examples/_pubsub`](/examples/_pubsub)) no longer need to be copied into +`internal/cmd`. Instead, implement `cmd.Command` in your own package and +register it with `cmd.RegisterCommand` from an `init()`, then blank-import +that package from your `main`: + +```go +package mypubsub + +func init() { + cmd.RegisterCommand("sqs", &SqsCommand{}) +} +``` + +```go +// in your main package +import _ "example.com/myclient/mypubsub" +``` + +See [`examples/_pubsub`](/examples/_pubsub) for a full working example. + #### Areas we need help with - testing diff --git a/cmd/main.go b/cmd/main.go index 5091c3a..f5f026b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -6,7 +6,7 @@ package main import ( "os" - "github.com/hpinc/tcli/internal/env" + "github.com/hpinc/tcli/pkg/env" ) // main is the entry point for the tcli application. diff --git a/examples/_pubsub/README.md b/examples/_pubsub/README.md index 6a84899..f36b315 100644 --- a/examples/_pubsub/README.md +++ b/examples/_pubsub/README.md @@ -6,17 +6,40 @@ This example shows how to extend `tcli` to support aws `sns` and `sqs` - [pubsub spec](/examples/_pubsub/pubsub.json) - [pubsub cmd support](/examples/_pubsub/cmd) +Now that tcli's reusable packages live under `pkg/` (instead of `internal/`), +`sqs`/`sns` support ships as its own self-contained Go package +(`examples/_pubsub/cmd`, `package pubsub`) that registers itself with +`cmd.RegisterCommand` — no copying source files into tcli's tree required. + To add pubsub as a module, do the following - add the module definition from modules.yaml to your tools/modules.yaml - copy `pubsub.json` to `tools/data` -- copy files under `cmd` to `internal/cmd` -- copy files under `common` to `internal/common` +- blank-import the `pubsub` package as shown below + + ```go + package main + + import ( + "os" + + // Blank-import registers the "file" command class with tcli's command + // registry via its init(). + _ "github.com/hpinc/tcli/examples/_pubsub/cmd" // registers sqs/sns + "github.com/hpinc/tcli/pkg/env" + ) + + func main() { + if err := env.Run(); err != nil { + os.Exit(1) + } + } + ``` ### Test it out List supported commands ```console -$ TCLI_CONFIG_ROOT=tools go run cmd/main.go pubsub +$ TCLI_CONFIG_ROOT=tools go run main.go pubsub Please specify a command. Supported commands are: - send_sns send sns message @@ -25,7 +48,7 @@ Please specify a command. Supported commands are: Get help on commands ```console -$ TCLI_CONFIG_ROOT=tools go run cmd/main.go pubsub send_sns -help +$ TCLI_CONFIG_ROOT=tools go run main.go pubsub send_sns -help Usage of send_sns: -arn string arn (default "arn:aws:sns:us-east-1:000000000000:dev") diff --git a/examples/_pubsub/cmd/sns.go b/examples/_pubsub/cmd/sns.go index a00ced2..9f92066 100644 --- a/examples/_pubsub/cmd/sns.go +++ b/examples/_pubsub/cmd/sns.go @@ -1,45 +1,45 @@ // Copyright 2025 HP Development Company, L.P. // SPDX-License-Identifier: MIT -package cmd +package pubsub import ( - "log" + "fmt" - "github.com/hpinc/tcli/internal/common" + pubsubcommon "github.com/hpinc/tcli/examples/_pubsub/common" + "github.com/hpinc/tcli/pkg/cmd" ) func init() { - cmds["sns"] = &SnsCommand{} + cmd.RegisterCommand("sns", &SnsCommand{}) } type SnsCommand struct { - CmdBase + cmd.CmdBase Name string Data string Arn string Endpoint string } -func (c *SnsCommand) Init(p *ParseResult) Command { +func (c *SnsCommand) Init(p *cmd.ParseResult) cmd.Command { k := SnsCommand{} k.Endpoint = *p.Values["endpoint"] k.Data = *p.Values["data"] k.Arn = *p.Values["arn"] k.Name = *p.Values["name"] - k.baseInit(p, k.send) + k.InitBase(p, k.send) return &k } // Function to publish the event to SNS func (c *SnsCommand) send() error { - cli, err := common.NewSNSClient(c.Endpoint) + cli, err := pubsubcommon.NewSNSClient(c.Endpoint) if err != nil { - log.Fatalf("Publish to sns failed: %v\n", err) + return fmt.Errorf("publish to sns failed: %w", err) } - err = cli.Publish(c.Arn, c.Data, c.Name) - if err != nil { - log.Fatalf("Publish to sns failed: %v\n", err) + if err := cli.Publish(c.Arn, c.Data, c.Name); err != nil { + return fmt.Errorf("publish to sns failed: %w", err) } return nil } diff --git a/examples/_pubsub/cmd/sqs.go b/examples/_pubsub/cmd/sqs.go index 8aa4ffb..5179451 100644 --- a/examples/_pubsub/cmd/sqs.go +++ b/examples/_pubsub/cmd/sqs.go @@ -1,44 +1,51 @@ // Copyright 2025 HP Development Company, L.P. // SPDX-License-Identifier: MIT -package cmd +// Package pubsub demonstrates adding a custom extension command to tcli +// without vendoring or copying files into the tcli module itself. It +// imports tcli's public pkg/cmd package and self-registers via +// cmd.RegisterCommand. Consumers only need to blank-import this package +// (e.g. `import _ "example.com/myclient/pubsub"`) from their main so its +// init() runs. +package pubsub import ( - "log" + "fmt" - "github.com/hpinc/tcli/internal/common" + pubsubcommon "github.com/hpinc/tcli/examples/_pubsub/common" + "github.com/hpinc/tcli/pkg/cmd" + tcommon "github.com/hpinc/tcli/pkg/common" ) func init() { - cmds["sqs"] = &SqsCommand{} + cmd.RegisterCommand("sqs", &SqsCommand{}) } type SqsCommand struct { - CmdBase + cmd.CmdBase Data string Url string Endpoint string } -func (c *SqsCommand) Init(p *ParseResult) Command { +func (c *SqsCommand) Init(p *cmd.ParseResult) cmd.Command { k := SqsCommand{} k.Endpoint = *p.Values["endpoint"] k.Data = *p.Values["data"] k.Url = *p.Values["queue_url"] - k.baseInit(p, k.send) + k.InitBase(p, k.send) return &k } -// Function to publish the event to SNS +// Function to publish the event to SQS func (c *SqsCommand) send() error { - data := common.GetJsonString(c.Data) - cli, err := common.NewSQSClient(c.Endpoint) + data := tcommon.GetJsonString(c.Data) + cli, err := pubsubcommon.NewSQSClient(c.Endpoint) if err != nil { - log.Fatalf("Publish to sqs failed: %v\n", err) + return fmt.Errorf("publish to sqs failed: %w", err) } - err = cli.Send(c.Url, data) - if err != nil { - log.Fatalf("Publish to sqs failed: %v\n", err) + if err := cli.Send(c.Url, data); err != nil { + return fmt.Errorf("publish to sqs failed: %w", err) } return nil } diff --git a/go.mod b/go.mod index ef636c6..acad773 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/hpinc/tcli -go 1.26.4 +go 1.26.5 require ( github.com/itchyny/gojq v0.12.19 diff --git a/internal/cmd/base.go b/internal/cmd/base.go deleted file mode 100644 index 129308f..0000000 --- a/internal/cmd/base.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2025 HP Development Company, L.P. -// SPDX-License-Identifier: MIT - -package cmd - -type CmdBase struct { - p *ParseResult - global *GlobalResult - runFunc fnRun -} - -func (c *CmdBase) baseInit(p *ParseResult, f fnRun) { - c.p = p - c.global = p.Global - c.runFunc = f -} - -func (c *CmdBase) GetBase() *CmdBase { - return c -} - -func (c *CmdBase) Execute() error { - return nil -} diff --git a/internal/cmd/command.go b/internal/cmd/command.go deleted file mode 100644 index c44eba6..0000000 --- a/internal/cmd/command.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright 2025 HP Development Company, L.P. -// SPDX-License-Identifier: MIT - -package cmd - -import ( - "github.com/hpinc/tcli/internal/common" - "github.com/hpinc/tcli/internal/config" -) - -// hold commands in a module -type commands map[string]Command -type fnRun func() error - -type Command interface { - Init(*ParseResult) Command - Execute() error - GetBase() *CmdBase -} - -var ( - cmds = make(commands) - log = config.GetLogger() -) - -func GetCommand(name string) (Command, error) { - if c, ok := cmds[name]; ok { - return c, nil - } - return nil, common.ErrNoSuchCommand -} diff --git a/pkg/cmd/base.go b/pkg/cmd/base.go new file mode 100644 index 0000000..53ca869 --- /dev/null +++ b/pkg/cmd/base.go @@ -0,0 +1,49 @@ +// Copyright 2025 HP Development Company, L.P. +// SPDX-License-Identifier: MIT + +package cmd + +type CmdBase struct { + p *ParseResult + global *GlobalResult + runFunc fnRun +} + +func (c *CmdBase) baseInit(p *ParseResult, f fnRun) { + c.p = p + c.global = p.Global + c.runFunc = f +} + +// InitBase initializes a CmdBase from outside this package. Custom Command +// implementations registered via RegisterCommand should call this from +// their Init method instead of reimplementing CmdBase's plumbing: +// +// func (c *MyCommand) Init(p *cmd.ParseResult) cmd.Command { +// k := MyCommand{} +// k.InitBase(p, k.run) +// return &k +// } +func (c *CmdBase) InitBase(p *ParseResult, f func() error) { + c.baseInit(p, f) +} + +// Params returns the parsed parameter values for this command, so external +// Command implementations can read parameters without needing direct +// access to CmdBase's unexported fields. +func (c *CmdBase) Params() *ParseResult { + return c.p +} + +// Global returns the parsed global flag values for this command. +func (c *CmdBase) Global() *GlobalResult { + return c.global +} + +func (c *CmdBase) GetBase() *CmdBase { + return c +} + +func (c *CmdBase) Execute() error { + return nil +} diff --git a/pkg/cmd/command.go b/pkg/cmd/command.go new file mode 100644 index 0000000..ab431e3 --- /dev/null +++ b/pkg/cmd/command.go @@ -0,0 +1,54 @@ +// Copyright 2025 HP Development Company, L.P. +// SPDX-License-Identifier: MIT + +package cmd + +import ( + "github.com/hpinc/tcli/pkg/common" + "github.com/hpinc/tcli/pkg/config" +) + +// hold commands in a module +type commands map[string]Command +type fnRun func() error + +type Command interface { + Init(*ParseResult) Command + Execute() error + GetBase() *CmdBase +} + +var ( + cmds = make(commands) + log = config.GetLogger() +) + +func GetCommand(name string) (Command, error) { + if c, ok := cmds[name]; ok { + return c, nil + } + return nil, common.ErrNoSuchCommand +} + +// RegisterCommand registers a Command implementation under the given +// extension class name (the value returned by Method.GetExtensionClass(), +// which maps to the "class" field of an operation's extension in the +// OpenAPI spec). +// +// This lets a program that imports tcli as a library add its own command +// types (e.g. for publishing to a queue or topic) without needing to copy +// source files into this package. Call it from an init() in your own +// package, then blank-import that package from your main so the init() +// runs: +// +// package mypubsub +// +// func init() { +// cmd.RegisterCommand("sqs", &SqsCommand{}) +// } +// +// // in your main package +// import _ "example.com/myclient/mypubsub" +func RegisterCommand(name string, c Command) { + cmds[name] = c +} diff --git a/internal/cmd/echo.go b/pkg/cmd/echo.go similarity index 83% rename from internal/cmd/echo.go rename to pkg/cmd/echo.go index 7720f6c..f49b2ec 100644 --- a/internal/cmd/echo.go +++ b/pkg/cmd/echo.go @@ -8,12 +8,12 @@ type EchoCommand struct { } func init() { - cmds["echo"] = &EchoCommand{} + RegisterCommand("echo", &EchoCommand{}) } func (c *EchoCommand) Init(p *ParseResult) Command { k := EchoCommand{} - k.baseInit(p, k.doEcho) + k.InitBase(p, k.doEcho) return &k } diff --git a/internal/cmd/exec_env.go b/pkg/cmd/exec_env.go similarity index 92% rename from internal/cmd/exec_env.go rename to pkg/cmd/exec_env.go index d1528cd..93b11b7 100644 --- a/internal/cmd/exec_env.go +++ b/pkg/cmd/exec_env.go @@ -4,9 +4,9 @@ package cmd import ( - "github.com/hpinc/tcli/internal/common" - "github.com/hpinc/tcli/internal/config" - "github.com/hpinc/tcli/internal/parser" + "github.com/hpinc/tcli/pkg/common" + "github.com/hpinc/tcli/pkg/config" + "github.com/hpinc/tcli/pkg/parser" ) type Environment struct { diff --git a/internal/cmd/http.go b/pkg/cmd/http.go similarity index 88% rename from internal/cmd/http.go rename to pkg/cmd/http.go index bb1b525..c8be53e 100644 --- a/internal/cmd/http.go +++ b/pkg/cmd/http.go @@ -10,7 +10,8 @@ import ( "net/http" "strconv" - "github.com/hpinc/tcli/internal/utils" + "github.com/hpinc/tcli/pkg/common" + "github.com/hpinc/tcli/pkg/utils" ) const IgnoreError = -1 @@ -20,12 +21,12 @@ type HttpCommand struct { } func init() { - cmds["http"] = &HttpCommand{} + RegisterCommand("http", &HttpCommand{}) } func (c *HttpCommand) Init(p *ParseResult) Command { k := HttpCommand{} - k.baseInit(p, k.http) + k.InitBase(p, k.http) return &k } @@ -44,7 +45,8 @@ func (c *HttpCommand) http() error { url, getData(result.body)) if err != nil { - log.Fatalf("Request error: %v\n", err) + log.Errorf("Request error: %v\n", err) + return err } req.Header = result.headers if len(*result.urlValues) > 0 { @@ -62,7 +64,8 @@ func (c *HttpCommand) http() error { client := utils.RetriableClient(int64(p.Global.RetryCount)) resp, err := client.Do(req) if err != nil { - log.Fatalf("Response error: %v\n", err) + log.Errorf("Response error: %v\n", err) + return err } // there might be useful results even when there is an error // so show the result first @@ -80,7 +83,7 @@ func (c *HttpCommand) http() error { log.Errorf("StatusCode: %d, Expected: %d", resp.StatusCode, code) if !p.Global.IgnoreError { - log.Fatalf("Exit on first error") + return common.ErrUnexpectedStatus } } return nil diff --git a/internal/cmd/parallel.go b/pkg/cmd/parallel.go similarity index 100% rename from internal/cmd/parallel.go rename to pkg/cmd/parallel.go diff --git a/internal/cmd/params.go b/pkg/cmd/params.go similarity index 97% rename from internal/cmd/params.go rename to pkg/cmd/params.go index fe7bbfd..dcd8f53 100644 --- a/internal/cmd/params.go +++ b/pkg/cmd/params.go @@ -10,9 +10,9 @@ import ( "net/url" "strings" - "github.com/hpinc/tcli/internal/common" - "github.com/hpinc/tcli/internal/config" - "github.com/hpinc/tcli/internal/parser" + "github.com/hpinc/tcli/pkg/common" + "github.com/hpinc/tcli/pkg/config" + "github.com/hpinc/tcli/pkg/parser" ) const JwtParam = "jwt" diff --git a/internal/cmd/tcp.go b/pkg/cmd/tcp.go similarity index 88% rename from internal/cmd/tcp.go rename to pkg/cmd/tcp.go index 9b8d1c7..ffc5d55 100644 --- a/internal/cmd/tcp.go +++ b/pkg/cmd/tcp.go @@ -7,7 +7,7 @@ import ( "fmt" "net" - "github.com/hpinc/tcli/internal/utils" + "github.com/hpinc/tcli/pkg/utils" ) type TcpCommand struct { @@ -15,12 +15,12 @@ type TcpCommand struct { } func init() { - cmds["tcp"] = &TcpCommand{} + RegisterCommand("tcp", &TcpCommand{}) } func (c *TcpCommand) Init(p *ParseResult) Command { k := TcpCommand{} - k.baseInit(p, k.doTcpRetry) + k.InitBase(p, k.doTcpRetry) return &k } diff --git a/internal/common/errors.go b/pkg/common/errors.go similarity index 88% rename from internal/common/errors.go rename to pkg/common/errors.go index b71039e..658c213 100644 --- a/internal/common/errors.go +++ b/pkg/common/errors.go @@ -12,4 +12,5 @@ var ( ErrNoSuchModule = errors.New("Module not found") ErrNoSuchCommand = errors.New("Command not found") ErrNoSuchSubCommand = errors.New("Subcommand not found") + ErrUnexpectedStatus = errors.New("Unexpected status code") ) diff --git a/internal/common/file.go b/pkg/common/file.go similarity index 100% rename from internal/common/file.go rename to pkg/common/file.go diff --git a/internal/common/json.go b/pkg/common/json.go similarity index 100% rename from internal/common/json.go rename to pkg/common/json.go diff --git a/internal/common/structs.go b/pkg/common/structs.go similarity index 100% rename from internal/common/structs.go rename to pkg/common/structs.go diff --git a/internal/config/config.go b/pkg/config/config.go similarity index 98% rename from internal/config/config.go rename to pkg/config/config.go index 5f26cf4..2ca5af3 100644 --- a/internal/config/config.go +++ b/pkg/config/config.go @@ -7,7 +7,7 @@ import ( "os" "path/filepath" - "github.com/hpinc/tcli/internal/common" + "github.com/hpinc/tcli/pkg/common" "gopkg.in/yaml.v2" ) diff --git a/internal/config/config_struct.go b/pkg/config/config_struct.go similarity index 95% rename from internal/config/config_struct.go rename to pkg/config/config_struct.go index 26bf28b..3028532 100644 --- a/internal/config/config_struct.go +++ b/pkg/config/config_struct.go @@ -3,7 +3,7 @@ package config -import "github.com/hpinc/tcli/internal/parser" +import "github.com/hpinc/tcli/pkg/parser" // proxy config type Proxy struct { diff --git a/internal/config/docprovider.go b/pkg/config/docprovider.go similarity index 100% rename from internal/config/docprovider.go rename to pkg/config/docprovider.go diff --git a/internal/config/docprovider_none.go b/pkg/config/docprovider_none.go similarity index 100% rename from internal/config/docprovider_none.go rename to pkg/config/docprovider_none.go diff --git a/internal/config/docprovider_shell.go b/pkg/config/docprovider_shell.go similarity index 100% rename from internal/config/docprovider_shell.go rename to pkg/config/docprovider_shell.go diff --git a/internal/config/log.go b/pkg/config/log.go similarity index 100% rename from internal/config/log.go rename to pkg/config/log.go diff --git a/internal/config/modules.go b/pkg/config/modules.go similarity index 97% rename from internal/config/modules.go rename to pkg/config/modules.go index 0204aca..b80b548 100644 --- a/internal/config/modules.go +++ b/pkg/config/modules.go @@ -8,8 +8,8 @@ import ( "path/filepath" "strings" - "github.com/hpinc/tcli/internal/common" - "github.com/hpinc/tcli/internal/parser" + "github.com/hpinc/tcli/pkg/common" + "github.com/hpinc/tcli/pkg/parser" "gopkg.in/yaml.v2" ) diff --git a/internal/config/profiles.go b/pkg/config/profiles.go similarity index 100% rename from internal/config/profiles.go rename to pkg/config/profiles.go diff --git a/internal/config/token_cache.go b/pkg/config/token_cache.go similarity index 95% rename from internal/config/token_cache.go rename to pkg/config/token_cache.go index c74f610..60f0d75 100644 --- a/internal/config/token_cache.go +++ b/pkg/config/token_cache.go @@ -7,7 +7,7 @@ import ( "fmt" "strings" - "github.com/hpinc/tcli/internal/common" + "github.com/hpinc/tcli/pkg/common" ) const ( diff --git a/internal/env/run.go b/pkg/env/run.go similarity index 95% rename from internal/env/run.go rename to pkg/env/run.go index 115cc86..6d6d526 100644 --- a/internal/env/run.go +++ b/pkg/env/run.go @@ -10,10 +10,10 @@ import ( "os" "strings" - "github.com/hpinc/tcli/internal/cmd" - "github.com/hpinc/tcli/internal/common" - "github.com/hpinc/tcli/internal/config" - "github.com/hpinc/tcli/internal/parser" + "github.com/hpinc/tcli/pkg/cmd" + "github.com/hpinc/tcli/pkg/common" + "github.com/hpinc/tcli/pkg/config" + "github.com/hpinc/tcli/pkg/parser" ) const ( diff --git a/internal/parser/doc_mapper.go b/pkg/parser/doc_mapper.go similarity index 99% rename from internal/parser/doc_mapper.go rename to pkg/parser/doc_mapper.go index ba8f094..023592d 100644 --- a/internal/parser/doc_mapper.go +++ b/pkg/parser/doc_mapper.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "github.com/hpinc/tcli/internal/common" + "github.com/hpinc/tcli/pkg/common" "github.com/pb33f/libopenapi" "github.com/pb33f/libopenapi/datamodel/high/base" v2 "github.com/pb33f/libopenapi/datamodel/high/v2" diff --git a/internal/parser/doc_mapper_test.go b/pkg/parser/doc_mapper_test.go similarity index 100% rename from internal/parser/doc_mapper_test.go rename to pkg/parser/doc_mapper_test.go diff --git a/internal/parser/parameter.go b/pkg/parser/parameter.go similarity index 95% rename from internal/parser/parameter.go rename to pkg/parser/parameter.go index 6f19554..2d2db43 100644 --- a/internal/parser/parameter.go +++ b/pkg/parser/parameter.go @@ -6,7 +6,7 @@ package parser import ( "fmt" - "github.com/hpinc/tcli/internal/common" + "github.com/hpinc/tcli/pkg/common" ) func (p *Parameter) DefaultStr() string { diff --git a/internal/parser/parse.go b/pkg/parser/parse.go similarity index 99% rename from internal/parser/parse.go rename to pkg/parser/parse.go index 4d0b1ed..1ad99ef 100644 --- a/internal/parser/parse.go +++ b/pkg/parser/parse.go @@ -7,7 +7,7 @@ import ( "fmt" "strings" - "github.com/hpinc/tcli/internal/common" + "github.com/hpinc/tcli/pkg/common" ) const definitionsPrefix = "#/definitions/" diff --git a/internal/parser/structs.go b/pkg/parser/structs.go similarity index 100% rename from internal/parser/structs.go rename to pkg/parser/structs.go diff --git a/internal/utils/format.go b/pkg/utils/format.go similarity index 97% rename from internal/utils/format.go rename to pkg/utils/format.go index d4c4a43..7c3e14f 100644 --- a/internal/utils/format.go +++ b/pkg/utils/format.go @@ -9,7 +9,7 @@ import ( "log" "strings" - "github.com/hpinc/tcli/internal/common" + "github.com/hpinc/tcli/pkg/common" "github.com/itchyny/gojq" ) diff --git a/internal/utils/request.go b/pkg/utils/request.go similarity index 96% rename from internal/utils/request.go rename to pkg/utils/request.go index ca5742d..f0f9ff3 100644 --- a/internal/utils/request.go +++ b/pkg/utils/request.go @@ -8,7 +8,7 @@ import ( "io" "net/http" - "github.com/hpinc/tcli/internal/config" + "github.com/hpinc/tcli/pkg/config" ) const ( diff --git a/internal/utils/retry_cli.go b/pkg/utils/retry_cli.go similarity index 98% rename from internal/utils/retry_cli.go rename to pkg/utils/retry_cli.go index 6d013c9..d9b1efd 100644 --- a/internal/utils/retry_cli.go +++ b/pkg/utils/retry_cli.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - "github.com/hpinc/tcli/internal/config" + "github.com/hpinc/tcli/pkg/config" ) const ( diff --git a/internal/utils/tcp.go b/pkg/utils/tcp.go similarity index 93% rename from internal/utils/tcp.go rename to pkg/utils/tcp.go index 58c47b1..3ac1cd1 100644 --- a/internal/utils/tcp.go +++ b/pkg/utils/tcp.go @@ -6,7 +6,7 @@ package utils import ( "time" - "github.com/hpinc/tcli/internal/config" + "github.com/hpinc/tcli/pkg/config" ) // RetryWait retries a function up to 'count' times, waiting an increasing amount of time between each attempt. diff --git a/tools/Dockerfile b/tools/Dockerfile index d24e747..92c6c49 100644 --- a/tools/Dockerfile +++ b/tools/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.26.4-alpine3.23 AS builder +FROM golang:1.26.5-alpine3.24 AS builder ADD . /go/src/tcli WORKDIR /go/src/tcli @@ -8,10 +8,7 @@ go build -o bin/tcli \ -ldflags "-s -w" cmd/main.go # use a minimal alpine image -FROM alpine:3.23.4 -RUN apk update --no-cache && \ -apk upgrade && \ -apk add busybox=1.37.0-r30 +FROM alpine:3.24.1 # make tcli available in path COPY --from=builder /go/src/tcli/bin/tcli /usr/local/bin/tcli