From da958da7506c52c2a10f6582772ec4334ca61f73 Mon Sep 17 00:00:00 2001 From: Dayuan Date: Wed, 21 Feb 2024 15:24:38 +0800 Subject: [PATCH] refactor: split types in the v1/types.go to separate files to maintain consistency with the coding style of the rest of the code --- pkg/apis/core/v1/{types.go => project.go} | 40 +++++------------------ pkg/apis/core/v1/stack.go | 17 ++++++++++ 2 files changed, 25 insertions(+), 32 deletions(-) rename pkg/apis/core/v1/{types.go => project.go} (62%) create mode 100644 pkg/apis/core/v1/stack.go diff --git a/pkg/apis/core/v1/types.go b/pkg/apis/core/v1/project.go similarity index 62% rename from pkg/apis/core/v1/types.go rename to pkg/apis/core/v1/project.go index 9c69dfdcf..1a880ba36 100644 --- a/pkg/apis/core/v1/types.go +++ b/pkg/apis/core/v1/project.go @@ -9,29 +9,6 @@ const ( AppConfigurationBuilder BuilderType = "AppConfiguration" ) -// Project is a definition of Kusion Project resource. -// -// A project is composed of one or more applications and is linked to a Git repository, -// which contains the project's desired manifests. -type Project struct { - // Name is a required fully qualified name. - Name string `json:"name" yaml:"name"` - - // Description is an optional informational description. - Description *string `json:"description,omitempty" yaml:"description,omitempty"` - // Labels is the list of labels that are assigned to this project. - Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` - - // Path is a directory path within the Git repository. - Path string `json:"path,omitempty" yaml:"path,omitempty"` - - // Generator controls how to generate the Intent. - Generator *GeneratorConfig `json:"generator,omitempty" yaml:"generator,omitempty"` - - // The set of stacks that are known about this project. - Stacks []*Stack `json:"stacks,omitempty" yaml:"stacks,omitempty"` -} - // GeneratorConfig holds the intent generation configurations defined in Project resource. type GeneratorConfig struct { // Type specifies the type of Generator. can be either "KCL" or "AppConfiguration". @@ -40,20 +17,19 @@ type GeneratorConfig struct { Configs map[string]interface{} `json:"configs,omitempty" yaml:"configs,omitempty"` } -// Stack is a definition of Kusion Stack resource. -// -// Stack provides a mechanism to isolate multiple deploys of same application, -// it's the target workspace that an application will be deployed to, also the -// smallest operation unit that can be configured and deployed independently. -type Stack struct { +// Project is a definition of Kusion Project resource. +// A project is composed of one or more applications and is linked to a Git repository, which contains the project's desired manifests. +type Project struct { // Name is a required fully qualified name. Name string `json:"name" yaml:"name"` - // Description is an optional informational description. Description *string `json:"description,omitempty" yaml:"description,omitempty"` - // Labels is the list of labels that are assigned to this stack. + // Labels is the list of labels that are assigned to this project. Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` - // Path is a directory path within the Git repository. Path string `json:"path,omitempty" yaml:"path,omitempty"` + // Generator controls how to generate the Intent. + Generator *GeneratorConfig `json:"generator,omitempty" yaml:"generator,omitempty"` + // The set of stacks that are known about this project. + Stacks []*Stack `json:"stacks,omitempty" yaml:"stacks,omitempty"` } diff --git a/pkg/apis/core/v1/stack.go b/pkg/apis/core/v1/stack.go new file mode 100644 index 000000000..fa9219741 --- /dev/null +++ b/pkg/apis/core/v1/stack.go @@ -0,0 +1,17 @@ +package v1 + +// Stack is a definition of Kusion Stack resource. +// +// Stack provides a mechanism to isolate multiple deploys of same application, +// it's the target workspace that an application will be deployed to, also the +// smallest operation unit that can be configured and deployed independently. +type Stack struct { + // Name is a required fully qualified name. + Name string `json:"name" yaml:"name"` + // Description is an optional informational description. + Description *string `json:"description,omitempty" yaml:"description,omitempty"` + // Labels is the list of labels that are assigned to this stack. + Labels map[string]string `json:"labels,omitempty" yaml:"labels,omitempty"` + // Path is a directory path within the Git repository. + Path string `json:"path,omitempty" yaml:"path,omitempty"` +}