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

refactor: move kubernetes-specific functions into pkg/be/kubernetes out of pkg/fe/transformer #196

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api
package shell

import (
"fmt"
Expand Down Expand Up @@ -35,7 +35,7 @@ func code(application hlir.Application, namespace string) (data, string, error)
}
}

func CodeB64(application hlir.Application, namespace string) (string, string, error) {
func codeB64(application hlir.Application, namespace string) (string, string, error) {
data, mountPath, err := code(application, namespace)
if err != nil {
return "", "", err
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package api
package shell

import (
"fmt"
Expand Down Expand Up @@ -133,7 +133,7 @@ rclone --retries 50 --config $config copyto -v s3:/%s /workdir/%s/%s
return volumes, volumeMounts, envFroms, initContainers, secrets, nil
}

func DatasetsB64(app hlir.Application, runname string, queueSpec queue.Spec) (string, string, string, string, []string, error) {
func datasetsB64(app hlir.Application, runname string, queueSpec queue.Spec) (string, string, string, string, []string, error) {
secretsB64 := []string{}

volumes, volumeMounts, envFroms, initContainers, secrets, err := datasets(app, runname, queueSpec)
Expand Down Expand Up @@ -171,3 +171,11 @@ func DatasetsB64(app hlir.Application, runname string, queueSpec queue.Spec) (st

return volumesB64, volumeMountsB64, envFromsB64, initContainersB64, secretsB64, nil
}

// Inject queue secrets
func envForQueue(queueSpec queue.Spec) envFrom {
return envFrom{
Prefix: "lunchpail_queue_",
SecretRef: secretRef{queueSpec.Name},
}
}
5 changes: 2 additions & 3 deletions pkg/be/kubernetes/shell/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"lunchpail.io/pkg/be/kubernetes/common"
templater "lunchpail.io/pkg/fe/template"
"lunchpail.io/pkg/fe/transformer/api"
"lunchpail.io/pkg/ir/llir"
"lunchpail.io/pkg/util"
)
Expand Down Expand Up @@ -40,12 +39,12 @@ func Template(ir llir.LLIR, c llir.ShellComponent, opts common.Options, verbose
return "", err
}

volumes, volumeMounts, envFroms, initContainers, secrets, err := api.DatasetsB64(c.Application, ir.RunName, ir.Queue)
volumes, volumeMounts, envFroms, initContainers, secrets, err := datasetsB64(c.Application, ir.RunName, ir.Queue)
if err != nil {
return "", err
}

workdirCmData, workdirCmMountPath, err := api.CodeB64(c.Application, ir.Namespace)
workdirCmData, workdirCmMountPath, err := codeB64(c.Application, ir.Namespace)
if err != nil {
return "", err
}
Expand Down
8 changes: 0 additions & 8 deletions pkg/fe/transformer/api/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,3 @@ func QueuePrefixPathForWorker(queueSpec queue.Spec, runname, poolName string) st
QueueSubPathForWorker(poolName, "$LUNCHPAIL_WORKER_NAME"),
)
}

// Inject queue secrets
func envForQueue(queueSpec queue.Spec) envFrom {
return envFrom{
Prefix: "lunchpail_queue_",
SecretRef: secretRef{queueSpec.Name},
}
}