Skip to content

Commit

Permalink
feat: update env patcher (#908)
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 authored Mar 12, 2024
1 parent b069d9a commit 3564daa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/design/kusion_module/kusion_modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ service Module {
type Intent.Resource struct {
...
// Add a new field to represent patchers
Patchers []Patcher
Patcher Patcher
}

// Kusion will patch these fields into the workload corresponding fields
Expand Down
19 changes: 13 additions & 6 deletions pkg/apis/core/v1/resource.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package v1

import "encoding/json"
import (
"encoding/json"

v1 "k8s.io/api/core/v1"
)

type Resources []Resource

Check failure on line 9 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Unit tests with coverage

other declaration of Resources

Check failure on line 9 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / e2e test

other declaration of Resources

Check failure on line 9 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Golang Lint

other declaration of Resources

Check failure on line 9 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Golang Lint

other declaration of Resources

Expand All @@ -20,17 +24,20 @@ type Resource struct {
// DependsOn contains all resources this resource depends on
DependsOn []string `json:"dependsOn,omitempty" yaml:"dependsOn,omitempty"`

// Patchers contain fields should be patched into the workload corresponding fields
Patchers []Patcher
// Patcher contains fields should be patched into the workload corresponding fields
Patcher Patcher `json:"patcher,omitempty" yaml:"patcher,omitempty"`

// Extensions specifies arbitrary metadata of this resource
Extensions map[string]interface{} `json:"extensions,omitempty" yaml:"extensions,omitempty"`
}

type Patcher struct {

Check failure on line 34 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Unit tests with coverage

other declaration of Patcher

Check failure on line 34 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / e2e test

other declaration of Patcher

Check failure on line 34 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Golang Lint

other declaration of Patcher (typecheck)
Environments map[string]string `json:"environments" yaml:"environments"`
Labels map[string]string `json:"labels" yaml:"labels"`
Annotations map[string]string `json:"annotations" yaml:"annotations"`
// Environments represent the environment variables patched to all containers in the workload.
Environments []v1.EnvVar `json:"environments" yaml:"environments"`
// Labels represent the labels patched to both the workload and pod.
Labels map[string]string `json:"labels" yaml:"labels"`
// Annotations represent the annotations patched to both the workload and pod.
Annotations map[string]string `json:"annotations" yaml:"annotations"`
}

func (r *Resource) ResourceKey() string {

Check failure on line 43 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Unit tests with coverage

Resources redeclared in this block

Check failure on line 43 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / e2e test

Resources redeclared in this block

Check failure on line 43 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Golang Lint

Resources redeclared in this block

Check failure on line 43 in pkg/apis/core/v1/resource.go

View workflow job for this annotation

GitHub Actions / Golang Lint

Resources redeclared in this block
Expand Down

0 comments on commit 3564daa

Please sign in to comment.