@@ -268,7 +268,8 @@ const (
268268 FieldHealthPolicy = "healthPolicy"
269269 FieldKCLHealthCheckKCL = "health.kcl"
270270 // kind field in kubernetes resource Attributes
271- FieldKind = "kind"
271+ FieldKind = "kind"
272+ FieldIsWorkload = "kusion.io/is-workload"
272273)
273274
274275// BackendConfigs contains the configuration of multiple backends and the current backend.
@@ -744,3 +745,59 @@ const (
744745 // The default maximum number of concurrent resource executions for Kusion is 10.
745746 DefaultMaxConcurrent = 10
746747)
748+
749+ type Status string
750+
751+ // Status is to represent resource status displayed by resource graph after apply succeed
752+ const (
753+ ApplySucceed Status = "Apply succeeded"
754+ ApplyFail Status = "Apply failed"
755+ Reconciled Status = "Apply succeeded | Reconciled"
756+ ReconcileFail Status = "Apply succeeded | Reconcile failed"
757+ )
758+
759+ // Graph represents the structure of a project's resources within a workspace, used by `resource graph` command.
760+ type Graph struct {
761+ // Name of the project
762+ Project string `yaml:"Project" json:"Project"`
763+ // Name of the workspace where the app is deployed
764+ Workspace string `yaml:"Workspace" json:"Workspace"`
765+ // All the resources related to the app
766+ Resources * GraphResources `yaml:"Resources" json:"Resources"`
767+ }
768+
769+ // GraphResources defines the categorized resources related to the application.
770+ type GraphResources struct {
771+ // WorkloadResources contains the resources that are directly related to the workload.
772+ WorkloadResources map [string ]* GraphResource `yaml:"WorkloadResources" json:"WorkloadResources"`
773+ // DependencyResources stores resources that are required dependencies for the workload.
774+ DependencyResources map [string ]* GraphResource `yaml:"DependencyResources" json:"DependencyResources"`
775+ // OtherResources holds independent resources that are not directly tied to workloads or dependencies.
776+ OtherResources map [string ]* GraphResource `yaml:"OtherResources" json:"OtherResources"`
777+ // ResourceIndex is a global mapping of resource IDs to their corresponding resource entries.
778+ ResourceIndex map [string ]* ResourceEntry `yaml:"ResourceIndex,omitempty" json:"ResourceIndex,omitempty"`
779+ }
780+
781+ // GraphResource represents an individual resource in the cluster.
782+ type GraphResource struct {
783+ // ID refers to Resource ID.
784+ ID string `yaml:"ID" json:"ID"`
785+ // Type refers to Resource Type in the cluster.
786+ Type string `yaml:"Type" json:"Type"`
787+ // Name refers to Resource name in the cluster.
788+ Name string `yaml:"Name" json:"Name"`
789+ // CloudResourceID refers to Resource ID in the cloud provider.
790+ CloudResourceID string `yaml:"CloudResourceID" json:"CloudResourceID"`
791+ // Resource status after apply.
792+ Status Status `yaml:"Status" json:"Status"`
793+ // Dependents lists the resources that depend on this resource.
794+ Dependents []string `yaml:"Dependents" json:"Dependents"`
795+ // Dependencies lists the resources that this resource relies upon.
796+ Dependencies []string `yaml:"Dependencies" json:"Dependencies"`
797+ }
798+
799+ // ResourceEntry stores a GraphResource and its associated Resource mapping.
800+ type ResourceEntry struct {
801+ Resource * GraphResource
802+ Category map [string ]* GraphResource
803+ }
0 commit comments