Skip to content

Commit bae1f15

Browse files
authored
Merge pull request #13 from stacklok/upgrade-toolhive-v0.2.7
Upgrade github.com/stacklok/toolhive to v0.2.7
2 parents 92d42bb + d2bfc77 commit bae1f15

File tree

18 files changed

+1072
-176
lines changed

18 files changed

+1072
-176
lines changed

cmd/import-from-toolhive/main.go

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import (
1818
)
1919

2020
var (
21-
sourceURL string
22-
sourceFile string
23-
outputDir string
24-
verbose bool
25-
dryRun bool
21+
sourceURL string
22+
sourceFile string
23+
outputDir string
24+
verbose bool
25+
dryRun bool
2626
)
2727

2828
var rootCmd = &cobra.Command{
@@ -174,7 +174,7 @@ func importEntry(name string, server *toolhiveRegistry.ImageMetadata, outputDir
174174
# Import timestamp: %s
175175
# ---
176176
`, name, time.Now().UTC().Format(time.RFC3339))
177-
177+
178178
finalContent := header + string(yamlData)
179179

180180
// Write the spec.yaml file
@@ -207,26 +207,26 @@ func sanitizeName(name string) string {
207207
"\\", "-",
208208
)
209209
sanitized := replacer.Replace(name)
210-
210+
211211
// Convert to lowercase
212212
sanitized = strings.ToLower(sanitized)
213-
213+
214214
// Remove any remaining non-alphanumeric characters except hyphens
215215
var result strings.Builder
216216
for _, r := range sanitized {
217217
if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '-' {
218218
result.WriteRune(r)
219219
}
220220
}
221-
221+
222222
// Remove leading/trailing hyphens
223223
finalName := strings.Trim(result.String(), "-")
224-
224+
225225
// Collapse multiple hyphens into one
226226
for strings.Contains(finalName, "--") {
227227
finalName = strings.ReplaceAll(finalName, "--", "-")
228228
}
229-
229+
230230
return finalName
231231
}
232232

@@ -237,41 +237,41 @@ func shouldCreateReadme(server *toolhiveRegistry.ImageMetadata) bool {
237237

238238
func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string {
239239
var readme strings.Builder
240-
240+
241241
readme.WriteString(fmt.Sprintf("# %s\n\n", name))
242-
242+
243243
if server.Description != "" {
244244
readme.WriteString(fmt.Sprintf("%s\n\n", server.Description))
245245
}
246-
246+
247247
// Basic information section
248248
readme.WriteString("## Basic Information\n\n")
249-
249+
250250
if server.Image != "" {
251251
readme.WriteString(fmt.Sprintf("- **Image:** `%s`\n", server.Image))
252252
}
253-
253+
254254
if server.RepositoryURL != "" {
255255
readme.WriteString(fmt.Sprintf("- **Repository:** [%s](%s)\n", server.RepositoryURL, server.RepositoryURL))
256256
}
257-
257+
258258
if server.Tier != "" {
259259
readme.WriteString(fmt.Sprintf("- **Tier:** %s\n", server.Tier))
260260
}
261-
261+
262262
if server.Status != "" {
263263
readme.WriteString(fmt.Sprintf("- **Status:** %s\n", server.Status))
264264
}
265-
265+
266266
if server.Transport != "" {
267267
readme.WriteString(fmt.Sprintf("- **Transport:** %s\n", server.Transport))
268268
}
269-
269+
270270
// Tools section
271271
if len(server.Tools) > 0 {
272272
readme.WriteString("\n## Available Tools\n\n")
273273
readme.WriteString(fmt.Sprintf("This server provides %d tools:\n\n", len(server.Tools)))
274-
274+
275275
// Group tools in columns for better readability if there are many
276276
if len(server.Tools) > 10 {
277277
for i := 0; i < len(server.Tools); i += 3 {
@@ -289,11 +289,11 @@ func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string
289289
}
290290
}
291291
}
292-
292+
293293
// Environment Variables section
294294
if len(server.EnvVars) > 0 {
295295
readme.WriteString("\n## Environment Variables\n\n")
296-
296+
297297
// Separate required and optional
298298
var required, optional []*toolhiveRegistry.EnvVar
299299
for _, env := range server.EnvVars {
@@ -303,7 +303,7 @@ func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string
303303
optional = append(optional, env)
304304
}
305305
}
306-
306+
307307
if len(required) > 0 {
308308
readme.WriteString("### Required\n\n")
309309
for _, env := range required {
@@ -314,7 +314,7 @@ func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string
314314
readme.WriteString(fmt.Sprintf("- **%s**%s: %s\n", env.Name, secret, env.Description))
315315
}
316316
}
317-
317+
318318
if len(optional) > 0 {
319319
readme.WriteString("\n### Optional\n\n")
320320
for _, env := range optional {
@@ -329,7 +329,7 @@ func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string
329329
}
330330
}
331331
}
332-
332+
333333
// Tags section
334334
if len(server.Tags) > 0 {
335335
readme.WriteString("\n## Tags\n\n")
@@ -338,7 +338,7 @@ func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string
338338
}
339339
readme.WriteString("\n")
340340
}
341-
341+
342342
// Metadata section
343343
if server.Metadata != nil {
344344
readme.WriteString("\n## Statistics\n\n")
@@ -352,6 +352,6 @@ func generateReadme(name string, server *toolhiveRegistry.ImageMetadata) string
352352
readme.WriteString(fmt.Sprintf("- 🕐 Last Updated: %s\n", server.Metadata.LastUpdated))
353353
}
354354
}
355-
355+
356356
return readme.String()
357357
}

cmd/registry-builder/main.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strings"
1010

1111
"github.com/spf13/cobra"
12+
1213
"github.com/stacklok/toolhive-registry/pkg/registry"
1314
)
1415

@@ -44,14 +45,14 @@ var validateCmd = &cobra.Command{
4445
Use: "validate",
4546
Short: "Validate registry entries",
4647
Long: `Validate all registry entries without building the output files.`,
47-
RunE: runValidate,
48+
RunE: runValidate,
4849
}
4950

5051
var listCmd = &cobra.Command{
5152
Use: "list",
5253
Short: "List all registry entries",
5354
Long: `List all registry entries found in the registry directory.`,
54-
RunE: runList,
55+
RunE: runList,
5556
}
5657

5758
var versionCmd = &cobra.Command{
@@ -114,7 +115,7 @@ func runBuild(cmd *cobra.Command, args []string) error {
114115

115116
// Determine which formats to build
116117
formats := determineFormats(outputFormat)
117-
118+
118119
// Build each format
119120
var builtFormats []string
120121
for _, format := range formats {
@@ -210,7 +211,7 @@ func runValidate(cmd *cobra.Command, args []string) error {
210211
}
211212

212213
entries := loader.GetEntries()
213-
214+
214215
// Create builder for validation
215216
builder := registry.NewBuilder(loader)
216217

@@ -241,15 +242,15 @@ func runList(cmd *cobra.Command, args []string) error {
241242
}
242243

243244
entries := loader.GetSortedEntries()
244-
245+
245246
fmt.Printf("Found %d registry entries:\n\n", len(entries))
246-
247+
247248
for _, entry := range entries {
248249
status := entry.Status
249250
if status == "" {
250251
status = "Active"
251252
}
252-
253+
253254
tier := entry.Tier
254255
if tier == "" {
255256
tier = "Community"

0 commit comments

Comments
 (0)