Skip to content

Commit bd36ceb

Browse files
committed
Automated lint fixes
Signed-off-by: Juan Antonio Osorio <[email protected]>
1 parent 162bcd0 commit bd36ceb

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

cmd/update-tools/main.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func runUpdate(_ *cobra.Command, args []string) error {
8484
newTools, err := fetchToolsFromMCP(serverName)
8585
if err != nil {
8686
logger.Warnf("Failed to fetch tools from MCP server: %v", err)
87-
87+
8888
if len(currentTools) > 0 && addWarnings {
8989
if !dryRun {
9090
if err := toolhive.AddWarningComment(specPath, "Tool list fetch failed", "Manual verification may be required"); err != nil {
@@ -103,7 +103,7 @@ func runUpdate(_ *cobra.Command, args []string) error {
103103
if len(newTools) == 0 && len(currentTools) > 0 {
104104
logger.Warnf("No tools detected but spec file had %d tools previously", len(currentTools))
105105
logger.Info("Keeping existing tools list")
106-
106+
107107
if addWarnings {
108108
if !dryRun {
109109
if err := toolhive.AddWarningComment(specPath, "Tool list could not be auto-updated", "Please verify the tools list manually"); err != nil {
@@ -209,40 +209,40 @@ func showDetailedDiff(current, new []string) {
209209
func showSummaryDiff(current, new []string) {
210210
currentSet := make(map[string]bool)
211211
newSet := make(map[string]bool)
212-
212+
213213
for _, t := range current {
214214
currentSet[t] = true
215215
}
216216
for _, t := range new {
217217
newSet[t] = true
218218
}
219-
219+
220220
// Find added tools
221221
var added []string
222222
for t := range newSet {
223223
if !currentSet[t] {
224224
added = append(added, t)
225225
}
226226
}
227-
227+
228228
// Find removed tools
229229
var removed []string
230230
for t := range currentSet {
231231
if !newSet[t] {
232232
removed = append(removed, t)
233233
}
234234
}
235-
235+
236236
sort.Strings(added)
237237
sort.Strings(removed)
238-
238+
239239
if len(added) > 0 {
240240
logger.Infof(" Added tools (%d):", len(added))
241241
for _, t := range added {
242242
logger.Infof(" + %s", t)
243243
}
244244
}
245-
245+
246246
if len(removed) > 0 {
247247
logger.Infof(" Removed tools (%d):", len(removed))
248248
for _, t := range removed {

pkg/toolhive/builder.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ func (b *CommandBuilder) Build() []string {
5757
func BuildRunCommand(spec *types.RegistryEntry, tempName, image string) []string {
5858
builder := NewCommandBuilder("run")
5959
builder.AddFlag("--name", tempName)
60-
60+
6161
if spec.ImageMetadata != nil {
6262
// Add transport
6363
builder.AddFlag("--transport", spec.ImageMetadata.Transport)
64-
64+
6565
// Add environment variables
6666
if spec.ImageMetadata.EnvVars != nil {
6767
for _, envVar := range spec.ImageMetadata.EnvVars {
@@ -75,15 +75,15 @@ func BuildRunCommand(spec *types.RegistryEntry, tempName, image string) []string
7575
}
7676
}
7777
}
78-
78+
7979
// Add permission profile
80-
if spec.ImageMetadata.Permissions != nil && spec.ImageMetadata.Permissions.Network != nil {
80+
if spec.Permissions != nil && spec.Permissions.Network != nil {
8181
builder.AddFlag("--permission-profile", "network")
8282
}
8383
}
84-
84+
8585
// Add the image as the last positional argument
8686
builder.AddPositional(image)
87-
87+
8888
return builder.Build()
89-
}
89+
}

pkg/toolhive/client.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"time"
99

1010
"github.com/stacklok/toolhive/pkg/logger"
11+
1112
"github.com/stacklok/toolhive-registry/pkg/types"
1213
)
1314

@@ -27,7 +28,7 @@ func NewClient(thvPath string, verbose bool) (*Client, error) {
2728
return nil, fmt.Errorf("thv binary not found in PATH: %w", err)
2829
}
2930
}
30-
31+
3132
return &Client{
3233
thvPath: thvPath,
3334
verbose: verbose,
@@ -58,11 +59,11 @@ func (c *Client) RunServer(spec *types.RegistryEntry, serverName string) (string
5859
// Build the run command
5960
tempName := fmt.Sprintf("temp-%s-%d", serverName, time.Now().Unix())
6061
runArgs := BuildRunCommand(spec, tempName, image)
61-
62+
6263
if c.verbose {
6364
logger.Debugf("Running command: thv %s", strings.Join(runArgs, " "))
6465
}
65-
66+
6667
runCmd := exec.Command(c.thvPath, runArgs...)
6768
runOutput, err := runCmd.CombinedOutput()
6869
if err != nil {
@@ -71,7 +72,7 @@ func (c *Client) RunServer(spec *types.RegistryEntry, serverName string) (string
7172

7273
// Give the server time to start
7374
time.Sleep(5 * time.Second)
74-
75+
7576
return tempName, nil
7677
}
7778

@@ -83,7 +84,7 @@ func (c *Client) ListTools(serverName string) ([]string, error) {
8384
AddFlag("--server", serverName).
8485
AddFlag("--format", "json").
8586
Build()
86-
87+
8788
listCmd := exec.Command(c.thvPath, listArgs...)
8889
output, err := listCmd.CombinedOutput()
8990
if err != nil {

pkg/toolhive/parser.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ func ParseToolsJSON(output string) ([]string, error) {
3232
return ParseToolsText(output)
3333
}
3434
jsonOutput := output[jsonStart:]
35-
35+
3636
var result MCPListOutput
3737
if err := json.Unmarshal([]byte(jsonOutput), &result); err != nil {
3838
logger.Debugf("Failed to parse JSON output: %v", err)
3939
// Fallback to text parsing
4040
return ParseToolsText(output)
4141
}
42-
42+
4343
var tools []string
4444
for _, tool := range result.Tools {
4545
tools = append(tools, tool.Name)
4646
}
47-
47+
4848
// Sort tools alphabetically
4949
sort.Strings(tools)
50-
50+
5151
return tools, nil
5252
}
5353

@@ -60,19 +60,19 @@ func ParseToolsText(output string) ([]string, error) {
6060
scanner := bufio.NewScanner(strings.NewReader(output))
6161
for scanner.Scan() {
6262
line := scanner.Text()
63-
63+
6464
// Look for TOOLS: section
6565
if strings.HasPrefix(line, "TOOLS:") {
6666
foundToolsSection = true
6767
continue
6868
}
69-
69+
7070
// Skip the NAME/DESCRIPTION header
7171
if foundToolsSection && strings.HasPrefix(line, "NAME") {
7272
foundHeader = true
7373
continue
7474
}
75-
75+
7676
// Extract tool names (first column)
7777
if foundToolsSection && foundHeader && len(line) > 0 {
7878
// Split by whitespace and get the first field
@@ -89,6 +89,6 @@ func ParseToolsText(output string) ([]string, error) {
8989

9090
// Sort tools alphabetically
9191
sort.Strings(tools)
92-
92+
9393
return tools, nil
94-
}
94+
}

pkg/toolhive/spec.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func updateToolsInNode(node *yaml.Node, tools []string) error {
6565
Kind: yaml.SequenceNode,
6666
Content: make([]*yaml.Node, 0, len(tools)),
6767
}
68-
68+
6969
for _, tool := range tools {
7070
toolsNode.Content = append(toolsNode.Content, &yaml.Node{
7171
Kind: yaml.ScalarNode,
@@ -105,14 +105,14 @@ func AddWarningComment(path, warning, detail string) error {
105105
lines := bytes.Split(data, []byte("\n"))
106106
var output bytes.Buffer
107107
warningAdded := false
108-
108+
109109
for i, line := range lines {
110110
// Write existing line
111111
if i > 0 {
112112
output.WriteByte('\n')
113113
}
114114
output.Write(line)
115-
115+
116116
// Add warning after initial comments but before content
117117
if !warningAdded && !bytes.HasPrefix(bytes.TrimSpace(line), []byte("#")) && len(bytes.TrimSpace(line)) > 0 {
118118
// Insert warning before this line
@@ -127,11 +127,11 @@ func AddWarningComment(path, warning, detail string) error {
127127
}
128128
output.WriteByte('\n')
129129
}
130-
130+
131131
// Add warning
132132
output.WriteString(fmt.Sprintf("# WARNING: %s on %s\n", warning, time.Now().Format("2006-01-02")))
133133
output.WriteString(fmt.Sprintf("# %s\n", detail))
134-
134+
135135
// Write current line
136136
output.Write(line)
137137
warningAdded = true
@@ -140,4 +140,4 @@ func AddWarningComment(path, warning, detail string) error {
140140

141141
// Write back to file
142142
return os.WriteFile(path, output.Bytes(), 0644)
143-
}
143+
}

0 commit comments

Comments
 (0)