provideDefaultConfig exports config for "name", "version", "env", "http", "grpc".
()
| 115 | |
| 116 | // provideDefaultConfig exports config for "name", "version", "env", "http", "grpc". |
| 117 | func provideDefaultConfig() []config.ExportedConfig { |
| 118 | return []config.ExportedConfig{ |
| 119 | { |
| 120 | Owner: "core", |
| 121 | Data: map[string]interface{}{ |
| 122 | "name": "app", |
| 123 | }, |
| 124 | Comment: "The name of the application", |
| 125 | Validate: func(data map[string]interface{}) error { |
| 126 | _, err := getString(data, "name") |
| 127 | if err != nil { |
| 128 | return fmt.Errorf("the name field is not valid: %w", err) |
| 129 | } |
| 130 | return nil |
| 131 | }, |
| 132 | }, |
| 133 | { |
| 134 | Owner: "core", |
| 135 | Data: map[string]interface{}{ |
| 136 | "env": "local", |
| 137 | }, |
| 138 | Comment: "The environment of the application, one of production, development, staging, testing or local", |
| 139 | Validate: func(data map[string]interface{}) error { |
| 140 | str, err := getString(data, "env") |
| 141 | if err != nil { |
| 142 | return fmt.Errorf("the env field is not valid: %w", err) |
| 143 | } |
| 144 | if config.NewEnv(str) != config.EnvUnknown { |
| 145 | return nil |
| 146 | } |
| 147 | return fmt.Errorf( |
| 148 | "the env field must be one of \"production\", \"development\", \"staging\", \"testing\" or \"local\", got %s", str) |
| 149 | }, |
| 150 | }, |
| 151 | { |
| 152 | Owner: "core", |
| 153 | Data: map[string]interface{}{ |
| 154 | "http": map[string]interface{}{ |
| 155 | "addr": ":8080", |
| 156 | "disable": false, |
| 157 | }, |
| 158 | }, |
| 159 | Comment: "The http address", |
| 160 | Validate: func(data map[string]interface{}) error { |
| 161 | disable, err := getBool(data, "http", "disable") |
| 162 | if err != nil { |
| 163 | return fmt.Errorf("the http.disable field is not valid: %w", err) |
| 164 | } |
| 165 | if disable { |
| 166 | return nil |
| 167 | } |
| 168 | str, err := getString(data, "http", "addr") |
| 169 | if err != nil { |
| 170 | return fmt.Errorf("the http.addr field is not valid: %w", err) |
| 171 | } |
| 172 | if _, err := net.ResolveTCPAddr("tcp", str); err != nil { |
| 173 | return fmt.Errorf("the http.addr field must be an valid address like :8080, got %s", str) |
| 174 | } |