Skip to content

Commit 0431e4d

Browse files
committed
cli-plugins/hooks: rename HookType to ResponseType
Rename the type to match the struct it's used for. Also; - Fix the type of the NextSteps const - Don't use iota for values; the ResponseType is used as part of the "wire" format, which means that plugins using the value can use a different version of the module code; using iota increases the risk of (accidentally) changing values, which would break the wire format. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 607ebfc commit 0431e4d

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

cli-plugins/hooks/hook_types.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package hooks
22

3+
// ResponseType is the type of response from the plugin.
4+
type ResponseType int
5+
6+
const (
7+
NextSteps ResponseType = 0
8+
)
9+
310
// Request is the type representing the information
411
// that plugins declaring support for hooks get passed when
512
// being invoked following a CLI command execution.
@@ -18,10 +25,17 @@ type Request struct {
1825
// representation of this type when their hook subcommand
1926
// is invoked.
2027
type Response struct {
21-
Type HookType
28+
Type ResponseType
2229
Template string
2330
}
2431

32+
// HookType is the type of response from the plugin.
33+
//
34+
// Deprecated: use [ResponseType] instead.
35+
//
36+
//go:fix inline
37+
type HookType = ResponseType
38+
2539
// HookMessage represents a plugin hook response.
2640
//
2741
// Deprecated: use [Response] instead.

cli-plugins/hooks/template.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import (
1111
"github.com/spf13/cobra"
1212
)
1313

14-
type HookType int
15-
16-
const (
17-
NextSteps = iota
18-
)
19-
2014
// TemplateReplaceSubcommandName returns a hook template string
2115
// that will be replaced by the CLI subcommand being executed
2216
//

0 commit comments

Comments
 (0)