Skip to content

Commit

Permalink
feat: refactor response struct
Browse files Browse the repository at this point in the history
  • Loading branch information
ffforest committed Nov 28, 2023
1 parent 39dc419 commit 8cde216
Show file tree
Hide file tree
Showing 13 changed files with 407 additions and 183 deletions.
8 changes: 4 additions & 4 deletions pkg/apis/search/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&TransformRuleList{},
&UniResource{},
&UniResourceList{},
&UniresourceTopology{},
&UniresourceTopologyList{},
&UniresourceYAML{},
&UniresourceYAMLList{},
&UniResourceTopology{},
&UniResourceTopologyList{},
&UniResourceYAML{},
&UniResourceYAMLList{},
)
return nil
}
26 changes: 18 additions & 8 deletions pkg/apis/search/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,16 @@ type ResourceSyncCondition struct {

type UniResource struct {
metav1.TypeMeta
Topology UniresourceTopology
YAML UniresourceYAML
Topology UniResourceTopology
YAML UniResourceYAML
}

// +k8s:deepcopy-gen=true

type UniresourceNode struct {
Identifier string
Parents []string
Children []string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -195,25 +203,27 @@ type UniResourceList struct {

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type UniresourceTopology struct {
type UniResourceTopology struct {
metav1.TypeMeta
Graph map[string]UniresourceNode
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type UniresourceTopologyList struct {
type UniResourceTopologyList struct {
metav1.TypeMeta
Items []UniresourceTopology
Items []UniResourceTopology
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type UniresourceYAML struct {
type UniResourceYAML struct {
metav1.TypeMeta
YAMLString string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type UniresourceYAMLList struct {
type UniResourceYAMLList struct {
metav1.TypeMeta
Items []UniresourceYAML
Items []UniResourceYAML
}
8 changes: 4 additions & 4 deletions pkg/apis/search/v1beta1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&TransformRuleList{},
&UniResource{},
&UniResourceList{},
&UniresourceTopology{},
&UniresourceTopologyList{},
&UniresourceYAML{},
&UniresourceYAMLList{},
&UniResourceTopology{},
&UniResourceTopologyList{},
&UniResourceYAML{},
&UniResourceYAMLList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
Expand Down
26 changes: 18 additions & 8 deletions pkg/apis/search/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ type ResourceSyncCondition struct {

type UniResource struct {
metav1.TypeMeta `json:",inline"`
Topology UniresourceTopology
YAML UniresourceYAML
Topology UniResourceTopology
YAML UniResourceYAML
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
Expand All @@ -230,27 +230,37 @@ type UniResourceList struct {
Items []runtime.RawExtension `json:"items"`
}

// +k8s:deepcopy-gen=true

type UniresourceNode struct {
Identifier string
Parents []string
Children []string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type UniresourceTopology struct {
type UniResourceTopology struct {
metav1.TypeMeta
Graph map[string]UniresourceNode
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type UniresourceTopologyList struct {
type UniResourceTopologyList struct {
metav1.TypeMeta
Items []UniresourceTopology
Items []UniResourceTopology
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type UniresourceYAML struct {
type UniResourceYAML struct {
metav1.TypeMeta
YAMLString string
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type UniresourceYAMLList struct {
type UniResourceYAMLList struct {
metav1.TypeMeta
Items []UniresourceYAML
Items []UniResourceYAML
}
150 changes: 94 additions & 56 deletions pkg/apis/search/v1beta1/zz_generated.conversion.go

Large diffs are not rendered by default.

83 changes: 59 additions & 24 deletions pkg/apis/search/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8cde216

Please sign in to comment.