2022-07-20 11:20:49 +02:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/zitadel/zitadel/internal/command"
|
|
|
|
"github.com/zitadel/zitadel/internal/config/systemdefaults"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
type externalConfigChange struct {
|
|
|
|
es *eventstore.Eventstore
|
|
|
|
ExternalDomain string `json:"externalDomain"`
|
|
|
|
ExternalSecure bool `json:"externalSecure"`
|
|
|
|
ExternalPort uint16 `json:"externalPort"`
|
|
|
|
|
|
|
|
currentExternalDomain string
|
|
|
|
currentExternalSecure bool
|
|
|
|
currentExternalPort uint16
|
2023-07-14 09:49:57 +03:00
|
|
|
defaults systemdefaults.SystemDefaults
|
2022-07-20 11:20:49 +02:00
|
|
|
}
|
|
|
|
|
2024-01-05 10:01:48 +01:00
|
|
|
func (mig *externalConfigChange) Check(lastRun map[string]interface{}) bool {
|
2022-07-20 11:20:49 +02:00
|
|
|
mig.currentExternalDomain, _ = lastRun["externalDomain"].(string)
|
|
|
|
externalPort, _ := lastRun["externalPort"].(float64)
|
|
|
|
mig.currentExternalPort = uint16(externalPort)
|
|
|
|
mig.currentExternalSecure, _ = lastRun["externalSecure"].(bool)
|
|
|
|
return mig.currentExternalSecure != mig.ExternalSecure ||
|
|
|
|
mig.currentExternalPort != mig.ExternalPort ||
|
|
|
|
mig.currentExternalDomain != mig.ExternalDomain
|
|
|
|
}
|
|
|
|
|
2024-01-25 17:28:20 +01:00
|
|
|
func (mig *externalConfigChange) Execute(ctx context.Context, _ eventstore.Event) error {
|
2023-04-25 09:02:29 +02:00
|
|
|
cmd, err := command.StartCommands(
|
|
|
|
mig.es,
|
2023-07-14 09:49:57 +03:00
|
|
|
mig.defaults,
|
2022-07-20 11:20:49 +02:00
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
mig.ExternalDomain,
|
|
|
|
mig.ExternalSecure,
|
|
|
|
mig.ExternalPort,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
2022-09-12 17:18:08 +01:00
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
2023-04-25 09:02:29 +02:00
|
|
|
nil,
|
2023-05-05 17:34:53 +02:00
|
|
|
nil,
|
2023-07-10 15:27:00 +02:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2023-08-23 10:04:29 +02:00
|
|
|
nil,
|
2022-09-12 17:18:08 +01:00
|
|
|
)
|
2022-07-20 11:20:49 +02:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return cmd.ChangeSystemConfig(ctx, mig.currentExternalDomain, mig.currentExternalPort, mig.currentExternalSecure)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mig *externalConfigChange) String() string {
|
|
|
|
return "config_change"
|
|
|
|
}
|