Skip to content

Commit 4d7d221

Browse files
committed
Generate proper set of commands to setup snap store proxy via cloudinit
While the proxyupdater worker is already capable of setting up snap to work with snap store proxies, it runs at a later stage than the point where we might need to install snap packages (e.g. lxd dependencies). This commit updates the cloudinit code to include the appropriate commands so that we can setup snap proxies as early as possible.
1 parent fe7a12d commit 4d7d221

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

cloudconfig/cloudinit/cloudinit_ubuntu.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,4 +313,22 @@ func (cfg *ubuntuCloudConfig) updateProxySettings(proxyCfg PackageManagerProxyCo
313313
utils.ShQuote(pkgCmder.ProxyConfigContents(aptProxy)),
314314
filename))
315315
}
316+
317+
// Write out the snap http/https proxy settings
318+
if snapProxy := proxyCfg.SnapProxy(); (snapProxy != proxy.Settings{}) {
319+
pkgCmder := cfg.paccmder[jujupackaging.SnapPackageManager]
320+
for _, cmd := range pkgCmder.SetProxyCmds(snapProxy) {
321+
cfg.AddBootCmd(cmd)
322+
}
323+
}
324+
325+
// Configure snap store proxy
326+
if proxyCfg.SnapStoreAssertions() != "" && proxyCfg.SnapStoreProxyID() != "" {
327+
cfg.AddBootCmd(fmt.Sprintf(
328+
`printf '%%s\n' %s > %s`,
329+
utils.ShQuote(proxyCfg.SnapStoreAssertions()),
330+
"/etc/snap.assertions"))
331+
cfg.AddBootCmd("snap ack /etc/snap.assertions")
332+
cfg.AddBootCmd("snap set core proxy.store=" + proxyCfg.SnapStoreProxyID())
333+
}
316334
}

0 commit comments

Comments
 (0)