Skip to content

Commit 16ec957

Browse files
committed
feat: fix lint
1 parent 8ed839f commit 16ec957

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

aitelemetry/connection_string_parser.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import (
88

99
type connectionVars struct {
1010
instrumentationKey string
11-
ingestionUrl string
11+
ingestionURL string
1212
}
1313

1414
func (c *connectionVars) String() string {
15-
return "InstrumentationKey=" + c.instrumentationKey + ";IngestionEndpoint=" + c.ingestionUrl
15+
return "InstrumentationKey=" + c.instrumentationKey + ";IngestionEndpoint=" + c.ingestionURL
1616
}
1717

1818
func parseConnectionString(connectionString string) (*connectionVars, error) {
@@ -39,12 +39,12 @@ func parseConnectionString(connectionString string) (*connectionVars, error) {
3939
connectionVars.instrumentationKey = value
4040
case "ingestionendpoint":
4141
if value != "" {
42-
connectionVars.ingestionUrl = value + "v2.1/track"
42+
connectionVars.ingestionURL = value + "v2.1/track"
4343
}
4444
}
4545
}
4646

47-
if connectionVars.instrumentationKey == "" || connectionVars.ingestionUrl == "" {
47+
if connectionVars.instrumentationKey == "" || connectionVars.ingestionURL == "" {
4848
return nil, errors.Errorf("missing required fields in connection string: %s", connectionVars)
4949
}
5050

aitelemetry/connection_string_parser_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/stretchr/testify/require"
77
)
88

9-
const connectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://ingestion.endpoint.com/;LiveEndpoint=https://live.endpoint.com/;ApplicationId=11111111-1111-1111-1111-111111111111"
9+
const connectionString = "InstrumentationKey=0000-0000-0000-0000-0000;IngestionEndpoint=https://ingestion.endpoint.com/;LiveEndpoint=https://live.endpoint.com/;ApplicationId=1111-1111-1111-1111-1111"
1010

1111
func TestParseConnectionString(t *testing.T) {
1212
tests := []struct {
@@ -19,8 +19,8 @@ func TestParseConnectionString(t *testing.T) {
1919
name: "Valid connection string and instrumentation key",
2020
connectionString: connectionString,
2121
want: &connectionVars{
22-
instrumentationKey: "00000000-0000-0000-0000-000000000000",
23-
ingestionUrl: "https://ingestion.endpoint.com/v2.1/track",
22+
instrumentationKey: "0000-0000-0000-0000-0000",
23+
ingestionURL: "https://ingestion.endpoint.com/v2.1/track",
2424
},
2525
wantErr: false,
2626
},
@@ -32,7 +32,7 @@ func TestParseConnectionString(t *testing.T) {
3232
},
3333
{
3434
name: "Valid instrumentation key with missing ingestion endpoint",
35-
connectionString: "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=",
35+
connectionString: "InstrumentationKey=0000-0000-0000-0000-0000;IngestionEndpoint=",
3636
want: nil,
3737
wantErr: true,
3838
},
@@ -59,7 +59,7 @@ func TestParseConnectionString(t *testing.T) {
5959
require.NoError(t, err, "Expected no error but got one")
6060
require.NotNil(t, got, "Expected a non-nil result")
6161
require.Equal(t, tt.want.instrumentationKey, got.instrumentationKey, "Instrumentation Key does not match")
62-
require.Equal(t, tt.want.ingestionUrl, got.ingestionUrl, "Ingestion URL does not match")
62+
require.Equal(t, tt.want.ingestionURL, got.ingestionURL, "Ingestion URL does not match")
6363
}
6464
})
6565
}

aitelemetry/telemetrywrapper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ func isPublicEnvironment(url string, retryCount, waitTimeInSecs int) (bool, erro
162162
return true, nil
163163
} else if err == nil {
164164
debugLog("[AppInsights] This is not azure public cloud:%s", cloudName)
165-
return false, fmt.Errorf("not an azure public cloud: %s", cloudName)
165+
return false, errors.Errorf("not an azure public cloud: %s", cloudName)
166166
}
167167

168168
debugLog("GetAzureCloud returned err :%v", err)
@@ -233,7 +233,7 @@ func NewWithConnectionString(connectionString string, aiConfig AIConfig) (Teleme
233233
}
234234

235235
telemetryConfig := appinsights.NewTelemetryConfiguration(connectionVars.instrumentationKey)
236-
telemetryConfig.EndpointUrl = connectionVars.ingestionUrl
236+
telemetryConfig.EndpointUrl = connectionVars.ingestionURL
237237
telemetryConfig.MaxBatchSize = aiConfig.BatchSize
238238
telemetryConfig.MaxBatchInterval = time.Duration(aiConfig.BatchInterval) * time.Second
239239

aitelemetry/telemetrywrapper_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func handleGetCloud(w http.ResponseWriter, req *http.Request) {
8787
w.Write([]byte(getCloudResponse))
8888
}
8989

90-
func initTelemetry(t *testing.T) (TelemetryHandle, TelemetryHandle) {
90+
func initTelemetry(_ *testing.T) (th1, th2 TelemetryHandle) {
9191
th1, err1 := NewAITelemetry(httpURL, "00ca2a73-c8d6-4929-a0c2-cf84545ec225", aiConfig)
9292
if err1 != nil {
9393
fmt.Printf("Error initializing AI telemetry: %v", err1)
@@ -98,7 +98,7 @@ func initTelemetry(t *testing.T) (TelemetryHandle, TelemetryHandle) {
9898
fmt.Printf("Error initializing AI telemetry with connection string: %v", err2)
9999
}
100100

101-
return th1, th2
101+
return
102102
}
103103

104104
func TestEmptyAIKey(t *testing.T) {

0 commit comments

Comments
 (0)