From 3564daa59824901e4d67f454ca4dc3742e54c6bf Mon Sep 17 00:00:00 2001 From: liu-hm19 Date: Tue, 12 Mar 2024 19:34:41 +0800 Subject: [PATCH] feat: update env patcher (#908) --- docs/design/kusion_module/kusion_modules.md | 2 +- pkg/apis/core/v1/resource.go | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/docs/design/kusion_module/kusion_modules.md b/docs/design/kusion_module/kusion_modules.md index 37c35ce0..fa20ad61 100644 --- a/docs/design/kusion_module/kusion_modules.md +++ b/docs/design/kusion_module/kusion_modules.md @@ -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 diff --git a/pkg/apis/core/v1/resource.go b/pkg/apis/core/v1/resource.go index 7ae71b6a..5ea4c242 100644 --- a/pkg/apis/core/v1/resource.go +++ b/pkg/apis/core/v1/resource.go @@ -1,6 +1,10 @@ package v1 -import "encoding/json" +import ( + "encoding/json" + + v1 "k8s.io/api/core/v1" +) type Resources []Resource @@ -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 {