mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-31 02:28:09 +00:00 
			
		
		
		
	Add API functions and completions for plugins (#4194)
This commit is contained in:
		 Seth Vargo
					Seth Vargo
				
			
				
					committed by
					
						 Jeff Mitchell
						Jeff Mitchell
					
				
			
			
				
	
			
			
			 Jeff Mitchell
						Jeff Mitchell
					
				
			
						parent
						
							43e9bcd948
						
					
				
				
					commit
					34beea85fb
				
			| @@ -139,6 +139,11 @@ func (b *BaseCommand) PredictVaultAuths() complete.Predictor { | ||||
| 	return NewPredict().VaultAuths() | ||||
| } | ||||
|  | ||||
| // PredictVaultPlugins returns a predictor for installed plugins. | ||||
| func (b *BaseCommand) PredictVaultPlugins() complete.Predictor { | ||||
| 	return NewPredict().VaultPlugins() | ||||
| } | ||||
|  | ||||
| // PredictVaultPolicies returns a predictor for "folders". See PredictVaultFiles | ||||
| // for more information and restrictions. | ||||
| func (b *BaseCommand) PredictVaultPolicies() complete.Predictor { | ||||
| @@ -177,6 +182,13 @@ func (p *Predict) VaultAuths() complete.Predictor { | ||||
| 	return p.filterFunc(p.auths) | ||||
| } | ||||
|  | ||||
| // VaultPlugins returns a predictor for Vault's plugin catalog. This is a public | ||||
| // API for consumers, but you probably want BaseCommand.PredictVaultPlugins | ||||
| // instead. | ||||
| func (p *Predict) VaultPlugins() complete.Predictor { | ||||
| 	return p.filterFunc(p.plugins) | ||||
| } | ||||
|  | ||||
| // VaultPolicies returns a predictor for Vault "folders". This is a public API for | ||||
| // consumers, but you probably want BaseCommand.PredictVaultPolicies instead. | ||||
| func (p *Predict) VaultPolicies() complete.Predictor { | ||||
| @@ -310,6 +322,22 @@ func (p *Predict) auths() []string { | ||||
| 	return list | ||||
| } | ||||
|  | ||||
| // plugins returns a sorted list of the plugins in the catalog. | ||||
| func (p *Predict) plugins() []string { | ||||
| 	client := p.Client() | ||||
| 	if client == nil { | ||||
| 		return nil | ||||
| 	} | ||||
|  | ||||
| 	result, err := client.Sys().ListPlugins(nil) | ||||
| 	if err != nil { | ||||
| 		return nil | ||||
| 	} | ||||
| 	plugins := result.Names | ||||
| 	sort.Strings(plugins) | ||||
| 	return plugins | ||||
| } | ||||
|  | ||||
| // policies returns a sorted list of the policies stored in this Vault | ||||
| // server. | ||||
| func (p *Predict) policies() []string { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user