@@ -20,9 +20,10 @@ import (
2020
2121// snap implements the Snap interface.
2222type snap struct {
23- snapDir string
24- snapDataDir string
25- runCommand func (context.Context , ... string ) error
23+ snapDir string
24+ snapDataDir string
25+ snapCommonDir string
26+ runCommand func (context.Context , ... string ) error
2627
2728 clusterTokensMu sync.Mutex
2829 certTokensMu sync.Mutex
@@ -34,12 +35,13 @@ type snap struct {
3435}
3536
3637// NewSnap creates a new interface with the MicroK8s snap.
37- // NewSnap accepts the $SNAP and $SNAP_DATA directories, and a number of options.
38- func NewSnap (snapDir , snapDataDir string , options ... func (s * snap )) Snap {
38+ // NewSnap accepts the $SNAP, $SNAP_DATA and $SNAP_COMMON, directories, and a number of options.
39+ func NewSnap (snapDir , snapDataDir , snapCommonDir string , options ... func (s * snap )) Snap {
3940 s := & snap {
40- snapDir : snapDir ,
41- snapDataDir : snapDataDir ,
42- runCommand : util .RunCommand ,
41+ snapDir : snapDir ,
42+ snapDataDir : snapDataDir ,
43+ snapCommonDir : snapCommonDir ,
44+ runCommand : util .RunCommand ,
4345 }
4446
4547 for _ , opt := range options {
@@ -56,6 +58,9 @@ func (s *snap) snapPath(parts ...string) string {
5658func (s * snap ) snapDataPath (parts ... string ) string {
5759 return filepath .Join (append ([]string {s .snapDataDir }, parts ... )... )
5860}
61+ func (s * snap ) snapCommonPath (parts ... string ) string {
62+ return filepath .Join (append ([]string {s .snapCommonDir }, parts ... )... )
63+ }
5964
6065func (s * snap ) GetGroupName () string {
6166 if s .isStrict () {
@@ -336,7 +341,15 @@ func (s *snap) SignCertificate(ctx context.Context, csrPEM []byte) ([]byte, erro
336341}
337342
338343func (s * snap ) ImportImage (ctx context.Context , reader io.Reader ) error {
339- importCmd := exec .CommandContext (ctx , s .snapPath ("microk8s-ctr.wrapper" ), "image" , "import" , "--platform" , runtime .GOARCH , "-" )
344+ importCmd := exec .CommandContext (ctx ,
345+ s .snapPath ("bin" , "ctr" ),
346+ "--namespace" , "k8s.io" ,
347+ "--address" , s .snapCommonPath ("run" , "containerd.sock" ),
348+ "image" ,
349+ "import" ,
350+ "--platform" , runtime .GOARCH ,
351+ "-" ,
352+ )
340353 importCmd .Stdin = reader
341354 importCmd .Stdout = os .Stdout
342355 importCmd .Stdout = os .Stderr
0 commit comments