Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update env patcher #908

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

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 {
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 {
Expand Down
Loading