feat: dynamically set swagger host, and some ui improvements on ssh page

This commit is contained in:
allanice001
2025-11-06 05:52:06 +00:00
parent 7dc7d1a1f1
commit 12f2c5e1c5
4 changed files with 40 additions and 29 deletions

View File

@@ -28,6 +28,7 @@ type Config struct {
Env string
Debug bool
Swagger bool
SwaggerHost string
}
var (
@@ -52,6 +53,7 @@ func Load() (Config, error) {
v.SetDefault("env", "development")
v.SetDefault("debug", false)
v.SetDefault("swagger", false)
v.SetDefault("swagger.host", "localhost:8080")
// Env setup and binding
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
@@ -73,6 +75,7 @@ func Load() (Config, error) {
"env",
"debug",
"swagger",
"swagger.host",
}
for _, k := range keys {
_ = v.BindEnv(k)
@@ -96,6 +99,7 @@ func Load() (Config, error) {
Env: v.GetString("env"),
Debug: v.GetBool("debug"),
Swagger: v.GetBool("swagger"),
SwaggerHost: v.GetString("swagger.host"),
}
// Validate

View File

@@ -62,6 +62,9 @@ func ListPublicSshKeys(db *gorm.DB) http.HandlerFunc {
return
}
if out == nil {
out = []dto.SshResponse{}
}
utils.WriteJSON(w, http.StatusOK, out)
}
}

11
main.go
View File

@@ -1,6 +1,12 @@
package main
import "github.com/glueops/autoglue/cmd"
import (
"os"
"github.com/glueops/autoglue/cmd"
"github.com/glueops/autoglue/docs"
"github.com/joho/godotenv"
)
// @title AutoGlue API
// @version 1.0
@@ -10,7 +16,6 @@ import "github.com/glueops/autoglue/cmd"
// @BasePath /api/v1
// @schemes http https
// @host localhost:8080
// @securityDefinitions.apikey BearerAuth
// @in header
@@ -33,5 +38,7 @@ import "github.com/glueops/autoglue/cmd"
// @description Org-level secret
func main() {
_ = godotenv.Load()
docs.SwaggerInfo.Host = os.Getenv("SWAGGER_HOST")
cmd.Execute()
}

View File

@@ -307,7 +307,7 @@ export const SshPage = () => {
<TableHeader>
<TableRow>
<TableHead>Name</TableHead>
<TableHead className="min-w-[360px]">Public Key</TableHead>
<TableHead>Public Key</TableHead>
<TableHead>Fingerprint</TableHead>
<TableHead>Created</TableHead>
<TableHead className="w-[160px] text-right">Actions</TableHead>
@@ -320,14 +320,12 @@ export const SshPage = () => {
return (
<TableRow key={k.id}>
<TableCell className="font-medium">{k.name || "—"}</TableCell>
<TableCell className="max-w-[560px] truncate">
<div className="flex items-start gap-2">
<TableCell>
<Tooltip>
<TooltipTrigger asChild>
<Badge variant="secondary" className="whitespace-nowrap">
{keyType}
</Badge>
<Tooltip>
<TooltipTrigger asChild>
<span className="font-mono text-xs">{truncated}</span>
</TooltipTrigger>
<TooltipContent className="max-w-[70vw]">
<div className="max-w-full">
@@ -335,7 +333,6 @@ export const SshPage = () => {
</div>
</TooltipContent>
</Tooltip>
</div>
</TableCell>
<TableCell className="font-mono text-xs">{k.fingerprint}</TableCell>
<TableCell>
@@ -352,14 +349,14 @@ export const SshPage = () => {
<TableCell className="space-x-2 text-right">
<Button
size="sm"
variant="ghost"
variant="outline"
onClick={() => copy(k.public_key ?? "", "Public key copied")}
>
Copy Pub
</Button>
<Button
size="sm"
variant="ghost"
variant="outline"
onClick={() => copy(k.fingerprint ?? "", "Fingerprint copied")}
>
Copy FP