-
Notifications
You must be signed in to change notification settings - Fork 1
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: adapt for tekton 0.55 #83
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.55.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
defaultBaseImage: build-harbor.alauda.cn/ops/distroless-static-nonroot:20220806 | ||
baseImageOverrides: | ||
# git-init uses a base image that includes Git, and supports running either | ||
# as root or as user nonroot with UID 65532. | ||
# image latest-glibc-hack is from katanomi tekton-operator hack Dockerfile | ||
github.com/tektoncd/pipeline/cmd/git-init: build-harbor.alauda.cn/3rdparty/cgr.dev/chainguard/git:latest-glibc-hack-20231016 |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -172,9 +172,8 @@ func MergePodTemplateWithDefault(tpl, defaultTpl *PodTemplate) *PodTemplate { | |
return defaultTpl | ||
default: | ||
// Otherwise, merge fields | ||
if tpl.Env == nil { | ||
tpl.Env = defaultTpl.Env | ||
} | ||
tpl.Env = mergeByName(defaultTpl.Env, tpl.Env) | ||
tpl.Volumes = mergeByName(defaultTpl.Volumes, tpl.Volumes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 等更新到社区的 v0.56.0 后,这部分就不需要了。 |
||
if tpl.NodeSelector == nil { | ||
tpl.NodeSelector = defaultTpl.NodeSelector | ||
} | ||
|
@@ -187,9 +186,6 @@ func MergePodTemplateWithDefault(tpl, defaultTpl *PodTemplate) *PodTemplate { | |
if tpl.SecurityContext == nil { | ||
tpl.SecurityContext = defaultTpl.SecurityContext | ||
} | ||
if tpl.Volumes == nil { | ||
tpl.Volumes = defaultTpl.Volumes | ||
} | ||
if tpl.RuntimeClassName == nil { | ||
tpl.RuntimeClassName = defaultTpl.RuntimeClassName | ||
} | ||
|
@@ -254,3 +250,48 @@ func MergeAAPodTemplateWithDefault(tpl, defaultTpl *AAPodTemplate) *AAPodTemplat | |
return tpl | ||
} | ||
} | ||
|
||
// mergeByName merges two slices of items with names based on the getName | ||
// function, giving priority to the items in the override slice. | ||
func mergeByName[T any](base, overrides []T) []T { | ||
if len(overrides) == 0 { | ||
return base | ||
} | ||
|
||
// create a map to store the names of the volumeVars in the override slice | ||
seen := make(map[string]struct{}) | ||
result := make([]T, 0, len(base)+len(overrides)) | ||
|
||
for _, item := range overrides { | ||
name := getName(item) | ||
if name != "" { | ||
result = append(result, item) | ||
seen[name] = struct{}{} | ||
} | ||
} | ||
|
||
// append the volumeVars in the original slice if they have a different name | ||
for _, item := range base { | ||
name := getName(item) | ||
if name != "" { | ||
if _, found := seen[name]; !found { | ||
result = append(result, item) | ||
} | ||
} | ||
} | ||
|
||
return result | ||
} | ||
|
||
// getName returns the name of the given item, or an empty string if the item | ||
// is not a supported type. | ||
func getName(item interface{}) string { | ||
switch item := item.(type) { | ||
case corev1.EnvVar: | ||
return item.Name | ||
case corev1.Volume: | ||
return item.Name | ||
default: | ||
return "" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -140,7 +140,6 @@ type Step struct { | |
Ref *Ref `json:"ref,omitempty"` | ||
// Params declares parameters passed to this step action. | ||
// +optional | ||
// +listType=atomic | ||
Params Params `json:"params,omitempty"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 改了后,controller-gen 生成 crds 时才不报错。 |
||
// Results declares StepResults produced by the Step. | ||
// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,6 +62,7 @@ type ParamSpec struct { | |
} | ||
|
||
// ParamSpecs is a list of ParamSpec | ||
// +listType=atomic | ||
type ParamSpecs []ParamSpec | ||
|
||
// PropertySpec defines the struct for object keys | ||
|
@@ -268,6 +269,7 @@ func (p Param) ParseTaskandResultName() (string, string) { | |
} | ||
|
||
// Params is a list of Param | ||
// +listType=atomic | ||
type Params []Param | ||
|
||
// ExtractParamArrayLengths extract and return the lengths of all array params | ||
|
@@ -482,11 +484,11 @@ var AllParamTypes = []ParamType{ParamTypeString, ParamTypeArray, ParamTypeObject | |
// Used in JSON unmarshalling so that a single JSON field can accept | ||
// either an individual string or an array of strings. | ||
type ParamValue struct { | ||
Type ParamType // Represents the stored type of ParamValues. | ||
StringVal string | ||
Type ParamType `json:"type"` // Represents the stored type of ParamValues. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 社区在这个 PR 中移除了 json 的 tag,他们给出了解释。但我们生成 crds 还是需要该 tag,所以加回来了。 |
||
StringVal string `json:"stringVal"` | ||
// +listType=atomic | ||
ArrayVal []string | ||
ObjectVal map[string]string | ||
ArrayVal []string `json:"arrayVal"` | ||
ObjectVal map[string]string `json:"objectVal"` | ||
} | ||
|
||
// UnmarshalJSON implements the json.Unmarshaller interface. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
修复安全问题。