Skip to content

Commit

Permalink
update config name
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidorin-oprea committed Oct 21, 2024
1 parent 203f99f commit bd3b518
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion exporter/azuredataexplorerexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ One authentication method is required:
- Managed identity:
- `managed_identity_id` (no default): The managed identity id to authenticate with. Set to "system" for system-assigned managed identity. Set the MI client Id (GUID) for user-assigned managed identity.
- Default authentication:
- `use_default_auth` (no default): Set to true to use the Azure [default authentication](https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication?tabs=bash#2-authenticate-with-azure). This is an optional setting and is set to false by default.
- `use_azure_auth` (default: false): Set to true to use the Azure [default authentication](https://learn.microsoft.com/en-us/azure/developer/go/azure-sdk-authentication?tabs=bash#2-authenticate-with-azure).

The following settings can be optionally configured and have default values:
> Note that the database tables are expected to be created upfront before the exporter is in operation , the definition of these are in the section [Database and Table definition scripts](#database-and-table-definition-scripts)
Expand Down
2 changes: 1 addition & 1 deletion exporter/azuredataexplorerexporter/adx_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func createKcsb(config *Config, version string) *kusto.ConnectionStringBuilder {
isSystemManagedIdentity := strings.EqualFold(strings.TrimSpace(config.ManagedIdentityID), "SYSTEM")
// If the user has managed identity done, use it. For System managed identity use the MI as system
switch {
case config.UseDefaultAuth:
case config.UseAzureAuth:
kcsb = kusto.NewConnectionStringBuilder(config.ClusterURI).WithDefaultAzureCredential()
case !isManagedIdentity:
kcsb = kusto.NewConnectionStringBuilder(config.ClusterURI).WithAadAppKey(config.ApplicationID, string(config.ApplicationKey), config.TenantID)
Expand Down
16 changes: 8 additions & 8 deletions exporter/azuredataexplorerexporter/adx_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func TestCreateKcsb(t *testing.T) {
name string // name of the test
config Config // config for the test
isMsi bool // is MSI enabled
isDefaultAuth bool // is default authentication enabled
isAzureAuth bool // is azure authentication enabled
applicationID string // application id
managedIdentityID string // managed identity id
}{
Expand Down Expand Up @@ -218,13 +218,13 @@ func TestCreateKcsb(t *testing.T) {
applicationID: "",
},
{
name: "workload identity",
name: "azure auth",
config: Config{
ClusterURI: "https://CLUSTER.kusto.windows.net",
Database: "tests",
UseDefaultAuth: true,
ClusterURI: "https://CLUSTER.kusto.windows.net",
Database: "tests",
UseAzureAuth: true,
},
isDefaultAuth: true,
isAzureAuth: true,
},
}
for i := range tests {
Expand All @@ -239,8 +239,8 @@ func TestCreateKcsb(t *testing.T) {
wantManagedID := tt.managedIdentityID
assert.Equal(t, wantManagedID, gotKcsb.ManagedServiceIdentity)
assert.Equal(t, "https://CLUSTER.kusto.windows.net", gotKcsb.DataSource)
wantIsDefault := tt.isDefaultAuth
assert.Equal(t, wantIsDefault, gotKcsb.DefaultAuth)
wantIsAzure := tt.isAzureAuth
assert.Equal(t, wantIsAzure, gotKcsb.DefaultAuth)
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions exporter/azuredataexplorerexporter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type Config struct {
ApplicationKey configopaque.String `mapstructure:"application_key"`
TenantID string `mapstructure:"tenant_id"`
ManagedIdentityID string `mapstructure:"managed_identity_id"`
UseDefaultAuth bool `mapstructure:"use_default_auth"`
UseAzureAuth bool `mapstructure:"use_azure_auth"`
Database string `mapstructure:"db_name"`
MetricTable string `mapstructure:"metrics_table_name"`
LogTable string `mapstructure:"logs_table_name"`
Expand Down Expand Up @@ -58,12 +58,12 @@ func (adxCfg *Config) Validate() error {
authMethods++
}

if adxCfg.UseDefaultAuth {
if adxCfg.UseAzureAuth {
authMethods++
}

if authMethods != 1 {
return errors.New(`either ["application_id" , "application_key" , "tenant_id"] or ["managed_identity_id"] or ["use_default_auth"] must be provided for auth`)
return errors.New(`either ["application_id" , "application_key" , "tenant_id"] or ["managed_identity_id"] or ["use_azure_auth"] must be provided for auth`)
}

if !(adxCfg.IngestionType == managedIngestType || adxCfg.IngestionType == queuedIngestTest || isEmpty(adxCfg.IngestionType)) {
Expand Down
16 changes: 8 additions & 8 deletions exporter/azuredataexplorerexporter/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestLoadConfig(t *testing.T) {
},
{
id: component.NewIDWithName(metadata.Type, "2"),
errorMessage: `either ["application_id" , "application_key" , "tenant_id"] or ["managed_identity_id"] or ["use_default_auth"] must be provided for auth`,
errorMessage: `either ["application_id" , "application_key" , "tenant_id"] or ["managed_identity_id"] or ["use_azure_auth"] must be provided for auth`,
},
{
id: component.NewIDWithName(metadata.Type, "3"),
Expand Down Expand Up @@ -114,13 +114,13 @@ func TestLoadConfig(t *testing.T) {
{
id: component.NewIDWithName(metadata.Type, "9"),
expected: &Config{
ClusterURI: "https://CLUSTER.kusto.windows.net",
Database: "oteldb",
MetricTable: "OTELMetrics",
LogTable: "OTELLogs",
TraceTable: "OTELTraces",
UseDefaultAuth: true,
IngestionType: queuedIngestTest,
ClusterURI: "https://CLUSTER.kusto.windows.net",
Database: "oteldb",
MetricTable: "OTELMetrics",
LogTable: "OTELLogs",
TraceTable: "OTELTraces",
UseAzureAuth: true,
IngestionType: queuedIngestTest,
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion exporter/azuredataexplorerexporter/testdata/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,4 @@ azuredataexplorer/9:
# Kusto cluster uri
cluster_uri: "https://CLUSTER.kusto.windows.net"
# weather to use the default azure auth
use_default_auth: true
use_azure_auth: true

0 comments on commit bd3b518

Please sign in to comment.