Skip to content

Commit 61ff1e3

Browse files
committed
* fix templates_test.go - removed orgId from urls
* changed implementation in alertmanager.go NewAlertmanager() to avoid null exception if there is no ParsedAppUrl provided in config (fixes a lot of tests) * changed implementation in navtree.go to remove the connections section (datasources) in another place, to help tests pass and makes more sense.
1 parent 7386a19 commit 61ff1e3

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

pkg/services/navtree/navtreeimpl/navtree.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,11 @@ func (s *ServiceImpl) GetNavTree(c *contextmodel.ReqContext, prefs *pref.Prefere
151151
}
152152
}
153153

154-
if connectionsSection := s.buildDataConnectionsNavLink(c); connectionsSection != nil {
155-
treeRoot.AddSection(connectionsSection)
156-
}
154+
// LOGZ.IO GRAFANA CHANGE :: DEV-45139 - hide datasources menu
155+
//if connectionsSection := s.buildDataConnectionsNavLink(c); connectionsSection != nil {
156+
// treeRoot.AddSection(connectionsSection)
157+
//}
158+
// LOGZ.IO GRAFANA CHANGE :: End
157159

158160
orgAdminNode, err := s.getAdminNode(c)
159161

@@ -485,7 +487,7 @@ func (s *ServiceImpl) buildDataConnectionsNavLink(c *contextmodel.ReqContext) *n
485487

486488
baseUrl := s.cfg.AppSubURL + "/connections"
487489

488-
if false && hasAccess(datasources.ConfigurationPageAccess) { // LOGZ.IO GRAFANA CHANGE :: hide datasources menu, should be done by altering permissions
490+
if hasAccess(datasources.ConfigurationPageAccess) {
489491
// Add new connection
490492
children = append(children, &navtree.NavLink{
491493
Id: "connections-add-new-connection",

pkg/services/ngalert/notifier/alertmanager.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,18 @@ func NewAlertmanager(ctx context.Context, orgID int64, cfg *setting.Cfg, store A
122122
},
123123
}
124124

125+
// LOGZ.IO GRAFANA CHANGE :: DEV-43657 - Set APP url to logzio grafana for alert notification URLs
126+
externalUrl := ""
127+
if cfg.ParsedAppURL != nil {
128+
externalUrl = cfg.ParsedAppURL.String()
129+
} else {
130+
externalUrl = cfg.AppURL
131+
}
132+
// LOGZ.IO GRAFANA CHANGE :: End
133+
125134
amcfg := &alertingNotify.GrafanaAlertmanagerConfig{
126135
WorkingDirectory: filepath.Join(cfg.DataPath, workingDir, strconv.Itoa(int(orgID))),
127-
ExternalURL: cfg.ParsedAppURL.String(), // LOGZ.IO GRAFANA CHANGE :: DEV-43657 - Set APP url to logzio grafana for alert notification URLs
136+
ExternalURL: externalUrl, // LOGZ.IO GRAFANA CHANGE :: DEV-43657 - Set APP url to logzio grafana for alert notification URLs
128137
AlertStoreCallback: nil,
129138
PeerTimeout: cfg.UnifiedAlerting.HAPeerTimeout,
130139
Silences: silencesOptions,

pkg/services/ngalert/notifier/templates_test.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,10 @@ CommonAnnotations: {{ range .CommonAnnotations.SortedPairs }}{{ .Name }}={{ .Val
124124
expected: TestTemplatesResults{
125125
Results: []alertingNotify.TestTemplatesResult{{
126126
Name: "slack.title",
127-
Text: fmt.Sprintf("http://localhost:9093/d/%s?orgId=%s",
128-
DefaultAnnotations[alertingModels.DashboardUIDAnnotation],
129-
DefaultAnnotations[alertingModels.OrgIDAnnotation]),
127+
// LOGZ.IO GRAFANA CHANGE :: DEV-45707: remove org id query param from notification urls
128+
Text: fmt.Sprintf("http://localhost:9093/d/%s",
129+
DefaultAnnotations[alertingModels.DashboardUIDAnnotation]),
130+
// LOGZ.IO GRAFANA CHANGE :: End
130131
}},
131132
Errors: nil,
132133
},
@@ -140,10 +141,11 @@ CommonAnnotations: {{ range .CommonAnnotations.SortedPairs }}{{ .Name }}={{ .Val
140141
expected: TestTemplatesResults{
141142
Results: []alertingNotify.TestTemplatesResult{{
142143
Name: "slack.title",
143-
Text: fmt.Sprintf("http://localhost:9093/d/%s?orgId=%s&viewPanel=%s",
144+
// LOGZ.IO GRAFANA CHANGE :: DEV-45707: remove org id query param from notification urls
145+
Text: fmt.Sprintf("http://localhost:9093/d/%s?viewPanel=%s",
144146
DefaultAnnotations[alertingModels.DashboardUIDAnnotation],
145-
DefaultAnnotations[alertingModels.OrgIDAnnotation],
146147
DefaultAnnotations[alertingModels.PanelIDAnnotation]),
148+
// LOGZ.IO GRAFANA CHANGE :: End
147149
}},
148150
Errors: nil,
149151
},
@@ -157,7 +159,7 @@ CommonAnnotations: {{ range .CommonAnnotations.SortedPairs }}{{ .Name }}={{ .Val
157159
expected: TestTemplatesResults{
158160
Results: []alertingNotify.TestTemplatesResult{{
159161
Name: "slack.title",
160-
Text: fmt.Sprintf("http://localhost:3000?orgId=%s", DefaultAnnotations[alertingModels.OrgIDAnnotation]),
162+
Text: "http://localhost:3000", // LOGZ.IO GRAFANA CHANGE :: DEV-45707: remove org id query param from notification urls
161163
}},
162164
Errors: nil,
163165
},

0 commit comments

Comments
 (0)