From 7dbe866db04691b17103dd4806e83d989a8f531b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?= Date: Tue, 23 Jan 2024 15:52:35 +0100 Subject: [PATCH] Subscribe cloud-init to config notifications --- windows-agent/internal/proservices/proservices.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/windows-agent/internal/proservices/proservices.go b/windows-agent/internal/proservices/proservices.go index 681bfc104..ceccbda4d 100644 --- a/windows-agent/internal/proservices/proservices.go +++ b/windows-agent/internal/proservices/proservices.go @@ -9,6 +9,7 @@ import ( agent_api "github.com/canonical/ubuntu-pro-for-windows/agentapi/go" "github.com/canonical/ubuntu-pro-for-windows/common" + "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/cloudinit" "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/config" "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/distros/database" "github.com/canonical/ubuntu-pro-for-windows/windows-agent/internal/grpc/interceptorschain" @@ -99,6 +100,16 @@ func New(ctx context.Context, args ...Option) (s Manager, err error) { conf := config.New(ctx, opts.cacheDir) + // Write cloud-init agent data, and do so again every time the config changes. + f := func() { + if err := cloudinit.WriteAgentData(ctx, conf); err != nil { + log.Error(ctx, err) + } + } + + f() + conf.Notify(f) + db, err := database.New(ctx, opts.cacheDir, conf) if err != nil { return s, err