Skip to content

Commit c47e9ec

Browse files
committed
chore: fix lint issues
1 parent 2e607a0 commit c47e9ec

File tree

6 files changed

+33
-26
lines changed

6 files changed

+33
-26
lines changed

cmd/client.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ func loadClientConfig(cmd *cobra.Command, cmdxConfig *config.Loader) (*ClientCon
5858
if err := cmdxConfig.Load(
5959
&clientConfig,
6060
); err != nil {
61-
return nil, err
62-
61+
return nil, err
6362
}
6463

6564
return &clientConfig, nil

cmd/help.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,20 @@ package cmd
22

33
import (
44
"github.com/MakeNowJust/heredoc"
5+
"github.com/raystack/salt/cli/commander"
56
)
67

7-
var envHelp = map[string]string{
8-
"short": "List of supported environment variables",
9-
"long": heredoc.Doc(`
10-
RAYSTACK_CONFIG_DIR: the directory where stencil will store configuration files. Default:
11-
"$XDG_CONFIG_HOME/raystack" or "$HOME/.config/raystack".
8+
var envHelpTopics = []commander.HelpTopic{
9+
{
10+
Name: "environment",
11+
Short: "List of supported environment variables",
12+
Long: heredoc.Doc(`
13+
RAYSTACK_CONFIG_DIR: the directory where stencil will store configuration files. Default:
14+
"$XDG_CONFIG_HOME/raystack" or "$HOME/.config/raystack".
1215
13-
NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.
16+
NO_COLOR: set to any value to avoid printing ANSI escape sequences for color output.
1417
15-
CLICOLOR: set to "0" to disable printing ANSI colors in output.
16-
`),
18+
CLICOLOR: set to "0" to disable printing ANSI colors in output.
19+
`),
20+
},
1721
}

cmd/root.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,22 @@ func New() *cobra.Command {
4545
cmd.AddCommand(SchemaCmd(cdk))
4646
cmd.AddCommand(SearchCmd(cdk))
4747

48+
hooks := []commander.HookBehavior{
49+
{
50+
Name: "client",
51+
Behavior: func(cmd *cobra.Command) {
52+
cmd.PersistentFlags().String("host", "", "Server host address")
53+
},
54+
},
55+
}
56+
4857
// Help topics
49-
cmdr := commander.New(cmd)
58+
cmdr := commander.New(
59+
cmd,
60+
commander.WithTopics(envHelpTopics),
61+
commander.WithHooks(hooks),
62+
)
5063
cmdr.Init()
51-
// cmdx.SetHelp(cmd)
52-
// cmd.AddCommand(cmdx.SetCompletionCmd("stencil"))
53-
// cmd.AddCommand(cmdx.SetHelpTopicCmd("environment", envHelp))
54-
// cmd.AddCommand(cmdx.SetRefCmd(cmd))
55-
56-
// cmdx.SetClientHook(cmd, func(cmd *cobra.Command) {
57-
// // client config
58-
// cmd.PersistentFlags().String("host", "", "Server host address")
59-
// })
6064

6165
return cmd
6266
}

formats/json/compatibility.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func TypeCheckExecutor(spec TypeCheckSpec) SchemaCompareCheck {
127127
currTypes := currSchema.Types
128128
err := elementsMatch(prevTypes, currTypes) // special case of integer being allowed to changed to number is not respected due to additional code complexity
129129
if err != nil {
130-
diffs.add(subSchemaTypeModification, currSchema.Location, err.Error())
130+
diffs.add(subSchemaTypeModification, currSchema.Location, "%s", err.Error())
131131
return
132132
}
133133
if len(currTypes) == 0 {

formats/json/compatibility_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func checkRequiredProperties(prevSchema, currSchema *jsonschema.Schema, diffs *c
168168
currReqiredProperties := currSchema.Required
169169
err := elementsMatch(prevRequiredProperties, currReqiredProperties)
170170
if err != nil {
171-
diffs.add(requiredFieldChanged, currSchema.Location, err.Error())
171+
diffs.add(requiredFieldChanged, currSchema.Location, "%s", err.Error())
172172
}
173173
}
174174

internal/store/postgres/namespace_repository.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,25 @@ func NewNamespaceRepository(dbc *DB) *NamespaceRepository {
4444
func (r *NamespaceRepository) Create(ctx context.Context, ns namespace.Namespace) (namespace.Namespace, error) {
4545
newNamespace := namespace.Namespace{}
4646
err := pgxscan.Get(ctx, r.db, &newNamespace, namespaceInsertQuery, ns.ID, ns.Format, ns.Compatibility, ns.Description)
47-
return newNamespace, wrapError(err, ns.ID)
47+
return newNamespace, wrapError(err, "%s", ns.ID)
4848
}
4949

5050
func (r *NamespaceRepository) Update(ctx context.Context, ns namespace.Namespace) (namespace.Namespace, error) {
5151
newNamespace := namespace.Namespace{}
5252
err := pgxscan.Get(ctx, r.db, &newNamespace, namespaceUpdateQuery, ns.ID, ns.Format, ns.Compatibility, ns.Description)
53-
return newNamespace, wrapError(err, ns.ID)
53+
return newNamespace, wrapError(err, "%s", ns.ID)
5454
}
5555

5656
func (r *NamespaceRepository) Get(ctx context.Context, id string) (namespace.Namespace, error) {
5757
newNamespace := namespace.Namespace{}
5858
err := pgxscan.Get(ctx, r.db, &newNamespace, namespaceGetQuery, id)
59-
return newNamespace, wrapError(err, id)
59+
return newNamespace, wrapError(err, "%s", id)
6060
}
6161

6262
func (r *NamespaceRepository) Delete(ctx context.Context, id string) error {
6363
_, err := r.db.Exec(ctx, namespaceDeleteQuery, id)
6464
r.db.Exec(ctx, deleteOrphanedData)
65-
return wrapError(err, id)
65+
return wrapError(err, "%s", id)
6666
}
6767

6868
func (r *NamespaceRepository) List(ctx context.Context) ([]namespace.Namespace, error) {

0 commit comments

Comments
 (0)