@@ -18,6 +18,7 @@ package model
1818
1919import (
2020 "path/filepath"
21+ "regexp"
2122
2223 "k8s.io/klog/v2"
2324 "k8s.io/kops/upup/pkg/fi"
@@ -33,24 +34,28 @@ var _ fi.NodeupModelBuilder = &NerdctlBuilder{}
3334
3435func (b * NerdctlBuilder ) Build (c * fi.NodeupModelBuilderContext ) error {
3536 if b .skipInstall () {
36- klog .Info ("containerd.skipInstall is set to true; won't install nerdctl" )
37+ klog .V ( 8 ). Info ("won't install nerdctl" )
3738 return nil
3839 }
3940
40- assetName := "nerdctl"
41- assetPath := ""
42- asset , err := b .Assets .Find (assetName , assetPath )
43- if err != nil {
44- klog .Warningf ("unable to locate asset %q: %v" , assetName , err )
41+ assets := b .Assets .FindMatches (regexp .MustCompile (`^nerdctl$` ))
42+ if len (assets ) == 0 {
43+ klog .Warning ("unable to find any nerdctl binaries in assets" )
44+ return nil
45+ }
46+ if len (assets ) > 1 {
47+ klog .Warning ("multiple nerdctl binaries are found" )
4548 return nil
4649 }
4750
48- c .AddTask (& nodetasks.File {
49- Path : b .nerdctlPath (),
50- Contents : asset ,
51- Type : nodetasks .FileType_File ,
52- Mode : s ("0755" ),
53- })
51+ for k , v := range assets {
52+ c .AddTask (& nodetasks.File {
53+ Path : filepath .Join (b .binaryPath (), k ),
54+ Contents : v ,
55+ Type : nodetasks .FileType_File ,
56+ Mode : s ("0755" ),
57+ })
58+ }
5459
5560 return nil
5661}
@@ -64,19 +69,14 @@ func (b *NerdctlBuilder) binaryPath() string {
6469 path = "/home/kubernetes/bin"
6570 }
6671 return path
67-
68- }
69-
70- func (b * NerdctlBuilder ) nerdctlPath () string {
71- return filepath .Join (b .binaryPath (), "nerdctl" )
7272}
7373
7474func (b * NerdctlBuilder ) skipInstall () bool {
75- d := b .NodeupConfig .ContainerdConfig
75+ containerd := b .NodeupConfig .ContainerdConfig
7676
77- if d == nil {
77+ if containerd == nil {
7878 return false
7979 }
8080
81- return d .SkipInstall
81+ return containerd .SkipInstall && ! containerd . InstallNerdCtl
8282}
0 commit comments