2022-07-20 09:20:49 +00: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 06:49:57 +00:00
|
|
|
defaults systemdefaults.SystemDefaults
|
2022-07-20 09:20:49 +00:00
|
|
|
}
|
|
|
|
|
2024-01-05 09:01:48 +00:00
|
|
|
func (mig *externalConfigChange) Check(lastRun map[string]interface{}) bool {
|
2022-07-20 09:20:49 +00: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 16:28:20 +00:00
|
|
|
func (mig *externalConfigChange) Execute(ctx context.Context, _ eventstore.Event) error {
|
2023-04-25 07:02:29 +00:00
|
|
|
cmd, err := command.StartCommands(
|
|
|
|
mig.es,
|
2023-07-14 06:49:57 +00:00
|
|
|
mig.defaults,
|
2022-07-20 09:20:49 +00:00
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
mig.ExternalDomain,
|
|
|
|
mig.ExternalSecure,
|
|
|
|
mig.ExternalPort,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
2022-09-12 16:18:08 +00:00
|
|
|
nil,
|
|
|
|
nil,
|
|
|
|
nil,
|
2023-04-25 07:02:29 +00:00
|
|
|
nil,
|
2023-05-05 15:34:53 +00:00
|
|
|
nil,
|
2023-07-10 13:27:00 +00:00
|
|
|
0,
|
|
|
|
0,
|
|
|
|
0,
|
2023-08-23 08:04:29 +00:00
|
|
|
nil,
|
2022-09-12 16:18:08 +00:00
|
|
|
)
|
2022-07-20 09:20:49 +00:00
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return cmd.ChangeSystemConfig(ctx, mig.currentExternalDomain, mig.currentExternalPort, mig.currentExternalSecure)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (mig *externalConfigChange) String() string {
|
|
|
|
return "config_change"
|
|
|
|
}
|