Skip to content

Commit

Permalink
Subscribe cloud-init to config notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
EduardGomezEscandell committed Jan 23, 2024
1 parent 7bfe8f5 commit 7dbe866
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions windows-agent/internal/proservices/proservices.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7dbe866

Please sign in to comment.