mirror of https://github.com/portainer/portainer
fix(api): skip guessing env when there is no env in DB (#12238)
parent
6f84317e7a
commit
80f53ed6ec
|
@ -76,12 +76,17 @@ func guessLocalEnvironment(dataStore dataservices.DataStore) (*portainer.Endpoin
|
||||||
|
|
||||||
endpoints, err := dataStore.Endpoint().Endpoints()
|
endpoints, err := dataStore.Endpoint().Endpoints()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("failed to retrieve endpoints: %w", err)
|
return nil, "", fmt.Errorf("failed to retrieve environments: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// skip guessing when there is no endpoints registered in DB
|
||||||
|
if len(endpoints) == 0 {
|
||||||
|
return nil, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
endpointTypes, ok := platformToEndpointType[platform]
|
endpointTypes, ok := platformToEndpointType[platform]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, "", errors.New("failed to determine endpoint type")
|
return nil, "", errors.New("failed to determine environment type")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, endpoint := range endpoints {
|
for _, endpoint := range endpoints {
|
||||||
|
@ -97,7 +102,7 @@ func guessLocalEnvironment(dataStore dataservices.DataStore) (*portainer.Endpoin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, "", errors.New("failed to find local endpoint")
|
return nil, "", errors.New("failed to find local environment")
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkDockerEnvTypeForUpgrade(environment *portainer.Endpoint) ContainerPlatform {
|
func checkDockerEnvTypeForUpgrade(environment *portainer.Endpoint) ContainerPlatform {
|
||||||
|
|
Loading…
Reference in New Issue