scaleway_sd_config: be more cautious with pointers
@@ -137,22 +137,31 @@ func (d *instanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group,
instanceBootTypeLabel: model.LabelValue(server.BootType),
instanceHostnameLabel: model.LabelValue(server.Hostname),
instanceIDLabel: model.LabelValue(server.ID),
- instanceImageArchLabel: model.LabelValue(server.Image.Arch),
- instanceImageIDLabel: model.LabelValue(server.Image.ID),
- instanceImageNameLabel: model.LabelValue(server.Image.Name),
- instanceLocationClusterID: model.LabelValue(server.Location.ClusterID),
- instanceLocationHypervisorID: model.LabelValue(server.Location.HypervisorID),
- instanceLocationNodeID: model.LabelValue(server.Location.NodeID),
instanceNameLabel: model.LabelValue(server.Name),
instanceOrganizationLabel: model.LabelValue(server.Organization),
instanceProjectLabel: model.LabelValue(server.Project),
- instanceSecurityGroupIDLabel: model.LabelValue(server.SecurityGroup.ID),
- instanceSecurityGroupNameLabel: model.LabelValue(server.SecurityGroup.Name),
instanceStateLabel: model.LabelValue(server.State),
instanceTypeLabel: model.LabelValue(server.CommercialType),
instanceZoneLabel: model.LabelValue(server.Zone.String()),
}
+ if server.Image != nil {
+ labels[instanceImageArchLabel] = model.LabelValue(server.Image.Arch)
+ labels[instanceImageIDLabel] = model.LabelValue(server.Image.ID)
+ labels[instanceImageNameLabel] = model.LabelValue(server.Image.Name)
+ }
+
+ if server.Location != nil {
+ labels[instanceLocationClusterID] = model.LabelValue(server.Location.ClusterID)
+ labels[instanceLocationHypervisorID] = model.LabelValue(server.Location.HypervisorID)
+ labels[instanceLocationNodeID] = model.LabelValue(server.Location.NodeID)
+ }
+
+ if server.SecurityGroup != nil {
+ labels[instanceSecurityGroupIDLabel] = model.LabelValue(server.SecurityGroup.ID)
+ labels[instanceSecurityGroupNameLabel] = model.LabelValue(server.SecurityGroup.Name)
+ }
+
if region, err := server.Zone.Region(); err == nil {
labels[instanceRegionLabel] = model.LabelValue(region.String())
}
