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

@@ -24,10 +24,11 @@ type Config struct {
GithubClientID string GithubClientID string
GithubClientSecret string GithubClientSecret string
UIDev bool UIDev bool
Env string Env string
Debug bool Debug bool
Swagger bool Swagger bool
SwaggerHost string
} }
var ( var (
@@ -52,6 +53,7 @@ func Load() (Config, error) {
v.SetDefault("env", "development") v.SetDefault("env", "development")
v.SetDefault("debug", false) v.SetDefault("debug", false)
v.SetDefault("swagger", false) v.SetDefault("swagger", false)
v.SetDefault("swagger.host", "localhost:8080")
// Env setup and binding // Env setup and binding
v.SetEnvKeyReplacer(strings.NewReplacer(".", "_")) v.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
@@ -73,6 +75,7 @@ func Load() (Config, error) {
"env", "env",
"debug", "debug",
"swagger", "swagger",
"swagger.host",
} }
for _, k := range keys { for _, k := range keys {
_ = v.BindEnv(k) _ = v.BindEnv(k)
@@ -92,10 +95,11 @@ func Load() (Config, error) {
GithubClientID: v.GetString("github.client.id"), GithubClientID: v.GetString("github.client.id"),
GithubClientSecret: v.GetString("github.client.secret"), GithubClientSecret: v.GetString("github.client.secret"),
UIDev: v.GetBool("ui.dev"), UIDev: v.GetBool("ui.dev"),
Env: v.GetString("env"), Env: v.GetString("env"),
Debug: v.GetBool("debug"), Debug: v.GetBool("debug"),
Swagger: v.GetBool("swagger"), Swagger: v.GetBool("swagger"),
SwaggerHost: v.GetString("swagger.host"),
} }
// Validate // Validate

View File

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

11
main.go
View File

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

View File

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