Skip to content

Commit

Permalink
Merge remote-tracking branch 'github/main' into refactor/engine
Browse files Browse the repository at this point in the history
# Conflicts:
#	pkg/engine/operation/models/change.go
#	pkg/engine/operation/models/change_test.go
#	pkg/engine/operation/preview.go
#	pkg/engine/operation/preview_test.go
#	pkg/engine/operation/resource_node.go
#	pkg/engine/operation/types.go
#	pkg/kusionctl/cmd/apply/options.go
#	pkg/kusionctl/cmd/apply/options_test.go
#	pkg/kusionctl/cmd/destroy/options.go
#	pkg/kusionctl/cmd/destroy/options_test.go
  • Loading branch information
SparkYuan committed Jun 17, 2022
2 parents ad7ccde + 6c6b761 commit 35f2b9e
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 84 deletions.
14 changes: 7 additions & 7 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# @global-owner1 and @global-owner2 will be requested for
# review when someone opens a pull request.
# * @global-owner1 @global-owner2
* @elliotxx @howieyuen @SparkYuan @markliby
* @KusionStack/kusion-cli-dev @KusionStack/kusion-engine-dev @KusionStack/go-reviewer

# Order is important; the last matching pattern takes the most
# precedence. When someone opens a pull request that only
Expand All @@ -24,14 +24,14 @@
# explicit write access to the repository. In this example,
# the octocats team in the octo-org organization owns all .txt files.
# *.txt @octo-org/octocats
*.go @KusionStack/kusion-dev
*.go @KusionStack/go-reviewer

# In this example, @doctocat owns any files in the build/logs
# directory at the root of the repository and any of its
# subdirectories.
# /build/logs/ @doctocat
/.github/ @elliotxx @howieyuen @SparkYuan @markliby
/pkg/engine/ @SparkYuan @markliby
/.github/ @KusionStack/ci-reviewer
/pkg/engine/ @KusionStack/kusion-engine-dev

# The `docs/*` pattern will match files like
# `docs/getting-started.md` but not further nested files like
Expand All @@ -46,15 +46,15 @@
# directory in the root of your repository and any of its
# subdirectories.
# /docs/ @doctocat
/docs/ @elliotxx @howieyuen
/docs/ @KusionStack/kusion-cli-dev @KusionStack/kusion-engine-dev

# In this example, any change inside the `/scripts` directory
# will require approval from @doctocat or @octocat.
# /scripts/ @doctocat @octocat
/scripts/ @elliotxx
/scripts/ @KusionStack/ci-reviewer

# In this example, @octocat owns any file in the `/apps`
# directory in the root of your repository except for the `/apps/github`
# subdirectory, as its owners are left empty.
# /apps/ @octocat
# /apps/github
# /apps/github
32 changes: 0 additions & 32 deletions .github/ISSUE_TEMPLATE.md

This file was deleted.

7 changes: 0 additions & 7 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/cla.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "CLA Assistant"
on:
issue_comment:
types: [created]
pull_request_target:
types: [opened,closed,synchronize]

jobs:
CLAssistant:
runs-on: ubuntu-latest
steps:
- name: "CLA Assistant"
if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
# Beta Release
uses: cla-assistant/github-action@v2.1.3-beta
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# the below token should have repo scope and must be manually added by you in the repository's secret
PERSONAL_ACCESS_TOKEN : ${{ secrets.KUSIONSTACK_BOT_TOKEN }}
with:
path-to-document: 'https://github.com/KusionStack/.github/blob/main/CLA.md' # e.g. a CLA or a DCO document

# branch should not be protected
lock-pullrequest-aftermerge: True
path-to-signatures: 'signatures/version1/cla.json'
remote-organization-name: KusionStack
remote-repository-name: cla.db
branch: 'main'
allowlist: 'test'

#below are the optional inputs - If the optional inputs are not given, then default values will be taken
#remote-organization-name: enter the remote organization name where the signatures should be stored (Default is storing the signatures in the same repository)
#remote-repository-name: enter the remote repository name where the signatures should be stored (Default is storing the signatures in the same repository)
#create-file-commit-message: 'For example: Creating file for storing CLA Signatures'
#signed-commit-message: 'For example: $contributorName has signed the CLA in #$pullRequestNo'
#custom-notsigned-prcomment: 'pull request comment with Introductory message to ask new contributors to sign'
#custom-pr-sign-comment: 'The signature to be committed in order to sign the CLA'
#custom-allsigned-prcomment: 'pull request comment when all contributors has signed, defaults to **CLA Assistant Lite bot** All Contributors have signed the CLA.'
#lock-pullrequest-aftermerge: false - if you don't want this bot to automatically lock the pull request after merging (default - true)
#use-dco-flag: true - If you are using DCO instead of CLA

7 changes: 0 additions & 7 deletions LEGAL.md

This file was deleted.

2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ require (
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99
gopkg.in/yaml.v3 v3.0.0
honnef.co/go/tools v0.3.0 // indirect
k8s.io/api v0.21.2
k8s.io/apimachinery v0.21.2
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1352,8 +1352,9 @@ gopkg.in/yaml.v3 v3.0.0-20191120175047-4206685974f2/go.mod h1:K4uyk7z7BCEPqu6E+C
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99 h1:dbuHpmKjkDzSOMKAWl10QNlgaZUd3V1q99xc81tt2Kc=
gopkg.in/yaml.v3 v3.0.0-20220512140231-539c8e751b99/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0 h1:hjy8E9ON/egN1tAYqKb61G10WtihqetD4sz2H+8nIeA=
gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.0.2/go.mod h1:3SzNCllyD9/Y+b5r9JIKQ474KzkZyqLqEfYqMsX94Bk=
gotest.tools/v3 v3.0.3 h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=
gotest.tools/v3 v3.0.3/go.mod h1:Z7Lb0S5l+klDB31fvDQX8ss/FlKDxtlFlw3Oa8Ymbl8=
Expand Down
2 changes: 1 addition & 1 deletion pkg/kusionctl/cmd/init/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (o *InitOptions) Run() error {

projectConfigs := map[string]interface{}{}
// prompt user-defined common configs which is project level
for _, f := range template.CommonConfigs {
for _, f := range template.ProjectConfigs {
projectConfigs[f.Name] = f.Default
// we don't prompt non-primitive types, such as: array and struct
if !f.Type.IsPrimitive() || o.Yes {
Expand Down
12 changes: 6 additions & 6 deletions pkg/scaffold/external_templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func LoadTemplate(path string) (Template, error) {
t.ProjectName = proj.ProjectName
t.Description = proj.Description
t.Quickstart = proj.Quickstart
t.CommonConfigs = proj.CommonTemplates
t.ProjectConfigs = proj.ProjectFields
t.StackConfigs = proj.StackTemplates
}

Expand All @@ -133,11 +133,11 @@ type Template struct {
Name string // The name of the template.

// following fields come from ProjectTemplate
ProjectName string // The name of the project.
Description string // Description of the template.
Quickstart string // Optional text to be displayed after template creation.
CommonConfigs []*FieldTemplate // CommonConfigs contains configuration in stack level
StackConfigs []*StackTemplate // StackConfigs contains configuration in stack level
ProjectName string // The name of the project.
Description string // Description of the template.
Quickstart string // Optional text to be displayed after template creation.
ProjectConfigs []*FieldTemplate // ProjectConfigs contains configuration in project level
StackConfigs []*StackTemplate // StackConfigs contains configuration in stack level
}

func RetrieveTemplates(templateNamePathOrURL string, online bool) (TemplateRepository, error) {
Expand Down
22 changes: 9 additions & 13 deletions pkg/scaffold/external_templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"testing"

"bou.ke/monkey"
"github.com/jinzhu/copier"
"github.com/pulumi/pulumi/sdk/v3/go/common/util/gitutil"
"github.com/stretchr/testify/assert"
"gopkg.in/src-d/go-git.v4/plumbing"
Expand All @@ -33,7 +34,7 @@ var (
ProjectName: "my-app",
Description: "A minimal kusion project of single stack",
Quickstart: "kusion compile main.k -Y ci-test/settings.yaml",
CommonConfigs: []*FieldTemplate{
ProjectConfigs: []*FieldTemplate{
{
Name: "ServiceName",
Description: "service name",
Expand Down Expand Up @@ -107,15 +108,12 @@ func TestTemplateRepository_Templates(t *testing.T) {
})

t.Run("read from subdir", func(t *testing.T) {
originalSubDir := localTemplateRepo.SubDirectory
defer func() {
localTemplateRepo.SubDirectory = originalSubDir
}()

localTemplateRepo.SubDirectory = localTemplateRepo.Root
templates, err := localTemplateRepo.Templates()
subRepo := TemplateRepository{}
copier.Copy(&subRepo, &localTemplateRepo)
subRepo.SubDirectory = localTemplateRepo.Root
templates, err := subRepo.Templates()
assert.Nil(t, err)
assert.Equal(t, []Template{localTemplate}, templates)
assert.Contains(t, templates, localTemplate)
})
}

Expand Down Expand Up @@ -254,7 +252,7 @@ func TestCopyTemplateFiles(t *testing.T) {
}()
// projectConfigs
projectConfigs := make(map[string]interface{})
for _, f := range localTemplate.CommonConfigs {
for _, f := range localTemplate.ProjectConfigs {
projectConfigs[f.Name] = f.Default
}
// stack2Configs
Expand All @@ -266,8 +264,6 @@ func TestCopyTemplateFiles(t *testing.T) {
}
stack2Configs[stack.Name] = configs
}
// project name
projectName := localTemplate.ProjectName
err = CopyTemplateFiles(localRoot, tmp, true, projectName, projectConfigs, stack2Configs)
err = CopyTemplateFiles(localTemplate.Dir, tmp, true, localTemplate.ProjectName, projectConfigs, stack2Configs)
assert.Nil(t, err)
}
2 changes: 1 addition & 1 deletion pkg/scaffold/internal/deployment-single-stack/kusion.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
projectName: my-app
description: A minimal kusion project of single stack
quickstart: kusion compile main.k -Y ci-test/settings.yaml
common:
projectFields:
# base/base.k
- name: ServiceName
description: service name
Expand Down
22 changes: 14 additions & 8 deletions pkg/scaffold/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type ProjectTemplate struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Quickstart contains optional text to be displayed after template creation.
Quickstart string `json:"quickstart,omitempty" yaml:"quickstart,omitempty"`
// CommonTemplates contains configuration in project level
CommonTemplates []*FieldTemplate `json:"common,omitempty" yaml:"common,omitempty"`
// ProjectFields contains configuration in project level
ProjectFields []*FieldTemplate `json:"projectFields,omitempty" yaml:"projectFields,omitempty"`
// StackTemplates contains configuration in stack level
StackTemplates []*StackTemplate `json:"stacks,omitempty" yaml:"stacks,omitempty"`
}
Expand All @@ -25,16 +25,20 @@ type StackTemplate struct {

type FieldTemplate struct {
// Name represents the field name, required
Name string `json:"name" yaml:"name"`
Name string `json:"name,omitempty" yaml:"name,omitempty"`
// Description represents the field description, optional
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// Type can be string/int/bool/float/array/struct, required
Type FieldType `json:"type" yaml:"type"`
// Default represents primitive field default value
// Type can be string/int/bool/float/array/map/struct/any, required
Type FieldType `json:"type,omitempty" yaml:"type,omitempty"`
// Default represents default value for all FieldType
Default interface{} `json:"default,omitempty" yaml:"default,omitempty"`
// Elem is active only when type is ArrayField
// Elem is effective only when type is ArrayField
Elem *FieldTemplate `json:"elem,omitempty" yaml:"elem,omitempty"`
// Fields is active only when type is StructField
// Key is effective only when type is MapField
Key *FieldTemplate `json:"key,omitempty" yaml:"key,omitempty"`
// Value is effective only when type is MapField
Value *FieldTemplate `json:"value,omitempty" yaml:"value,omitempty"`
// Fields is effective only when type is StructField
Fields []*FieldTemplate `json:"fields,omitempty" yaml:"fields,omitempty"`
}

Expand All @@ -46,7 +50,9 @@ const (
BoolField FieldType = "bool"
FloatField FieldType = "float"
ArrayField FieldType = "array"
MapField FieldType = "map"
StructField FieldType = "struct"
AnyField FieldType = "any" // AnyField equal to interface{}
)

func (f FieldType) IsPrimitive() bool {
Expand Down

0 comments on commit 35f2b9e

Please sign in to comment.