@@ -53,80 +53,80 @@ var defaultLoggingConfig = helpers.LoggingConfig{
53
53
}
54
54
55
55
type SchedulerConfig struct {
56
- SchedulerURL string `yaml:"scheduler_url"`
57
- TLSClientCerts models.TLSCerts `yaml:"tls"`
56
+ SchedulerURL string `yaml:"scheduler_url" json:"scheduler_url" `
57
+ TLSClientCerts models.TLSCerts `yaml:"tls" json:"tls `
58
58
}
59
59
type ScalingEngineConfig struct {
60
- ScalingEngineUrl string `yaml:"scaling_engine_url"`
61
- TLSClientCerts models.TLSCerts `yaml:"tls"`
60
+ ScalingEngineUrl string `yaml:"scaling_engine_url" json:"scaling_engine_url" `
61
+ TLSClientCerts models.TLSCerts `yaml:"tls" json:"tls `
62
62
}
63
63
64
64
type EventGeneratorConfig struct {
65
- EventGeneratorUrl string `yaml:"event_generator_url"`
66
- TLSClientCerts models.TLSCerts `yaml:"tls"`
65
+ EventGeneratorUrl string `yaml:"event_generator_url" json:"event_generator_url" `
66
+ TLSClientCerts models.TLSCerts `yaml:"tls" json:"tls" `
67
67
}
68
68
type MetricsForwarderConfig struct {
69
- MetricsForwarderUrl string `yaml:"metrics_forwarder_url"`
70
- MetricsForwarderMtlsUrl string `yaml:"metrics_forwarder_mtls_url"`
69
+ MetricsForwarderUrl string `yaml:"metrics_forwarder_url" json:"metrics_forwarder_url" `
70
+ MetricsForwarderMtlsUrl string `yaml:"metrics_forwarder_mtls_url" json:"metrics_forwarder_mtls_url" `
71
71
}
72
72
73
73
type PlanDefinition struct {
74
- PlanCheckEnabled bool `yaml:"planCheckEnabled"`
75
- SchedulesCount int `yaml:"schedules_count"`
76
- ScalingRulesCount int `yaml:"scaling_rules_count"`
77
- PlanUpdateable bool `yaml:"plan_updateable"`
74
+ PlanCheckEnabled bool `yaml:"planCheckEnabled" json:"planCheckEnabled" `
75
+ SchedulesCount int `yaml:"schedules_count" json:"schedules_count" `
76
+ ScalingRulesCount int `yaml:"scaling_rules_count" json:"scaling_rules_count" `
77
+ PlanUpdateable bool `yaml:"plan_updateable" json:"plan_updateable" `
78
78
}
79
79
80
80
type BrokerCredentialsConfig struct {
81
- BrokerUsername string `yaml:"broker_username"`
82
- BrokerUsernameHash []byte `yaml:"broker_username_hash"`
83
- BrokerPassword string `yaml:"broker_password"`
84
- BrokerPasswordHash []byte `yaml:"broker_password_hash"`
81
+ BrokerUsername string `yaml:"broker_username" json:"broker_username" `
82
+ BrokerUsernameHash []byte `yaml:"broker_username_hash" json:"broker_username_hash" `
83
+ BrokerPassword string `yaml:"broker_password" json:"broker_password" `
84
+ BrokerPasswordHash []byte `yaml:"broker_password_hash" json:"broker_password_hash" `
85
85
}
86
86
87
87
type ScalingRulesConfig struct {
88
- CPU LowerUpperThresholdConfig `yaml:"cpu"`
89
- CPUUtil LowerUpperThresholdConfig `yaml:"cpuutil"`
90
- DiskUtil LowerUpperThresholdConfig `yaml:"diskutil"`
91
- Disk LowerUpperThresholdConfig `yaml:"disk"`
88
+ CPU LowerUpperThresholdConfig `yaml:"cpu" json:"cpu" `
89
+ CPUUtil LowerUpperThresholdConfig `yaml:"cpuutil" json:"cpuutil" `
90
+ DiskUtil LowerUpperThresholdConfig `yaml:"diskutil" json:"diskutil" `
91
+ Disk LowerUpperThresholdConfig `yaml:"disk" json:"disk" `
92
92
}
93
93
94
94
type LowerUpperThresholdConfig struct {
95
- LowerThreshold int `yaml:"lower_threshold"`
96
- UpperThreshold int `yaml:"upper_threshold"`
95
+ LowerThreshold int `yaml:"lower_threshold" json:"lower_threshold" `
96
+ UpperThreshold int `yaml:"upper_threshold" json:"upper_threshold" `
97
97
}
98
98
99
99
type Config struct {
100
- Logging helpers.LoggingConfig `yaml:"logging"`
101
- BrokerServer helpers.ServerConfig `yaml:"broker_server"`
102
- Server helpers.ServerConfig `yaml:"public_api_server"`
103
-
104
- VCAPServer helpers.ServerConfig `yaml:"vcap_server"`
105
-
106
- Db map [string ]db.DatabaseConfig `yaml:"db"`
107
- BrokerCredentials []BrokerCredentialsConfig `yaml:"broker_credentials"`
108
- APIClientId string `yaml:"api_client_id"`
109
- PlanCheck * PlanCheckConfig `yaml:"plan_check"`
110
- CatalogPath string `yaml:"catalog_path"`
111
- CatalogSchemaPath string `yaml:"catalog_schema_path"`
112
- DashboardRedirectURI string `yaml:"dashboard_redirect_uri"`
113
- PolicySchemaPath string `yaml:"policy_schema_path"`
114
- Scheduler SchedulerConfig `yaml:"scheduler"`
115
- ScalingEngine ScalingEngineConfig `yaml:"scaling_engine"`
116
- EventGenerator EventGeneratorConfig `yaml:"event_generator"`
117
- CF cf.Config `yaml:"cf"`
118
- InfoFilePath string `yaml:"info_file_path"`
119
- MetricsForwarder MetricsForwarderConfig `yaml:"metrics_forwarder"`
120
- Health helpers.HealthConfig `yaml:"health"`
121
- RateLimit models.RateLimitConfig `yaml:"rate_limit"`
122
- CredHelperImpl string `yaml:"cred_helper_impl"`
123
- StoredProcedureConfig * models.StoredProcedureConfig `yaml:"stored_procedure_binding_credential_config"`
124
- ScalingRules ScalingRulesConfig `yaml:"scaling_rules"`
125
- DefaultCustomMetricsCredentialType string `yaml:"default_credential_type"`
100
+ Logging helpers.LoggingConfig `yaml:"logging" json:"logging" `
101
+ BrokerServer helpers.ServerConfig `yaml:"broker_server" json:"broker_server" `
102
+ Server helpers.ServerConfig `yaml:"public_api_server" json:"public_api_server" `
103
+
104
+ VCAPServer helpers.ServerConfig `yaml:"vcap_server" json:"vcap_server" `
105
+
106
+ Db map [string ]db.DatabaseConfig `yaml:"db" json:"db,omitempty" `
107
+ BrokerCredentials []BrokerCredentialsConfig `yaml:"broker_credentials" json:"broker_credentials" `
108
+ APIClientId string `yaml:"api_client_id" json:"api_client_id" `
109
+ PlanCheck * PlanCheckConfig `yaml:"plan_check" json:"plan_check" `
110
+ CatalogPath string `yaml:"catalog_path" json:"catalog_path" `
111
+ CatalogSchemaPath string `yaml:"catalog_schema_path" json:"catalog_schema_path" `
112
+ DashboardRedirectURI string `yaml:"dashboard_redirect_uri" json:"dashboard_redirect_uri" `
113
+ PolicySchemaPath string `yaml:"policy_schema_path" json:"policy_schema_path" `
114
+ Scheduler SchedulerConfig `yaml:"scheduler" json:"scheduler" `
115
+ ScalingEngine ScalingEngineConfig `yaml:"scaling_engine" json:"scaling_engine" `
116
+ EventGenerator EventGeneratorConfig `yaml:"event_generator" json:"event_generator" `
117
+ CF cf.Config `yaml:"cf" json:"cf" `
118
+ InfoFilePath string `yaml:"info_file_path" json:"info_file_path" `
119
+ MetricsForwarder MetricsForwarderConfig `yaml:"metrics_forwarder" json:"metrics_forwarder" `
120
+ Health helpers.HealthConfig `yaml:"health" json:"health" `
121
+ RateLimit models.RateLimitConfig `yaml:"rate_limit" json:"rate_limit,omitempty" `
122
+ CredHelperImpl string `yaml:"cred_helper_impl" json:"cred_helper_impl" `
123
+ StoredProcedureConfig * models.StoredProcedureConfig `yaml:"stored_procedure_binding_credential_config" json:"stored_procedure_binding_credential_config" `
124
+ ScalingRules ScalingRulesConfig `yaml:"scaling_rules" json:"scaling_rules" `
125
+ DefaultCustomMetricsCredentialType string `yaml:"default_credential_type" json:"default_credential_type" `
126
126
}
127
127
128
128
type PlanCheckConfig struct {
129
- PlanDefinitions map [string ]PlanDefinition `yaml:"plan_definitions"`
129
+ PlanDefinitions map [string ]PlanDefinition `yaml:"plan_definitions" json:"plan_definitions" `
130
130
}
131
131
132
132
func defaultConfig () Config {
@@ -274,9 +274,23 @@ func LoadConfig(filepath string, vcapReader configutil.VCAPConfigurationReader)
274
274
return & conf , nil
275
275
}
276
276
277
- func (c * Config ) ToJSON () string {
278
- b , _ := json .Marshal (c )
279
- return string (b )
277
+ func FromJSON (data []byte ) (* Config , error ) {
278
+ result := & Config {}
279
+ err := json .Unmarshal (data , result )
280
+ if err != nil {
281
+ return nil , fmt .Errorf ("failed to unmarshal config from json: %s" , err )
282
+ }
283
+ return result , nil
284
+ }
285
+
286
+ func (c * Config ) ToJSON () (string , error ) {
287
+ b , err := json .Marshal (c )
288
+
289
+ if err != nil {
290
+ err = fmt .Errorf ("failed to marshal config to json: %s" , err )
291
+ return "" , err
292
+ }
293
+ return string (b ), nil
280
294
}
281
295
func (c * Config ) Validate () error {
282
296
err := c .CF .Validate ()
0 commit comments