Merge pull request #8737 from roidelapluie/scwpointer

scaleway_sd_config: be more cautious with pointers
pull/8743/head
Julien Pivotto 2021-04-20 12:07:33 +02:00 committed by GitHub
commit 5f4a5e79ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 17 deletions

View File

@ -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())
}