From 55176804a02f7b73ef3bd7bd009bbdfb655a8804 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Edu=20G=C3=B3mez=20Escandell?=
 <edu.gomez.escandell@canonical.com>
Date: Tue, 7 Nov 2023 15:12:08 +0200
Subject: [PATCH] Prioritize Organization settings

Now that the write permissions to the registry are irrelevant, we
need a way for the sysadmin to enforce its configuration on the machine.
To achieve this, we set the org-provided Landscape and Pro settings
as the top layer.
---
 windows-agent/internal/config/config_source.go | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/windows-agent/internal/config/config_source.go b/windows-agent/internal/config/config_source.go
index 17225474f..940fdafa1 100644
--- a/windows-agent/internal/config/config_source.go
+++ b/windows-agent/internal/config/config_source.go
@@ -26,6 +26,10 @@ type subscription struct {
 }
 
 func (s subscription) resolve() (string, Source) {
+	if s.Organization != "" {
+		return s.Organization, SourceRegistry
+	}
+
 	if s.Store != "" {
 		return s.Store, SourceMicrosoftStore
 	}
@@ -34,10 +38,6 @@ func (s subscription) resolve() (string, Source) {
 		return s.User, SourceUser
 	}
 
-	if s.Organization != "" {
-		return s.Organization, SourceRegistry
-	}
-
 	return "", SourceNone
 }
 
@@ -50,13 +50,13 @@ type landscapeConf struct {
 }
 
 func (p landscapeConf) resolve() (string, Source) {
-	if p.UserConfig != "" {
-		return p.UserConfig, SourceUser
-	}
-
 	if p.OrgConfig != "" {
 		return p.OrgConfig, SourceRegistry
 	}
 
+	if p.UserConfig != "" {
+		return p.UserConfig, SourceUser
+	}
+
 	return "", SourceNone
 }