@@ -288,19 +288,16 @@ func (c WorkerPoolConverter) toHcl(pool octopus.WorkerPool, _ bool, lookup bool,
288
288
289
289
// Fallback is used when the default worker pool, usually called "Hosted Ubuntu" or "Hosted Windows", is not found.
290
290
// An empty string falls back to the default worker pool.
291
- fallback := ""
291
+ // Note this string is used inside an interpolation, which is why it is wrapped in quotes.
292
+ fallback := "\" \" "
292
293
293
294
if forceLookup {
294
295
c .createDynamicWorkerPoolLookupResource (resourceName ,
295
- "workerpool_" + sanitizer . SanitizeName ( fallback ) ,
296
+ fallback ,
296
297
& thisResource ,
297
298
pool ,
298
299
stateless )
299
300
300
- dependencies .AddResource (* c .createStandAloneLookupResource (
301
- "workerpool_" + sanitizer .SanitizeName (fallback ),
302
- fallback ))
303
-
304
301
} else {
305
302
if c .GenerateImportScripts && ! stateless {
306
303
c .toBashImport (octopusdeployDynamicWorkerPoolResourceType , resourceName , pool .Name , dependencies )
@@ -431,6 +428,12 @@ func (c WorkerPoolConverter) createStaticWorkerPoolResource(resourceName string,
431
428
// to an on-premise instance, or vice versa.
432
429
func (c WorkerPoolConverter ) createStandAloneLookupResource (resourceName string , resourceDisplayName string ) * data.ResourceDetails {
433
430
431
+ // Resource names might be empty - a default worker pool is just an empty string.
432
+ // There is no need to create a data source for it.
433
+ if resourceDisplayName == "" {
434
+ return nil
435
+ }
436
+
434
437
thisResource := data.ResourceDetails {}
435
438
thisResource .FileName = "space_population/" + resourceName + ".tf"
436
439
thisResource .Name = resourceDisplayName
@@ -476,13 +479,13 @@ func (c WorkerPoolConverter) createStaticWorkerPoolLookupResource(resourceName s
476
479
}
477
480
}
478
481
479
- func (c WorkerPoolConverter ) createDynamicWorkerPoolLookupResource (resourceName string , fallbackResourceName string , thisResource * data.ResourceDetails , pool octopus.WorkerPool , stateless bool ) {
482
+ func (c WorkerPoolConverter ) createDynamicWorkerPoolLookupResource (resourceName string , fallbackDataLookup string , thisResource * data.ResourceDetails , pool octopus.WorkerPool , stateless bool ) {
480
483
if stateless {
481
484
// Stateless modules try to use the dynamic worker pool first, and if that fails, use the static worker pool
482
485
// This allows a module created on a cloud instance to be used in an on-premise instance.
483
486
thisResource .Lookup = "${length(data." + octopusdeployWorkerPoolsDataType + "." + resourceName + ".worker_pools) != 0 " +
484
487
"? data." + octopusdeployWorkerPoolsDataType + "." + resourceName + ".worker_pools[0].id " +
485
- ": data. " + octopusdeployWorkerPoolsDataType + "." + fallbackResourceName + ".worker_pools[0].id }"
488
+ ": " + fallbackDataLookup + "}"
486
489
} else {
487
490
thisResource .Lookup = "${data." + octopusdeployWorkerPoolsDataType + "." + resourceName + ".worker_pools[0].id}"
488
491
}
0 commit comments