mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 18:48:08 +00:00 
			
		
		
		
	Add a metadata node_id field for Atlas usage and fix tests
This commit is contained in:
		| @@ -428,6 +428,7 @@ func parseListeners(result *Config, list *ast.ObjectList) error { | |||||||
| 			"address", | 			"address", | ||||||
| 			"endpoint", | 			"endpoint", | ||||||
| 			"infrastructure", | 			"infrastructure", | ||||||
|  | 			"node_id", | ||||||
| 			"tls_disable", | 			"tls_disable", | ||||||
| 			"tls_cert_file", | 			"tls_cert_file", | ||||||
| 			"tls_key_file", | 			"tls_key_file", | ||||||
| @@ -456,6 +457,9 @@ func parseListeners(result *Config, list *ast.ObjectList) error { | |||||||
| 				if m["infrastructure"] == "" { | 				if m["infrastructure"] == "" { | ||||||
| 					return multierror.Prefix(fmt.Errorf("'infrastructure' must be specified for an Atlas listener"), fmt.Sprintf("listeners.%s", key)) | 					return multierror.Prefix(fmt.Errorf("'infrastructure' must be specified for an Atlas listener"), fmt.Sprintf("listeners.%s", key)) | ||||||
| 				} | 				} | ||||||
|  | 				if m["node_id"] == "" { | ||||||
|  | 					return multierror.Prefix(fmt.Errorf("'node_id' must be specified for an Atlas listener"), fmt.Sprintf("listeners.%s", key)) | ||||||
|  | 				} | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -16,17 +16,18 @@ func TestLoadConfigFile(t *testing.T) { | |||||||
| 	expected := &Config{ | 	expected := &Config{ | ||||||
| 		Listeners: []*Listener{ | 		Listeners: []*Listener{ | ||||||
| 			&Listener{ | 			&Listener{ | ||||||
| 				Type: "tcp", | 				Type: "atlas", | ||||||
| 				Config: map[string]string{ | 				Config: map[string]string{ | ||||||
| 					"address": "127.0.0.1:443", | 					"token":          "foobar", | ||||||
|  | 					"infrastructure": "foo/bar", | ||||||
|  | 					"endpoint":       "https://foo.bar:1111", | ||||||
|  | 					"node_id":        "foo_node", | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 			&Listener{ | 			&Listener{ | ||||||
| 				Type: "atlas", | 				Type: "tcp", | ||||||
| 				Config: map[string]string{ | 				Config: map[string]string{ | ||||||
| 					Token:          "foobar", | 					"address": "127.0.0.1:443", | ||||||
| 					Infrastructure: "foo/bar", |  | ||||||
| 					Endpoint:       "https://foo.bar:1111", |  | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| @@ -83,9 +84,10 @@ func TestLoadConfigFile_json(t *testing.T) { | |||||||
| 			&Listener{ | 			&Listener{ | ||||||
| 				Type: "atlas", | 				Type: "atlas", | ||||||
| 				Config: map[string]string{ | 				Config: map[string]string{ | ||||||
| 					Token:          "foobar", | 					"token":          "foobar", | ||||||
| 					Infrastructure: "foo/bar", | 					"infrastructure": "foo/bar", | ||||||
| 					Endpoint:       "https://foo.bar:1111", | 					"endpoint":       "https://foo.bar:1111", | ||||||
|  | 					"node_id":        "foo_node", | ||||||
| 				}, | 				}, | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
|   | |||||||
| @@ -31,7 +31,9 @@ func atlasListenerFactory(config map[string]string, logger io.Writer) (net.Liste | |||||||
| 		Service:      "vault", | 		Service:      "vault", | ||||||
| 		Version:      version.GetVersion().String(), | 		Version:      version.GetVersion().String(), | ||||||
| 		ResourceType: "vault-cluster", | 		ResourceType: "vault-cluster", | ||||||
| 		Meta:         map[string]string{}, | 		Meta: map[string]string{ | ||||||
|  | 			"node_id": config["node_id"], | ||||||
|  | 		}, | ||||||
| 		Atlas: scada.AtlasConfig{ | 		Atlas: scada.AtlasConfig{ | ||||||
| 			Endpoint:       config["endpoint"], | 			Endpoint:       config["endpoint"], | ||||||
| 			Infrastructure: config["infrastructure"], | 			Infrastructure: config["infrastructure"], | ||||||
|   | |||||||
| @@ -7,6 +7,7 @@ listener "atlas" { | |||||||
|     token = "foobar" |     token = "foobar" | ||||||
|     infrastructure = "foo/bar" |     infrastructure = "foo/bar" | ||||||
|     endpoint = "https://foo.bar:1111" |     endpoint = "https://foo.bar:1111" | ||||||
|  |     node_id = "foo_node" | ||||||
| } | } | ||||||
|  |  | ||||||
| listener "tcp" { | listener "tcp" { | ||||||
|   | |||||||
| @@ -1,22 +1,24 @@ | |||||||
| { | { | ||||||
|   "listener":{ | 	"listener": [{ | ||||||
|     "tcp":{ | 		"tcp": { | ||||||
|       "address":"127.0.0.1:443" | 			"address": "127.0.0.1:443" | ||||||
|     } | 		} | ||||||
|   }, | 	}, { | ||||||
|   "atlas":{ | 		"atlas": { | ||||||
|     "token":"foobar", | 			"token": "foobar", | ||||||
|     "infrastructure":"foo/bar", | 			"infrastructure": "foo/bar", | ||||||
|     "endpoint":"https://foo.bar:1111" | 			"endpoint": "https://foo.bar:1111", | ||||||
|   }, | 			"node_id": "foo_node" | ||||||
|   "backend":{ | 		} | ||||||
|     "consul":{ | 	}], | ||||||
|       "foo":"bar" | 	"backend": { | ||||||
|     } | 		"consul": { | ||||||
|   }, | 			"foo": "bar" | ||||||
|   "telemetry":{ | 		} | ||||||
|     "statsite_address":"baz" | 	}, | ||||||
|   }, | 	"telemetry": { | ||||||
|   "max_lease_ttl":"10h", | 		"statsite_address": "baz" | ||||||
|   "default_lease_ttl":"10h" | 	}, | ||||||
|  | 	"max_lease_ttl": "10h", | ||||||
|  | 	"default_lease_ttl": "10h" | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jeff Mitchell
					Jeff Mitchell