@@ -75,11 +75,6 @@ func getBaseImage(bo *options.BuildOptions) build.GetBase {
75
75
}
76
76
77
77
fetch := func (ctx context.Context , ref name.Reference ) (build.Result , error ) {
78
- // For ko.local, look in the daemon.
79
- if ref .Context ().RegistryStr () == publish .LocalDomain {
80
- return daemon .Image (ref )
81
- }
82
-
83
78
ropt = append (ropt , remote .WithContext (ctx ))
84
79
85
80
desc , err := remote .Get (ref , ropt ... )
@@ -91,6 +86,7 @@ func getBaseImage(bo *options.BuildOptions) build.GetBase {
91
86
}
92
87
return desc .Image ()
93
88
}
89
+
94
90
return func (ctx context.Context , s string ) (name.Reference , build.Result , error ) {
95
91
s = strings .TrimPrefix (s , build .StrictScheme )
96
92
// Viper configuration file keys are case insensitive, and are
@@ -112,9 +108,26 @@ func getBaseImage(bo *options.BuildOptions) build.GetBase {
112
108
return nil , nil , fmt .Errorf ("parsing base image (%q): %w" , baseImage , err )
113
109
}
114
110
115
- result , err := cache .get (ctx , ref , fetch )
116
- if err != nil {
117
- return ref , result , err
111
+ var result build.Result
112
+
113
+ // For ko.local, look in the daemon.
114
+ if ref .Context ().RegistryStr () == publish .LocalDomain {
115
+ result , err = daemon .Image (ref )
116
+ if err != nil {
117
+ return nil , nil , fmt .Errorf ("loading %s from daemon: %w" , ref , err )
118
+ }
119
+ } else {
120
+ result , err = cache .get (ctx , ref , fetch )
121
+ if err != nil {
122
+ // We don't expect this to fail, usually, but the cache should also not be fatal.
123
+ // Log it so people can complain about it and we can fix the cache.
124
+ log .Printf ("cache.get(%q) failed with %v" , ref .String (), err )
125
+
126
+ result , err = fetch (ctx , ref )
127
+ if err != nil {
128
+ return nil , nil , fmt .Errorf ("pulling %s: %w" , ref , err )
129
+ }
130
+ }
118
131
}
119
132
120
133
if _ , ok := ref .(name.Digest ); ok {
0 commit comments