Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit ce625cf

Browse files
committed
Work around no base images
Signed-off-by: Christian Dupuis <[email protected]>
1 parent 31b9b64 commit ce625cf

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

commands/cmd.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ func NewRootCmd(name string, isPlugin bool, dockerCli command.Cli) *cobra.Comman
138138
if err != nil {
139139
return err
140140
}
141-
sb.Source.BaseImages = bi.ImagesByDiffIds
141+
if bi != nil && len(bi.ImagesByDiffIds) > 0 {
142+
sb.Source.BaseImages = bi.ImagesByDiffIds
143+
}
142144
}
143145

144146
js, err := json.MarshalIndent(sb, "", " ")

query/base.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ func ForBaseImageInGraphQL(cfg *v1.ConfigFile, excludeSelf bool) (*types.BaseIma
227227
diffIds = diffIds[0 : len(diffIds)-1]
228228
}
229229

230+
if len(diffIds) == 0 {
231+
return nil, nil
232+
}
233+
230234
url := "https://api.dso.docker.com/v1/graphql"
231235
client := graphql.NewClient(url, nil)
232236
variables := map[string]interface{}{

registry/save.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ func (c *ImageCache) StoreImage() error {
8181
skill.Log.Debugf("Copying image to %s", c.ImagePath)
8282

8383
if format := os.Getenv("ATOMIST_CACHE_FORMAT"); format == "" || format == "oci" {
84+
spinner := internal.StartSpinner("info", "Copying image", c.cli.Out().IsTerminal())
85+
defer spinner.Stop()
8486
p, err := layout.FromPath(c.ImagePath)
8587
if err != nil {
8688
p, err = layout.Write(c.ImagePath, empty.Index)
@@ -91,6 +93,7 @@ func (c *ImageCache) StoreImage() error {
9193
if err = p.AppendImage(*c.Image); err != nil {
9294
return err
9395
}
96+
spinner.Stop()
9497
skill.Log.Infof("Copied image")
9598
return nil
9699
} else if format == "tar" {
@@ -140,14 +143,15 @@ func (c *ImageCache) Cleanup() {
140143
if !c.copy {
141144
return
142145
}
143-
e := os.Remove(c.ImagePath)
146+
e := os.RemoveAll(c.ImagePath)
144147
if e != nil {
145-
skill.Log.Warnf("Failed to delete tmp image archive %s", c.ImagePath)
148+
skill.Log.Warnf("Failed to delete tmp image archive %s: %v", c.ImagePath, e)
146149
}
147150
}
148151

149152
// SaveImage stores the v1.Image at path returned in OCI format
150153
func SaveImage(image string, cli command.Cli) (*ImageCache, error) {
154+
skill.Log.Infof("Requesting image %s", image)
151155
ref, err := name.ParseReference(image)
152156
if err != nil {
153157
return nil, errors.Wrapf(err, "failed to parse reference: %s", image)

0 commit comments

Comments
 (0)