(name string)
| 71 | } |
| 72 | |
| 73 | func (i *InstanceCache) GetEntityForInstance(name string) (params.ForgeEntity, bool) { |
| 74 | instance, ok := i.GetInstance(name) |
| 75 | if !ok { |
| 76 | return params.ForgeEntity{}, ok |
| 77 | } |
| 78 | |
| 79 | var entityID string |
| 80 | switch { |
| 81 | case instance.ScaleSetID > 0: |
| 82 | if scaleSet, ok := GetScaleSetByID(instance.ScaleSetID); ok { |
| 83 | scaleSetEntity, err := scaleSet.GetEntity() |
| 84 | if err != nil { |
| 85 | return params.ForgeEntity{}, false |
| 86 | } |
| 87 | entityID = scaleSetEntity.ID |
| 88 | } |
| 89 | case instance.PoolID != "": |
| 90 | if pool, ok := GetPoolByID(instance.PoolID); ok { |
| 91 | poolEntity, err := pool.GetEntity() |
| 92 | if err != nil { |
| 93 | return params.ForgeEntity{}, false |
| 94 | } |
| 95 | entityID = poolEntity.ID |
| 96 | } |
| 97 | default: |
| 98 | return params.ForgeEntity{}, false |
| 99 | } |
| 100 | |
| 101 | // Get the full entity |
| 102 | if entityID != "" { |
| 103 | if entity, ok := GetEntity(entityID); ok { |
| 104 | return entity, true |
| 105 | } |
| 106 | } |
| 107 | return params.ForgeEntity{}, false |
| 108 | } |
| 109 | |
| 110 | func (i *InstanceCache) GetInstancesForPool(poolID string) []params.Instance { |
| 111 | i.mux.Lock() |
no test coverage detected