Skip to content

Commit

Permalink
[feat]: [DBOPS-845]: Support for ServiceAccountToken JDBC connector (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek-CDC authored Jan 24, 2025
1 parent 432f8fd commit d3172de
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 7 deletions.
9 changes: 9 additions & 0 deletions harness/nextgen/docs/JdbcServiceAccountDto.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# JdbcServiceAccountDto

## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**ServiceAccountTokenRef** | **string** | | [default to null]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

2 changes: 2 additions & 0 deletions harness/nextgen/enum_jdbc_auth_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ type JDBCAuthType string

var JDBCAuthTypes = struct {
UsernamePassword JDBCAuthType
ServiceAccount JDBCAuthType
}{
UsernamePassword: "UsernamePassword",
ServiceAccount: "ServiceAccount",
}

func (e JDBCAuthType) String() string {
Expand Down
1 change: 1 addition & 0 deletions harness/nextgen/model_jdbc_authentication_dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ import "encoding/json"
type JdbcAuthenticationDto struct {
Type_ JDBCAuthType `json:"type"`
UsernamePassword *JdbcUserNamePasswordDto `json:"-"`
ServiceAccount *JdbcServiceAccountDto `json:"-"`
Spec json.RawMessage `json:"spec,omitempty"`
}
19 changes: 17 additions & 2 deletions harness/nextgen/model_jdbc_authentication_serializer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nextgen

import (
"encoding/json"
"fmt"
)

func (a *JdbcAuthenticationDto) UnmarshalJSON(data []byte) error {
Expand All @@ -19,7 +20,14 @@ func (a *JdbcAuthenticationDto) UnmarshalJSON(data []byte) error {
return err
}

err = json.Unmarshal(aux.Spec, &a.UsernamePassword)
switch a.Type_ {
case JDBCAuthTypes.UsernamePassword:
err = json.Unmarshal(aux.Spec, &a.UsernamePassword)
case JDBCAuthTypes.ServiceAccount:
err = json.Unmarshal(aux.Spec, &a.ServiceAccount)
default:
panic(fmt.Sprintf("unknown jdbc auth method type %s", a.Type_))
}

return err
}
Expand All @@ -30,7 +38,14 @@ func (a *JdbcAuthenticationDto) MarshalJSON() ([]byte, error) {
var spec []byte
var err error

spec, err = json.Marshal(a.UsernamePassword)
switch a.Type_ {
case JDBCAuthTypes.UsernamePassword:
spec, err = json.Marshal(a.UsernamePassword)
case JDBCAuthTypes.ServiceAccount:
spec, err = json.Marshal(a.ServiceAccount)
default:
panic(fmt.Sprintf("unknown jdbc auth method type %s", a.Type_))
}

if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions harness/nextgen/model_jdbc_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ package nextgen

// This contains details of the JDBC connector
type JdbcConnector struct {
Url string `json:"url"`
Auth *JdbcAuthenticationDto `json:"auth,omitempty"`
DelegateSelectors []string `json:"delegateSelectors,omitempty"`
ConnectorType string `json:"connectorType"`
ExecuteOnDelegate bool `json:"executeOnDelegate"`
Url string `json:"url"`
Auth *JdbcAuthenticationDto `json:"auth,omitempty"`
DelegateSelectors []string `json:"delegateSelectors,omitempty"`
ExecuteOnDelegate bool `json:"executeOnDelegate"`
IgnoreTestConnection bool `json:"ignoreTestConnection,omitempty"`
}
14 changes: 14 additions & 0 deletions harness/nextgen/model_jdbc_service_account_dto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Harness NextGen Software Delivery Platform API Reference
*
* This is the Open Api Spec 3 for the NextGen Manager. This is under active development. Beware of the breaking change with respect to the generated code stub
*
* API version: 3.0
* Contact: contact@harness.io
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package nextgen

type JdbcServiceAccountDto struct {
ServiceAccountTokenRef string `json:"serviceAccountTokenRef"`
}

0 comments on commit d3172de

Please sign in to comment.