55 "path"
66 "strings"
77
8+ "github.com/loft-sh/devspace/pkg/devspace/pullsecrets"
9+
810 "github.com/loft-sh/devspace/pkg/util/ptr"
911
1012 "github.com/loft-sh/devspace/pkg/devspace/config/versions/config"
@@ -177,9 +179,10 @@ func (c *Config) Upgrade(log log.Logger) (config.Config, error) {
177179 // pull secrets
178180 pullSecrets := []string {}
179181 nextConfig .PullSecrets = map [string ]* next.PullSecretConfig {}
182+ pullSecretsByRegistry := map [string ]* next.PullSecretConfig {}
180183 for idx , pullSecret := range c .PullSecrets {
181184 pullSecretName := fmt .Sprintf ("pull-secret-%d" , idx )
182- nextConfig . PullSecrets [ pullSecretName ] = & next.PullSecretConfig {
185+ pullSecretConfig : = & next.PullSecretConfig {
183186 Name : pullSecretName ,
184187 Registry : pullSecret .Registry ,
185188 Username : pullSecret .Username ,
@@ -188,13 +191,50 @@ func (c *Config) Upgrade(log log.Logger) (config.Config, error) {
188191 Secret : pullSecret .Secret ,
189192 ServiceAccounts : pullSecret .ServiceAccounts ,
190193 }
194+ nextConfig .PullSecrets [pullSecretName ] = pullSecretConfig
195+ pullSecretsByRegistry [pullSecret .Registry ] = pullSecretConfig
196+
191197 if pullSecret .Disabled {
192198 continue
193199 }
194200
195201 pullSecrets = append (pullSecrets , pullSecretName )
196202 }
197203
204+ // Add pull secrets for images for backwards compatibility
205+ for k , image := range c .Images {
206+ registryURL , err := pullsecrets .GetRegistryFromImageName (image .Image )
207+ if err != nil {
208+ return nil , err
209+ }
210+
211+ if registryURL == "" {
212+ // Skip
213+ continue
214+ }
215+
216+ if image .CreatePullSecret != nil && ! * image .CreatePullSecret {
217+ // Disabled
218+ continue
219+ }
220+
221+ if pullSecretsByRegistry [registryURL ] != nil {
222+ // Already configured
223+ continue
224+ }
225+
226+ // Create a default pull secret config for images without pull secrets.
227+ pullSecretName := encoding .Convert (k )
228+ pullSecretConfig := & next.PullSecretConfig {
229+ Name : pullSecretName ,
230+ Registry : registryURL ,
231+ }
232+ nextConfig .PullSecrets [pullSecretName ] = pullSecretConfig
233+ pullSecretsByRegistry [registryURL ] = pullSecretConfig
234+
235+ pullSecrets = append (pullSecrets , pullSecretName )
236+ }
237+
198238 // use a pretty simple pipeline which was used by DevSpace before
199239 if len (pullSecrets ) > 0 {
200240 deployPipeline += fmt .Sprintf ("ensure_pull_secrets %s\n " , strings .Join (pullSecrets , " " ))
0 commit comments