change snake_case run template yaml to camelCase (#1183)

Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>

Signed-off-by: Mukundan Sundararajan <65565396+mukundansundar@users.noreply.github.com>
This commit is contained in:
Mukundan Sundararajan 2023-01-27 10:36:44 +05:30 committed by GitHub
parent 17dbe5bb13
commit 1a9029ce71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 131 additions and 131 deletions

View File

@ -40,38 +40,38 @@ const (
// RunConfig represents the application configuration parameters.
type RunConfig struct {
SharedRunConfig `yaml:",inline"`
AppID string `env:"APP_ID" arg:"app-id" yaml:"app_id"`
AppPort int `env:"APP_PORT" arg:"app-port" yaml:"app_port" default:"-1"`
HTTPPort int `env:"DAPR_HTTP_PORT" arg:"dapr-http-port" yaml:"dapr_http_port" default:"-1"`
GRPCPort int `env:"DAPR_GRPC_PORT" arg:"dapr-grpc-port" yaml:"dapr_grpc_port" default:"-1"`
ProfilePort int `arg:"profile-port" yaml:"profile_port" default:"-1"`
AppID string `env:"APP_ID" arg:"app-id" yaml:"appID"`
AppPort int `env:"APP_PORT" arg:"app-port" yaml:"appPort" default:"-1"`
HTTPPort int `env:"DAPR_HTTP_PORT" arg:"dapr-http-port" yaml:"daprHTTPPort" default:"-1"`
GRPCPort int `env:"DAPR_GRPC_PORT" arg:"dapr-grpc-port" yaml:"daprGRPCPort" default:"-1"`
ProfilePort int `arg:"profile-port" yaml:"profilePort" default:"-1"`
Command []string `yaml:"command"`
MetricsPort int `env:"DAPR_METRICS_PORT" arg:"metrics-port" yaml:"metrics_port" default:"-1"`
UnixDomainSocket string `arg:"unix-domain-socket" yaml:"unix_domain_socket"`
InternalGRPCPort int `arg:"dapr-internal-grpc-port" yaml:"dapr_internal_grpc_port" default:"-1"`
MetricsPort int `env:"DAPR_METRICS_PORT" arg:"metrics-port" yaml:"metricsPort" default:"-1"`
UnixDomainSocket string `arg:"unix-domain-socket" yaml:"unixDomainSocket"`
InternalGRPCPort int `arg:"dapr-internal-grpc-port" yaml:"daprInternalGRPCPort" default:"-1"`
}
// SharedRunConfig represents the application configuration parameters, which can be shared across many apps.
type SharedRunConfig struct {
ConfigFile string `arg:"config" yaml:"config_file"`
AppProtocol string `arg:"app-protocol" yaml:"app_protocol" default:"http"`
APIListenAddresses string `arg:"dapr-listen-addresses" yaml:"api_listen_addresses"`
EnableProfiling bool `arg:"enable-profiling" yaml:"enable_profiling"`
LogLevel string `arg:"log-level" yaml:"log_level"`
MaxConcurrency int `arg:"app-max-concurrency" yaml:"app_max_concurrency" default:"-1"`
PlacementHostAddr string `arg:"placement-host-address" yaml:"placement_host_address"`
ConfigFile string `arg:"config" yaml:"configFilePath"`
AppProtocol string `arg:"app-protocol" yaml:"appProtocol" default:"http"`
APIListenAddresses string `arg:"dapr-listen-addresses" yaml:"apiListenAddresses"`
EnableProfiling bool `arg:"enable-profiling" yaml:"enableProfiling"`
LogLevel string `arg:"log-level" yaml:"logLevel"`
MaxConcurrency int `arg:"app-max-concurrency" yaml:"appMaxConcurrency" default:"-1"`
PlacementHostAddr string `arg:"placement-host-address" yaml:"placementHostAddress"`
ComponentsPath string `arg:"components-path"`
ResourcesPath string `arg:"resources-path" yaml:"resources_path"`
AppSSL bool `arg:"app-ssl" yaml:"app_ssl"`
MaxRequestBodySize int `arg:"dapr-http-max-request-size" yaml:"dapr_http_max_request_size" default:"-1"`
HTTPReadBufferSize int `arg:"dapr-http-read-buffer-size" yaml:"dapr_http_read_buffer_size" default:"-1"`
EnableAppHealth bool `arg:"enable-app-health-check" yaml:"enable_app_health_check"`
AppHealthPath string `arg:"app-health-check-path" yaml:"app_health_check_path"`
AppHealthInterval int `arg:"app-health-probe-interval" ifneq:"0" yaml:"app_health_probe_interval"`
AppHealthTimeout int `arg:"app-health-probe-timeout" ifneq:"0" yaml:"app_health_probe_timeout"`
AppHealthThreshold int `arg:"app-health-threshold" ifneq:"0" yaml:"app_health_threshold"`
EnableAPILogging bool `arg:"enable-api-logging" yaml:"enable_api_logging"`
DaprdInstallPath string `yaml:"dapr_path"`
ResourcesPath string `arg:"resources-path" yaml:"resourcesPath"`
AppSSL bool `arg:"app-ssl" yaml:"appSSL"`
MaxRequestBodySize int `arg:"dapr-http-max-request-size" yaml:"daprHTTPMaxRequestSize" default:"-1"`
HTTPReadBufferSize int `arg:"dapr-http-read-buffer-size" yaml:"daprHTTPReadBufferSize" default:"-1"`
EnableAppHealth bool `arg:"enable-app-health-check" yaml:"enableAppHealthCheck"`
AppHealthPath string `arg:"app-health-check-path" yaml:"appHealthCheckPath"`
AppHealthInterval int `arg:"app-health-probe-interval" ifneq:"0" yaml:"appHealthProbeInterval"`
AppHealthTimeout int `arg:"app-health-probe-timeout" ifneq:"0" yaml:"appHealthProbeTimeout"`
AppHealthThreshold int `arg:"app-health-threshold" ifneq:"0" yaml:"appHealthThreshold"`
EnableAPILogging bool `arg:"enable-api-logging" yaml:"enableApiLogging"`
DaprdInstallPath string `yaml:"daprPath"`
Env map[string]string `yaml:"env"`
}

View File

@ -39,7 +39,7 @@ type RunFileConfig struct {
// App represents the configuration options for the apps in the run file.
type App struct {
standalone.RunConfig `yaml:",inline"`
AppDirPath string `yaml:"app_dir_path"`
AppDirPath string `yaml:"appDirPath"`
AppLogFileName string
DaprdLogFileName string
AppLogWriteCloser io.WriteCloser

View File

@ -58,7 +58,7 @@ func (a *RunFileConfig) validateRunConfig(runFilePath string) error {
}
for i := 0; i < len(a.Apps); i++ {
if a.Apps[i].AppDirPath == "" {
return errors.New("required filed 'app_dir_path' not found in the provided app config file")
return errors.New("required field 'appDirPath' not found in the provided app config file")
}
// It resolves the relative AppDirPath to absolute path and validates it.
err := a.resolvePathToAbsAndValidate(baseDir, &a.Apps[i].AppDirPath)
@ -121,8 +121,8 @@ func (a *RunFileConfig) mergeCommonAndAppsSharedRunConfig() {
}
}
// Set AppID to the directory name of app_dir_path.
// app_dir_path is a mandatory field in the run file and at this point it is already validated and resolved to its absolute path.
// Set AppID to the directory name of appDirPath.
// appDirPath is a mandatory field in the run file and at this point it is already validated and resolved to its absolute path.
func (a *RunFileConfig) setAppIDIfEmpty() error {
for i := range a.Apps {
if a.Apps[i].AppID == "" {
@ -136,12 +136,12 @@ func (a *RunFileConfig) setAppIDIfEmpty() error {
return nil
}
// Gets the base path from the absolute path of the app_dir_path.
// Gets the base path from the absolute path of the appDirPath.
func (a *RunFileConfig) getBasePathFromAbsPath(appDirPath string) (string, error) {
if filepath.IsAbs(appDirPath) {
return filepath.Base(appDirPath), nil
}
return "", fmt.Errorf("error in getting the base path from the provided app_dir_path %q: ", appDirPath)
return "", fmt.Errorf("error in getting the base path from the provided appDirPath %q: ", appDirPath)
}
// resolvePathToAbsAndValidate resolves the relative paths in run file to absolute path and validates the file path.
@ -198,7 +198,7 @@ func (a *RunFileConfig) mergeCommonAndAppsEnv() {
}
// resolveResourcesFilePath resolves the resources path for the app.
// Precedence order for resources_path -> apps[i].resources_path > apps[i].app_dir_path/.dapr/resources > common.resources_path > dapr default resources path.
// Precedence order for resourcesPath -> apps[i].resourcesPath > apps[i].appDirPath/.dapr/resources > common.resourcesPath > dapr default resources path.
func (a *RunFileConfig) resolveResourcesFilePath(app *App) error {
if app.ResourcesPath != "" {
return nil
@ -219,7 +219,7 @@ func (a *RunFileConfig) resolveResourcesFilePath(app *App) error {
}
// resolveConfigFilePath resolves the config file path for the app.
// Precedence order for config_file -> apps[i].config_file > apps[i].app_dir_path/.dapr/config.yaml > common.config_file > dapr default config file.
// Precedence order for configFile -> apps[i].configFile > apps[i].appDirPath/.dapr/config.yaml > common.configFile > dapr default config file.
func (a *RunFileConfig) resolveConfigFilePath(app *App) error {
if app.ConfigFile != "" {
return nil

View File

@ -68,7 +68,7 @@ func TestRunConfigFile(t *testing.T) {
assert.Equal(t, "", apps[0].UnixDomainSocket)
assert.Equal(t, "/tmp/test-socket", apps[1].UnixDomainSocket)
// test resources_path and config_path after precedence order logic.
// test resourcesPath and configPath after precedence order logic.
assert.Equal(t, filepath.Join(apps[0].AppDirPath, "resources"), apps[0].ResourcesPath)
assert.Equal(t, filepath.Join(apps[1].AppDirPath, ".dapr", "resources"), apps[1].ResourcesPath)
@ -110,21 +110,21 @@ func TestRunConfigFile(t *testing.T) {
appIndex int
}{
{
name: "resources_path and config_path are set in app section",
name: "resourcesPath and configPath are set in app section",
disableCommonSection: false,
expectedResourcesPath: filepath.Join(config.Apps[0].AppDirPath, "resources"),
expectedConfigFilePath: filepath.Join(config.Apps[0].AppDirPath, "config.yaml"),
appIndex: 0,
},
{
name: "resources_path and config_path present in .dapr directory under appDirPath",
name: "resourcesPath and configPath present in .dapr directory under appDirPath",
disableCommonSection: false,
expectedResourcesPath: filepath.Join(config.Apps[1].AppDirPath, ".dapr", "resources"),
expectedConfigFilePath: filepath.Join(config.Apps[1].AppDirPath, ".dapr", "config.yaml"),
appIndex: 1,
},
{
name: "resources_path and config_path are resolved from common's section",
name: "resourcesPath and configPath are resolved from common's section",
disableCommonSection: false,
expectedResourcesPath: config.Common.ResourcesPath, // from common section.
expectedConfigFilePath: config.Common.ConfigFile, // from common section.
@ -138,7 +138,7 @@ func TestRunConfigFile(t *testing.T) {
config.Common.ResourcesPath = ""
config.Common.ConfigFile = ""
}
// test precedence logic for resources_path and config_path.
// test precedence logic for resourcesPath and configPath.
config.resolveResourcesAndConfigFilePaths()
assert.Equal(t, tc.expectedResourcesPath, config.Apps[tc.appIndex].ResourcesPath)
assert.Equal(t, tc.expectedConfigFilePath, config.Apps[tc.appIndex].ConfigFile)
@ -168,13 +168,13 @@ func TestRunConfigFile(t *testing.T) {
appIndex int
}{
{
name: "resources_path and config_path are resolved from dapr's default installation path.",
name: "resourcesPath and configPath are resolved from dapr's default installation path.",
expectedResourcesPath: app1ResourcesPath,
expectedConfigFilePath: app1ConfigFilePath,
appIndex: 0,
},
{
name: "resources_path and config_path are resolved from dapr's custom installation path.",
name: "resourcesPath and configPath are resolved from dapr's custom installation path.",
expectedResourcesPath: app2ResourcesPath,
expectedConfigFilePath: app2ConfigFilePath,
appIndex: 1,
@ -183,7 +183,7 @@ func TestRunConfigFile(t *testing.T) {
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
// test precedence logic for resources_path and config_path.
// test precedence logic for resourcesPath and configPath.
config.resolveResourcesAndConfigFilePaths()
assert.Equal(t, tc.expectedResourcesPath, config.Apps[tc.appIndex].ResourcesPath)
assert.Equal(t, tc.expectedConfigFilePath, config.Apps[tc.appIndex].ConfigFile)

View File

@ -1,23 +1,23 @@
version: 1
common:
resources_path: ./app/resources
app_protocol: HTTP
app_health_probe_timeout: 10
resourcesPath: ./app/resources
appProtocol: HTTP
appHealthProbeTimeout: 10
env:
DEBUG: false
tty: sts
apps:
- app_dir_path: ./webapp/
resources_path: ./resources
config_file: ./config.yaml
app_port: 8080
app_health_probe_timeout: 1
- appDirPath: ./webapp/
resourcesPath: ./resources
configFilePath: ./config.yaml
appPort: 8080
appHealthProbeTimeout: 1
command: ["python3", "app.py"]
- app_id: backend
app_dir_path: ./backend/
app_protocol: GRPC
app_port: 3000
unix_domain_socket: /tmp/test-socket
- appID: backend
appDirPath: ./backend/
appProtocol: GRPC
appPort: 3000
unixDomainSocket: /tmp/test-socket
env:
DEBUG: true
command: ["./backend"]

View File

@ -1,24 +1,24 @@
version: 1
common:
resources_path: ./app/resources
app_protocol: HTTP
app_health_probe_timeout: 10
resourcesPath: ./app/resources
appProtocol: HTTP
appHealthProbeTimeout: 10
env:
- name: DEBUG
value: false
- name: tty
value: sts
apps:
- app_dir_path: ./webapp/
resources_path: ./resources
config_file: ./config.yaml
app_port: 8080
app_health_probe_timeout: 1
- appDirPath: ./webapp/
resourcesPath: ./resources
configFilePath: ./config.yaml
appPort: 8080
appHealthProbeTimeout: 1
command: ["python3", "app.py"]
- app_id: backend
app_protocol: GRPC
app_port: 3000
unix_domain_socket: /tmp/test-socket
- appID: backend
appProtocol: GRPC
appPort: 3000
unixDomainSocket: /tmp/test-socket
env:
- name: DEBUG
value: true

View File

@ -1,25 +1,25 @@
version: 1
common:
resources_path: ./app/resources
app_protocol: HTTP
app_health_probe_timeout: 10
resourcesPath: ./app/resources
appProtocol: HTTP
appHealthProbeTimeout: 10
env:
- name: DEBUG
value: false
- name: tty
value: sts
apps:
- app_dir_path: ./webapp/
resources_path: ./resources
config_file: ./config.yaml
app_port: 8080
app_health_probe_timeout: 1
- appDirPath: ./webapp/
resourcesPath: ./resources
configFilePath: ./config.yaml
appPort: 8080
appHealthProbeTimeout: 1
command: ["python3", "app.py"]
- app_id: backend
app_dir_path: ./invalid_backend/
app_protocol: GRPC
app_port: 3000
unix_domain_socket: /tmp/test-socket
- appID: backend
appDirPath: ./invalid_backend/
appProtocol: GRPC
appPort: 3000
unixDomainSocket: /tmp/test-socket
env:
- name: DEBUG
value: true

View File

@ -1,15 +1,15 @@
version: 1
common:
resources_path: ./app/resources
config_file: ./app/config.yaml
resourcesPath: ./app/resources
configFilePath: ./app/config.yaml
apps:
# tests resources_path and config_file resolved from app's section.
- app_dir_path: ./webapp/
resources_path: ./resources
config_file: ./config.yaml
# tests resources_path and config_file resolved from app/.dapr folder.
- app_id: backend
app_dir_path: ./backend/
# tests resources_path and config_file resolved from common's section.
- app_id: app_common_section
app_dir_path: ./app_precedence_rule/
# tests resourcesPath and config_file resolved from app's section.
- appDirPath: ./webapp/
resourcesPath: ./resources
configFilePath: ./config.yaml
# tests resourcesPath and config_file resolved from app/.dapr folder.
- appID: backend
appDirPath: ./backend/
# tests resourcesPath and config_file resolved from common's section.
- appID: app_common_section
appDirPath: ./app_precedence_rule/

View File

@ -1,10 +1,10 @@
version: 1
common:
apps:
# tests resources_path and config_file resolved from dapr's default installation directory.
- app_id: app_default_dapr_dir
app_dir_path: ./app_precedence_rule/
# tests resources_path and config_file resolved from dapr's custom installation directory.
- app_id: app_custom_dapr_dir
app_dir_path: ./app_precedence_rule/
dapr_path: ../custom_dapr_dir
# tests resourcesPath and config_file resolved from dapr's default installation directory.
- appID: app_default_dapr_dir
appDirPath: ./app_precedence_rule/
# tests resourcesPath and config_file resolved from dapr's custom installation directory.
- appID: app_custom_dapr_dir
appDirPath: ./app_precedence_rule/
daprPath: ../custom_dapr_dir

View File

@ -1,12 +1,12 @@
version: 1
apps:
- app_dir_path: ../../../apps/processor/
app_port: 9081
dapr_http_port: 3510
- appDirPath: ../../../apps/processor/
appPort: 9081
daprHTTPPort: 3510
command: ["go","run", "app.go"]
- app_id: emit-metrics
app_dir_path: ../../../apps/emit-metrics/
dapr_http_port: 3511
- appID: emit-metrics
appDirPath: ../../../apps/emit-metrics/
daprHTTPPort: 3511
env:
DAPR_HOST_ADD: localhost
command: ["go","run", "app.go"]

View File

@ -1,12 +1,12 @@
version: 1
apps:
- app_dir_path: ../../../apps/processor/
app_port: 9081
dapr_http_port: 3510
- appDirPath: ../../../apps/processor/
appPort: 9081
daprHTTPPort: 3510
command: ["go","run", "app.go"]
- app_id: emit-metrics
app_dir_path: ../../../apps/emit-metrics/
dapr_http_port: 3511
- appID: emit-metrics
appDirPath: ../../../apps/emit-metrics/
daprHTTPPort: 3511
env:
DAPR_HOST_ADD: localhost
command: [""]

View File

@ -1,10 +1,10 @@
version: 1
apps:
- app_dir_path: ../../../apps/processor/
app_port: 9081
dapr_http_port: 3510
- appDirPath: ../../../apps/processor/
appPort: 9081
daprHTTPPort: 3510
command: ["go","run", "app.go"]
- app_id: emit-metrics
app_dir_path: ../../../apps/emit-metrics/
dapr_http_port: 3511 # required env var DAPR_HOST_ADD not set in the yaml file
- appID: emit-metrics
appDirPath: ../../../apps/emit-metrics/
daprHTTPPort: 3511 # required env var DAPR_HOST_ADD not set in the yaml file
command: ["go","run", "app.go"]

View File

@ -2,16 +2,16 @@ version: 1
common:
# Unused resources. This is set so that when dapr is not init validation does not fail.
# Used in test run template when dapr is not init.
resources_path: ../resources
config_file_path: appconfig.yaml
resourcesPath: ../resources
configFilePath: appconfig.yaml
apps:
- app_dir_path: ../../../apps/processor/
app_port: 9081
dapr_http_port: 3510
- appDirPath: ../../../apps/processor/
appPort: 9081
daprHTTPPort: 3510
command: ["go","run", "app.go"]
- app_id: emit-metrics
app_dir_path: ../../../apps/emit-metrics/
dapr_http_port: 3511
- appID: emit-metrics
appDirPath: ../../../apps/emit-metrics/
daprHTTPPort: 3511
env:
DAPR_HOST_ADD: localhost

View File

@ -1,12 +1,12 @@
version: 1
apps:
- app_dir_path: ../../../apps/processor/
app_port: 9081
dapr_http_port: 3510
- appDirPath: ../../../apps/processor/
appPort: 9081
daprHTTPPort: 3510
command: ["go","run", "app.go"]
- app_id: emit-metrics
app_dir_path: ../../../apps/emit-metrics/
dapr_http_port: 3511
- appID: emit-metrics
appDirPath: ../../../apps/emit-metrics/
daprHTTPPort: 3511
env:
DAPR_HOST_ADD: localhost
# Set wrong app name