Skip to content

Commit

Permalink
host-ctr: remove redundant variable, reword comment
Browse files Browse the repository at this point in the history
This removes a redundant copy of the image source and rewords the
comment above matching the image against the ECR image source regex.
  • Loading branch information
etungsten committed Nov 30, 2022
1 parent daf9b3f commit 4ca408f
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions sources/host-ctr/cmd/host-ctr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func runCtr(containerdSocket string, namespace string, containerID string, sourc
}
defer client.Close()

// Parse the source ref if it looks like an ECR ref.
// Check if the image source is an ECR image. If it is, then we need to handle it with the ECR resolver.
isECRImage := ecrRegex.MatchString(source)
var img containerd.Image
if isECRImage {
Expand Down Expand Up @@ -506,18 +506,17 @@ func pullImageOnly(containerdSocket string, namespace string, source string, reg
}
defer client.Close()

// Parse the source ref if it looks like an ECR ref.
// Check if the image source is an ECR image. If it is, then we need to handle it with the ECR resolver.
isECRImage := ecrRegex.MatchString(source)
ref := source
if isECRImage {
_, err = fetchECRImage(ctx, source, client, registryConfigPath, useCachedImage)
if err != nil {
return err
}
} else {
_, err = fetchImage(ctx, ref, client, registryConfigPath, useCachedImage)
_, err = fetchImage(ctx, source, client, registryConfigPath, useCachedImage)
if err != nil {
log.G(ctx).WithField("ref", ref).Error(err)
log.G(ctx).WithField("ref", source).Error(err)
return err
}
}
Expand Down

0 comments on commit 4ca408f

Please sign in to comment.