Upgrade to Go 1.19 (#2347)
This commit is contained in:
1 parent
07a4082aa1
commit
aef9073fa6
77 files changed
+334
-294
No files matched your search
+1
-1
@@ -1 +1 @@
|
||||
1.18.4
|
||||
1.19.0
|
||||
@@ -86,7 +86,7 @@ for permanent installations, are detailed in our [Installation Guide](https://ww
|
||||
### Build and Start Boundary in Dev Mode
|
||||
|
||||
If you have the following requirements met locally:
|
||||
- Golang v1.18 or greater
|
||||
- Golang v1.19 or greater
|
||||
- Docker
|
||||
- [Boundary UI Dependencies](https://github.com/hashicorp/boundary-ui#prerequisites)
|
||||
|
||||
|
||||
+2
-3
@@ -1,15 +1,15 @@
|
||||
module github.com/hashicorp/boundary/api
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/fatih/structs v1.1.0
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2
|
||||
github.com/hashicorp/go-kms-wrapping/v2 v2.0.1
|
||||
github.com/hashicorp/go-retryablehttp v0.6.8
|
||||
github.com/hashicorp/go-rootcerts v1.0.2
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.1
|
||||
github.com/hashicorp/go-uuid v1.0.2
|
||||
github.com/mitchellh/mapstructure v1.4.1
|
||||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
|
||||
@@ -27,7 +27,6 @@ require (
|
||||
github.com/mattn/go-colorable v0.1.6 // indirect
|
||||
github.com/mattn/go-isatty v0.0.12 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rogpeppe/go-internal v1.6.1 // indirect
|
||||
github.com/ryanuber/go-glob v1.0.0 // indirect
|
||||
|
||||
@@ -15,8 +15,6 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.m
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
VERSION="1.18.4"
|
||||
VERSION="1.19"
|
||||
|
||||
[ -z "$GOROOT" ] && GOROOT="$HOME/.go"
|
||||
[ -z "$GOPATH" ] && GOPATH="$HOME/go"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module github.com/hashicorp/boundary
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
replace github.com/hashicorp/boundary/api => ./api
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ func (r *Repository) LookupAuthMethod(ctx context.Context, publicId string, opt
|
||||
|
||||
// ListAuthMethods returns a slice of AuthMethods for the scopeId. The
|
||||
// WithUnauthenticatedUser, WithLimit and WithOrder options are supported and
|
||||
// all other options are ignored.
|
||||
// all other options are ignored.
|
||||
func (r *Repository) ListAuthMethods(ctx context.Context, scopeIds []string, opt ...Option) ([]*AuthMethod, error) {
|
||||
const op = "oidc.(Repository).ListAuthMethods"
|
||||
if len(scopeIds) == 0 {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// expiration time and a last accessed time which are used to determine if the
|
||||
// token can still be used.
|
||||
//
|
||||
// Repository
|
||||
// # Repository
|
||||
//
|
||||
// A repository provides methods for creating, validating a provided token value,
|
||||
// and deleting the auth token. At validation time if the token is determined
|
||||
|
||||
@@ -855,11 +855,11 @@ func MakeSighupCh() chan struct{} {
|
||||
//
|
||||
// The setting is derived from one of the following, in order:
|
||||
//
|
||||
// * Via the supplied value if non-zero.
|
||||
// * BOUNDARY_STATUS_GRACE_PERIOD, if defined, can be set to an
|
||||
// integer value to define the setting.
|
||||
// * If either of these is missing, the default is used. See the
|
||||
// defaultStatusGracePeriod value for the default value.
|
||||
// - Via the supplied value if non-zero.
|
||||
// - BOUNDARY_STATUS_GRACE_PERIOD, if defined, can be set to an
|
||||
// integer value to define the setting.
|
||||
// - If either of these is missing, the default is used. See the
|
||||
// defaultStatusGracePeriod value for the default value.
|
||||
//
|
||||
// The minimum setting for this value is the default setting. Values
|
||||
// below this will be reset to the default.
|
||||
|
||||
@@ -619,7 +619,6 @@ func Parse(d string) (*Config, error) {
|
||||
}
|
||||
|
||||
// supportControllersRawConfig returns either initialUpstreamsRaw or controllersRaw depending on which is populated. Errors when both fields are populated.
|
||||
//
|
||||
func supportControllersRawConfig(initialUpstreamsRaw, controllersRaw any) (any, error) {
|
||||
switch {
|
||||
case initialUpstreamsRaw == nil && controllersRaw != nil:
|
||||
|
||||
@@ -97,10 +97,12 @@ func defaultExtract(sd data, usernameAttr, privateKeyAttr, passphraseAttr string
|
||||
// 'data' field within the data map.
|
||||
//
|
||||
// Additionaly it validates the data is in the expected KV-v2 format:
|
||||
// {
|
||||
// "data": {},
|
||||
// "metadata: {}
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// "data": {},
|
||||
// "metadata: {}
|
||||
// }
|
||||
//
|
||||
// If the format does not match, it returns ("", ""). See:
|
||||
// https://www.vaultproject.io/api/secret/kv/kv-v2#sample-response-1
|
||||
func kv2Extract(sd data, usernameAttr, privateKeyAttr, passphraseAttr string) (
|
||||
|
||||
@@ -82,10 +82,12 @@ func defaultExtract(sd data, usernameAttr, passwordAttr string) (username string
|
||||
// 'data' field within the data map.
|
||||
//
|
||||
// Additionaly it validates the data is in the expected KV-v2 format:
|
||||
// {
|
||||
// "data": {},
|
||||
// "metadata: {}
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// "data": {},
|
||||
// "metadata: {}
|
||||
// }
|
||||
//
|
||||
// If the format does not match, it returns ("", ""). See:
|
||||
// https://www.vaultproject.io/api/secret/kv/kv-v2#sample-response-1
|
||||
func kv2Extract(sd data, usernameAttr, passwordAttr string) (username string, password string) {
|
||||
|
||||
@@ -248,7 +248,9 @@ type Token struct {
|
||||
// expiration_time is calculated when the token is renewed.
|
||||
//
|
||||
// The calculation is:
|
||||
// expiration_time := time.Now().Add(LeaseDuration * time.Second)
|
||||
//
|
||||
// expiration_time := time.Now().Add(LeaseDuration * time.Second)
|
||||
//
|
||||
// LeaseDuration is a value returned by Vault when the token is renewed.
|
||||
//
|
||||
// https://www.vaultproject.io/api-docs/auth/token#renew-a-token-self
|
||||
@@ -664,7 +666,9 @@ type Credential struct {
|
||||
// retrieved and whenever the credential's lease is renewed.
|
||||
//
|
||||
// The calculation is:
|
||||
// expiration_time := time.Now().Add(LeaseDuration * time.Second)
|
||||
//
|
||||
// expiration_time := time.Now().Add(LeaseDuration * time.Second)
|
||||
//
|
||||
// LeaseDuration is a value returned by Vault when the credential is
|
||||
// retrieved or the lease for the credential is renewed.
|
||||
//
|
||||
|
||||
@@ -738,9 +738,9 @@ func (v *TestVaultServer) addPolicy(t testing.TB, name string, pc pathCapabiliti
|
||||
// standard set of polices attached to tokens created with v.CreateToken.
|
||||
// The policy is defined as:
|
||||
//
|
||||
// path "mountPath/*" {
|
||||
// capabilities = ["create", "read", "update", "delete", "list"]
|
||||
// }
|
||||
// path "mountPath/*" {
|
||||
// capabilities = ["create", "read", "update", "delete", "list"]
|
||||
// }
|
||||
func (v *TestVaultServer) MountPKI(t testing.TB, opt ...TestOption) *vault.Secret {
|
||||
t.Helper()
|
||||
require := require.New(t)
|
||||
@@ -802,9 +802,9 @@ func (v *TestVaultServer) MountPKI(t testing.TB, opt ...TestOption) *vault.Secre
|
||||
// standard set of polices attached to tokens created with v.CreateToken.
|
||||
// The policy is defined as:
|
||||
//
|
||||
// path "secret/*" {
|
||||
// capabilities = ["create", "read", "update", "delete", "list"]
|
||||
// }
|
||||
// path "secret/*" {
|
||||
// capabilities = ["create", "read", "update", "delete", "list"]
|
||||
// }
|
||||
//
|
||||
// All options are ignored.
|
||||
func (v *TestVaultServer) AddKVPolicy(t testing.TB, _ ...TestOption) {
|
||||
@@ -872,9 +872,9 @@ func NewTestVaultServer(t testing.TB, opt ...TestOption) *TestVaultServer {
|
||||
// to the standard set of polices attached to tokens created with
|
||||
// v.CreateToken. The policy is defined as:
|
||||
//
|
||||
// path "mountPath/*" {
|
||||
// capabilities = ["create", "read", "update", "delete", "list"]
|
||||
// }
|
||||
// path "mountPath/*" {
|
||||
// capabilities = ["create", "read", "update", "delete", "list"]
|
||||
// }
|
||||
//
|
||||
// MountDatabase returns a TestDatabase for testing credentials from the
|
||||
// mount.
|
||||
|
||||
@@ -936,9 +936,9 @@ func toStoragePwAccount(amId string, item *pb.Account) (*password.Account, error
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetAccountRequest) error {
|
||||
const op = "accounts.validateGetRequest"
|
||||
if req == nil {
|
||||
|
||||
@@ -818,9 +818,9 @@ func toAuthTokenProto(t *authtoken.AuthToken) *pba.AuthToken {
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetAuthMethodRequest) error {
|
||||
const op = "authmethod.validateGetRequest"
|
||||
if req == nil {
|
||||
|
||||
@@ -362,9 +362,9 @@ func toProto(ctx context.Context, in *authtoken.AuthToken, opt ...handlers.Optio
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetAuthTokenRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, authtoken.AuthTokenPrefix)
|
||||
}
|
||||
|
||||
+3
-3
@@ -633,9 +633,9 @@ func toStorageVaultLibrary(storeId string, in *pb.CredentialLibrary) (out *vault
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetCredentialLibraryRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, vault.CredentialLibraryPrefix)
|
||||
}
|
||||
|
||||
@@ -627,9 +627,9 @@ func toSshPrivateKeyStorageCredential(ctx context.Context, storeId string, in *p
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetCredentialRequest) error {
|
||||
return handlers.ValidateGetRequest(
|
||||
handlers.NoopValidatorFn,
|
||||
|
||||
@@ -770,9 +770,9 @@ func toStorageVaultStore(scopeId string, in *pb.CredentialStore) (out *vault.Cre
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetCredentialStoreRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, vault.CredentialStorePrefix, static.CredentialStorePrefix, static.PreviousCredentialStorePrefix)
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func NewFilter(f string) (*Filter, error) {
|
||||
// Match returns if the provided interface matches the filter.
|
||||
// If the filter does not match the structure of the object being Matched, false is returned.
|
||||
// TODO: Support more than just matching against the item being filtered. Also allow matching against
|
||||
// values in the request or the request context itself.
|
||||
// values in the request or the request context itself.
|
||||
func (f *Filter) Match(item interface{}) bool {
|
||||
if f.eval == nil {
|
||||
return true
|
||||
|
||||
@@ -651,9 +651,9 @@ func toProto(ctx context.Context, in *iam.Group, members []*iam.GroupMember, opt
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetGroupRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, iam.GroupPrefix)
|
||||
}
|
||||
|
||||
@@ -814,11 +814,11 @@ func toStoragePluginCatalog(ctx context.Context, projectId, plgId string, item *
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// * The type asserted by the ID and/or field is known
|
||||
// * If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
// - The type asserted by the ID and/or field is known
|
||||
// - If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
func validateGetRequest(req *pbs.GetHostCatalogRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, static.HostCatalogPrefix, plugin.HostCatalogPrefix, plugin.PreviousHostCatalogPrefix)
|
||||
}
|
||||
|
||||
@@ -937,11 +937,11 @@ func toStoragePluginSet(ctx context.Context, catalogId string, item *pb.HostSet)
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// * The type asserted by the ID and/or field is known
|
||||
// * If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
// - The type asserted by the ID and/or field is known
|
||||
// - If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
func validateGetRequest(req *pbs.GetHostSetRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, static.HostSetPrefix, plugin.HostSetPrefix, plugin.PreviousHostSetPrefix)
|
||||
}
|
||||
|
||||
@@ -601,11 +601,11 @@ func toProto(ctx context.Context, in host.Host, opt ...handlers.Option) (*pb.Hos
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// * The type asserted by the ID and/or field is known
|
||||
// * If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
// - The type asserted by the ID and/or field is known
|
||||
// - If relevant, the type derived from the id prefix matches what is claimed by the type field
|
||||
func validateGetRequest(req *pbs.GetHostRequest) error {
|
||||
return handlers.ValidateGetRequest(func() map[string]string {
|
||||
badFields := map[string]string{}
|
||||
|
||||
@@ -572,9 +572,9 @@ func toProto(ctx context.Context, in auth.ManagedGroup, opt ...handlers.Option)
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetManagedGroupRequest) error {
|
||||
const op = "managed_groups.validateGetRequest"
|
||||
if req == nil {
|
||||
|
||||
@@ -880,9 +880,9 @@ func toProto(ctx context.Context, in *iam.Role, principals []*iam.PrincipalRole,
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetRoleRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, iam.RolePrefix)
|
||||
}
|
||||
|
||||
@@ -591,9 +591,9 @@ func ToProto(ctx context.Context, in *iam.Scope, opt ...handlers.Option) (*pb.Sc
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetScopeRequest) error {
|
||||
badFields := map[string]string{}
|
||||
id := req.GetId()
|
||||
|
||||
@@ -473,9 +473,9 @@ func toProto(ctx context.Context, in *session.Session, opt ...handlers.Option) (
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetSessionRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, session.SessionPrefix)
|
||||
}
|
||||
|
||||
@@ -1570,9 +1570,9 @@ func toProto(ctx context.Context, in target.Target, hostSources []target.HostSou
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetTargetRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, target.Prefixes()...)
|
||||
}
|
||||
|
||||
@@ -661,9 +661,9 @@ func toProto(ctx context.Context, in *iam.User, accts []string, opt ...handlers.
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetUserRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, iam.UserPrefix)
|
||||
}
|
||||
|
||||
@@ -717,9 +717,9 @@ func tagsToMapProto(in map[string][]string) (map[string]*structpb.ListValue, err
|
||||
|
||||
// A validateX method should exist for each method above. These methods do not make calls to any backing service but enforce
|
||||
// requirements on the structure of the request. They verify that:
|
||||
// * The path passed in is correctly formatted
|
||||
// * All required parameters are set
|
||||
// * There are no conflicting parameters provided
|
||||
// - The path passed in is correctly formatted
|
||||
// - All required parameters are set
|
||||
// - There are no conflicting parameters provided
|
||||
func validateGetRequest(req *pbs.GetWorkerRequest) error {
|
||||
return handlers.ValidateGetRequest(handlers.NoopValidatorFn, req, server.WorkerPrefix)
|
||||
}
|
||||
|
||||
@@ -284,7 +284,7 @@ func (s *sess) RequestConnectConnection(ctx context.Context, info *pbs.ConnectCo
|
||||
}
|
||||
|
||||
// CancelOpenLocalConnections closes the local connections in this session
|
||||
//based on the connection's state by calling the connections context cancel
|
||||
// based on the connection's state by calling the connections context cancel
|
||||
// function.
|
||||
//
|
||||
// The returned slice are connection ids that were closed.
|
||||
|
||||
+21
-21
@@ -3,27 +3,27 @@
|
||||
//
|
||||
// Example Usage:
|
||||
//
|
||||
// import (
|
||||
// "testing"
|
||||
// import (
|
||||
// "testing"
|
||||
//
|
||||
// "github.com/hashicorp/internal/db/assert"
|
||||
// )
|
||||
// "github.com/hashicorp/internal/db/assert"
|
||||
// )
|
||||
//
|
||||
// func TestSomeDatabase(t *testing.T) {
|
||||
// conn, err := sql.Open("postgres", "postgres://postgres:secret@localhost:%s?sslmode=disable")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// defer conn.Close()
|
||||
// db, err := gorm.Open("postgres", conn)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// m := TestModel{}
|
||||
// if err = rw.Create(&m); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// dbassert := dbassert.New(t, db)
|
||||
// dbassert.FieldIsNull(&someModel, "someField")
|
||||
// }
|
||||
// func TestSomeDatabase(t *testing.T) {
|
||||
// conn, err := sql.Open("postgres", "postgres://postgres:secret@localhost:%s?sslmode=disable")
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// defer conn.Close()
|
||||
// db, err := gorm.Open("postgres", conn)
|
||||
// if err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// m := TestModel{}
|
||||
// if err = rw.Create(&m); err != nil {
|
||||
// t.Fatal(err)
|
||||
// }
|
||||
// dbassert := dbassert.New(t, db)
|
||||
// dbassert.FieldIsNull(&someModel, "someField")
|
||||
// }
|
||||
package dbassert
|
||||
@@ -27,9 +27,11 @@ type ExprValue struct {
|
||||
// column values for database operations. See: Expr(...)
|
||||
//
|
||||
// Set name column to null example:
|
||||
//
|
||||
// SetColumnValues(map[string]interface{}{"name": Expr("NULL")})
|
||||
//
|
||||
// Set exp_time column to N seconds from now:
|
||||
//
|
||||
// SetColumnValues(map[string]interface{}{"exp_time": Expr("wt_add_seconds_to_now(?)", 10)})
|
||||
func Expr(expr string, args ...interface{}) ExprValue {
|
||||
return ExprValue{sql: expr, vars: args}
|
||||
|
||||
@@ -7,16 +7,15 @@
|
||||
// prior to creating a schema.Manager. This is generally done in an init
|
||||
// function of another package, i.e.:
|
||||
//
|
||||
// //go:embed postgres
|
||||
// var postgres embed.FS
|
||||
// //go:embed postgres
|
||||
// var postgres embed.FS
|
||||
//
|
||||
// func init() {
|
||||
// schema.RegisterEdition("oss", schema.Postgres, postgres, 0)
|
||||
// }
|
||||
// func init() {
|
||||
// schema.RegisterEdition("oss", schema.Postgres, postgres, 0)
|
||||
// }
|
||||
//
|
||||
// Then a manager can be created and used to apply the migrations:
|
||||
//
|
||||
// m := schema.NewManager(ctx, schema.Postgres, db)
|
||||
// m.ApplyMigrations()
|
||||
//
|
||||
// m := schema.NewManager(ctx, schema.Postgres, db)
|
||||
// m.ApplyMigrations()
|
||||
package schema
|
||||
@@ -58,22 +58,22 @@ func (e Editions) Sort() {
|
||||
// lower number indicates a higher priority. New will panic if the structure
|
||||
// of the embed.FS is not correct. The files must be structured as follows:
|
||||
//
|
||||
// <majorVersion>/
|
||||
// <minorVersion>_<description>.up.sql
|
||||
// <majorVersion>/
|
||||
// <minorVersion>_<description>.up.sql
|
||||
//
|
||||
// Where majorVersion and minorVersion are integers. There can be any number of
|
||||
// leading directories prior to the major versions. For example a directory
|
||||
// structure like the following is correct:
|
||||
//
|
||||
// migrations/oss/postgres/
|
||||
// 0/
|
||||
// 01_initial.up.sql
|
||||
// 1/
|
||||
// 01_add_columns.up.sql
|
||||
// 02_rename_table.up.sql
|
||||
// 2/
|
||||
// 01_add_new_table.up.sql
|
||||
// 02_refactor_views.up.sql
|
||||
// migrations/oss/postgres/
|
||||
// 0/
|
||||
// 01_initial.up.sql
|
||||
// 1/
|
||||
// 01_add_columns.up.sql
|
||||
// 02_rename_table.up.sql
|
||||
// 2/
|
||||
// 01_add_new_table.up.sql
|
||||
// 02_refactor_views.up.sql
|
||||
func New(name string, dialect Dialect, m embed.FS, priority int, opt ...Option) (Edition, error) {
|
||||
var largestSchemaVersion int
|
||||
migrations := make(migration.Migrations)
|
||||
|
||||
@@ -451,7 +451,7 @@ func (p *Postgres) EnsureMigrationLogTable(ctx context.Context) error {
|
||||
|
||||
// GetMigrationLog will retrieve the migration logs from the db for the last
|
||||
// migration.
|
||||
// The WithDeleteLog option is supported and will remove all log entries,
|
||||
// The WithDeleteLog option is supported and will remove all log entries,
|
||||
// after reading the entries, when provided.
|
||||
func (p *Postgres) GetMigrationLog(ctx context.Context, opt ...log.Option) ([]*log.Entry, error) {
|
||||
const op = "postgres.(Postgres).GetMigrationLog"
|
||||
|
||||
@@ -19,7 +19,7 @@ type LogEntry struct {
|
||||
|
||||
// GetMigrationLog will retrieve the migration logs from the db for the last
|
||||
// migration. Once it's read the entries, it will delete them from the database.
|
||||
// The WithDeleteLog option is supported and will remove all log entries when provided.
|
||||
// The WithDeleteLog option is supported and will remove all log entries when provided.
|
||||
func (b *Manager) GetMigrationLog(ctx context.Context, opt ...Option) ([]LogEntry, error) {
|
||||
const op = "schema.GetMigrationLog"
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
// postgres contains the sql for creating the base tables used to manage
|
||||
// migrations.
|
||||
//
|
||||
//go:embed base/postgres
|
||||
var postgres embed.FS
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
// belonging to the same project scope.
|
||||
//
|
||||
// The repair functionality removes all illegal associations and returns a report.
|
||||
//
|
||||
package hook46001
|
||||
|
||||
import (
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
)
|
||||
|
||||
// postgres contains the migrations sql files for postgres oss edition
|
||||
//
|
||||
//go:embed postgres
|
||||
var postgres embed.FS
|
||||
|
||||
|
||||
@@ -38,7 +38,8 @@ type testServer struct {
|
||||
// 4) asserting some bits about the state of the db.
|
||||
//
|
||||
// Tests migration:
|
||||
// migrations/oss/11/01_server_type_enum.up.sql
|
||||
//
|
||||
// migrations/oss/11/01_server_type_enum.up.sql
|
||||
func Test_ServerEnumChanges(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
@@ -13,7 +13,8 @@ import (
|
||||
)
|
||||
|
||||
// Tests migration:
|
||||
// migrations/oss/12/01_timestamp_sub_funcs.up.sql
|
||||
//
|
||||
// migrations/oss/12/01_timestamp_sub_funcs.up.sql
|
||||
func TestWtSubSeconds(t *testing.T) {
|
||||
t.Parallel()
|
||||
require := require.New(t)
|
||||
|
||||
@@ -15,7 +15,8 @@ import (
|
||||
)
|
||||
|
||||
// Tests migration:
|
||||
// migrations/oss/2/10_auth.up.sql
|
||||
//
|
||||
// migrations/oss/2/10_auth.up.sql
|
||||
func Test_AuthMethodSubtypes(t *testing.T) {
|
||||
t.Parallel()
|
||||
assert, require := assert.New(t), require.New(t)
|
||||
|
||||
@@ -599,6 +599,7 @@ type ChangeStateRequest struct {
|
||||
// The mutation will fail if the version does not match the latest known good version.
|
||||
Version uint32 `protobuf:"varint,2,opt,name=version,proto3" json:"version,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *ChangeStateRequest_Attributes
|
||||
// *ChangeStateRequest_OidcChangeStateAttributes
|
||||
Attrs isChangeStateRequest_Attrs `protobuf_oneof:"attrs"`
|
||||
@@ -867,6 +868,7 @@ type AuthenticateRequest struct {
|
||||
// to keep it safe from rogue JS in the browser.
|
||||
Type string `protobuf:"bytes,6,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *AuthenticateRequest_Attributes
|
||||
// *AuthenticateRequest_PasswordLoginAttributes
|
||||
// *AuthenticateRequest_OidcStartAttributes
|
||||
@@ -1025,6 +1027,7 @@ type AuthenticateResponse struct {
|
||||
// The type of the token returned. Either "cookie" or "token".
|
||||
Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *AuthenticateResponse_Attributes
|
||||
// *AuthenticateResponse_OidcAuthMethodAuthenticateStartResponse
|
||||
// *AuthenticateResponse_OidcAuthMethodAuthenticateCallbackResponse
|
||||
|
||||
@@ -26,6 +26,7 @@ type Credential struct {
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
// Types that are assignable to Credential:
|
||||
//
|
||||
// *Credential_UsernamePassword
|
||||
// *Credential_SshPrivateKey
|
||||
Credential isCredential_Credential `protobuf_oneof:"credential"`
|
||||
|
||||
@@ -396,6 +396,7 @@ type Job struct {
|
||||
|
||||
Type JOBTYPE `protobuf:"varint,1,opt,name=type,proto3,enum=controller.servers.services.v1.JOBTYPE" json:"type,omitempty"`
|
||||
// Types that are assignable to JobInfo:
|
||||
//
|
||||
// *Job_SessionInfo
|
||||
JobInfo isJob_JobInfo `protobuf_oneof:"job_info"`
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ type Err struct {
|
||||
// wrapped represents an optionally wrapped error
|
||||
//
|
||||
// Types that are assignable to Wrapped:
|
||||
//
|
||||
// *Err_Err
|
||||
// *Err_StdError
|
||||
// *Err_None
|
||||
|
||||
@@ -34,6 +34,7 @@ type TestResource struct {
|
||||
Type string `protobuf:"bytes,2,opt,name=type,proto3" json:"type,omitempty"`
|
||||
OtherId string `protobuf:"bytes,3,opt,name=other_id,json=otherId,proto3" json:"other_id,omitempty"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *TestResource_Attributes
|
||||
// *TestResource_SubResourceAttributes
|
||||
Attrs isTestResource_Attrs `protobuf_oneof:"attrs"`
|
||||
@@ -302,6 +303,7 @@ type TestCustomTransformation struct {
|
||||
SomeRandomId string `protobuf:"bytes,1,opt,name=some_random_id,json=someRandomId,proto3" json:"some_random_id,omitempty"`
|
||||
SecondaryId string `protobuf:"bytes,2,opt,name=secondary_id,json=secondaryId,proto3" json:"secondary_id,omitempty"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *TestCustomTransformation_Attributes
|
||||
// *TestCustomTransformation_SubResourceAttributes
|
||||
Attrs isTestCustomTransformation_Attrs `protobuf_oneof:"attrs"`
|
||||
@@ -968,6 +970,7 @@ type TestNoItemAttributes struct {
|
||||
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *TestNoItemAttributes_Attributes
|
||||
// *TestNoItemAttributes_SubResourceAttributes
|
||||
Attrs isTestNoItemAttributes_Attrs `protobuf_oneof:"attrs"`
|
||||
|
||||
@@ -429,7 +429,8 @@ func (x *HostCatalogSecret) GetKeyId() string {
|
||||
}
|
||||
|
||||
// TODO: Add a field which tracks if the host in cache should be considered
|
||||
// invalid and fall back to the plugin provided data.
|
||||
//
|
||||
// invalid and fall back to the plugin provided data.
|
||||
type Host struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
|
||||
+11
-11
@@ -10,25 +10,25 @@
|
||||
// referenced. A host set can only reference hosts from the host catalog
|
||||
// that owns it. Host addresses must be unique within a host catalog.
|
||||
//
|
||||
// Repository
|
||||
// # Repository
|
||||
//
|
||||
// A repository provides methods for creating, updating, retrieving, and
|
||||
// deleting host catalogs, host sets, and hosts. A new repository should be
|
||||
// created for each transaction. For example:
|
||||
//
|
||||
// var wrapper wrapping.Wrapper
|
||||
// ... init wrapper...
|
||||
// var wrapper wrapping.Wrapper
|
||||
// ... init wrapper...
|
||||
//
|
||||
// // db implements both the reader and writer interfaces.
|
||||
// db, _ := db.Open(db.Postgres, url)
|
||||
// // db implements both the reader and writer interfaces.
|
||||
// db, _ := db.Open(db.Postgres, url)
|
||||
//
|
||||
// var repo *static.Repository
|
||||
// var repo *static.Repository
|
||||
//
|
||||
// repo, _ = static.NewRepository(db, db, wrapper)
|
||||
// catalog, _ := repo.LookupCatalog(ctx, catalogId)
|
||||
// repo, _ = static.NewRepository(db, db, wrapper)
|
||||
// catalog, _ := repo.LookupCatalog(ctx, catalogId)
|
||||
//
|
||||
// catalog.Name = "new name"
|
||||
// catalog.Name = "new name"
|
||||
//
|
||||
// repo, _ = static.NewRepository(db, db, wrapper)
|
||||
// catalog, _ := repo.UpdateCatalog(ctx, catalog, []string{"Name"})
|
||||
// repo, _ = static.NewRepository(db, db, wrapper)
|
||||
// catalog, _ := repo.UpdateCatalog(ctx, catalog, []string{"Name"})
|
||||
package static
|
||||
@@ -139,7 +139,7 @@ func (r *UserRole) SetTableName(n string) {
|
||||
}
|
||||
}
|
||||
|
||||
// GroupRole is a group assigned to a role
|
||||
// GroupRole is a group assigned to a role
|
||||
type GroupRole struct {
|
||||
*store.GroupRole
|
||||
tableName string `gorm:"-"`
|
||||
|
||||
@@ -17,8 +17,9 @@ import (
|
||||
// be nil.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// reader, _ := NewDerivedReader(wrapper, userId, jobId)
|
||||
// key := ed25519.GenerateKey(reader)
|
||||
// key := ed25519.GenerateKey(reader)
|
||||
func NewDerivedReader(ctx context.Context, wrapper wrapping.Wrapper, lenLimit int64, salt, info []byte) (*io.LimitedReader, error) {
|
||||
const op = "crypto.NewDerivedReader"
|
||||
if wrapper == nil {
|
||||
|
||||
@@ -15,21 +15,21 @@ import (
|
||||
//
|
||||
// The following rules apply:
|
||||
//
|
||||
// * The source (src) map is merged into the destination map (dst). If the
|
||||
// source map is nil, the destination will be a valid, but empty, map.
|
||||
// - The source (src) map is merged into the destination map (dst). If the
|
||||
// source map is nil, the destination will be a valid, but empty, map.
|
||||
//
|
||||
// * Values are overwritten by the source map if they exist in both.
|
||||
// - Values are overwritten by the source map if they exist in both.
|
||||
//
|
||||
// * Values are deleted from the destination if they are set to null in the
|
||||
// source.
|
||||
// - Values are deleted from the destination if they are set to null in the
|
||||
// source.
|
||||
//
|
||||
// * Maps are recursively applied, meaning that a nested map at key "foo" in
|
||||
// the destination would be patched with a map at key "foo" in the
|
||||
// source.
|
||||
// - Maps are recursively applied, meaning that a nested map at key "foo" in
|
||||
// the destination would be patched with a map at key "foo" in the
|
||||
// source.
|
||||
//
|
||||
// * A map in the destination is overwritten by a non-map in the source,
|
||||
// and a non-map in the destination is overwritten by a map in the
|
||||
// source.
|
||||
// - A map in the destination is overwritten by a non-map in the source,
|
||||
// and a non-map in the destination is overwritten by a map in the
|
||||
// source.
|
||||
//
|
||||
// PatchStruct returns the updated map as a copy, dst and src are not altered.
|
||||
func PatchStruct(dst, src *structpb.Struct) *structpb.Struct {
|
||||
|
||||
@@ -282,12 +282,14 @@ type WithOnConflict struct {
|
||||
// target defines the on conflict target
|
||||
//
|
||||
// Types that are assignable to Target:
|
||||
//
|
||||
// *WithOnConflict_Constraint
|
||||
// *WithOnConflict_Columns
|
||||
Target isWithOnConflict_Target `protobuf_oneof:"target"`
|
||||
// action defines the on conflict action
|
||||
//
|
||||
// Types that are assignable to Action:
|
||||
//
|
||||
// *WithOnConflict_DoNothing
|
||||
// *WithOnConflict_UpdateAll
|
||||
// *WithOnConflict_ColumnValues
|
||||
@@ -478,6 +480,7 @@ type ColumnValue struct {
|
||||
// value of the column
|
||||
//
|
||||
// Types that are assignable to Value:
|
||||
//
|
||||
// *ColumnValue_Raw
|
||||
// *ColumnValue_ExprValue
|
||||
// *ColumnValue_Column
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
|
||||
// Version of oplog entries (among other things, it's used to manage upgrade
|
||||
// compatibility when replicating)
|
||||
//
|
||||
// v1: initial version
|
||||
// v2: adds the new Message.Opts
|
||||
const Version = "v2"
|
||||
@@ -338,7 +339,7 @@ func (e *Entry) WriteEntryWith(ctx context.Context, tx *Writer, ticket *store.Ti
|
||||
}
|
||||
|
||||
// Write the entry as is with whatever it has for e.Data marshaled into a FIFO QueueBuffer
|
||||
// Cipherer != nil then the data is authentication encrypted
|
||||
// If Cipherer != nil then the data is authentication encrypted
|
||||
func (e *Entry) Write(ctx context.Context, tx *Writer, ticket *store.Ticket) error {
|
||||
const op = "oplog.(Entry).Write"
|
||||
if err := e.validate(ctx); err != nil {
|
||||
|
||||
@@ -10,37 +10,37 @@
|
||||
// running state for a specific job. The private_id (primary key) is generated by the
|
||||
// repository during RunJobs.
|
||||
//
|
||||
// Repository
|
||||
// # Repository
|
||||
//
|
||||
// A repository provides methods for creating, updating, retrieving, and
|
||||
// deleting Jobs. It also provides methods to run jobs, update progress of runs
|
||||
// and complete, fail or interrupt runs.
|
||||
// A new repository should be created for each transaction. For example:
|
||||
//
|
||||
// var wrapper wrapping.Wrapper
|
||||
// ... init wrapper ...
|
||||
// var wrapper wrapping.Wrapper
|
||||
// ... init wrapper ...
|
||||
//
|
||||
// // db implements both the reader and writer interfaces.
|
||||
// db, _ := db.Open(db.Postgres, url)
|
||||
// // db implements both the reader and writer interfaces.
|
||||
// db, _ := db.Open(db.Postgres, url)
|
||||
//
|
||||
// var repo *job.Repository
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// var repo *job.Repository
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
//
|
||||
// var j *job.Job
|
||||
// j, _ = repo.UpsertJob(context.Background(), j, "name", "description")
|
||||
// var j *job.Job
|
||||
// j, _ = repo.UpsertJob(context.Background(), j, "name", "description")
|
||||
//
|
||||
// var runs []*Run
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// runs, _ = repo.RunJobs(context.Background(), "serverId")
|
||||
// var runs []*Run
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// runs, _ = repo.RunJobs(context.Background(), "serverId")
|
||||
//
|
||||
// ... run job ...
|
||||
// ... run job ...
|
||||
//
|
||||
// var run *Run
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// run, _ = repo.UpdateProgress(ctx, run, []string{"TotalCount", "CompletedCount"})
|
||||
// var run *Run
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// run, _ = repo.UpdateProgress(ctx, run, []string{"TotalCount", "CompletedCount"})
|
||||
//
|
||||
// nextJobRun = time.Now().Add(time.Hour)
|
||||
// nextJobRun = time.Now().Add(time.Hour)
|
||||
//
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// run, _ = repo.CompleteRun(ctx, run.PrivateId, job.Completed, nextJobRun)
|
||||
// repo, _ = job.NewRepository(db, db, wrapper)
|
||||
// run, _ = repo.CompleteRun(ctx, run.PrivateId, job.Completed, nextJobRun)
|
||||
package job
|
||||
@@ -424,9 +424,10 @@ func (r *Repository) CancelSession(ctx context.Context, sessionId string, sessio
|
||||
}
|
||||
|
||||
// TerminateCompletedSessions will terminate sessions in the repo based on:
|
||||
// * sessions that have exhausted their connection limit and all their connections are closed.
|
||||
// * sessions that are expired and all their connections are closed.
|
||||
// * sessions that are canceling and all their connections are closed
|
||||
// - sessions that have exhausted their connection limit and all their connections are closed.
|
||||
// - sessions that are expired and all their connections are closed.
|
||||
// - sessions that are canceling and all their connections are closed
|
||||
//
|
||||
// This function should called on a periodic basis a Controllers via it's
|
||||
// "ticker" pattern.
|
||||
func (r *Repository) TerminateCompletedSessions(ctx context.Context) (int, error) {
|
||||
@@ -453,9 +454,9 @@ func (r *Repository) TerminateCompletedSessions(ctx context.Context) (int, error
|
||||
|
||||
// terminateSessionIfPossible is called on connection close and will attempt to close the connection's
|
||||
// session if the following conditions are met:
|
||||
// * sessions that have exhausted their connection limit and all their connections are closed.
|
||||
// * sessions that are expired and all their connections are closed.
|
||||
// * sessions that are canceling and all their connections are closed
|
||||
// - sessions that have exhausted their connection limit and all their connections are closed.
|
||||
// - sessions that are expired and all their connections are closed.
|
||||
// - sessions that are canceling and all their connections are closed
|
||||
func (r *Repository) terminateSessionIfPossible(ctx context.Context, sessionId string) (int, error) {
|
||||
const op = "session.(Repository).terminateSessionIfPossible"
|
||||
rowsAffected := 0
|
||||
|
||||
@@ -99,13 +99,13 @@ func convertAttributesToDefault(msg proto.Message, st Subtype) error {
|
||||
// that there is a structpb.Struct field named "attributes" as part of the
|
||||
// oneof. Thus the message must be like:
|
||||
//
|
||||
// message Foo {
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 100;
|
||||
// // other attribute fields
|
||||
// }
|
||||
// }
|
||||
// message Foo {
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 100;
|
||||
// // other attribute fields
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// If the message does not conform to this structure,
|
||||
// the original message is returned.
|
||||
|
||||
@@ -37,60 +37,60 @@ func messageDomain(m proto.Message) string {
|
||||
// The first structure is a message that contains a single "item" that is a
|
||||
// message that has a "type" and an "attrs" oneof for attributes:
|
||||
//
|
||||
// message CreateFooRequest {
|
||||
// item Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// string type = 1;
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
// message CreateFooRequest {
|
||||
// item Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// string type = 1;
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The second structure is similar to the first, but rather then the type field
|
||||
// being provided, an id field is set. Note this is a different id from the
|
||||
// third structure. In this case it is an id for a related resource and the id
|
||||
// is marked with the "subtype_source_id" custom option:
|
||||
//
|
||||
// message CreateFooRequest {
|
||||
// item Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// string bar_id = 1 [(custom_options.v1.subtype_source_id) = true];
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
// message CreateFooRequest {
|
||||
// item Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// string bar_id = 1 [(custom_options.v1.subtype_source_id) = true];
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The third structure is a message that contains an id string and an "item"
|
||||
// that is a message that has an "attrs" oneof for attributes:
|
||||
//
|
||||
// message UpdateFooRequest {
|
||||
// string id = 1;
|
||||
// item Foo = 2;
|
||||
// }
|
||||
// message Foo {
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
// message UpdateFooRequest {
|
||||
// string id = 1;
|
||||
// item Foo = 2;
|
||||
// }
|
||||
// message Foo {
|
||||
// // other fields
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The forth structure is a message that contains an id string and an "attrs" oneof for
|
||||
// attributes:
|
||||
//
|
||||
// message FooActionRequest {
|
||||
// string id = 1;
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
// message FooActionRequest {
|
||||
// string id = 1;
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Also note that for any of the id based lookups to function, the file that contains
|
||||
// the proto.Message definition must set the "domain" custom option.
|
||||
@@ -189,28 +189,28 @@ func transformRequest(msg proto.Message) error {
|
||||
// The first structure is a message that contains a single "item" that is a
|
||||
// message that has an "attrs" oneof for attributes:
|
||||
//
|
||||
// message CreateFooResponse {
|
||||
// item Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
// message CreateFooResponse {
|
||||
// item Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// The second structure is a message that contains a single "items" that is a
|
||||
// slice of item messages that have an "attrs" oneof for attributes:
|
||||
//
|
||||
// message ListFooResponse {
|
||||
// items []Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
// message ListFooResponse {
|
||||
// items []Foo = 1;
|
||||
// }
|
||||
// message Foo {
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(custom_options.v1.subtype) = "default"];
|
||||
// // other subtype attributes types
|
||||
// }
|
||||
// }
|
||||
func transformResponseAttributes(res proto.Message) error {
|
||||
r := res.ProtoReflect()
|
||||
fields := r.Descriptor().Fields()
|
||||
@@ -257,42 +257,43 @@ func transformResponse(msg proto.Message) error {
|
||||
//
|
||||
// For example with a protobuf message definition like:
|
||||
//
|
||||
// message Account {
|
||||
// string id = 1;
|
||||
// string type = 2;
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(controller.custom_options.v1.subtype) = "default"];
|
||||
// PasswordAttributes password_attributes = 20 [(controller.custom_options.v1.subtype) = "password"];
|
||||
// }
|
||||
// }
|
||||
// message Account {
|
||||
// string id = 1;
|
||||
// string type = 2;
|
||||
// oneof attrs {
|
||||
// google.protobuf.Struct attributes = 10 [(controller.custom_options.v1.subtype) = "default"];
|
||||
// PasswordAttributes password_attributes = 20 [(controller.custom_options.v1.subtype) = "password"];
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// message PasswordAttributes {
|
||||
// string login_name = 1;
|
||||
// }
|
||||
// message PasswordAttributes {
|
||||
// string login_name = 1;
|
||||
// }
|
||||
//
|
||||
// message AccountCreateRequest {
|
||||
// Account item = 1;
|
||||
// }
|
||||
// message AccountCreateRequest {
|
||||
// Account item = 1;
|
||||
// }
|
||||
//
|
||||
// message AccountCreateResponse {
|
||||
// Account item = 1;
|
||||
// }
|
||||
// message AccountCreateResponse {
|
||||
// Account item = 1;
|
||||
// }
|
||||
//
|
||||
// And a create request with JSON request body like:
|
||||
// {
|
||||
// "type": "password",
|
||||
// "attributes": {
|
||||
// "login_name": "tim"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// {
|
||||
// "type": "password",
|
||||
// "attributes": {
|
||||
// "login_name": "tim"
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Will result in a proto request like:
|
||||
//
|
||||
// type:"password" attributes:{fields:{key:"login_name" value:{string_value:"tim"}}}
|
||||
// type:"password" attributes:{fields:{key:"login_name" value:{string_value:"tim"}}}
|
||||
//
|
||||
// This request will be transformed into:
|
||||
//
|
||||
// type:"password" password_attributes:{login_name:"tim"}
|
||||
// type:"password" password_attributes:{login_name:"tim"}
|
||||
func AttributeTransformerInterceptor(_ context.Context) grpc.UnaryServerInterceptor {
|
||||
const op = "subtypes.AttributeTransformInterceptor"
|
||||
return func(interceptorCtx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
const contentDir = ".tmp/boundary-ui/ui/admin/dist"
|
||||
|
||||
// content is our static web server content.
|
||||
//
|
||||
//go:embed .tmp/boundary-ui/ui/admin/dist
|
||||
var content embed.FS
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
const contentDir = "assets"
|
||||
|
||||
// content is our static web server content.
|
||||
//
|
||||
//go:embed assets
|
||||
var content embed.FS
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
const contentDir = "assets"
|
||||
|
||||
// content is our static web server content.
|
||||
//
|
||||
//go:embed assets
|
||||
var content embed.FS
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
module github.com/hashicorp/boundary/sdk
|
||||
|
||||
go 1.18
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/hashicorp/eventlogger v0.1.1-0.20211106154408-4ff8da3a890c
|
||||
|
||||
@@ -52,6 +52,7 @@ type Account struct {
|
||||
// The ID of the Auth Method that is associated with this Account.
|
||||
AuthMethodId string `protobuf:"bytes,90,opt,name=auth_method_id,proto3" json:"auth_method_id,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *Account_Attributes
|
||||
// *Account_PasswordAccountAttributes
|
||||
// *Account_OidcAccountAttributes
|
||||
|
||||
@@ -52,6 +52,7 @@ type AuthMethod struct {
|
||||
// The Auth Method type.
|
||||
Type string `protobuf:"bytes,90,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *AuthMethod_Attributes
|
||||
// *AuthMethod_PasswordAuthMethodAttributes
|
||||
// *AuthMethod_OidcAuthMethodsAttributes
|
||||
|
||||
@@ -52,6 +52,7 @@ type CredentialLibrary struct {
|
||||
// The Credential Library type.
|
||||
Type string `protobuf:"bytes,90,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *CredentialLibrary_Attributes
|
||||
// *CredentialLibrary_VaultCredentialLibraryAttributes
|
||||
Attrs isCredentialLibrary_Attrs `protobuf_oneof:"attrs"`
|
||||
|
||||
@@ -52,6 +52,7 @@ type Credential struct {
|
||||
// The Credential type.
|
||||
Type string `protobuf:"bytes,90,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *Credential_Attributes
|
||||
// *Credential_UsernamePasswordAttributes
|
||||
// *Credential_SshPrivateKeyAttributes
|
||||
|
||||
@@ -52,6 +52,7 @@ type CredentialStore struct {
|
||||
// The Credential Store type.
|
||||
Type string `protobuf:"bytes,90,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *CredentialStore_Attributes
|
||||
// *CredentialStore_VaultCredentialStoreAttributes
|
||||
Attrs isCredentialStore_Attrs `protobuf_oneof:"attrs"`
|
||||
|
||||
@@ -56,6 +56,7 @@ type HostCatalog struct {
|
||||
// The type of Host Catalog.
|
||||
Type string `protobuf:"bytes,90,opt,name=type,proto3" json:"type,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *HostCatalog_Attributes
|
||||
Attrs isHostCatalog_Attrs `protobuf_oneof:"attrs"`
|
||||
// Secrets specific to the catalog type. These are never output.
|
||||
|
||||
@@ -57,6 +57,7 @@ type Host struct {
|
||||
// Output only. A list of Host Sets containing this Host.
|
||||
HostSetIds []string `protobuf:"bytes,100,rep,name=host_set_ids,proto3" json:"host_set_ids,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *Host_Attributes
|
||||
// *Host_StaticHostAttributes
|
||||
Attrs isHost_Attrs `protobuf_oneof:"attrs"`
|
||||
|
||||
@@ -70,6 +70,7 @@ type HostSet struct {
|
||||
// be valid for all plugin types.
|
||||
SyncIntervalSeconds *wrapperspb.Int32Value `protobuf:"bytes,102,opt,name=sync_interval_seconds,proto3" json:"sync_interval_seconds,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *HostSet_Attributes
|
||||
Attrs isHostSet_Attrs `protobuf_oneof:"attrs"`
|
||||
// Output only. The available actions on this resource for this user.
|
||||
|
||||
@@ -52,6 +52,7 @@ type ManagedGroup struct {
|
||||
// The ID of the Auth Method that is associated with this ManagedGroup.
|
||||
AuthMethodId string `protobuf:"bytes,90,opt,name=auth_method_id,proto3" json:"auth_method_id,omitempty" class:"public"` // @gotags: `class:"public"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *ManagedGroup_Attributes
|
||||
// *ManagedGroup_OidcManagedGroupAttributes
|
||||
Attrs isManagedGroup_Attrs `protobuf_oneof:"attrs"`
|
||||
|
||||
@@ -418,6 +418,7 @@ type Target struct {
|
||||
// Output only. The injected application credential sources associated with this Target.
|
||||
InjectedApplicationCredentialSources []*CredentialSource `protobuf:"bytes,530,rep,name=injected_application_credential_sources,proto3" json:"injected_application_credential_sources,omitempty"`
|
||||
// Types that are assignable to Attrs:
|
||||
//
|
||||
// *Target_Attributes
|
||||
// *Target_TcpTargetAttributes
|
||||
// *Target_SshTargetAttributes
|
||||
|
||||
@@ -6,20 +6,20 @@
|
||||
// To use this package in a test add something like the following in the
|
||||
// beginning of the test:
|
||||
//
|
||||
// c, u, _, err := dbtest.StartUsingTemplate(dbtest.Postgres)
|
||||
// require.NoError(t, err)
|
||||
// t.Cleanup(func() {
|
||||
// require.NoError(t, c())
|
||||
// })
|
||||
// // use u to get a connection to the new database
|
||||
// dBase, err := common.SqlOpen("postgres", u)
|
||||
// c, u, _, err := dbtest.StartUsingTemplate(dbtest.Postgres)
|
||||
// require.NoError(t, err)
|
||||
// t.Cleanup(func() {
|
||||
// require.NoError(t, c())
|
||||
// })
|
||||
// // use u to get a connection to the new database
|
||||
// dBase, err := common.SqlOpen("postgres", u)
|
||||
//
|
||||
// By default this uses a template that already has all of the boundary
|
||||
// migrations run. If a test needs a database without any migrations, like in
|
||||
// the case where the migration code needs to be tested, a different template
|
||||
// can be specified. This should generally be template1:
|
||||
//
|
||||
// c, u, _, err := dbtest.StartUsingTemplate(dbtest.Postgres, dbtest.WithTemplate(dbtest.Template1))
|
||||
// c, u, _, err := dbtest.StartUsingTemplate(dbtest.Postgres, dbtest.WithTemplate(dbtest.Template1))
|
||||
//
|
||||
// See https://www.postgresql.org/docs/13/manage-ag-templatedbs.html
|
||||
package dbtest
|
||||
@@ -33,9 +33,10 @@ import (
|
||||
// to predictable files for use in benchmarking.
|
||||
//
|
||||
// Each database dump contains:
|
||||
// * N number of sessions, with each session having M connections.
|
||||
// * P users, each owning an even amount of the sessions. All users
|
||||
// use the password "testpassword" to login.
|
||||
// - N number of sessions, with each session having M connections.
|
||||
// - P users, each owning an even amount of the sessions. All users
|
||||
// use the password "testpassword" to login.
|
||||
//
|
||||
// It is safe for users of these dumps to assume all of this, for the variables
|
||||
// N, M and P defined in the "scenarios" struct below.
|
||||
func TestGenerateSessionBenchmarkTemplateDumps(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user