Add Certificates page and Traefik API frontend client

This commit is contained in:
backup 2026-09-02 12:42:52 -05:00
commit 7fc90524b5
40 changed files with 6585 additions and 359 deletions

View file

@ -355,4 +355,92 @@ func (m *MockClient) GetOverview(ctx context.Context) (*models.Overview, error)
func ptr[T any](v T) *T {
return &v
}
}
// MockAPIClient implements the new TraefikAPI interface with v3.7 types
type MockAPIClient struct{}
func NewMockAPIClient() *MockAPIClient { return &MockAPIClient{} }
func (m *MockAPIClient) GetHealthz(ctx context.Context) (*HealthResponse, error) {
return &HealthResponse{Status: "OK", Version: "3.7.0"}, nil
}
func (m *MockAPIClient) GetOverview(ctx context.Context) (*Overview, error) {
return &Overview{
HTTP: struct {
Routers Section `json:"routers"`
Services Section `json:"services"`
Middlewares Section `json:"middlewares"`
}{
Routers: Section{Total: 4, Warnings: 0, Errors: 1},
Services: Section{Total: 5, Warnings: 1, Errors: 0},
Middlewares: Section{Total: 5, Warnings: 0, Errors: 0},
},
TCP: struct {
Routers Section `json:"routers"`
Services Section `json:"services"`
Middlewares Section `json:"middlewares"`
}{
Routers: Section{Total: 0, Warnings: 0, Errors: 0},
Services: Section{Total: 0, Warnings: 0, Errors: 0},
Middlewares: Section{Total: 0, Warnings: 0, Errors: 0},
},
UDP: struct {
Routers Section `json:"routers"`
Services Section `json:"services"`
}{
Routers: Section{Total: 0, Warnings: 0, Errors: 0},
Services: Section{Total: 0, Warnings: 0, Errors: 0},
},
Providers: []string{"docker", "file", "internal"},
TotalRouters: 4,
TotalServices: 5,
TotalMiddlewares: 5,
TraefikVersion: "3.7.0",
TraefikCodename: "lascaux",
}, nil
}
func (m *MockAPIClient) GetEntrypoints(ctx context.Context) ([]Entrypoint, error) {
return []Entrypoint{
{Name: "web", Address: ":80"},
{Name: "websecure", Address: ":443"},
{Name: "traefik", Address: ":8080"},
}, nil
}
func (m *MockAPIClient) GetRouters(ctx context.Context) ([]Router, error) {
return []Router{
{Name: "api@internal", Provider: "internal", Rule: "PathPrefix(`/api`)", EntryPoints: []string{"traefik"}, Service: "api@internal", Status: "enabled"},
{Name: "web@docker", Provider: "docker", Rule: "Host(`web.example.com`)", EntryPoints: []string{"web"}, Service: "web@docker", Status: "enabled"},
}, nil
}
func (m *MockAPIClient) GetServices(ctx context.Context) ([]Service, error) {
return []Service{
{Name: "web@docker", Provider: "docker", Type: "loadbalancer", Status: "enabled", Middlewares: []string{"auth@docker"}},
{Name: "api@internal", Provider: "internal", Type: "loadbalancer", Status: "enabled"},
}, nil
}
func (m *MockAPIClient) GetMiddlewares(ctx context.Context) ([]Middleware, error) {
return []Middleware{
{Name: "auth@docker", Provider: "docker", Type: "forwardAuth", Status: "enabled"},
}, nil
}
func (m *MockAPIClient) GetProviders(ctx context.Context) ([]Provider, error) {
return []Provider{{Name: "docker"}, {Name: "file"}, {Name: "internal"}}, nil
}
func (m *MockAPIClient) GetCertificates(ctx context.Context) ([]Certificate, error) {
now := time.Now()
return []Certificate{
{Store: "default", Names: []string{"example.com"}, SANs: []string{"example.com"}, Issuer: "CN=Test CA", NotAfter: now.Add(24 * time.Hour), NotBefore: now.Add(-24 * time.Hour), SerialNumber: "1"},
{Store: "default", Names: []string{"expired.com"}, SANs: []string{"expired.com"}, Issuer: "CN=Test CA", NotAfter: now.Add(-24 * time.Hour), NotBefore: now.Add(-48 * time.Hour), SerialNumber: "2"},
}, nil
}
var _ TraefikAPI = (*MockAPIClient)(nil)
var _ TraefikAPI = (*Client)(nil)