fix(api): skip guessing env when there is no env in DB (#12238)

pull/12227/head
LP B 2 months ago committed by GitHub
parent 6f84317e7a
commit 80f53ed6ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -76,12 +76,17 @@ func guessLocalEnvironment(dataStore dataservices.DataStore) (*portainer.Endpoin
endpoints, err := dataStore.Endpoint().Endpoints()
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]
if !ok {
return nil, "", errors.New("failed to determine endpoint type")
return nil, "", errors.New("failed to determine environment type")
}
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 {

Loading…
Cancel
Save