Skip to content

Commit 728e8c1

Browse files
committed
fix: determine helper arch automatically & fix use context
1 parent 5c8391a commit 728e8c1

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

cmd/use/context.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package use
22

33
import (
4+
"fmt"
45
"github.com/loft-sh/devspace/cmd/flags"
56
"github.com/loft-sh/devspace/pkg/devspace/config/loader"
67
"github.com/loft-sh/devspace/pkg/util/factory"
@@ -34,15 +35,15 @@ devspace use context my-context
3435
`,
3536
Args: cobra.MaximumNArgs(1),
3637
RunE: func(cobraCmd *cobra.Command, args []string) error {
37-
return cmd.RunUseContext(f, cobraCmd, args)
38+
return cmd.RunUseContext(f, args)
3839
},
3940
}
4041

4142
return useContext
4243
}
4344

4445
// RunUseContext executes the functionality "devspace use namespace"
45-
func (cmd *ContextCmd) RunUseContext(f factory.Factory, cobraCmd *cobra.Command, args []string) error {
46+
func (cmd *ContextCmd) RunUseContext(f factory.Factory, args []string) error {
4647
// Load kube-config
4748
log := f.GetLog()
4849
kubeLoader := f.NewKubeConfigLoader()
@@ -72,6 +73,12 @@ func (cmd *ContextCmd) RunUseContext(f factory.Factory, cobraCmd *cobra.Command,
7273
}
7374
}
7475

76+
// check if context exists
77+
_, found := kubeConfig.Contexts[context]
78+
if !found {
79+
return fmt.Errorf("couldn't find context %s in kube config", context)
80+
}
81+
7582
// Save old context
7683
oldContext := kubeConfig.CurrentContext
7784

pkg/devspace/services/inject/inject.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"io"
1212
"io/fs"
1313
"io/ioutil"
14+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415
"net/http"
1516
"os"
1617
"path/filepath"
@@ -65,6 +66,14 @@ func InjectDevSpaceHelper(ctx context.Context, client kubectl.Client, pod *v1.Po
6566
} else {
6667
arch = "-" + arch
6768
}
69+
} else {
70+
// check arch on pod node
71+
node, err := client.KubeClient().CoreV1().Nodes().Get(ctx, pod.Spec.NodeName, metav1.GetOptions{})
72+
if err == nil {
73+
if node.Labels != nil && node.Labels["beta.kubernetes.io/arch"] == "arm64" {
74+
arch = "-" + string(latest.ContainerArchitectureArm64)
75+
}
76+
}
6877
}
6978

7079
// Check if sync is already in pod

0 commit comments

Comments
 (0)