Skip to content

Commit

Permalink
Merge pull request #2262 from superfly/feat/migrate-to-v2/error-on-ex…
Browse files Browse the repository at this point in the history
…perimental

Disallow `experimental` features in V2 configs
  • Loading branch information
dangra committed May 12, 2023
2 parents 3bf2cca + e847908 commit 0fb42c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 7 additions & 6 deletions internal/appconfig/config.go
Expand Up @@ -102,12 +102,13 @@ type Build struct {
}

type Experimental struct {
Cmd []string `toml:"cmd,omitempty" json:"cmd,omitempty"`
Entrypoint []string `toml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
Exec []string `toml:"exec,omitempty" json:"exec,omitempty"`
AutoRollback bool `toml:"auto_rollback,omitempty" json:"auto_rollback,omitempty"`
EnableConsul bool `toml:"enable_consul,omitempty" json:"enable_consul,omitempty"`
EnableEtcd bool `toml:"enable_etcd,omitempty" json:"enable_etcd,omitempty"`
Cmd []string `toml:"cmd,omitempty" json:"cmd,omitempty"`
Entrypoint []string `toml:"entrypoint,omitempty" json:"entrypoint,omitempty"`
Exec []string `toml:"exec,omitempty" json:"exec,omitempty"`
AutoRollback bool `toml:"auto_rollback,omitempty" json:"auto_rollback,omitempty"`
EnableConsul bool `toml:"enable_consul,omitempty" json:"enable_consul,omitempty"`
EnableEtcd bool `toml:"enable_etcd,omitempty" json:"enable_etcd,omitempty"`
AllowedPublicPorts []int `toml:"allowed_public_ports,omitempty" json:"allowed_public_ports,omitempty"`
}

func (c *Config) ConfigFilePath() string {
Expand Down
13 changes: 13 additions & 0 deletions internal/appconfig/validation.go
Expand Up @@ -96,6 +96,7 @@ func (cfg *Config) ValidateForMachinesPlatform(ctx context.Context) (err error,
cfg.validateProcessesSection,
cfg.validateMachineConversion,
cfg.validateConsoleCommand,
cfg.validateNoExperimental,
}

for _, vFunc := range validators {
Expand All @@ -119,6 +120,18 @@ func (cfg *Config) ValidateForMachinesPlatform(ctx context.Context) (err error,
return nil, extra_info
}

func (cfg *Config) validateNoExperimental() (extraInfo string, err error) {
if cfg.Experimental == nil {
return
}

if len(cfg.Experimental.AllowedPublicPorts) != 0 {
extraInfo += "experimental.allowed_public_ports is not supported in Apps V2\n"
err = ValidationError
}
return
}

func (cfg *Config) validateBuildStrategies() (extraInfo string, err error) {
buildStrats := cfg.BuildStrategies()
if len(buildStrats) > 1 {
Expand Down

0 comments on commit 0fb42c3

Please sign in to comment.