mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add function to get endpoint group by name
This commit is contained in:
parent
d2030e6bfb
commit
b4f6dd7476
@ -12,6 +12,7 @@ const (
|
|||||||
ErrStackNotFound = Error("Stack not found")
|
ErrStackNotFound = Error("Stack not found")
|
||||||
ErrStackClusterNotFound = Error("Stack cluster not found")
|
ErrStackClusterNotFound = Error("Stack cluster not found")
|
||||||
ErrEndpointNotFound = Error("Endpoint not found")
|
ErrEndpointNotFound = Error("Endpoint not found")
|
||||||
|
ErrEndpointGroupNotFound = Error("Endpoint group not found")
|
||||||
ErrSeveralEndpointsAvailable = Error("Several endpoints available")
|
ErrSeveralEndpointsAvailable = Error("Several endpoints available")
|
||||||
ErrNoEndpointsAvailable = Error("No endpoints available")
|
ErrNoEndpointsAvailable = Error("No endpoints available")
|
||||||
)
|
)
|
||||||
@ -92,6 +93,26 @@ func GetEndpointByName(name string) (endpoint portainer.Endpoint, err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetEndpointGroupByName(name string) (endpointGroup portainer.EndpointGroup, err error) {
|
||||||
|
portainerClient, err := GetClient()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
endpointGroups, err := portainerClient.GetEndpointGroups()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, endpointGroup := range endpointGroups {
|
||||||
|
if endpointGroup.Name == name {
|
||||||
|
return endpointGroup, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = ErrEndpointGroupNotFound
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func GetEndpointFromListById(endpoints []portainer.Endpoint, id portainer.EndpointID) (endpoint portainer.Endpoint, err error) {
|
func GetEndpointFromListById(endpoints []portainer.Endpoint, id portainer.EndpointID) (endpoint portainer.Endpoint, err error) {
|
||||||
for i := range endpoints {
|
for i := range endpoints {
|
||||||
if endpoints[i].ID == id {
|
if endpoints[i].ID == id {
|
||||||
|
Loading…
Reference in New Issue
Block a user