Skip to content

Commit d7f2c05

Browse files
authored
Remove server's support for .yaml based configuration (#183)
* Rename server's config flag to --config-dir * . * remove server --config completely * . * Delete mTLS test as config not supported
1 parent d4a0004 commit d7f2c05

6 files changed

Lines changed: 8 additions & 249 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Test
2929
env:
3030
CGO_ENABLED: 0
31-
run: go test -v ./...
31+
run: go test ./...
3232

3333
test-shellcheck:
3434
name: Shellcheck

app/mtls_test.go

Lines changed: 0 additions & 148 deletions
This file was deleted.

common/flags.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ var (
3232
FlagCodecAuth = "codec-auth"
3333
FlagCodecEndpoint = "codec-endpoint"
3434
FlagConcurrency = "concurrency"
35-
FlagConfig = "config"
3635
FlagContextTimeout = "context-timeout"
3736
FlagCronSchedule = "cron"
3837
FlagDBPath = "db-filename"

server/commands.go

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,6 @@ func NewServerCommands(defaultCfg *sconfig.Config) []*cli.Command {
129129
EnvVars: nil,
130130
Value: nil,
131131
},
132-
&cli.StringFlag{
133-
Name: common.FlagConfig,
134-
Aliases: []string{"c"},
135-
Usage: `Path to config directory.`,
136-
EnvVars: []string{config.EnvKeyConfigDir},
137-
Value: "",
138-
},
139132
&cli.StringSliceFlag{
140133
Name: common.FlagDynamicConfigValue,
141134
Usage: `Dynamic config value, as KEY=JSON_VALUE (string values need quotes).`,
@@ -170,13 +163,6 @@ func NewServerCommands(defaultCfg *sconfig.Config) []*cli.Command {
170163
return cli.Exit(fmt.Sprintf("bad value %q passed for flag %q", c.String(common.FlagIP), common.FlagIP), 1)
171164
}
172165

173-
if c.IsSet(common.FlagConfig) {
174-
cfgPath := c.String(common.FlagConfig)
175-
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
176-
return cli.Exit(fmt.Sprintf("bad value %q passed for flag %q: file not found", c.String(common.FlagConfig), common.FlagConfig), 1)
177-
}
178-
}
179-
180166
return nil
181167
},
182168
Action: func(c *cli.Context) error {
@@ -210,20 +196,6 @@ func NewServerCommands(defaultCfg *sconfig.Config) []*cli.Command {
210196
if err != nil {
211197
return err
212198
}
213-
214-
baseConfig := &config.Config{}
215-
if c.IsSet(common.FlagConfig) {
216-
// Temporal server requires a couple of persistence config values to
217-
// be explicitly set or the config loading fails. While these are the
218-
// same values used internally, they are overridden later anyways,
219-
// they are just here to pass validation.
220-
baseConfig.Persistence.DefaultStore = sconfig.PersistenceStoreName
221-
baseConfig.Persistence.NumHistoryShards = 1
222-
if err := config.Load("temporal", c.String(common.FlagConfig), "", &baseConfig); err != nil {
223-
return err
224-
}
225-
}
226-
227199
interruptChan := make(chan interface{}, 1)
228200
go func() {
229201
if doneChan := c.Done(); doneChan != nil {
@@ -245,7 +217,7 @@ func NewServerCommands(defaultCfg *sconfig.Config) []*cli.Command {
245217
WithUpstreamOptions(
246218
temporal.InterruptOn(interruptChan),
247219
),
248-
WithBaseConfig(baseConfig),
220+
WithBaseConfig(&config.Config{}),
249221
}
250222

251223
if c.IsSet(common.FlagDBPath) {
@@ -267,11 +239,11 @@ func NewServerCommands(defaultCfg *sconfig.Config) []*cli.Command {
267239
},
268240
}
269241

270-
opt, err := newUIOption(uiBaseCfg, c.String(common.FlagConfig))
271-
242+
opt, err := newUIOption(uiBaseCfg)
272243
if err != nil {
273244
return err
274245
}
246+
275247
if opt != nil {
276248
opts = append(opts, opt)
277249
}

server/ui.go

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,11 @@ package server
2929
// This file should be the only one to import ui-server packages.
3030
// This is to avoid embedding the UI's static assets in the binary when the `headless` build tag is enabled.
3131
import (
32-
"strings"
33-
34-
provider "github.com/temporalio/ui-server/v2/plugins/fs_config_provider"
3532
uiserver "github.com/temporalio/ui-server/v2/server"
3633
uiconfig "github.com/temporalio/ui-server/v2/server/config"
3734
uiserveroptions "github.com/temporalio/ui-server/v2/server/server_options"
3835
)
3936

40-
func newUIOption(c *uiconfig.Config, configDir string) (ServerOption, error) {
41-
cfg, err := MergeWithConfigFile(
42-
c,
43-
configDir,
44-
)
45-
if err != nil {
46-
return nil, err
47-
}
48-
return WithUI(uiserver.NewServer(uiserveroptions.WithConfigProvider(cfg))), nil
49-
}
50-
51-
func MergeWithConfigFile(cfg *uiconfig.Config, configDir string) (*uiconfig.Config, error) {
52-
if configDir != "" {
53-
if err := provider.Load(configDir, cfg, "temporal-ui"); err != nil {
54-
if !strings.HasPrefix(err.Error(), "no config files found") {
55-
return nil, err
56-
}
57-
}
58-
}
59-
60-
return cfg, nil
37+
func newUIOption(c *uiconfig.Config) (ServerOption, error) {
38+
return WithUI(uiserver.NewServer(uiserveroptions.WithConfigProvider(c))), nil
6139
}

server/ui_test.go

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -33,55 +33,13 @@ import (
3333
)
3434

3535
func TestNewUIConfig(t *testing.T) {
36-
c := &uiconfig.Config{
36+
cfg := &uiconfig.Config{
3737
Host: "localhost",
3838
Port: 8233,
3939
TemporalGRPCAddress: "localhost:7233",
4040
EnableUI: true,
4141
}
42-
cfg, err := MergeWithConfigFile(c, "")
43-
if err != nil {
44-
t.Errorf("cannot create config: %s", err)
45-
return
46-
}
47-
if err = cfg.Validate(); err != nil {
48-
t.Errorf("config not valid: %s", err)
49-
}
50-
}
51-
52-
func TestNewUIConfigWithMissingConfigFile(t *testing.T) {
53-
c := &uiconfig.Config{
54-
Host: "localhost",
55-
Port: 8233,
56-
TemporalGRPCAddress: "localhost:7233",
57-
EnableUI: true,
58-
}
59-
cfg, err := MergeWithConfigFile(c, "wibble")
60-
if err != nil {
61-
t.Errorf("cannot create config: %s", err)
62-
return
63-
}
64-
if err = cfg.Validate(); err != nil {
42+
if err := cfg.Validate(); err != nil {
6543
t.Errorf("config not valid: %s", err)
6644
}
6745
}
68-
69-
func TestNewUIConfigWithPresentConfigFile(t *testing.T) {
70-
c := &uiconfig.Config{
71-
Host: "localhost",
72-
Port: 8233,
73-
TemporalGRPCAddress: "localhost:7233",
74-
EnableUI: true,
75-
}
76-
cfg, err := MergeWithConfigFile(c, "testdata")
77-
if err != nil {
78-
t.Errorf("cannot create config: %s", err)
79-
return
80-
}
81-
if err = cfg.Validate(); err != nil {
82-
t.Errorf("config not valid: %s", err)
83-
}
84-
if cfg.TLS.ServerName != "local.dev" {
85-
t.Errorf("did not load expected config file")
86-
}
87-
}

0 commit comments

Comments
 (0)