Updated protos to support bitbucket Api token authentication (#5171)
This commit is contained in:
@@ -899,6 +899,69 @@ func (x *GoogleDriveDWD) GetExcludeUsers() []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
type BitbucketApiToken struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Email string `protobuf:"bytes,1,opt,name=email,proto3" json:"email,omitempty"`
|
||||
Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"`
|
||||
Username string `protobuf:"bytes,3,opt,name=username,proto3" json:"username,omitempty"` // optional; falls back to Bitbucket's documented alias for git ops when omitted
|
||||
}
|
||||
|
||||
func (x *BitbucketApiToken) Reset() {
|
||||
*x = BitbucketApiToken{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_credentials_proto_msgTypes[15]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *BitbucketApiToken) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*BitbucketApiToken) ProtoMessage() {}
|
||||
|
||||
func (x *BitbucketApiToken) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_credentials_proto_msgTypes[15]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use BitbucketApiToken.ProtoReflect.Descriptor instead.
|
||||
func (*BitbucketApiToken) Descriptor() ([]byte, []int) {
|
||||
return file_credentials_proto_rawDescGZIP(), []int{15}
|
||||
}
|
||||
|
||||
func (x *BitbucketApiToken) GetEmail() string {
|
||||
if x != nil {
|
||||
return x.Email
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BitbucketApiToken) GetToken() string {
|
||||
if x != nil {
|
||||
return x.Token
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *BitbucketApiToken) GetUsername() string {
|
||||
if x != nil {
|
||||
return x.Username
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
var File_credentials_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_credentials_proto_rawDesc = []byte{
|
||||
@@ -994,11 +1057,17 @@ var file_credentials_proto_rawDesc = []byte{
|
||||
0x52, 0x0c, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x55, 0x73, 0x65, 0x72, 0x73, 0x12, 0x23,
|
||||
0x0a, 0x0d, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x75, 0x73, 0x65, 0x72, 0x73, 0x18,
|
||||
0x04, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0c, 0x65, 0x78, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x55, 0x73,
|
||||
0x65, 0x72, 0x73, 0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
|
||||
0x6d, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74,
|
||||
0x79, 0x2f, 0x74, 0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f,
|
||||
0x70, 0x6b, 0x67, 0x2f, 0x70, 0x62, 0x2f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61,
|
||||
0x6c, 0x73, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x65, 0x72, 0x73, 0x22, 0x5b, 0x0a, 0x11, 0x42, 0x69, 0x74, 0x62, 0x75, 0x63, 0x6b, 0x65, 0x74,
|
||||
0x41, 0x70, 0x69, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x6d, 0x61, 0x69,
|
||||
0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x14,
|
||||
0x0a, 0x05, 0x74, 0x6f, 0x6b, 0x65, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74,
|
||||
0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x1a, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x75, 0x73, 0x65, 0x72, 0x6e, 0x61, 0x6d, 0x65,
|
||||
0x42, 0x3f, 0x5a, 0x3d, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74,
|
||||
0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x73, 0x65, 0x63, 0x75, 0x72, 0x69, 0x74, 0x79, 0x2f, 0x74,
|
||||
0x72, 0x75, 0x66, 0x66, 0x6c, 0x65, 0x68, 0x6f, 0x67, 0x2f, 0x76, 0x33, 0x2f, 0x70, 0x6b, 0x67,
|
||||
0x2f, 0x70, 0x62, 0x2f, 0x63, 0x72, 0x65, 0x64, 0x65, 0x6e, 0x74, 0x69, 0x61, 0x6c, 0x73, 0x70,
|
||||
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -1013,7 +1082,7 @@ func file_credentials_proto_rawDescGZIP() []byte {
|
||||
return file_credentials_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_credentials_proto_msgTypes = make([]protoimpl.MessageInfo, 15)
|
||||
var file_credentials_proto_msgTypes = make([]protoimpl.MessageInfo, 16)
|
||||
var file_credentials_proto_goTypes = []interface{}{
|
||||
(*Unauthenticated)(nil), // 0: credentials.Unauthenticated
|
||||
(*SSHAuth)(nil), // 1: credentials.SSHAuth
|
||||
@@ -1030,6 +1099,7 @@ var file_credentials_proto_goTypes = []interface{}{
|
||||
(*GitHubApp)(nil), // 12: credentials.GitHubApp
|
||||
(*SlackTokens)(nil), // 13: credentials.SlackTokens
|
||||
(*GoogleDriveDWD)(nil), // 14: credentials.GoogleDriveDWD
|
||||
(*BitbucketApiToken)(nil), // 15: credentials.BitbucketApiToken
|
||||
}
|
||||
var file_credentials_proto_depIdxs = []int32{
|
||||
10, // 0: credentials.SES.creds:type_name -> credentials.AWS
|
||||
@@ -1226,6 +1296,18 @@ func file_credentials_proto_init() {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_credentials_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*BitbucketApiToken); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@@ -1233,7 +1315,7 @@ func file_credentials_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_credentials_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 15,
|
||||
NumMessages: 16,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
@@ -1666,3 +1666,111 @@ var _ interface {
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = GoogleDriveDWDValidationError{}
|
||||
|
||||
// Validate checks the field values on BitbucketApiToken with the rules defined
|
||||
// in the proto definition for this message. If any rules are violated, the
|
||||
// first error encountered is returned, or nil if there are no violations.
|
||||
func (m *BitbucketApiToken) Validate() error {
|
||||
return m.validate(false)
|
||||
}
|
||||
|
||||
// ValidateAll checks the field values on BitbucketApiToken with the rules
|
||||
// defined in the proto definition for this message. If any rules are
|
||||
// violated, the result is a list of violation errors wrapped in
|
||||
// BitbucketApiTokenMultiError, or nil if none found.
|
||||
func (m *BitbucketApiToken) ValidateAll() error {
|
||||
return m.validate(true)
|
||||
}
|
||||
|
||||
func (m *BitbucketApiToken) validate(all bool) error {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
var errors []error
|
||||
|
||||
// no validation rules for Email
|
||||
|
||||
// no validation rules for Token
|
||||
|
||||
// no validation rules for Username
|
||||
|
||||
if len(errors) > 0 {
|
||||
return BitbucketApiTokenMultiError(errors)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// BitbucketApiTokenMultiError is an error wrapping multiple validation errors
|
||||
// returned by BitbucketApiToken.ValidateAll() if the designated constraints
|
||||
// aren't met.
|
||||
type BitbucketApiTokenMultiError []error
|
||||
|
||||
// Error returns a concatenation of all the error messages it wraps.
|
||||
func (m BitbucketApiTokenMultiError) Error() string {
|
||||
var msgs []string
|
||||
for _, err := range m {
|
||||
msgs = append(msgs, err.Error())
|
||||
}
|
||||
return strings.Join(msgs, "; ")
|
||||
}
|
||||
|
||||
// AllErrors returns a list of validation violation errors.
|
||||
func (m BitbucketApiTokenMultiError) AllErrors() []error { return m }
|
||||
|
||||
// BitbucketApiTokenValidationError is the validation error returned by
|
||||
// BitbucketApiToken.Validate if the designated constraints aren't met.
|
||||
type BitbucketApiTokenValidationError struct {
|
||||
field string
|
||||
reason string
|
||||
cause error
|
||||
key bool
|
||||
}
|
||||
|
||||
// Field function returns field value.
|
||||
func (e BitbucketApiTokenValidationError) Field() string { return e.field }
|
||||
|
||||
// Reason function returns reason value.
|
||||
func (e BitbucketApiTokenValidationError) Reason() string { return e.reason }
|
||||
|
||||
// Cause function returns cause value.
|
||||
func (e BitbucketApiTokenValidationError) Cause() error { return e.cause }
|
||||
|
||||
// Key function returns key value.
|
||||
func (e BitbucketApiTokenValidationError) Key() bool { return e.key }
|
||||
|
||||
// ErrorName returns error name.
|
||||
func (e BitbucketApiTokenValidationError) ErrorName() string {
|
||||
return "BitbucketApiTokenValidationError"
|
||||
}
|
||||
|
||||
// Error satisfies the builtin error interface
|
||||
func (e BitbucketApiTokenValidationError) Error() string {
|
||||
cause := ""
|
||||
if e.cause != nil {
|
||||
cause = fmt.Sprintf(" | caused by: %v", e.cause)
|
||||
}
|
||||
|
||||
key := ""
|
||||
if e.key {
|
||||
key = "key for "
|
||||
}
|
||||
|
||||
return fmt.Sprintf(
|
||||
"invalid %sBitbucketApiToken.%s: %s%s",
|
||||
key,
|
||||
e.field,
|
||||
e.reason,
|
||||
cause)
|
||||
}
|
||||
|
||||
var _ error = BitbucketApiTokenValidationError{}
|
||||
|
||||
var _ interface {
|
||||
Field() string
|
||||
Reason() string
|
||||
Key() bool
|
||||
Cause() error
|
||||
ErrorName() string
|
||||
} = BitbucketApiTokenValidationError{}
|
||||
|
||||
+888
-867
File diff suppressed because it is too large
Load Diff
@@ -761,6 +761,47 @@ func (m *Bitbucket) validate(all bool) error {
|
||||
}
|
||||
}
|
||||
|
||||
case *Bitbucket_ApiToken:
|
||||
if v == nil {
|
||||
err := BitbucketValidationError{
|
||||
field: "Credential",
|
||||
reason: "oneof value cannot be a typed-nil",
|
||||
}
|
||||
if !all {
|
||||
return err
|
||||
}
|
||||
errors = append(errors, err)
|
||||
}
|
||||
|
||||
if all {
|
||||
switch v := interface{}(m.GetApiToken()).(type) {
|
||||
case interface{ ValidateAll() error }:
|
||||
if err := v.ValidateAll(); err != nil {
|
||||
errors = append(errors, BitbucketValidationError{
|
||||
field: "ApiToken",
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
})
|
||||
}
|
||||
case interface{ Validate() error }:
|
||||
if err := v.Validate(); err != nil {
|
||||
errors = append(errors, BitbucketValidationError{
|
||||
field: "ApiToken",
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if v, ok := interface{}(m.GetApiToken()).(interface{ Validate() error }); ok {
|
||||
if err := v.Validate(); err != nil {
|
||||
return BitbucketValidationError{
|
||||
field: "ApiToken",
|
||||
reason: "embedded message failed validation",
|
||||
cause: err,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
_ = v // ensures v is used
|
||||
}
|
||||
|
||||
@@ -84,3 +84,9 @@ message GoogleDriveDWD {
|
||||
repeated string include_users = 3;
|
||||
repeated string exclude_users = 4;
|
||||
}
|
||||
|
||||
message BitbucketApiToken {
|
||||
string email = 1;
|
||||
string token = 2;
|
||||
string username = 3; // optional; falls back to Bitbucket's documented alias for git ops when omitted
|
||||
}
|
||||
+1
-1
@@ -107,7 +107,7 @@ message Bitbucket {
|
||||
string token = 2;
|
||||
credentials.Oauth2 oauth = 3;
|
||||
credentials.BasicAuth basic_auth = 4;
|
||||
|
||||
credentials.BitbucketApiToken api_token = 14;
|
||||
}
|
||||
repeated string repositories = 5;
|
||||
repeated string ignore_repos = 6;
|
||||
|
||||
Reference in New Issue
Block a user