ngalert make: Support GNU install on Darwin (#78482)

* ngalert `make`: Support GNU install on Darwin
Currently, the Makefile assumes that Darwin is using the Mac version of `sed`
I have the GNU version, so it failed. With this PR, it checks which version is installed
I also called `make` and there are some changes that came out of it

* swagger-gen
This commit is contained in:
Julien Duchesne 2023-12-04 10:11:39 -05:00 committed by GitHub
parent ac1b9e44a2
commit 3c51190392
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 453 additions and 38 deletions

View File

@ -252,6 +252,7 @@ func (api *API) RegisterRulerApiEndpoints(srv RulerApi, m *metrics.API) {
group.Get(
toMacaronPath("/api/ruler/grafana/api/v1/export/rules"),
requestmeta.SetOwner(requestmeta.TeamAlerting),
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
api.authorize(http.MethodGet, "/api/ruler/grafana/api/v1/export/rules"),
metrics.Instrument(
http.MethodGet,
@ -287,6 +288,7 @@ func (api *API) RegisterRulerApiEndpoints(srv RulerApi, m *metrics.API) {
group.Post(
toMacaronPath("/api/ruler/grafana/api/v1/rules/{Namespace}/export"),
requestmeta.SetOwner(requestmeta.TeamAlerting),
requestmeta.SetSLOGroup(requestmeta.SLOGroupHighSlow),
api.authorize(http.MethodPost, "/api/ruler/grafana/api/v1/rules/{Namespace}/export"),
metrics.Instrument(
http.MethodPost,

View File

@ -15,8 +15,12 @@ GENERATED_GO_MATCHERS = ./go/*.go
SED_INPLACE := -i
ifneq ($(OS),Windows_NT)
# If we're not using the GNU version of sed, we need to specify an argument to -i
UNAME := $(shell uname)
ifeq ($(UNAME),Darwin)
isGNU := $(shell sed --help 2>&1 | grep -c GNU)
ifneq ($(isGNU),0)
# Do nothing
else ifeq ($(UNAME),Darwin)
SED_INPLACE = -i ''
endif
endif

View File

@ -280,6 +280,9 @@
},
"type": "object"
},
"AlertStateType": {
"type": "string"
},
"AlertingFileExport": {
"properties": {
"apiVersion": {
@ -401,6 +404,80 @@
},
"type": "object"
},
"Annotation": {
"properties": {
"alertId": {
"format": "int64",
"type": "integer"
},
"alertName": {
"type": "string"
},
"avatarUrl": {
"type": "string"
},
"created": {
"format": "int64",
"type": "integer"
},
"dashboardId": {
"format": "int64",
"type": "integer"
},
"dashboardUID": {
"type": "string"
},
"data": {
"$ref": "#/definitions/Json"
},
"email": {
"type": "string"
},
"id": {
"format": "int64",
"type": "integer"
},
"login": {
"type": "string"
},
"newState": {
"type": "string"
},
"panelId": {
"format": "int64",
"type": "integer"
},
"prevState": {
"type": "string"
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"text": {
"type": "string"
},
"time": {
"format": "int64",
"type": "integer"
},
"timeEnd": {
"format": "int64",
"type": "integer"
},
"updated": {
"format": "int64",
"type": "integer"
},
"userId": {
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"ApiRuleNode": {
"properties": {
"alert": {
@ -512,6 +589,9 @@
},
"username": {
"type": "string"
},
"username_file": {
"type": "string"
}
},
"title": "BasicAuth contains basic HTTP authentication credentials.",
@ -577,12 +657,75 @@
},
"type": "array"
},
"CookieType": {
"type": "string"
},
"CounterResetHint": {
"description": "or alternatively that we are dealing with a gauge histogram, where counter resets do not apply.",
"format": "uint8",
"title": "CounterResetHint contains the known information about a counter reset,",
"type": "integer"
},
"CreateLibraryElementCommand": {
"description": "CreateLibraryElementCommand is the command for adding a LibraryElement",
"properties": {
"folderId": {
"description": "ID of the folder where the library element is stored.\n\nDeprecated: use FolderUID instead",
"format": "int64",
"type": "integer"
},
"folderUid": {
"description": "UID of the folder where the library element is stored.",
"type": "string"
},
"kind": {
"description": "Kind of element to create, Use 1 for library panels or 2 for c.\nDescription:\n1 - library panels\n2 - library variables",
"enum": [
1,
2
],
"format": "int64",
"type": "integer"
},
"model": {
"description": "The JSON model for the library element.",
"type": "object"
},
"name": {
"description": "Name of the library element.",
"type": "string"
},
"uid": {
"type": "string"
}
},
"type": "object"
},
"DashboardACLUpdateItem": {
"properties": {
"permission": {
"$ref": "#/definitions/PermissionType"
},
"role": {
"enum": [
"None",
"Viewer",
"Editor",
"Admin"
],
"type": "string"
},
"teamId": {
"format": "int64",
"type": "integer"
},
"userId": {
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"DataLink": {
"description": "DataLink define what",
"properties": {
@ -608,6 +751,9 @@
"description": "Error is a property to be set if the corresponding DataQuery has an error.",
"type": "string"
},
"ErrorSource": {
"$ref": "#/definitions/ErrorSource"
},
"Frames": {
"$ref": "#/definitions/Frames"
},
@ -813,6 +959,10 @@
},
"type": "object"
},
"ErrorSource": {
"description": "ErrorSource type defines the source of the error",
"type": "string"
},
"ErrorType": {
"title": "ErrorType models the different API error types.",
"type": "string"
@ -1810,6 +1960,82 @@
},
"type": "array"
},
"LegacyAlert": {
"properties": {
"Created": {
"format": "date-time",
"type": "string"
},
"DashboardID": {
"format": "int64",
"type": "integer"
},
"EvalData": {
"$ref": "#/definitions/Json"
},
"ExecutionError": {
"type": "string"
},
"For": {
"$ref": "#/definitions/Duration"
},
"Frequency": {
"format": "int64",
"type": "integer"
},
"Handler": {
"format": "int64",
"type": "integer"
},
"ID": {
"format": "int64",
"type": "integer"
},
"Message": {
"type": "string"
},
"Name": {
"type": "string"
},
"NewStateDate": {
"format": "date-time",
"type": "string"
},
"OrgID": {
"format": "int64",
"type": "integer"
},
"PanelID": {
"format": "int64",
"type": "integer"
},
"Settings": {
"$ref": "#/definitions/Json"
},
"Severity": {
"type": "string"
},
"Silenced": {
"type": "boolean"
},
"State": {
"$ref": "#/definitions/AlertStateType"
},
"StateChanges": {
"format": "int64",
"type": "integer"
},
"Updated": {
"format": "date-time",
"type": "string"
},
"Version": {
"format": "int64",
"type": "integer"
}
},
"type": "object"
},
"LinkTransformationConfig": {
"properties": {
"expression": {
@ -1849,7 +2075,7 @@
},
"MatchRegexps": {
"additionalProperties": {
"$ref": "#/definitions/Regexp"
"type": "string"
},
"title": "MatchRegexps represents a map of Regexp.",
"type": "object"
@ -1881,6 +2107,48 @@
},
"type": "array"
},
"MetricRequest": {
"properties": {
"debug": {
"type": "boolean"
},
"from": {
"description": "From Start time in epoch timestamps in milliseconds or relative using Grafana time units.",
"example": "now-1h",
"type": "string"
},
"queries": {
"description": "queries.refId Specifies an identifier of the query. Is optional and default to “A”.\nqueries.datasourceId Specifies the data source to be queried. Each query in the request must have an unique datasourceId.\nqueries.maxDataPoints - Species maximum amount of data points that dashboard panel can render. Is optional and default to 100.\nqueries.intervalMs - Specifies the time interval in milliseconds of time series. Is optional and defaults to 1000.",
"example": [
{
"datasource": {
"uid": "PD8C576611E62080A"
},
"format": "table",
"intervalMs": 86400000,
"maxDataPoints": 1092,
"rawSql": "SELECT 1 as valueOne, 2 as valueTwo",
"refId": "A"
}
],
"items": {
"$ref": "#/definitions/Json"
},
"type": "array"
},
"to": {
"description": "To End time in epoch timestamps in milliseconds or relative using Grafana time units.",
"example": "now",
"type": "string"
}
},
"required": [
"from",
"to",
"queries"
],
"type": "object"
},
"MultiStatus": {
"type": "object"
},
@ -1914,6 +2182,24 @@
},
"type": "object"
},
"NewApiKeyResult": {
"properties": {
"id": {
"example": 1,
"format": "int64",
"type": "integer"
},
"key": {
"example": "glsa_yscW25imSKJIuav8zF37RZmnbiDvB05G_fcaaf58a",
"type": "string"
},
"name": {
"example": "grafana",
"type": "string"
}
},
"type": "object"
},
"NotFound": {
"type": "object"
},
@ -2218,9 +2504,56 @@
},
"type": "object"
},
"PatchPrefsCmd": {
"properties": {
"cookies": {
"items": {
"$ref": "#/definitions/CookieType"
},
"type": "array"
},
"homeDashboardId": {
"default": 0,
"description": "The numerical :id of a favorited dashboard",
"format": "int64",
"type": "integer"
},
"homeDashboardUID": {
"type": "string"
},
"language": {
"type": "string"
},
"queryHistory": {
"$ref": "#/definitions/QueryHistoryPreference"
},
"theme": {
"enum": [
"light",
"dark"
],
"type": "string"
},
"timezone": {
"enum": [
"utc",
"browser"
],
"type": "string"
},
"weekStart": {
"type": "string"
}
},
"type": "object"
},
"PermissionDenied": {
"type": "object"
},
"PermissionType": {
"format": "int64",
"type": "integer"
},
"Point": {
"description": "If H is not nil, then this is a histogram point and only (T, H) is valid.\nIf H is nil, then only (T, V) is valid.",
"properties": {
@ -2780,6 +3113,14 @@
},
"type": "object"
},
"QueryHistoryPreference": {
"properties": {
"homeTab": {
"type": "string"
}
},
"type": "object"
},
"QueryStat": {
"description": "The embedded FieldConfig's display name must be set.\nIt corresponds to the QueryResultMetaStat on the frontend (https://github.com/grafana/grafana/blob/master/packages/grafana-data/src/types/data.ts#L53).",
"properties": {
@ -2973,11 +3314,6 @@
"title": "ReceiverExport is the provisioned file export of alerting.ReceiverV1.",
"type": "object"
},
"Regexp": {
"description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.",
"title": "Regexp is the representation of a compiled regular expression.",
"type": "object"
},
"RelativeTimeRange": {
"description": "RelativeTimeRange is the per query start and end time\nfor requests.",
"properties": {
@ -3921,6 +4257,61 @@
"title": "A URL represents a parsed URL (technically, a URI reference).",
"type": "object"
},
"UpdateDashboardACLCommand": {
"properties": {
"items": {
"items": {
"$ref": "#/definitions/DashboardACLUpdateItem"
},
"type": "array"
}
},
"type": "object"
},
"UpdatePrefsCmd": {
"properties": {
"cookies": {
"items": {
"$ref": "#/definitions/CookieType"
},
"type": "array"
},
"homeDashboardId": {
"default": 0,
"description": "The numerical :id of a favorited dashboard",
"format": "int64",
"type": "integer"
},
"homeDashboardUID": {
"type": "string"
},
"language": {
"type": "string"
},
"queryHistory": {
"$ref": "#/definitions/QueryHistoryPreference"
},
"theme": {
"enum": [
"light",
"dark",
"system"
],
"type": "string"
},
"timezone": {
"enum": [
"utc",
"browser"
],
"type": "string"
},
"weekStart": {
"type": "string"
}
},
"type": "object"
},
"UpdateRuleGroupResponse": {
"properties": {
"created": {
@ -4124,6 +4515,7 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@ -4308,6 +4700,7 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
},
@ -4368,6 +4761,7 @@
"type": "array"
},
"integration": {
"description": "Integration integration",
"properties": {
"lastNotifyAttempt": {
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
@ -4549,7 +4943,6 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",

View File

@ -512,6 +512,9 @@
},
"username": {
"type": "string"
},
"username_file": {
"type": "string"
}
},
"title": "BasicAuth contains basic HTTP authentication credentials.",
@ -608,6 +611,9 @@
"description": "Error is a property to be set if the corresponding DataQuery has an error.",
"type": "string"
},
"ErrorSource": {
"$ref": "#/definitions/ErrorSource"
},
"Frames": {
"$ref": "#/definitions/Frames"
},
@ -813,6 +819,10 @@
},
"type": "object"
},
"ErrorSource": {
"description": "ErrorSource type defines the source of the error",
"type": "string"
},
"ErrorType": {
"title": "ErrorType models the different API error types.",
"type": "string"
@ -1849,7 +1859,7 @@
},
"MatchRegexps": {
"additionalProperties": {
"$ref": "#/definitions/Regexp"
"type": "string"
},
"title": "MatchRegexps represents a map of Regexp.",
"type": "object"
@ -2973,11 +2983,6 @@
"title": "ReceiverExport is the provisioned file export of alerting.ReceiverV1.",
"type": "object"
},
"Regexp": {
"description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.",
"title": "Regexp is the representation of a compiled regular expression.",
"type": "object"
},
"RelativeTimeRange": {
"description": "RelativeTimeRange is the per query start and end time\nfor requests.",
"properties": {
@ -3882,6 +3887,7 @@
"type": "object"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.",
"properties": {
"ForceQuery": {
"type": "boolean"
@ -3917,7 +3923,7 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "URL is a custom URL type that allows validation at configuration load time.",
"title": "A URL represents a parsed URL (technically, a URI reference).",
"type": "object"
},
"UpdateRuleGroupResponse": {
@ -4123,6 +4129,7 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@ -4307,7 +4314,6 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
},
@ -4363,6 +4369,7 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
@ -4513,6 +4520,7 @@
"type": "array"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",

View File

@ -3492,6 +3492,9 @@
},
"username": {
"type": "string"
},
"username_file": {
"type": "string"
}
}
},
@ -3588,6 +3591,9 @@
"description": "Error is a property to be set if the corresponding DataQuery has an error.",
"type": "string"
},
"ErrorSource": {
"$ref": "#/definitions/ErrorSource"
},
"Frames": {
"$ref": "#/definitions/Frames"
},
@ -3792,6 +3798,10 @@
}
}
},
"ErrorSource": {
"description": "ErrorSource type defines the source of the error",
"type": "string"
},
"ErrorType": {
"type": "string",
"title": "ErrorType models the different API error types."
@ -4832,7 +4842,7 @@
"type": "object",
"title": "MatchRegexps represents a map of Regexp.",
"additionalProperties": {
"$ref": "#/definitions/Regexp"
"type": "string"
}
},
"MatchType": {
@ -5955,11 +5965,6 @@
}
}
},
"Regexp": {
"description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.",
"type": "object",
"title": "Regexp is the representation of a compiled regular expression."
},
"RelativeTimeRange": {
"description": "RelativeTimeRange is the per query start and end time\nfor requests.",
"type": "object",
@ -6864,8 +6869,9 @@
}
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use the EscapedPath method, which preserves\nthe original encoding of Path.\n\nThe RawPath field is an optional field which is only set when the default\nencoding of Path is different from the escaped path. See the EscapedPath method\nfor more details.\n\nURL's String method uses the EscapedPath method to obtain the path.",
"type": "object",
"title": "URL is a custom URL type that allows validation at configuration load time.",
"title": "A URL represents a parsed URL (technically, a URI reference).",
"properties": {
"ForceQuery": {
"type": "boolean"
@ -7105,6 +7111,7 @@
}
},
"alertGroup": {
"description": "AlertGroup alert group",
"type": "object",
"required": [
"alerts",
@ -7292,7 +7299,6 @@
"$ref": "#/definitions/gettableAlert"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"$ref": "#/definitions/gettableAlert"
@ -7350,6 +7356,7 @@
"$ref": "#/definitions/gettableSilence"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"type": "array",
"items": {
"$ref": "#/definitions/gettableSilence"
@ -7502,6 +7509,7 @@
}
},
"postableSilence": {
"description": "PostableSilence postable silence",
"type": "object",
"required": [
"comment",

View File

@ -12258,6 +12258,9 @@
},
"username": {
"type": "string"
},
"username_file": {
"type": "string"
}
}
},
@ -15555,7 +15558,7 @@
"type": "object",
"title": "MatchRegexps represents a map of Regexp.",
"additionalProperties": {
"$ref": "#/definitions/Regexp"
"type": "string"
}
},
"MatchType": {
@ -17593,11 +17596,6 @@
}
}
},
"Regexp": {
"description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.",
"type": "object",
"title": "Regexp is the representation of a compiled regular expression."
},
"RelativeTimeRange": {
"description": "RelativeTimeRange is the per query start and end time\nfor requests.",
"type": "object",
@ -20445,6 +20443,7 @@
}
},
"alertGroup": {
"description": "AlertGroup alert group",
"type": "object",
"required": [
"alerts",
@ -20657,6 +20656,7 @@
}
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"$ref": "#/definitions/gettableAlert"
@ -20717,6 +20717,7 @@
}
},
"integration": {
"description": "Integration integration",
"type": "object",
"required": [
"name",
@ -20926,7 +20927,6 @@
}
},
"receiver": {
"description": "Receiver receiver",
"type": "object",
"required": [
"active",

View File

@ -3264,6 +3264,9 @@
},
"username": {
"type": "string"
},
"username_file": {
"type": "string"
}
},
"title": "BasicAuth contains basic HTTP authentication credentials.",
@ -6561,7 +6564,7 @@
},
"MatchRegexps": {
"additionalProperties": {
"$ref": "#/components/schemas/Regexp"
"type": "string"
},
"title": "MatchRegexps represents a map of Regexp.",
"type": "object"
@ -8600,11 +8603,6 @@
},
"type": "object"
},
"Regexp": {
"description": "A Regexp is safe for concurrent use by multiple goroutines,\nexcept for configuration methods, such as Longest.",
"title": "Regexp is the representation of a compiled regular expression.",
"type": "object"
},
"RelativeTimeRange": {
"description": "RelativeTimeRange is the per query start and end time\nfor requests.",
"properties": {
@ -11451,6 +11449,7 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@ -11663,6 +11662,7 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/components/schemas/gettableAlert"
},
@ -11723,6 +11723,7 @@
"type": "array"
},
"integration": {
"description": "Integration integration",
"properties": {
"lastNotifyAttempt": {
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
@ -11932,7 +11933,6 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",