Files
kubeviz/internal/model/model.go
Clemens Hering 1a0bbe9dfd
Some checks failed
Deploy KubeViz / deploy (push) Has been cancelled
Teststand
2026-03-01 07:40:49 +01:00

122 lines
3.7 KiB
Go

package model
import "time"
// Resource represents a normalized Kubernetes manifest.
type Resource struct {
ID string `json:"id"`
APIVersion string `json:"apiVersion"`
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace"`
ClusterScoped bool `json:"clusterScoped"`
Labels map[string]string `json:"labels,omitempty"`
Raw map[string]any `json:"raw"`
IsSensitive bool `json:"isSensitive"`
KeyNames []string `json:"keyNames,omitempty"`
References []ResourceReference `json:"references,omitempty"`
OwnerRefs []OwnerReference `json:"ownerReferences,omitempty"`
WorkloadMeta *WorkloadMetadata `json:"workloadMeta,omitempty"`
CreatedAt time.Time `json:"createdAt"`
}
type ResourceReference struct {
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
Relation string `json:"relation"`
}
type OwnerReference struct {
Kind string `json:"kind"`
Name string `json:"name"`
}
type WorkloadMetadata struct {
PodTemplateLabels map[string]string `json:"podTemplateLabels,omitempty"`
ServiceSelectors map[string]string `json:"serviceSelectors,omitempty"`
}
type ParseIssue struct {
Document int `json:"document"`
Message string `json:"message"`
}
type ParseSummary struct {
Resources int `json:"resources"`
Issues []ParseIssue `json:"issues"`
}
type Dataset struct {
Resources map[string]*Resource `json:"resources"`
Summary ParseSummary `json:"summary"`
Duplicates []string `json:"duplicates,omitempty"`
CreatedAt time.Time `json:"createdAt"`
ModifiedAt time.Time `json:"modifiedAt"`
}
type GraphNode struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace"`
Labels map[string]string `json:"labels,omitempty"`
HealthHint string `json:"healthHint,omitempty"`
IsSensitive bool `json:"isSensitive"`
IsGroup bool `json:"isGroup,omitempty"`
GroupBy string `json:"groupBy,omitempty"`
GroupKey string `json:"groupKey,omitempty"`
MemberCount int `json:"memberCount,omitempty"`
}
type GraphEdge struct {
Source string `json:"source"`
Target string `json:"target"`
RelationType string `json:"relationType"`
Label string `json:"label,omitempty"`
}
type GraphStats struct {
TotalNodes int `json:"totalNodes"`
TotalEdges int `json:"totalEdges"`
Kinds map[string]int `json:"kinds"`
}
type GraphResponse struct {
Nodes []GraphNode `json:"nodes"`
Edges []GraphEdge `json:"edges"`
Stats GraphStats `json:"stats"`
Groups []GraphGroup `json:"groups,omitempty"`
Findings []Finding `json:"findings,omitempty"`
}
type GraphGroup struct {
Key string `json:"key"`
Label string `json:"label"`
Mode string `json:"mode"`
Count int `json:"count"`
Collapsed bool `json:"collapsed"`
}
type Finding struct {
ID string `json:"id"`
Category string `json:"category"`
Rule string `json:"rule"`
Severity string `json:"severity"`
ResourceID string `json:"resourceId,omitempty"`
Message string `json:"message"`
}
type DiffItem struct {
ID string `json:"id"`
Kind string `json:"kind"`
Name string `json:"name"`
Namespace string `json:"namespace,omitempty"`
}
type DiffResponse struct {
Added []DiffItem `json:"added"`
Removed []DiffItem `json:"removed"`
Changed []DiffItem `json:"changed"`
}