[hack] ignores embedded field in generation
This commit is contained in:
@@ -5,7 +5,8 @@ GO_PKG_FILES = $(shell find $(PKG_DIR) -name *.go -print)
|
|||||||
|
|
||||||
|
|
||||||
spec.json: $(GO_PKG_FILES)
|
spec.json: $(GO_PKG_FILES)
|
||||||
swagger generate spec -m -w $(PKG_DIR) -o $@
|
swagger generate spec -m -w $(PKG_DIR) | jq 'del(.definitions.ApiAlertingConfig.properties.route)' > $@
|
||||||
|
|
||||||
|
|
||||||
.PHONY: openapi
|
.PHONY: openapi
|
||||||
openapi: spec.json
|
openapi: spec.json
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
[view api](https://grafana.github.io/alerting-api/)
|
[view api](https://grafana.github.io/alerting-api/)
|
||||||
|
|
||||||
This repo aims to define the unified alerting API as code. It generates OpenAPI definitions from go structs, initially pulled from
|
This repo aims to define the unified alerting API as code. It generates OpenAPI definitions from go structs
|
||||||
|
|
||||||
|
|
||||||
## Running
|
## Running
|
||||||
@@ -11,3 +11,4 @@ This repo aims to define the unified alerting API as code. It generates OpenAPI
|
|||||||
|
|
||||||
## Requires
|
## Requires
|
||||||
- [go-swagger](https://github.com/go-swagger/go-swagger)
|
- [go-swagger](https://github.com/go-swagger/go-swagger)
|
||||||
|
- [jq](https://stedolan.github.io/jq/)
|
||||||
|
|||||||
@@ -174,8 +174,8 @@ type AlertingConfigResponse struct {
|
|||||||
type ApiAlertingConfig struct {
|
type ApiAlertingConfig struct {
|
||||||
config.Config
|
config.Config
|
||||||
|
|
||||||
// Override/eliminate Routes tree in AM config - we'll set it via new fields
|
// TODO: PR a followup to https://github.com/go-swagger/go-swagger/pull/1527 in order to allow
|
||||||
Route struct{} `yaml:"route,omitempty" json:"route,omitempty"`
|
// explicitly ignoring embedded fields. In the meantime, these are hackily removed in our make targets via `jq`
|
||||||
|
|
||||||
AlertManagerRoute *config.Route `yaml:"alertmanager_route,omitempty" json:"alertmanager_route,omitempty"`
|
AlertManagerRoute *config.Route `yaml:"alertmanager_route,omitempty" json:"alertmanager_route,omitempty"`
|
||||||
GrafanaManagedRoute *config.Route `yaml:"grafana_managed_route,omitempty" json:"grafana_managed_route,omitempty"`
|
GrafanaManagedRoute *config.Route `yaml:"grafana_managed_route,omitempty" json:"grafana_managed_route,omitempty"`
|
||||||
|
|||||||
@@ -949,9 +949,15 @@
|
|||||||
"ApiAlertingConfig": {
|
"ApiAlertingConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"alertmanager_route": {
|
||||||
|
"$ref": "#/definitions/Route"
|
||||||
|
},
|
||||||
"global": {
|
"global": {
|
||||||
"$ref": "#/definitions/GlobalConfig"
|
"$ref": "#/definitions/GlobalConfig"
|
||||||
},
|
},
|
||||||
|
"grafana_managed_route": {
|
||||||
|
"$ref": "#/definitions/Route"
|
||||||
|
},
|
||||||
"inhibit_rules": {
|
"inhibit_rules": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
@@ -967,9 +973,6 @@
|
|||||||
},
|
},
|
||||||
"x-go-name": "Receivers"
|
"x-go-name": "Receivers"
|
||||||
},
|
},
|
||||||
"route": {
|
|
||||||
"$ref": "#/definitions/Route"
|
|
||||||
},
|
|
||||||
"templates": {
|
"templates": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
@@ -1533,6 +1536,19 @@
|
|||||||
"GrafanaReceiver": {
|
"GrafanaReceiver": {
|
||||||
"$ref": "#/definitions/CreateAlertNotificationCommand"
|
"$ref": "#/definitions/CreateAlertNotificationCommand"
|
||||||
},
|
},
|
||||||
|
"GrafanaReceivers": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"grafana_managed_receiver_configs": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"$ref": "#/definitions/GrafanaReceiver"
|
||||||
|
},
|
||||||
|
"x-go-name": "GrafanaManagedReceivers"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
|
||||||
|
},
|
||||||
"HTTPClientConfig": {
|
"HTTPClientConfig": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "HTTPClientConfig configures an HTTP client.",
|
"title": "HTTPClientConfig configures an HTTP client.",
|
||||||
@@ -1648,7 +1664,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"Expr": {
|
"Expr": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"example": "(node_filesystem_avail_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} node_filesystem_size_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} * 100 \u003c 5 and node_filesystem_readonly{fstype!=\"\",job=\"integrations/node_exporter\"} == 0)"
|
"example": "(node_filesystem_avail_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} node_filesystem_size_bytes{fstype!=\"\",job=\"integrations/node_exporter\"} * 100 < 5 and node_filesystem_readonly{fstype!=\"\",job=\"integrations/node_exporter\"} == 0)"
|
||||||
},
|
},
|
||||||
"datasourceUid": {
|
"datasourceUid": {
|
||||||
"description": "DatasourceUID is required if the query will be sent to grafana to be executed",
|
"description": "DatasourceUID is required if the query will be sent to grafana to be executed",
|
||||||
@@ -2615,8 +2631,9 @@
|
|||||||
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
|
"x-go-package": "github.com/grafana/alerting-api/pkg/api"
|
||||||
},
|
},
|
||||||
"URL": {
|
"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 RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
|
||||||
"type": "object",
|
"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": {
|
"properties": {
|
||||||
"ForceQuery": {
|
"ForceQuery": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@@ -2649,7 +2666,7 @@
|
|||||||
"$ref": "#/definitions/Userinfo"
|
"$ref": "#/definitions/Userinfo"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"x-go-package": "github.com/prometheus/common/config"
|
"x-go-package": "net/url"
|
||||||
},
|
},
|
||||||
"UpdateDashboardAclCommand": {
|
"UpdateDashboardAclCommand": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
@@ -3473,4 +3490,4 @@
|
|||||||
"type": "basic"
|
"type": "basic"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user