-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use BUILD_MINIMAL env to build minimal Vault with few storage options…
… and plugins (#27394)
- Loading branch information
Showing
12 changed files
with
417 additions
and
217 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```release-note:feature | ||
**Vault Minimal Version**: Add the ability to build a minimal version of Vault | ||
with only core features using the BUILD_MINIMAL environment variable. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
//go:build !minimal | ||
|
||
package command | ||
|
||
import ( | ||
"maps" | ||
|
||
credAliCloud "github.com/hashicorp/vault-plugin-auth-alicloud" | ||
credCF "github.com/hashicorp/vault-plugin-auth-cf" | ||
credGcp "github.com/hashicorp/vault-plugin-auth-gcp/plugin" | ||
credKerb "github.com/hashicorp/vault-plugin-auth-kerberos" | ||
credOCI "github.com/hashicorp/vault-plugin-auth-oci" | ||
credAws "github.com/hashicorp/vault/builtin/credential/aws" | ||
credGitHub "github.com/hashicorp/vault/builtin/credential/github" | ||
credLdap "github.com/hashicorp/vault/builtin/credential/ldap" | ||
credOkta "github.com/hashicorp/vault/builtin/credential/okta" | ||
credUserpass "github.com/hashicorp/vault/builtin/credential/userpass" | ||
_ "github.com/hashicorp/vault/helper/builtinplugins" | ||
physAerospike "github.com/hashicorp/vault/physical/aerospike" | ||
physAliCloudOSS "github.com/hashicorp/vault/physical/alicloudoss" | ||
physAzure "github.com/hashicorp/vault/physical/azure" | ||
physCassandra "github.com/hashicorp/vault/physical/cassandra" | ||
physCockroachDB "github.com/hashicorp/vault/physical/cockroachdb" | ||
physConsul "github.com/hashicorp/vault/physical/consul" | ||
physCouchDB "github.com/hashicorp/vault/physical/couchdb" | ||
physDynamoDB "github.com/hashicorp/vault/physical/dynamodb" | ||
physEtcd "github.com/hashicorp/vault/physical/etcd" | ||
physFoundationDB "github.com/hashicorp/vault/physical/foundationdb" | ||
physGCS "github.com/hashicorp/vault/physical/gcs" | ||
physManta "github.com/hashicorp/vault/physical/manta" | ||
physMSSQL "github.com/hashicorp/vault/physical/mssql" | ||
physMySQL "github.com/hashicorp/vault/physical/mysql" | ||
physOCI "github.com/hashicorp/vault/physical/oci" | ||
physPostgreSQL "github.com/hashicorp/vault/physical/postgresql" | ||
physS3 "github.com/hashicorp/vault/physical/s3" | ||
physSpanner "github.com/hashicorp/vault/physical/spanner" | ||
physSwift "github.com/hashicorp/vault/physical/swift" | ||
physZooKeeper "github.com/hashicorp/vault/physical/zookeeper" | ||
"github.com/hashicorp/vault/sdk/physical" | ||
physFile "github.com/hashicorp/vault/sdk/physical/file" | ||
) | ||
|
||
func newFullAddonCommands() (map[string]physical.Factory, map[string]LoginHandler) { | ||
addonPhysicalBackends := map[string]physical.Factory{ | ||
"aerospike": physAerospike.NewAerospikeBackend, | ||
"alicloudoss": physAliCloudOSS.NewAliCloudOSSBackend, | ||
"azure": physAzure.NewAzureBackend, | ||
"cassandra": physCassandra.NewCassandraBackend, | ||
"cockroachdb": physCockroachDB.NewCockroachDBBackend, | ||
"consul": physConsul.NewConsulBackend, | ||
"couchdb_transactional": physCouchDB.NewTransactionalCouchDBBackend, | ||
"couchdb": physCouchDB.NewCouchDBBackend, | ||
"dynamodb": physDynamoDB.NewDynamoDBBackend, | ||
"etcd": physEtcd.NewEtcdBackend, | ||
"file_transactional": physFile.NewTransactionalFileBackend, | ||
"file": physFile.NewFileBackend, | ||
"foundationdb": physFoundationDB.NewFDBBackend, | ||
"gcs": physGCS.NewBackend, | ||
"manta": physManta.NewMantaBackend, | ||
"mssql": physMSSQL.NewMSSQLBackend, | ||
"mysql": physMySQL.NewMySQLBackend, | ||
"oci": physOCI.NewBackend, | ||
"postgresql": physPostgreSQL.NewPostgreSQLBackend, | ||
"s3": physS3.NewS3Backend, | ||
"spanner": physSpanner.NewBackend, | ||
"swift": physSwift.NewSwiftBackend, | ||
"zookeeper": physZooKeeper.NewZooKeeperBackend, | ||
} | ||
addonLoginHandlers := map[string]LoginHandler{ | ||
"alicloud": &credAliCloud.CLIHandler{}, | ||
"aws": &credAws.CLIHandler{}, | ||
"cf": &credCF.CLIHandler{}, | ||
"gcp": &credGcp.CLIHandler{}, | ||
"github": &credGitHub.CLIHandler{}, | ||
"kerberos": &credKerb.CLIHandler{}, | ||
"ldap": &credLdap.CLIHandler{}, | ||
"oci": &credOCI.CLIHandler{}, | ||
"okta": &credOkta.CLIHandler{}, | ||
"pcf": &credCF.CLIHandler{}, // Deprecated. | ||
"radius": &credUserpass.CLIHandler{ | ||
DefaultMount: "radius", | ||
}, | ||
} | ||
|
||
return addonPhysicalBackends, addonLoginHandlers | ||
} | ||
|
||
func extendAddonCommands() { | ||
addonPhysicalBackends, addonLoginHandlers := newFullAddonCommands() | ||
|
||
maps.Copy(physicalBackends, addonPhysicalBackends) | ||
maps.Copy(loginHandlers, addonLoginHandlers) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
//go:build !enterprise && !minimal | ||
|
||
package command | ||
|
||
import ( | ||
"maps" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
// Test_extendAddonCommands tests extendAddonCommands() extends physical and logical backends with | ||
// those generated by newFullAddonCommands() | ||
func Test_extendAddonCommands(t *testing.T) { | ||
expMinPhysicalBackends := maps.Clone(physicalBackends) | ||
expMinLoginHandlers := maps.Clone(loginHandlers) | ||
|
||
expAddonPhysicalBackends, expAddonLoginHandlers := newFullAddonCommands() | ||
|
||
extendAddonCommands() | ||
|
||
require.Equal(t, len(expMinPhysicalBackends)+len(expAddonPhysicalBackends), len(physicalBackends), | ||
"extended total physical backends mismatch total of minimal and full addon physical backends") | ||
require.Equal(t, len(expMinLoginHandlers)+len(expAddonLoginHandlers), len(loginHandlers), | ||
"extended total login handlers mismatch total of minimal and full addon login handlers") | ||
|
||
for k := range expMinPhysicalBackends { | ||
require.Contains(t, physicalBackends, k, "expected to contain minimal physical backend") | ||
} | ||
|
||
for k := range expAddonPhysicalBackends { | ||
require.Contains(t, physicalBackends, k, "expected to contain full addon physical backend") | ||
} | ||
|
||
for k := range expMinLoginHandlers { | ||
require.Contains(t, loginHandlers, k, "expected to contain minimal login handler") | ||
} | ||
|
||
for k := range expAddonLoginHandlers { | ||
require.Contains(t, loginHandlers, k, "expected to contain full addon login handler") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
//go:build minimal | ||
|
||
package command | ||
|
||
import ( | ||
_ "github.com/hashicorp/vault/helper/builtinplugins" | ||
) | ||
|
||
func extendAddonCommands() { | ||
// No-op | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.