@@ -29,21 +29,15 @@ import {
2929} from './types.js' ;
3030
3131/**
32- * Return the changes required to meet the nextConfig, given the currentConfig.
33- * All changes are given in the order they should be applied, in order to minimize operational risks.
34- *
35- * @param currentConfig
36- * @param nextConfig
32+ * Return the keyspace changes (buckets, scopes, collections, indexes) required
33+ * to meet the nextConfig, given the currentConfig.
3734 */
38- export function getCouchbaseClusterChanges (
35+ export function getCouchbaseKeyspaceChanges (
3936 currentConfig : Partial < CouchbaseClusterConfig > ,
4037 nextConfig : Partial < CouchbaseClusterConfig >
4138) : CouchbaseClusterChange [ ] {
4239 const changes : CouchbaseClusterChange [ ] = [ ] ;
4340
44- ///////////////
45- // KEYSPACES //
46- ///////////////
4741 const currentKeyspaceConfig = currentConfig . keyspaces ?? { } ;
4842 const nextKeyspaceConfig = nextConfig . keyspaces ?? { } ;
4943
@@ -147,19 +141,42 @@ export function getCouchbaseClusterChanges(
147141 ) ;
148142 } ) ;
149143
150- ///////////
151- // USERS //
152- ///////////
144+ return changes ;
145+ }
146+
147+ /**
148+ * Return the access changes (users, and later roles) required
149+ * to meet the nextConfig, given the currentConfig.
150+ */
151+ export function getCouchbaseAccessChanges (
152+ currentConfig : Partial < CouchbaseClusterConfig > ,
153+ nextConfig : Partial < CouchbaseClusterConfig >
154+ ) : CouchbaseClusterChange [ ] {
153155 const currentUsersConfig = currentConfig . users ?? [ ] ;
154156 const nextUsersConfig = nextConfig . users ?? [ ] ;
155157
156158 const newUsers = getNewUsers ( currentUsersConfig , nextUsersConfig ) ;
157159 const updatedUsers = getUpdatedUsers ( currentUsersConfig , nextUsersConfig ) ;
158160 const obsoleteUsers = getObsoleteUsers ( currentUsersConfig , nextUsersConfig ) ;
159161
160- changes . push ( ...newUsers , ...updatedUsers , ...obsoleteUsers ) ;
162+ return [ ...newUsers , ...updatedUsers , ...obsoleteUsers ] ;
163+ }
161164
162- return changes ;
165+ /**
166+ * Return all changes required to meet the nextConfig, given the currentConfig.
167+ * All changes are given in the order they should be applied, in order to minimize operational risks.
168+ *
169+ * @param currentConfig
170+ * @param nextConfig
171+ */
172+ export function getCouchbaseClusterChanges (
173+ currentConfig : Partial < CouchbaseClusterConfig > ,
174+ nextConfig : Partial < CouchbaseClusterConfig >
175+ ) : CouchbaseClusterChange [ ] {
176+ return [
177+ ...getCouchbaseKeyspaceChanges ( currentConfig , nextConfig ) ,
178+ ...getCouchbaseAccessChanges ( currentConfig , nextConfig ) ,
179+ ] ;
163180}
164181
165182/**
0 commit comments