func()

in pkg/providers/instance/instance.go [192:211]


func (p *Provider) convertAgentPoolToInstance(ctx context.Context, apObj *armcontainerservice.AgentPool, id string) (*Instance, error) {
	if apObj == nil || len(id) == 0 {
		return nil, fmt.Errorf("agent pool or provider id is nil")
	}

	instanceLabels := lo.MapValues(apObj.Properties.NodeLabels, func(k *string, _ string) string {
		return lo.FromPtr(k)
	})

	return &Instance{
		Name:     apObj.Name,
		ID:       to.Ptr(id),
		Type:     apObj.Properties.VMSize,
		SubnetID: apObj.Properties.VnetSubnetID,
		Tags:     apObj.Properties.Tags,
		State:    apObj.Properties.ProvisioningState,
		Labels:   instanceLabels,
		ImageID:  apObj.Properties.NodeImageVersion,
	}, nil
}