Skip to content

Commit

Permalink
feat: make Azure Monitor LogAnalytics workspace subscription id and r…
Browse files Browse the repository at this point in the history
…esource group required [PC-11222] (#234)
  • Loading branch information
nikodemrafalski authored Jan 15, 2024
1 parent ef70f9e commit f333b6c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions manifest/v1alpha/slo/metrics_azure_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ var validAzureResourceGroupRegex = regexp.MustCompile(`^[a-zA-Z0-9-._()]+$`)
var azureMonitorMetricLogAnalyticsWorkspaceValidation = validation.New[AzureMonitorMetricLogAnalyticsWorkspace](
validation.For(func(a AzureMonitorMetricLogAnalyticsWorkspace) string { return a.SubscriptionID }).
WithName("subscriptionId").
OmitEmpty(). //TODO: replace this with Required() when log analytics discovery (PC-11169) is implemented
Required().
Rules(validation.StringUUID()),
validation.For(func(a AzureMonitorMetricLogAnalyticsWorkspace) string { return a.ResourceGroup }).
WithName("resourceGroup").
OmitEmpty(). //TODO: replace this with Required() when log analytics discovery (PC-11169) is implemented
Required().
Rules(validation.StringMatchRegexp(validAzureResourceGroupRegex)),
validation.For(func(a AzureMonitorMetricLogAnalyticsWorkspace) string { return a.WorkspaceID }).
WithName("workspaceId").
Expand Down
14 changes: 12 additions & 2 deletions manifest/v1alpha/slo/metrics_azure_monitor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,20 @@ func TestAzureMonitorLogAnalyticsWorkspace(t *testing.T) {
slo := validRawMetricSLO(v1alpha.AzureMonitor)
slo.Spec.Objectives[0].RawMetric.MetricQuery.AzureMonitor = getValidAzureMetric(AzureMonitorDataTypeLogs)
slo.Spec.Objectives[0].RawMetric.MetricQuery.AzureMonitor.Workspace = &AzureMonitorMetricLogAnalyticsWorkspace{
WorkspaceID: "",
SubscriptionID: "",
ResourceGroup: "",
WorkspaceID: "",
}
err := validate(slo)
testutils.AssertContainsErrors(t, slo, err, 1,
testutils.AssertContainsErrors(t, slo, err, 3,
testutils.ExpectedError{
Prop: "spec.objectives[0].rawMetric.query.azureMonitor.workspace.subscriptionId",
Code: validation.ErrorCodeRequired,
},
testutils.ExpectedError{
Prop: "spec.objectives[0].rawMetric.query.azureMonitor.workspace.resourceGroup",
Code: validation.ErrorCodeRequired,
},
testutils.ExpectedError{
Prop: "spec.objectives[0].rawMetric.query.azureMonitor.workspace.workspaceId",
Code: validation.ErrorCodeRequired,
Expand Down
10 changes: 6 additions & 4 deletions sdk/test_data/client/simple_module/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module simple_module

go 1.20
go 1.21

toolchain go1.21.4

require github.com/nobl9/nobl9-go v0.73.0

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/aws/aws-sdk-go v1.48.14 // indirect
github.com/aws/aws-sdk-go v1.49.16 // indirect
github.com/bmatcuk/doublestar/v4 v4.6.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/fatih/color v1.15.0 // indirect
Expand Down Expand Up @@ -34,11 +36,11 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/rs/zerolog v1.31.0 // indirect
golang.org/x/crypto v0.17.0 // indirect
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb // indirect
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
)

replace github.com/nobl9/nobl9-go => ../../../../.
replace github.com/nobl9/nobl9-go => ../../../../.
2 changes: 2 additions & 0 deletions sdk/test_data/client/simple_module/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/aws/aws-sdk-go v1.48.14 h1:nVLrp+F84SG+xGiFMfe1TE6ZV6smF+42tuuNgYGV30s=
github.com/aws/aws-sdk-go v1.48.14/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/aws/aws-sdk-go v1.49.16/go.mod h1:LF8svs817+Nz+DmiMQKTO3ubZ/6IaTpq3TjupRn3Eqk=
github.com/bmatcuk/doublestar/v4 v4.6.1 h1:FH9SifrbvJhnlQpztAx++wlkk70QBf0iBWDwNy7PA4I=
github.com/bmatcuk/doublestar/v4 v4.6.1/go.mod h1:xBQ8jztBU6kakFMg+8WGxn0c6z1fTSPVIjEY1Wr7jzc=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
Expand Down Expand Up @@ -91,6 +92,7 @@ golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4=
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb h1:c0vyKkb6yr3KR7jEfJaOSv4lG7xPkbN6r52aJz1d8a8=
golang.org/x/exp v0.0.0-20231206192017-f3f8817b8deb/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
Expand Down

0 comments on commit f333b6c

Please sign in to comment.