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

sort agent config in configmap #16

Merged
merged 2 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions examples/lightrunjavaagent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ spec:
# platform - `linux/alpine`
# agent version - first part of the tag (1.7.0)
# init container sub-version - last part of the tag (init.0)
image: "lightruncom/k8s-operator-init-java-agent-linux:1.8.5-init.1"
image: "lightruncom/k8s-operator-init-java-agent-linux:latest"
# Volume name in case you have some convention in the names
sharedVolumeName: lightrun-agent-init
# Mount path where volume will be parked. Various distributions may have it's limitations.
Expand All @@ -56,7 +56,7 @@ spec:
agentTags:
- operator
- example
- 1.8.5
- latest
# Agent name. If not provided, pod name will be used
#agentName: "operator-test-agent"

Expand Down
12 changes: 10 additions & 2 deletions internal/controller/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controller
import (
"context"
"hash/fnv"
"sort"
"time"

agentv1beta "github.com/lightrun-platform/lightrun-k8s-operator/api/v1beta"
Expand Down Expand Up @@ -173,8 +174,15 @@ func removeString(slice []string, s string) (result []string) {

func parseAgentConfig(config map[string]string) string {
var cm_data string
for k, v := range config {
cm_data = cm_data + k + "=" + v + "\n"
var keys []string
// sort keys to preserve order in hash
for k := range config {
keys = append(keys, k)
}
sort.Strings(keys)

for _, k := range keys {
cm_data = cm_data + k + "=" + config[k] + "\n"
}
return cm_data
}
Expand Down
Loading