func()

in pkg/providers/instance/instance.go [292:322]


func (p *Provider) fromAPListToInstances(ctx context.Context, apList []*armcontainerservice.AgentPool) ([]*Instance, error) {
	instances := []*Instance{}
	if len(apList) == 0 {
		return instances, cloudprovider.NewNodeClaimNotFoundError(fmt.Errorf("agentpools not found"))
	}
	for index := range apList {
		// skip agentPool that is not owned by kaito
		if !agentPoolIsOwnedByKaito(apList[index]) {
			continue
		}

		// skip agentPool which is not created from nodeclaim
		if !agentPoolIsCreatedFromNodeClaim(apList[index]) {
			continue
		}

		instance, err := p.fromKaitoAgentPoolToInstance(ctx, apList[index])
		if err != nil {
			return instances, err
		}
		if instance != nil {
			instances = append(instances, instance)
		}
	}

	if len(instances) == 0 {
		return instances, cloudprovider.NewNodeClaimNotFoundError(fmt.Errorf("agentpools not found"))
	}

	return instances, nil
}