scaleway_sd_config: be more cautious with pointers

Signed-off-by: Julien Pivotto <roidelapluie@inuits.eu>
This commit is contained in:
Julien Pivotto 2021-04-19 20:40:14 +02:00
parent a9a5f04ff9
commit 73237c04bf

View file

@ -134,23 +134,32 @@ func (d *instanceDiscovery) refresh(ctx context.Context) ([]*targetgroup.Group,
var targets []model.LabelSet
for _, server := range servers.Servers {
labels := model.LabelSet{
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()),
instanceBootTypeLabel: model.LabelValue(server.BootType),
instanceHostnameLabel: model.LabelValue(server.Hostname),
instanceIDLabel: model.LabelValue(server.ID),
instanceNameLabel: model.LabelValue(server.Name),
instanceOrganizationLabel: model.LabelValue(server.Organization),
instanceProjectLabel: model.LabelValue(server.Project),
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 {