Skip to content

Commit d18da01

Browse files
authored
[nydusify] Override source imageRef fetched from containerd (#22)
* [nydusify] Override source imageRef fetched from containerd In case containerd has some hosts.toml specific configuration, the imageRef of the containerId can be different to the actual url to fetch the image This PR allow to override the imageRef fetched from containerd Signed-off-by: Etienne Carriere <etienne.carriere@datadoghq.com> * Change argument to source-image-ref Signed-off-by: Etienne Carriere <etienne.carriere@datadoghq.com> --------- Signed-off-by: Etienne Carriere <etienne.carriere@datadoghq.com>
1 parent d36a3bd commit d18da01

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

contrib/nydusify/cmd/nydusify.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,6 +1444,12 @@ func main() {
14441444
Usage: "Target nydus image reference",
14451445
EnvVars: []string{"TARGET"},
14461446
},
1447+
&cli.StringFlag{
1448+
Name: "source-image-ref",
1449+
Required: false,
1450+
Usage: "Override the source nydus image reference (useful when containerd uses hosts.toml remapping)",
1451+
EnvVars: []string{"SOURCE_IMAGE_REF"},
1452+
},
14471453
&cli.BoolFlag{
14481454
Name: "source-insecure",
14491455
Required: false,
@@ -1499,6 +1505,7 @@ func main() {
14991505
ContainerdAddress: c.String("containerd-address"),
15001506
Namespace: c.String("namespace"),
15011507
ContainerID: c.String("container"),
1508+
SourceImageRef: c.String("source-image-ref"),
15021509
TargetRef: c.String("target"),
15031510
SourceInsecure: c.Bool("source-insecure"),
15041511
TargetInsecure: c.Bool("target-insecure"),

contrib/nydusify/pkg/committer/commiter.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ type Opt struct {
4646
Namespace string
4747

4848
ContainerID string
49+
SourceImageRef string
4950
SourceInsecure bool
5051
TargetRef string
5152
TargetInsecure bool
@@ -104,6 +105,9 @@ func (cm *Committer) Commit(ctx context.Context, opt Opt) error {
104105
}
105106

106107
originalSourceRef := inspect.Image
108+
if opt.SourceImageRef != "" {
109+
originalSourceRef = opt.SourceImageRef
110+
}
107111

108112
logrus.Infof("pulling base bootstrap")
109113
start := time.Now()

0 commit comments

Comments
 (0)