Skip to content

Commit

Permalink
refactor: split types in the v1/types.go to separate files to maintai…
Browse files Browse the repository at this point in the history
…n consistency with the coding style of the rest of the code
  • Loading branch information
SparkYuan committed Feb 21, 2024
1 parent e795868 commit da958da
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 32 deletions.
40 changes: 8 additions & 32 deletions pkg/apis/core/v1/types.go → pkg/apis/core/v1/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand All @@ -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"`
}
17 changes: 17 additions & 0 deletions pkg/apis/core/v1/stack.go
Original file line number Diff line number Diff line change
@@ -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"`
}

0 comments on commit da958da

Please sign in to comment.