mirror of https://github.com/portainer/portainer
fix(docker): add docker desktop extension flag in settings and add migration EE-5277 (#8948)
parent
e156243e43
commit
83551201fb
|
@ -1,6 +1,8 @@
|
|||
package datastore
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
)
|
||||
|
||||
|
@ -20,6 +22,12 @@ func (store *Store) Init() error {
|
|||
}
|
||||
|
||||
func (store *Store) checkOrCreateDefaultSettings() error {
|
||||
|
||||
isDDExtention := false
|
||||
if _, ok := os.LookupEnv("DOCKER_EXTENSION"); ok {
|
||||
isDDExtention = true
|
||||
}
|
||||
|
||||
// TODO: these need to also be applied when importing
|
||||
settings, err := store.SettingsService.Settings()
|
||||
if store.IsErrObjectNotFound(err) {
|
||||
|
@ -51,6 +59,8 @@ func (store *Store) checkOrCreateDefaultSettings() error {
|
|||
UserSessionTimeout: portainer.DefaultUserSessionTimeout,
|
||||
KubeconfigExpiry: portainer.DefaultKubeconfigExpiry,
|
||||
KubectlShellImage: portainer.DefaultKubectlShellImage,
|
||||
|
||||
IsDockerDesktopExtention: isDDExtention,
|
||||
}
|
||||
|
||||
return store.SettingsService.UpdateSettings(defaultSettings)
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
package migrator
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
func (m *Migrator) migrateDockerDesktopExtentionSetting() error {
|
||||
log.Info().Msg("updating docker desktop extention flag in settings")
|
||||
|
||||
isDDExtention := false
|
||||
if _, ok := os.LookupEnv("DOCKER_EXTENSION"); ok {
|
||||
isDDExtention = true
|
||||
}
|
||||
|
||||
settings, err := m.settingsService.Settings()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
settings.IsDockerDesktopExtention = isDDExtention
|
||||
err = m.settingsService.UpdateSettings(settings)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -211,6 +211,8 @@ func (m *Migrator) initMigrations() {
|
|||
m.addMigrations("2.17", m.migrateDBVersionToDB80)
|
||||
m.addMigrations("2.18", m.migrateDBVersionToDB90)
|
||||
|
||||
m.addMigrations("2.19", m.migrateDockerDesktopExtentionSetting)
|
||||
|
||||
// Add new migrations below...
|
||||
// One function per migration, each versions migration funcs in the same file.
|
||||
}
|
||||
|
|
|
@ -606,6 +606,7 @@
|
|||
"InternalAuthSettings": {
|
||||
"RequiredPasswordLength": 12
|
||||
},
|
||||
"IsDockerDesktopExtention": false,
|
||||
"KubeconfigExpiry": "0",
|
||||
"KubectlShellImage": "portainer/kubectl-shell",
|
||||
"LDAPSettings": {
|
||||
|
@ -945,6 +946,6 @@
|
|||
}
|
||||
],
|
||||
"version": {
|
||||
"VERSION": "{\"SchemaVersion\":\"2.19.0\",\"MigratorCount\":0,\"Edition\":1,\"InstanceID\":\"463d5c47-0ea5-4aca-85b1-405ceefee254\"}"
|
||||
"VERSION": "{\"SchemaVersion\":\"2.19.0\",\"MigratorCount\":1,\"Edition\":1,\"InstanceID\":\"463d5c47-0ea5-4aca-85b1-405ceefee254\"}"
|
||||
}
|
||||
}
|
|
@ -49,6 +49,8 @@ type publicSettingsResponse struct {
|
|||
// The check in interval for edge agent (in seconds) - used in non async mode [seconds]
|
||||
CheckinInterval int `example:"60"`
|
||||
}
|
||||
|
||||
IsDockerDesktopExtention bool `json:"IsDockerDesktopExtention" example:"false"`
|
||||
}
|
||||
|
||||
// @id SettingsPublic
|
||||
|
@ -89,6 +91,8 @@ func generatePublicSettings(appSettings *portainer.Settings) *publicSettingsResp
|
|||
publicSettings.Edge.CommandInterval = appSettings.Edge.CommandInterval
|
||||
publicSettings.Edge.CheckinInterval = appSettings.EdgeAgentCheckinInterval
|
||||
|
||||
publicSettings.IsDockerDesktopExtention = appSettings.IsDockerDesktopExtention
|
||||
|
||||
//if OAuth authentication is on, compose the related fields from application settings
|
||||
if publicSettings.AuthenticationMethod == portainer.AuthenticationOAuth {
|
||||
publicSettings.OAuthLogoutURI = appSettings.OAuthSettings.LogoutURI
|
||||
|
|
|
@ -3,7 +3,6 @@ package jwt
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
portainer "github.com/portainer/portainer/api"
|
||||
|
@ -169,7 +168,12 @@ func (service *Service) generateSignedToken(data *portainer.TokenData, expiresAt
|
|||
return "", fmt.Errorf("invalid scope: %v", scope)
|
||||
}
|
||||
|
||||
if _, ok := os.LookupEnv("DOCKER_EXTENSION"); ok {
|
||||
settings, err := service.dataStore.Settings().Settings()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed fetching settings from db: %w", err)
|
||||
}
|
||||
|
||||
if settings.IsDockerDesktopExtention {
|
||||
// Set expiration to 99 years for docker desktop extension.
|
||||
log.Info().Msg("detected docker desktop extension mode")
|
||||
expiresAt = time.Now().Add(time.Hour * 8760 * 99).Unix()
|
||||
|
|
|
@ -967,6 +967,8 @@ type (
|
|||
AllowStackManagementForRegularUsers bool `json:"AllowStackManagementForRegularUsers"`
|
||||
AllowDeviceMappingForRegularUsers bool `json:"AllowDeviceMappingForRegularUsers"`
|
||||
AllowContainerCapabilitiesForRegularUsers bool `json:"AllowContainerCapabilitiesForRegularUsers"`
|
||||
|
||||
IsDockerDesktopExtention bool `json:"IsDockerDesktopExtention"`
|
||||
}
|
||||
|
||||
// SnapshotJob represents a scheduled job that can create environment(endpoint) snapshots
|
||||
|
|
Loading…
Reference in New Issue