@@ -73,40 +73,42 @@ func (c *Configuration) migrateUsers() ([]string, error) {
7373 clusterModeStoragePath := path .Join (c .HAProxy .DataplaneStorageDir , storage .ClusterModeDataFileName )
7474
7575 usersToMigrate := make ([]storagetype.User , 0 )
76- for _ , singleModeUser := range dapiCfgStorage .Dataplaneapi .Users {
77- found := false
78- // Only migrate cluster users
79- if ! singleModeUser .IsClusterUser () {
80- continue
81- }
76+ if dapiCfgStorage .Dataplaneapi != nil {
77+ for _ , singleModeUser := range dapiCfgStorage .Dataplaneapi .Users {
78+ found := false
79+ // Only migrate cluster users
80+ if ! singleModeUser .IsClusterUser () {
81+ continue
82+ }
8283
83- var muser storagetype.User
84- for _ , muser = range dapiStorageUsers {
85- if muser .Name == singleModeUser .Name {
86- found = true
87- break
84+ var muser storagetype.User
85+ for _ , muser = range dapiStorageUsers {
86+ if muser .Name == singleModeUser .Name {
87+ found = true
88+ break
89+ }
8890 }
89- }
9091
91- // Already migrated
92- if found {
93- msg := fmt .Sprintf ("[CFG DEPRECATED] [SKIP] [User] [%s]: already migrated. Old location [%s] New location [%s]. Use only new location" ,
94- singleModeUser .Name ,
95- c .HAProxy .DataplaneConfig ,
96- clusterModeStoragePath )
97- // Logging is not done here as at startup, the logger is not yet initialized
98- // so it's done later on
99- deprecationInfoMsg = append (deprecationInfoMsg , msg )
100- } else {
101- // If not already migrated, then migrate it
102- msg := fmt .Sprintf ("[CFG DEPRECATED] [MIGRATE] [User] [%s]: migrating. Old location [%s] New location [%s]. Use only new location" ,
103- singleModeUser .Name ,
104- c .HAProxy .DataplaneConfig ,
105- clusterModeStoragePath )
106- // Logging is not done here as at startup, the logger is not yet initialized
107- // so it's done later on
108- deprecationInfoMsg = append (deprecationInfoMsg , msg )
109- usersToMigrate = append (usersToMigrate , singleModeUser )
92+ // Already migrated
93+ if found {
94+ msg := fmt .Sprintf ("[CFG DEPRECATED] [SKIP] [User] [%s]: already migrated. Old location [%s] New location [%s]. Use only new location" ,
95+ singleModeUser .Name ,
96+ c .HAProxy .DataplaneConfig ,
97+ clusterModeStoragePath )
98+ // Logging is not done here as at startup, the logger is not yet initialized
99+ // so it's done later on
100+ deprecationInfoMsg = append (deprecationInfoMsg , msg )
101+ } else {
102+ // If not already migrated, then migrate it
103+ msg := fmt .Sprintf ("[CFG DEPRECATED] [MIGRATE] [User] [%s]: migrating. Old location [%s] New location [%s]. Use only new location" ,
104+ singleModeUser .Name ,
105+ c .HAProxy .DataplaneConfig ,
106+ clusterModeStoragePath )
107+ // Logging is not done here as at startup, the logger is not yet initialized
108+ // so it's done later on
109+ deprecationInfoMsg = append (deprecationInfoMsg , msg )
110+ usersToMigrate = append (usersToMigrate , singleModeUser )
111+ }
110112 }
111113 }
112114 if err := c .clusterModeStorage .AddUsersAndStore (usersToMigrate ); err != nil {
0 commit comments