@@ -302,12 +302,11 @@ func (c *Client) ResourcePools(ctx context.Context, path string) ([]*object.Reso
302
302
return items , nil
303
303
}
304
304
305
- // EnsureVMFolder creates the a VM folder with the given path if it doesn't
306
- // already exist.
307
- // LP: #1849194
308
- // Two string arguments needed: folderPath will be split on "/"
309
- // whereas credAttrFolder is added as subfolder structure from DC's root-folder
310
- func (c * Client ) EnsureVMFolder (ctx context.Context , credAttrFolder string , folderPath string ) (* object.Folder , error ) {
305
+ // EnsureVMFolder creates the a VM folder with the given path if it doesn't already exist.
306
+ // Two string arguments needed: relativeFolderPath will be split on "/"
307
+ // whereas parentFolderName is the subfolder in DC's root-folder.
308
+ // The parentFolderName will fallback to DC's root-folder if it's an empty string.
309
+ func (c * Client ) EnsureVMFolder (ctx context.Context , parentFolderName string , relativeFolderPath string ) (* object.Folder , error ) {
311
310
312
311
finder , _ , err := c .finder (ctx )
313
312
if err != nil {
@@ -335,18 +334,12 @@ func (c *Client) EnsureVMFolder(ctx context.Context, credAttrFolder string, fold
335
334
return nil , errors .Trace (err )
336
335
}
337
336
338
- // LP: #1849194
339
- // User do not necessarily own permission to create credAttrFolder
340
- // since that demands Add_folder permissions from the root-folder's DC.
341
- // Join paths folders.VMFolder and credentials attribute.
342
- parentFolder , err := c .FindFolder (ctx , credAttrFolder )
343
- // Consider the case where folder from credential attribute comes empty:
344
- // path.Join ignores empty entries.
337
+ parentFolder , err := c .FindFolder (ctx , parentFolderName )
345
338
if err != nil {
346
339
return nil , errors .Trace (err )
347
340
}
348
341
// Creating "Juju Controller (...)" folder and then model folder, for example.
349
- for _ , name := range strings .Split (folderPath , "/" ) {
342
+ for _ , name := range strings .Split (relativeFolderPath , "/" ) {
350
343
folder , err := createFolder (parentFolder , name )
351
344
if err != nil {
352
345
return nil , errors .Annotatef (err , "creating folder %q in %q" , name , parentFolder .InventoryPath )
0 commit comments