Skip to content

Commit

Permalink
feat: make kwasmDir configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
trutx committed May 24, 2024
1 parent a1882db commit f2630ab
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions controllers/provisioner_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type ProvisionerReconciler struct {
Scheme *runtime.Scheme
AutoProvision bool
InstallerImage string
KwasmDir string
}

const (
Expand Down Expand Up @@ -177,6 +178,10 @@ func (r *ProvisionerReconciler) deployJob(node *corev1.Node, req ctrl.Request) (
Name: "NODE_ROOT",
Value: "/mnt/node-root",
},
{
Name: "KWASM_DIR",
Value: r.KwasmDir,
},
},
VolumeMounts: []corev1.VolumeMount{
{
Expand Down
4 changes: 4 additions & 0 deletions controllers/provisioner_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (

var namespaceName = "kwasm-provisioner"
var installerImage = "ghcr.io/kwasm/kwasm-node-installer:latest"
var kwasmDir = "/opt/kwasm"

var _ = Describe("ProvisionerController", func() {
Context("Kwasm Provisioner controller test", func() {
Expand Down Expand Up @@ -45,6 +46,7 @@ var _ = Describe("ProvisionerController", func() {
Client: k8sClient,
Scheme: k8sClient.Scheme(),
InstallerImage: installerImage,
KwasmDir: kwasmDir,
}
err = k8sClient.Create(ctx, node)
Expect(err).NotTo(HaveOccurred())
Expand Down Expand Up @@ -92,6 +94,7 @@ var _ = Describe("ProvisionerController", func() {
Client: k8sClient,
Scheme: k8sClient.Scheme(),
InstallerImage: installerImage,
KwasmDir: kwasmDir,
}

node = &corev1.Node{
Expand Down Expand Up @@ -121,6 +124,7 @@ var _ = Describe("ProvisionerController", func() {
Client: k8sClient,
Scheme: k8sClient.Scheme(),
InstallerImage: installerImage,
KwasmDir: kwasmDir,
AutoProvision: true,
}
node = &corev1.Node{
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,18 @@ func main() {
setupLog.Info(fmt.Sprintf("INSTALLER_IMAGE=%s", installerImage))
}

kwasmDir := "/opt/kwasm"
if kwasmDirEnv, found := os.LookupEnv("KWASM_DIR"); found {
kwasmDir = kwasmDirEnv
setupLog.Info(fmt.Sprintf("KWASM_DIR=%s", kwasmDir))
}

if err = (&controllers.ProvisionerReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
AutoProvision: autoProvision,
InstallerImage: installerImage,
KwasmDir: kwasmDir,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "Provisioner")
os.Exit(1)
Expand Down

0 comments on commit f2630ab

Please sign in to comment.