mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
debugd: filter own instance from list of discovered debugd instances
This commit is contained in:
parent
7143b29caf
commit
6954683f18
@ -49,10 +49,21 @@ func NewAzure(ctx context.Context) (*Fetcher, error) {
|
||||
|
||||
// DiscoverDebugdIPs will query the metadata of all instances and return any ips of instances already set up for debugging.
|
||||
func (f *Fetcher) DiscoverDebugdIPs(ctx context.Context) ([]string, error) {
|
||||
self, err := f.metaAPI.Self(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving own instance failed: %w", err)
|
||||
}
|
||||
instances, err := f.metaAPI.List(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("retrieving instances failed: %w", err)
|
||||
}
|
||||
// filter own instance from instance list
|
||||
for i, instance := range instances {
|
||||
if instance.ProviderID == self.ProviderID {
|
||||
instances = append(instances[:i], instances[i+1:]...)
|
||||
break
|
||||
}
|
||||
}
|
||||
var ips []string
|
||||
for _, instance := range instances {
|
||||
ips = append(ips, instance.IPs...)
|
||||
|
@ -34,7 +34,7 @@ func TestDiscoverDebugIPs(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expectedIPs: []string{
|
||||
"192.0.2.0", "192.0.2.1", "192.0.2.2",
|
||||
"192.0.2.1", "192.0.2.2",
|
||||
},
|
||||
},
|
||||
"retrieve fails": {
|
||||
|
Loading…
Reference in New Issue
Block a user