Skip to content

Conversation

@googs1025
Copy link
Member

What this PR does / why we need it

  • playground.Spec.BackendRuntimeConfig.Envs is set by the user. There is a high probability that Envs is the same as BackendRuntime.Spec.Envs. We should use the overwrite method instead of just appending.

Which issue(s) this PR fixes

Fixes None

Special notes for your reviewer

Does this PR introduce a user-facing change?

None

@InftyAI-Agent InftyAI-Agent added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Apr 14, 2025
@InftyAI-Agent InftyAI-Agent requested a review from kerthcet April 14, 2025 13:07
Comment on lines +55 to +59
result := make([]corev1.EnvVar, 0, len(envMap))
for _, env := range envMap {
result = append(result, env)
}
return result
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import maps and then

Suggested change
result := make([]corev1.EnvVar, 0, len(envMap))
for _, env := range envMap {
result = append(result, env)
}
return result
return maps.Values(envMap)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maps.Values(envMap) returns an iterator instead of a slice object, we still need to iterate over it, something like this.

        result := make([]corev1.EnvVar, 0, len(envMap))
	for env := range maps.Values(envMap) {
		result = append(result, env)
	}
	return result

envs := parser.Envs()
if playground.Spec.BackendRuntimeConfig != nil {
envs = append(envs, playground.Spec.BackendRuntimeConfig.Envs...)
envs = util.MergeEnvs(envs, playground.Spec.BackendRuntimeConfig.Envs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think even we didn't merge them, still work here because the latter env will overwrite the former ones, but merge them makes it more clear. Thanks!

},
want: []corev1.EnvVar{
{Name: "VAR1", Value: "value1"},
{Name: "VAR2", Value: "new_value2"}, // 被覆盖
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No chinese here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad... remove

@kerthcet
Copy link
Member

/lgtm
/approve

@kerthcet
Copy link
Member

/kind cleanup

@InftyAI-Agent InftyAI-Agent added lgtm Looks good to me, indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 17, 2025
@InftyAI-Agent InftyAI-Agent added cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Apr 17, 2025
@InftyAI-Agent InftyAI-Agent merged commit 1c23184 into InftyAI:main Apr 17, 2025
27 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Looks good to me, indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants