mirror of
https://github.com/prometheus-operator/prometheus-operator.git
synced 2025-04-21 03:38:43 +00:00
Documentation: add links to type in API docs
This commit is contained in:
parent
009820a3b8
commit
6648ea426c
3 changed files with 115 additions and 84 deletions
|
@ -10,7 +10,7 @@ AlertingSpec defines paramters for alerting configuration of Prometheus servers.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| alertmanagers | AlertmanagerEndpoints Prometheus should fire alerts against. | `[]AlertmanagerEndpoints` | true |
|
||||
| alertmanagers | AlertmanagerEndpoints Prometheus should fire alerts against. | [][AlertmanagerEndpoints](#alertmanagerendpoints) | true |
|
||||
|
||||
## Alertmanager
|
||||
|
||||
|
@ -18,9 +18,9 @@ Describes an Alertmanager cluster.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| metadata | Standard object’s metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | `metav1.ObjectMeta` | false |
|
||||
| spec | Specification of the desired behavior of the Alertmanager cluster. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | `AlertmanagerSpec` | true |
|
||||
| status | Most recent observed status of the Alertmanager cluster. Read-only. Not included when requesting from the apiserver, only from the Prometheus Operator API itself. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | `*AlertmanagerStatus` | false |
|
||||
| metadata | Standard object’s metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | [metav1.ObjectMeta](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_objectmeta) | false |
|
||||
| spec | Specification of the desired behavior of the Alertmanager cluster. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | [AlertmanagerSpec](#alertmanagerspec) | true |
|
||||
| status | Most recent observed status of the Alertmanager cluster. Read-only. Not included when requesting from the apiserver, only from the Prometheus Operator API itself. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | *[AlertmanagerStatus](#alertmanagerstatus) | false |
|
||||
|
||||
## AlertmanagerEndpoints
|
||||
|
||||
|
@ -28,10 +28,10 @@ AlertmanagerEndpoints defines a selection of a single Endpoints object containin
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| namespace | Namespace of Endpoints object. | `string` | true |
|
||||
| name | Name of Endpoints object in Namespace. | `string` | true |
|
||||
| port | Port the Alertmanager API is exposed on. | `intstr.IntOrString` | true |
|
||||
| scheme | Scheme to use when firing alerts. | `string` | true |
|
||||
| namespace | Namespace of Endpoints object. | string | true |
|
||||
| name | Name of Endpoints object in Namespace. | string | true |
|
||||
| port | Port the Alertmanager API is exposed on. | intstr.IntOrString | true |
|
||||
| scheme | Scheme to use when firing alerts. | string | true |
|
||||
|
||||
## AlertmanagerList
|
||||
|
||||
|
@ -39,8 +39,8 @@ A list of Alertmanagers.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| metadata | Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | `metav1.ListMeta` | false |
|
||||
| items | List of Alertmanagers | `[]Alertmanager` | true |
|
||||
| metadata | Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | [metav1.ListMeta](https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_listmeta) | false |
|
||||
| items | List of Alertmanagers | [][Alertmanager](#alertmanager) | true |
|
||||
|
||||
## AlertmanagerSpec
|
||||
|
||||
|
@ -48,12 +48,12 @@ Specification of the desired behavior of the Alertmanager cluster. More info: ht
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| version | Version the cluster should be on. | `string` | false |
|
||||
| baseImage | Base image that is used to deploy pods. | `string` | false |
|
||||
| replicas | Size is the expected size of the alertmanager cluster. The controller will eventually make the size of the running cluster equal to the expected size. | `*int32` | false |
|
||||
| storage | Storage is the definition of how storage will be used by the Alertmanager instances. | `*StorageSpec` | false |
|
||||
| externalUrl | ExternalURL is the URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically. | `string` | false |
|
||||
| paused | If set to true all actions on the underlaying managed objects are not goint to be performed, except for delete actions. | `bool` | false |
|
||||
| version | Version the cluster should be on. | string | false |
|
||||
| baseImage | Base image that is used to deploy pods. | string | false |
|
||||
| replicas | Size is the expected size of the alertmanager cluster. The controller will eventually make the size of the running cluster equal to the expected size. | *int32 | false |
|
||||
| storage | Storage is the definition of how storage will be used by the Alertmanager instances. | *[StorageSpec](#storagespec) | false |
|
||||
| externalUrl | ExternalURL is the URL under which Alertmanager is externally reachable (for example, if Alertmanager is served via a reverse proxy). Used for generating relative and absolute links back to Alertmanager itself. If the URL has a path portion, it will be used to prefix all HTTP endpoints served by Alertmanager. If omitted, relevant URL components will be derived automatically. | string | false |
|
||||
| paused | If set to true all actions on the underlaying managed objects are not goint to be performed, except for delete actions. | bool | false |
|
||||
|
||||
## AlertmanagerStatus
|
||||
|
||||
|
@ -61,11 +61,11 @@ Most recent observed status of the Alertmanager cluster. Read-only. Not included
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| paused | Represents whether any actions on the underlaying managed objects are being performed. Only delete actions will be performed. | `bool` | true |
|
||||
| replicas | Total number of non-terminated pods targeted by this Alertmanager cluster (their labels match the selector). | `int32` | true |
|
||||
| updatedReplicas | Total number of non-terminated pods targeted by this Alertmanager cluster that have the desired version spec. | `int32` | true |
|
||||
| availableReplicas | Total number of available pods (ready for at least minReadySeconds) targeted by this Alertmanager cluster. | `int32` | true |
|
||||
| unavailableReplicas | Total number of unavailable pods targeted by this Alertmanager cluster. | `int32` | true |
|
||||
| paused | Represents whether any actions on the underlaying managed objects are being performed. Only delete actions will be performed. | bool | true |
|
||||
| replicas | Total number of non-terminated pods targeted by this Alertmanager cluster (their labels match the selector). | int32 | true |
|
||||
| updatedReplicas | Total number of non-terminated pods targeted by this Alertmanager cluster that have the desired version spec. | int32 | true |
|
||||
| availableReplicas | Total number of available pods (ready for at least minReadySeconds) targeted by this Alertmanager cluster. | int32 | true |
|
||||
| unavailableReplicas | Total number of unavailable pods targeted by this Alertmanager cluster. | int32 | true |
|
||||
|
||||
## Endpoint
|
||||
|
||||
|
@ -73,13 +73,13 @@ Endpoint defines a scrapeable endpoint serving Prometheus metrics.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| port | Name of the service port this endpoint refers to. Mutually exclusive with targetPort. | `string` | false |
|
||||
| targetPort | Name or number of the target port of the endpoint. Mutually exclusive with port. | `intstr.IntOrString` | false |
|
||||
| path | HTTP path to scrape for metrics. | `string` | false |
|
||||
| scheme | HTTP scheme to use for scraping. | `string` | false |
|
||||
| interval | Interval at which metrics should be scraped | `string` | false |
|
||||
| tlsConfig | TLS configuration to use when scraping the endpoint | `*TLSConfig` | false |
|
||||
| bearerTokenFile | File to read bearer token for scraping targets. | `string` | false |
|
||||
| port | Name of the service port this endpoint refers to. Mutually exclusive with targetPort. | string | false |
|
||||
| targetPort | Name or number of the target port of the endpoint. Mutually exclusive with port. | intstr.IntOrString | false |
|
||||
| path | HTTP path to scrape for metrics. | string | false |
|
||||
| scheme | HTTP scheme to use for scraping. | string | false |
|
||||
| interval | Interval at which metrics should be scraped | string | false |
|
||||
| tlsConfig | TLS configuration to use when scraping the endpoint | *[TLSConfig](#tlsconfig) | false |
|
||||
| bearerTokenFile | File to read bearer token for scraping targets. | string | false |
|
||||
|
||||
## NamespaceSelector
|
||||
|
||||
|
@ -87,8 +87,8 @@ A selector for selecting namespaces either selecting all namespaces or a list of
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| any | Boolean describing whether all namespaces are selected in contrast to a list restricting them. | `bool` | false |
|
||||
| matchNames | List of namespace names. | `[]string` | false |
|
||||
| any | Boolean describing whether all namespaces are selected in contrast to a list restricting them. | bool | false |
|
||||
| matchNames | List of namespace names. | []string | false |
|
||||
|
||||
## Prometheus
|
||||
|
||||
|
@ -96,9 +96,9 @@ Prometheus defines a Prometheus deployment.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| metadata | Standard object’s metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | `metav1.ObjectMeta` | false |
|
||||
| spec | Specification of the desired behavior of the Prometheus cluster. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | `PrometheusSpec` | true |
|
||||
| status | Most recent observed status of the Prometheus cluster. Read-only. Not included when requesting from the apiserver, only from the Prometheus Operator API itself. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | `*PrometheusStatus` | false |
|
||||
| metadata | Standard object’s metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | [metav1.ObjectMeta](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_objectmeta) | false |
|
||||
| spec | Specification of the desired behavior of the Prometheus cluster. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | [PrometheusSpec](#prometheusspec) | true |
|
||||
| status | Most recent observed status of the Prometheus cluster. Read-only. Not included when requesting from the apiserver, only from the Prometheus Operator API itself. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#spec-and-status | *[PrometheusStatus](#prometheusstatus) | false |
|
||||
|
||||
## PrometheusList
|
||||
|
||||
|
@ -106,8 +106,8 @@ PrometheusList is a list of Prometheuses.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| metadata | Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | `metav1.ListMeta` | false |
|
||||
| items | List of Prometheuses | `[]*Prometheus` | true |
|
||||
| metadata | Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | [metav1.ListMeta](https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_listmeta) | false |
|
||||
| items | List of Prometheuses | []*[Prometheus](#prometheus) | true |
|
||||
|
||||
## PrometheusSpec
|
||||
|
||||
|
@ -115,19 +115,19 @@ Specification of the desired behavior of the Prometheus cluster. More info: http
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| serviceMonitorSelector | ServiceMonitors to be selected for target discovery. | `*metav1.LabelSelector` | false |
|
||||
| version | Version of Prometheus to be deployed. | `string` | false |
|
||||
| paused | When a Prometheus deployment is paused, no actions except for deletion will be performed on the underlying objects. | `bool` | false |
|
||||
| baseImage | Base image to use for a Prometheus deployment. | `string` | false |
|
||||
| replicas | Number of instances to deploy for a Prometheus deployment. | `*int32` | false |
|
||||
| retention | Time duration Prometheus shall retain data for. | `string` | false |
|
||||
| externalUrl | The external URL the Prometheus instances will be available under. This is necessary to generate correct URLs. This is necessary if Prometheus is not served from root of a DNS name. | `string` | false |
|
||||
| routePrefix | The route prefix Prometheus registers HTTP handlers for. This is useful, if using ExternalURL and a proxy is rewriting HTTP routes of a request, and the actual ExternalURL is still true, but the server serves requests under a different route prefix. For example for use with `kubectl proxy`. | `string` | false |
|
||||
| storage | Storage spec to specify how storage shall be used. | `*StorageSpec` | false |
|
||||
| alerting | Define details regarding alerting. | `AlertingSpec` | false |
|
||||
| resources | Define resources requests and limits for single Pods. | `v1.ResourceRequirements` | false |
|
||||
| nodeSelector | Define which Nodes the Pods are scheduled on. | `map[string]string` | false |
|
||||
| serviceAccountName | ServiceAccountName is the name of the ServiceAccount to use to run the Prometheus Pods. | `string` | false |
|
||||
| serviceMonitorSelector | ServiceMonitors to be selected for target discovery. | *[metav1.LabelSelector](https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_labelselector) | false |
|
||||
| version | Version of Prometheus to be deployed. | string | false |
|
||||
| paused | When a Prometheus deployment is paused, no actions except for deletion will be performed on the underlying objects. | bool | false |
|
||||
| baseImage | Base image to use for a Prometheus deployment. | string | false |
|
||||
| replicas | Number of instances to deploy for a Prometheus deployment. | *int32 | false |
|
||||
| retention | Time duration Prometheus shall retain data for. | string | false |
|
||||
| externalUrl | The external URL the Prometheus instances will be available under. This is necessary to generate correct URLs. This is necessary if Prometheus is not served from root of a DNS name. | string | false |
|
||||
| routePrefix | The route prefix Prometheus registers HTTP handlers for. This is useful, if using ExternalURL and a proxy is rewriting HTTP routes of a request, and the actual ExternalURL is still true, but the server serves requests under a different route prefix. For example for use with `kubectl proxy`. | string | false |
|
||||
| storage | Storage spec to specify how storage shall be used. | *[StorageSpec](#storagespec) | false |
|
||||
| alerting | Define details regarding alerting. | [AlertingSpec](#alertingspec) | false |
|
||||
| resources | Define resources requests and limits for single Pods. | [v1.ResourceRequirements](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_resourcerequirements) | false |
|
||||
| nodeSelector | Define which Nodes the Pods are scheduled on. | map[string]string | false |
|
||||
| serviceAccountName | ServiceAccountName is the name of the ServiceAccount to use to run the Prometheus Pods. | string | false |
|
||||
|
||||
## PrometheusStatus
|
||||
|
||||
|
@ -135,11 +135,11 @@ Most recent observed status of the Prometheus cluster. Read-only. Not included w
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| paused | Represents whether any actions on the underlaying managed objects are being performed. Only delete actions will be performed. | `bool` | true |
|
||||
| replicas | Total number of non-terminated pods targeted by this Prometheus deployment (their labels match the selector). | `int32` | true |
|
||||
| updatedReplicas | Total number of non-terminated pods targeted by this Prometheus deployment that have the desired version spec. | `int32` | true |
|
||||
| availableReplicas | Total number of available pods (ready for at least minReadySeconds) targeted by this Prometheus deployment. | `int32` | true |
|
||||
| unavailableReplicas | Total number of unavailable pods targeted by this Prometheus deployment. | `int32` | true |
|
||||
| paused | Represents whether any actions on the underlaying managed objects are being performed. Only delete actions will be performed. | bool | true |
|
||||
| replicas | Total number of non-terminated pods targeted by this Prometheus deployment (their labels match the selector). | int32 | true |
|
||||
| updatedReplicas | Total number of non-terminated pods targeted by this Prometheus deployment that have the desired version spec. | int32 | true |
|
||||
| availableReplicas | Total number of available pods (ready for at least minReadySeconds) targeted by this Prometheus deployment. | int32 | true |
|
||||
| unavailableReplicas | Total number of unavailable pods targeted by this Prometheus deployment. | int32 | true |
|
||||
|
||||
## ServiceMonitor
|
||||
|
||||
|
@ -147,8 +147,8 @@ ServiceMonitor defines monitoring for a set of services.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| metadata | Standard object’s metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | `metav1.ObjectMeta` | false |
|
||||
| spec | Specification of desired Service selection for target discrovery by Prometheus. | `ServiceMonitorSpec` | true |
|
||||
| metadata | Standard object’s metadata. More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | [metav1.ObjectMeta](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_objectmeta) | false |
|
||||
| spec | Specification of desired Service selection for target discrovery by Prometheus. | [ServiceMonitorSpec](#servicemonitorspec) | true |
|
||||
|
||||
## ServiceMonitorList
|
||||
|
||||
|
@ -156,8 +156,8 @@ A list of ServiceMonitors.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| metadata | Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | `metav1.ListMeta` | false |
|
||||
| items | List of ServiceMonitors | `[]*ServiceMonitor` | true |
|
||||
| metadata | Standard list metadata More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata | [metav1.ListMeta](https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_listmeta) | false |
|
||||
| items | List of ServiceMonitors | []*[ServiceMonitor](#servicemonitor) | true |
|
||||
|
||||
## ServiceMonitorSpec
|
||||
|
||||
|
@ -165,10 +165,10 @@ ServiceMonitorSpec contains specification parameters for a ServiceMonitor.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| jobLabel | The label to use to retrieve the job name from. | `string` | false |
|
||||
| endpoints | A list of endpoints allowed as part of this ServiceMonitor. | `[]Endpoint` | false |
|
||||
| selector | Selector to select Endpoints objects. | `metav1.LabelSelector` | true |
|
||||
| namespaceSelector | Selector to select which namespaces the Endpoints objects are discovered from. | `NamespaceSelector` | false |
|
||||
| jobLabel | The label to use to retrieve the job name from. | string | false |
|
||||
| endpoints | A list of endpoints allowed as part of this ServiceMonitor. | [][Endpoint](#endpoint) | false |
|
||||
| selector | Selector to select Endpoints objects. | [metav1.LabelSelector](https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_labelselector) | true |
|
||||
| namespaceSelector | Selector to select which namespaces the Endpoints objects are discovered from. | [NamespaceSelector](#namespaceselector) | false |
|
||||
|
||||
## StorageSpec
|
||||
|
||||
|
@ -176,9 +176,9 @@ StorageSpec defines the configured storage for a group Prometheus servers.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| class | Name of the StorageClass to use when requesting storage provisioning. More info: https://kubernetes.io/docs/user-guide/persistent-volumes/#storageclasses | `string` | true |
|
||||
| selector | A label query over volumes to consider for binding. | `*metav1.LabelSelector` | true |
|
||||
| resources | Resources represents the minimum resources the volume should have. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#resources | `v1.ResourceRequirements` | true |
|
||||
| class | Name of the StorageClass to use when requesting storage provisioning. More info: https://kubernetes.io/docs/user-guide/persistent-volumes/#storageclasses | string | true |
|
||||
| selector | A label query over volumes to consider for binding. | *[metav1.LabelSelector](https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_labelselector) | true |
|
||||
| resources | Resources represents the minimum resources the volume should have. More info: http://kubernetes.io/docs/user-guide/persistent-volumes#resources | [v1.ResourceRequirements](https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_resourcerequirements) | true |
|
||||
|
||||
## TLSConfig
|
||||
|
||||
|
@ -186,8 +186,8 @@ TLSConfig specifies TLS configuration parameters.
|
|||
|
||||
| Field | Description | Scheme | Required |
|
||||
| ----- | ----------- | ------ | -------- |
|
||||
| caFile | The CA cert to use for the targets. | `string` | false |
|
||||
| certFile | The client cert file for the targets. | `string` | false |
|
||||
| keyFile | The client key file for the targets. | `string` | false |
|
||||
| serverName | Used to verify the hostname for the targets. | `string` | false |
|
||||
| insecureSkipVerify | Disable target certificate validation. | `bool` | false |
|
||||
| caFile | The CA cert to use for the targets. | string | false |
|
||||
| certFile | The client cert file for the targets. | string | false |
|
||||
| keyFile | The client key file for the targets. | string | false |
|
||||
| serverName | Used to verify the hostname for the targets. | string | false |
|
||||
| insecureSkipVerify | Disable target certificate validation. | bool | false |
|
||||
|
|
12
Makefile
12
Makefile
|
@ -44,19 +44,13 @@ clean-e2e:
|
|||
kubectl delete namespace $(NAMESPACE)
|
||||
|
||||
promu:
|
||||
@GOOS=$(shell uname -s | tr A-Z a-z) \
|
||||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
|
||||
go get -u github.com/prometheus/promu
|
||||
@go get -u github.com/prometheus/promu
|
||||
|
||||
embedmd:
|
||||
@GOOS=$(shell uname -s | tr A-Z a-z) \
|
||||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
|
||||
go get github.com/campoy/embedmd
|
||||
@go get github.com/campoy/embedmd
|
||||
|
||||
apidocgen:
|
||||
@GOOS=$(shell uname -s | tr A-Z a-z) \
|
||||
GOARCH=$(subst x86_64,amd64,$(patsubst i%86,386,$(shell uname -m))) \
|
||||
go install github.com/coreos/prometheus-operator/cmd/apidocgen
|
||||
@go install github.com/coreos/prometheus-operator/cmd/apidocgen
|
||||
|
||||
docs: embedmd apidocgen
|
||||
embedmd -w `find Documentation -name "*.md"`
|
||||
|
|
|
@ -20,10 +20,29 @@ This Document documents the types introduced by the Prometheus Operator to be co
|
|||
> Note this document is generated from code comments. When contributing a change to this document please do so by changing the code comments.`
|
||||
)
|
||||
|
||||
var (
|
||||
links = map[string]string{
|
||||
"metav1.ObjectMeta": "https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_objectmeta",
|
||||
"metav1.ListMeta": "https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_listmeta",
|
||||
"metav1.LabelSelector": "https://kubernetes.io/docs/api-reference/v1/definitions/#_unversioned_labelselector",
|
||||
"v1.ResourceRequirements": "https://kubernetes.io/docs/api-reference/v1/definitions/#_v1_resourcerequirements",
|
||||
}
|
||||
|
||||
selfLinks = map[string]string{}
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(firstParagraph)
|
||||
|
||||
types := ParseDocumentationFrom(os.Args[1])
|
||||
for _, t := range types {
|
||||
strukt := t[0]
|
||||
selfLinks[strukt.Name] = "#" + strings.ToLower(strukt.Name)
|
||||
}
|
||||
|
||||
// we need to parse once more to now add the self links
|
||||
types = ParseDocumentationFrom(os.Args[1])
|
||||
|
||||
for _, t := range types {
|
||||
strukt := t[0]
|
||||
fmt.Printf("\n## %s\n\n%s\n\n", strukt.Name, strukt.Doc)
|
||||
|
@ -32,7 +51,7 @@ func main() {
|
|||
fmt.Println("| ----- | ----------- | ------ | -------- |")
|
||||
fields := t[1:(len(t))]
|
||||
for _, f := range fields {
|
||||
fmt.Println("|", f.Name, "|", f.Doc, "| `"+f.Type+"` |", f.Mandatory, "|")
|
||||
fmt.Println("|", f.Name, "|", f.Doc, "|", f.Type, "|", f.Mandatory, "|")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -131,6 +150,24 @@ func fmtRawDoc(rawDoc string) string {
|
|||
return postDoc
|
||||
}
|
||||
|
||||
func toLink(typeName string) string {
|
||||
selfLink, hasSelfLink := selfLinks[typeName]
|
||||
if hasSelfLink {
|
||||
return wrapInLink(typeName, selfLink)
|
||||
}
|
||||
|
||||
link, hasLink := links[typeName]
|
||||
if hasLink {
|
||||
return wrapInLink(typeName, link)
|
||||
}
|
||||
|
||||
return typeName
|
||||
}
|
||||
|
||||
func wrapInLink(text, link string) string {
|
||||
return fmt.Sprintf("[%s](%s)", text, link)
|
||||
}
|
||||
|
||||
// fieldName returns the name of the field as it should appear in JSON format
|
||||
// "-" indicates that this field is not part of the JSON representation
|
||||
func fieldName(field *ast.Field) string {
|
||||
|
@ -166,19 +203,19 @@ func fieldRequired(field *ast.Field) bool {
|
|||
func fieldType(typ ast.Expr) string {
|
||||
switch typ.(type) {
|
||||
case *ast.Ident:
|
||||
return typ.(*ast.Ident).Name
|
||||
return toLink(typ.(*ast.Ident).Name)
|
||||
case *ast.StarExpr:
|
||||
return "*" + fieldType(typ.(*ast.StarExpr).X)
|
||||
return "*" + toLink(fieldType(typ.(*ast.StarExpr).X))
|
||||
case *ast.SelectorExpr:
|
||||
e := typ.(*ast.SelectorExpr)
|
||||
pkg := e.X.(*ast.Ident)
|
||||
t := e.Sel
|
||||
return pkg.Name + "." + t.Name
|
||||
return toLink(pkg.Name + "." + t.Name)
|
||||
case *ast.ArrayType:
|
||||
return "[]" + fieldType(typ.(*ast.ArrayType).Elt)
|
||||
return "[]" + toLink(fieldType(typ.(*ast.ArrayType).Elt))
|
||||
case *ast.MapType:
|
||||
mapType := typ.(*ast.MapType)
|
||||
return "map[" + fieldType(mapType.Key) + "]" + fieldType(mapType.Value)
|
||||
return "map[" + toLink(fieldType(mapType.Key)) + "]" + toLink(fieldType(mapType.Value))
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue