Skip to content

Commit

Permalink
fix: rename internal networking flag
Browse files Browse the repository at this point in the history
  • Loading branch information
amlmtl committed Apr 19, 2024
1 parent ecf39ef commit 42bc59d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
20 changes: 10 additions & 10 deletions pkg/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ type SampleDatasource struct {
}

type datasourceJsonData struct {
UseInternalNetworking bool `json:"useInternalNetworking"`
UseExternalEspUrl bool `json:"useExternalEspUrl"`
OauthPassThru bool `json:"oauthPassThru"`
TlsSkipVerify bool `json:"tlsSkipVerify"`
}
Expand All @@ -112,13 +112,13 @@ func (d *SampleDatasource) Dispose() {
func (d *SampleDatasource) QueryData(ctx context.Context, req *backend.QueryDataRequest) (*backend.QueryDataResponse, error) {
response := backend.NewQueryDataResponse()

datasourceJsonData := datasourceJsonData{UseInternalNetworking: true}
err := json.Unmarshal(req.PluginContext.DataSourceInstanceSettings.JSONData, &datasourceJsonData)
var dJsonData datasourceJsonData
err := json.Unmarshal(req.PluginContext.DataSourceInstanceSettings.JSONData, &dJsonData)
if err != nil {
return nil, err
}
var authorizationHeaderPtr *string = nil
if datasourceJsonData.OauthPassThru {
if dJsonData.OauthPassThru {
authorizationHeader := req.GetHTTPHeader(backend.OAuthIdentityTokenHeaderName)
authorizationHeaderPtr = &authorizationHeader
}
Expand All @@ -132,10 +132,10 @@ func (d *SampleDatasource) QueryData(ctx context.Context, req *backend.QueryData
}

var serverUrl string
if d.jsonData.UseInternalNetworking {
serverUrl = qdto.InternalServerUrl
} else {
if d.jsonData.UseExternalEspUrl {
serverUrl = qdto.ExternalServerUrl
} else {
serverUrl = qdto.InternalServerUrl
}

var authHeaderToBePassed *string = nil
Expand All @@ -151,11 +151,11 @@ func (d *SampleDatasource) QueryData(ctx context.Context, req *backend.QueryData

func (d *SampleDatasource) query(_ context.Context, datasourceUid string, qdto querydto.QueryDTO, authorizationHeader *string) backend.DataResponse {
var qServerUrl string
if d.jsonData.UseInternalNetworking {
if d.jsonData.UseExternalEspUrl {
qServerUrl = qdto.ExternalServerUrl
} else {
qServerUrl = qdto.InternalServerUrl
log.DefaultLogger.Debug("Using internal ESP server URL from query", "query", qdto)
} else {
qServerUrl = qdto.ExternalServerUrl
}

s, err := server.FromUrlString(qServerUrl)
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,5 @@ export function isField(espObject: EspObject | undefined): espObject is Field {
export interface EspDataSourceOptions extends DataSourceJsonData {
oauthPassThru: boolean;
tlsSkipVerify: boolean;
useInternalNetworking: boolean;
useExternalEspUrl: boolean;
}

0 comments on commit 42bc59d

Please sign in to comment.