1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

refactor(edge/updates): sync changes from EE [EE-4288] (#7726)

This commit is contained in:
Chaim Lev-Ari 2022-12-01 08:40:52 +02:00 committed by GitHub
parent 4fee359247
commit 82e9e2a895
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
80 changed files with 1099 additions and 1892 deletions

View file

@ -2,8 +2,10 @@ package edge
import (
"errors"
"fmt"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/dataservices"
)
// EdgeStackRelatedEndpoints returns a list of environments(endpoints) related to this Edge stack
@ -29,3 +31,33 @@ func EdgeStackRelatedEndpoints(edgeGroupIDs []portainer.EdgeGroupID, endpoints [
return edgeStackEndpoints, nil
}
type EndpointRelationsConfig struct {
Endpoints []portainer.Endpoint
EndpointGroups []portainer.EndpointGroup
EdgeGroups []portainer.EdgeGroup
}
// FetchEndpointRelationsConfig fetches config needed for Edge Stack related endpoints
func FetchEndpointRelationsConfig(dataStore dataservices.DataStore) (*EndpointRelationsConfig, error) {
endpoints, err := dataStore.Endpoint().Endpoints()
if err != nil {
return nil, fmt.Errorf("unable to retrieve environments from database: %w", err)
}
endpointGroups, err := dataStore.EndpointGroup().EndpointGroups()
if err != nil {
return nil, fmt.Errorf("unable to retrieve environment groups from database: %w", err)
}
edgeGroups, err := dataStore.EdgeGroup().EdgeGroups()
if err != nil {
return nil, fmt.Errorf("unable to retrieve edge groups from database: %w", err)
}
return &EndpointRelationsConfig{
Endpoints: endpoints,
EndpointGroups: endpointGroups,
EdgeGroups: edgeGroups,
}, nil
}