mirror of
https://gitlab.com/psuapp/psu.git
synced 2024-08-30 18:12:34 +00:00
Add function to get endpoint by its name
This commit is contained in:
parent
d28a78cf28
commit
a6f4f88fd2
@ -11,6 +11,7 @@ import (
|
||||
const (
|
||||
ErrStackNotFound = Error("Stack not found")
|
||||
ErrStackClusterNotFound = Error("Stack cluster not found")
|
||||
ErrEndpointNotFound = Error("Endpoint not found")
|
||||
ErrSeveralEndpointsAvailable = Error("Several endpoints available")
|
||||
ErrNoEndpointsAvailable = Error("No endpoints available")
|
||||
)
|
||||
@ -71,6 +72,26 @@ func GetStackByName(name string, swarmId string, endpointId portainer.EndpointID
|
||||
return
|
||||
}
|
||||
|
||||
func GetEndpointByName(name string) (endpoint portainer.Endpoint, err error) {
|
||||
portainerClient, err := GetClient()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
endpoints, err := portainerClient.GetEndpoints()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
for _, endpoint := range endpoints {
|
||||
if endpoint.Name == name {
|
||||
return endpoint, nil
|
||||
}
|
||||
}
|
||||
err = ErrEndpointNotFound
|
||||
return
|
||||
}
|
||||
|
||||
func GetEndpointSwarmClusterId(endpointId portainer.EndpointID) (endpointSwarmClusterId string, err error) {
|
||||
// Get docker information for endpoint
|
||||
portainerClient, err := GetClient()
|
||||
|
Loading…
Reference in New Issue
Block a user