Skip to content

Commit

Permalink
fix: when frontcmd is null, it still passes cmd to deployment
Browse files Browse the repository at this point in the history
Signed-off-by: joshua <[email protected]>
  • Loading branch information
sujoshua committed Aug 25, 2024
1 parent 36de8f2 commit 941a477
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func mergeDefaults(config *controller.Config) {
"component": "caddy"
},
"output": "loki",
"url": "http://loki:3000/loki/api/v1/push"
"url": "http://loki:3100/loki/api/v1/push"
},
"encoder": {
"format": "json"
Expand Down
22 changes: 15 additions & 7 deletions internal/controller/job_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,19 @@ func (r *JobReconciler) getFrontConfig(job *v1beta1.Job) (frontConfig string, er

func (r *JobReconciler) checkRsyncFront(job *v1beta1.Job) (disableFront, disableRsync bool, frontCmd, rsyncCmd []string, frontMode, frontImage, rsyncImage string) {
frontMode, frontImage, rsyncImage = r.Config.FrontMode, r.Config.FrontImage, r.Config.RsyncImage
frontCmd, rsyncCmd = strings.Split(r.Config.FrontCmd, " "), strings.Split(r.Config.RsyncCmd, " ")

if job.Spec.Deploy.FrontCmd != "" {
frontCmd = strings.Split(job.Spec.Deploy.FrontCmd, " ")
} else if r.Config.FrontCmd != "" {
frontCmd = strings.Split(r.Config.FrontCmd, " ")
}

if job.Spec.Deploy.RsyncCmd != "" {
rsyncCmd = strings.Split(job.Spec.Deploy.RsyncCmd, " ")
} else if r.Config.RsyncCmd != "" {
rsyncCmd = strings.Split(r.Config.RsyncCmd, " ")
}

if s, err := strconv.ParseBool(job.Spec.Deploy.DisableFront); err == nil {
disableFront = s
}
Expand All @@ -73,9 +85,7 @@ func (r *JobReconciler) checkRsyncFront(job *v1beta1.Job) (disableFront, disable
} else if frontImage == "" {
frontImage = frontMode + ":latest"
}
if job.Spec.Deploy.FrontCmd != "" {
frontCmd = strings.Split(job.Spec.Deploy.FrontCmd, " ")
}

if s, err := strconv.ParseBool(job.Spec.Deploy.DisableRsync); err == nil {
disableRsync = s
}
Expand All @@ -85,9 +95,7 @@ func (r *JobReconciler) checkRsyncFront(job *v1beta1.Job) (disableFront, disable
if rsyncImage == "" {
disableRsync = true
}
if job.Spec.Deploy.RsyncCmd != "" {
rsyncCmd = strings.Split(job.Spec.Deploy.RsyncCmd, " ")
}

return
}

Expand Down

0 comments on commit 941a477

Please sign in to comment.