Skip to content

Commit 942e3a4

Browse files
committed
Add anyMatch for InstanceType
1 parent d17351e commit 942e3a4

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

serverscom/instances.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ func (i *instances) InstanceType(ctx context.Context, nodeName types.NodeName) (
149149
}
150150

151151
for _, instance := range cloudInstances {
152-
if instance.Name == string(nodeName) {
152+
if instance.Name == string(nodeName) || anyMatch(string(nodeName), instance.PrivateIPv4Address, instance.PublicIPv4Address) {
153153
return cloudInstanceType, nil
154154
}
155155
}
@@ -164,7 +164,7 @@ func (i *instances) InstanceType(ctx context.Context, nodeName types.NodeName) (
164164
}
165165

166166
for _, host := range hosts {
167-
if host.Title == string(nodeName) {
167+
if host.Title == string(nodeName) || anyMatch(string(nodeName), host.PrivateIPv4Address, host.PublicIPv4Address) {
168168
switch host.Type {
169169
case "dedicated_server":
170170
return dedicatedServerType, nil
@@ -176,7 +176,7 @@ func (i *instances) InstanceType(ctx context.Context, nodeName types.NodeName) (
176176
}
177177
}
178178

179-
return "", fmt.Errorf("can't find instance by name: %s", string(nodeName))
179+
return "", fmt.Errorf("can't find instance type by name: %s", string(nodeName))
180180
}
181181

182182
func (i *instances) InstanceTypeByProviderID(ctx context.Context, providerID string) (string, error) {

0 commit comments

Comments
 (0)