mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-11-03 20:17:59 +00:00 
			
		
		
		
	Add the ability to use a dev Consul node for dev storage (#6965)
This commit is contained in:
		@@ -108,6 +108,7 @@ type ServerCommand struct {
 | 
				
			|||||||
	flagTestVerifyOnly   bool
 | 
						flagTestVerifyOnly   bool
 | 
				
			||||||
	flagCombineLogs      bool
 | 
						flagCombineLogs      bool
 | 
				
			||||||
	flagTestServerConfig bool
 | 
						flagTestServerConfig bool
 | 
				
			||||||
 | 
						flagDevConsul        bool
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type ServerListener struct {
 | 
					type ServerListener struct {
 | 
				
			||||||
@@ -292,6 +293,13 @@ func (c *ServerCommand) Flags() *FlagSets {
 | 
				
			|||||||
		Hidden:  true,
 | 
							Hidden:  true,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						f.BoolVar(&BoolVar{
 | 
				
			||||||
 | 
							Name:    "dev-consul",
 | 
				
			||||||
 | 
							Target:  &c.flagDevConsul,
 | 
				
			||||||
 | 
							Default: false,
 | 
				
			||||||
 | 
							Hidden:  true,
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// TODO: should the below flags be public?
 | 
						// TODO: should the below flags be public?
 | 
				
			||||||
	f.BoolVar(&BoolVar{
 | 
						f.BoolVar(&BoolVar{
 | 
				
			||||||
		Name:    "combine-logs",
 | 
							Name:    "combine-logs",
 | 
				
			||||||
@@ -400,7 +408,20 @@ func (c *ServerCommand) Run(args []string) int {
 | 
				
			|||||||
	// Load the configuration
 | 
						// Load the configuration
 | 
				
			||||||
	var config *server.Config
 | 
						var config *server.Config
 | 
				
			||||||
	if c.flagDev {
 | 
						if c.flagDev {
 | 
				
			||||||
		config = server.DevConfig(c.flagDevHA, c.flagDevTransactional)
 | 
							var devStorageType string
 | 
				
			||||||
 | 
							switch {
 | 
				
			||||||
 | 
							case c.flagDevConsul:
 | 
				
			||||||
 | 
								devStorageType = "consul"
 | 
				
			||||||
 | 
							case c.flagDevHA && c.flagDevTransactional:
 | 
				
			||||||
 | 
								devStorageType = "inmem_transactional_ha"
 | 
				
			||||||
 | 
							case !c.flagDevHA && c.flagDevTransactional:
 | 
				
			||||||
 | 
								devStorageType = "inmem_transactional"
 | 
				
			||||||
 | 
							case c.flagDevHA && !c.flagDevTransactional:
 | 
				
			||||||
 | 
								devStorageType = "inmem_ha"
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								devStorageType = "inmem"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							config = server.DevConfig(devStorageType)
 | 
				
			||||||
		if c.flagDevListenAddr != "" {
 | 
							if c.flagDevListenAddr != "" {
 | 
				
			||||||
			config.Listeners[0].Config["address"] = c.flagDevListenAddr
 | 
								config.Listeners[0].Config["address"] = c.flagDevListenAddr
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -80,13 +80,13 @@ type Config struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// DevConfig is a Config that is used for dev mode of Vault.
 | 
					// DevConfig is a Config that is used for dev mode of Vault.
 | 
				
			||||||
func DevConfig(ha, transactional bool) *Config {
 | 
					func DevConfig(storageType string) *Config {
 | 
				
			||||||
	ret := &Config{
 | 
						ret := &Config{
 | 
				
			||||||
		DisableMlock:      true,
 | 
							DisableMlock:      true,
 | 
				
			||||||
		EnableRawEndpoint: true,
 | 
							EnableRawEndpoint: true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Storage: &Storage{
 | 
							Storage: &Storage{
 | 
				
			||||||
			Type: "inmem",
 | 
								Type: storageType,
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Listeners: []*Listener{
 | 
							Listeners: []*Listener{
 | 
				
			||||||
@@ -109,15 +109,6 @@ func DevConfig(ha, transactional bool) *Config {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	switch {
 | 
					 | 
				
			||||||
	case ha && transactional:
 | 
					 | 
				
			||||||
		ret.Storage.Type = "inmem_transactional_ha"
 | 
					 | 
				
			||||||
	case !ha && transactional:
 | 
					 | 
				
			||||||
		ret.Storage.Type = "inmem_transactional"
 | 
					 | 
				
			||||||
	case ha && !transactional:
 | 
					 | 
				
			||||||
		ret.Storage.Type = "inmem_ha"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return ret
 | 
						return ret
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user