Skip to content

Commit

Permalink
Secretless backport (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
AsafMah authored Apr 9, 2024
1 parent 87083c8 commit 69fbfdb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ jobs:
build:
name: Build
runs-on: ubuntu-latest
environment: build
permissions:
checks: write
pull-requests: write
id-token: write
contents: read
steps:

- name: Azure login
uses: azure/login@v2
with:
client-id: ${{ secrets.APP_ID }}
tenant-id: ${{ secrets.AUTH_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- name: Check out code into the Go module directory
uses: actions/checkout@v2

Expand Down Expand Up @@ -48,9 +56,6 @@ jobs:
go test -p 100 -race -coverprofile=coverage.out -json -v ./... 2>&1 > /tmp/gotest.log
env:
ENGINE_CONNECTION_STRING: ${{ secrets.ENGINE_CONNECTION_STRING }}
AZURE_CLIENT_ID: ${{ secrets.APP_ID }}
AZURE_CLIENT_SECRET: ${{ secrets.APP_KEY }}
AZURE_TENANT_ID: ${{ secrets.AUTH_ID }}
TEST_DATABASE: ${{ secrets.TEST_DATABASE }}
SECONDARY_ENGINE_CONNECTION_STRING: ${{ secrets.SECONDARY_ENGINE_CONNECTION_STRING }}
SECONDARY_DATABASE: ${{ secrets.SECONDARY_DATABASE }}
Expand Down Expand Up @@ -83,7 +88,7 @@ jobs:
permissions:
checks: write
pull-requests: write

steps:
- name: Download Artifacts
uses: actions/download-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion kusto/test/etoe/etoe_env.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func init() {
return
}

if testConfig.ClientID == "" {
if testConfig.ClientID == "" || testConfig.ClientSecret == "" || testConfig.TenantID == "" {
testConfig.kcsb = kusto.NewConnectionStringBuilder(testConfig.Endpoint).WithAzCli()
} else {
testConfig.kcsb = kusto.NewConnectionStringBuilder(testConfig.Endpoint).WithAadAppKey(testConfig.ClientID, testConfig.ClientSecret, testConfig.TenantID)
Expand Down
25 changes: 19 additions & 6 deletions kusto/test/etoe/etoe_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,19 @@ func TestAuth(t *testing.T) {
},
},
}
defaultCred, err := azidentity.NewDefaultAzureCredential(&azidentity.DefaultAzureCredentialOptions{
ClientOptions: azcore.ClientOptions{
Transport: &transporter,
},
})
var defaultCred azcore.TokenCredential
var err error

if testConfig.ClientSecret != "" {
defaultCred, err = azidentity.NewDefaultAzureCredential(&azidentity.DefaultAzureCredentialOptions{
ClientOptions: azcore.ClientOptions{
Transport: &transporter,
},
})
} else {
defaultCred, err = azidentity.NewAzureCLICredential(&azidentity.AzureCLICredentialOptions{})
}

require.NoError(t, err)
credential, err := azidentity.NewChainedTokenCredential([]azcore.TokenCredential{
defaultCred,
Expand Down Expand Up @@ -1664,8 +1672,13 @@ func TestMultipleClusters(t *testing.T) { //ok
t.Log("Closed client")
})

skcsb := kusto.NewConnectionStringBuilder(testConfig.SecondaryEndpoint).WithAadAppKey(testConfig.ClientID, testConfig.ClientSecret, testConfig.TenantID)
var skcsb *kusto.ConnectionStringBuilder

if testConfig.ClientID == "" || testConfig.ClientSecret == "" || testConfig.TenantID == "" {
skcsb = kusto.NewConnectionStringBuilder(testConfig.SecondaryEndpoint).WithAzCli()
} else {
skcsb = kusto.NewConnectionStringBuilder(testConfig.SecondaryEndpoint).WithAadAppKey(testConfig.ClientID, testConfig.ClientSecret, testConfig.TenantID)
}
secondaryClient, err := kusto.New(skcsb)
if err != nil {
panic(err)
Expand Down

0 comments on commit 69fbfdb

Please sign in to comment.