Skip to content

Commit

Permalink
fix: make lighthousejob more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
msvticket committed Jan 10, 2024
1 parent 561929c commit 50b3f44
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/plugins/trigger/periodic.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ func (pa *PeriodicAgent) UpdatePeriodicsForRepo(
}

pj := jobutil.NewLighthouseJob(jobutil.PeriodicSpec(l, p, refs), labels, p.Annotations)
lighthouseData, err := json.Marshal(pj)
lighthouseData, err := json.MarshalIndent(pj, "", " ")

// Only apply if any value have changed
existingCm := getExistingConfigMap(p)

if existingCm == nil || existingCm.Data["lighthousejob.yaml"] != string(lighthouseData) {
if existingCm == nil || existingCm.Data["lighthousejob.json"] != string(lighthouseData) {
var cm *applyv1.ConfigMapApplyConfiguration
if existingCm != nil {
cm, err = applyv1.ExtractConfigMap(existingCm, fieldManager)
Expand All @@ -325,7 +325,7 @@ func (pa *PeriodicAgent) UpdatePeriodicsForRepo(
if cm.Data == nil {
cm.Data = make(map[string]string)
}
cm.Data["lighthousejob.yaml"] = string(lighthouseData)
cm.Data["lighthousejob.json"] = string(lighthouseData)

_, err := cmInterface.Apply(context.TODO(), cm, metav1.ApplyOptions{Force: true, FieldManager: fieldManager})
if err != nil {
Expand Down Expand Up @@ -405,7 +405,7 @@ func (pa *PeriodicAgent) constructCronJob(resourceName, configMapName string, la
WithCommand("/bin/sh").
WithArgs("-c", `
set -o errexit
create_output=$(kubectl create -f /config/lighthousejob.yaml)
create_output=$(kubectl create -f /config/lighthousejob.json)
[[ $create_output =~ (.*)\ ]]
kubectl patch ${BASH_REMATCH[1]} --type=merge --subresource status --patch 'status: {state: triggered}'
`).
Expand Down

0 comments on commit 50b3f44

Please sign in to comment.