Documentation
¶
Index ¶
- Variables
- func CarryRecordingRuleVersion(src, dst *dash0api.RecordingRule)
- func DetectSpamFilterAPIVersion(data []byte) (string, error)
- func KindDisplayName(kind string) string
- func PrintDiff(w io.Writer, displayKind, name string, before, after any) error
- func PrometheusRuleHasAlerts(crd *dash0api.RecordingRule) bool
- func ReadDefinition(path string, target interface{}, stdin io.Reader) error
- func ReadDefinitionFile(path string, target interface{}) error
- func ReadRawInput(path string, stdin io.Reader) ([]byte, error)
- func RecordingOnlyPrometheusRule(crd *dash0api.RecordingRule) *dash0api.RecordingRule
- func RegisterCommonFlags(cmd *cobra.Command, flags *CommonFlags)
- func RegisterDeleteFlags(cmd *cobra.Command, flags *DeleteFlags)
- func RegisterFileInputFlags(cmd *cobra.Command, flags *FileInputFlags)
- func RegisterGetFlags(cmd *cobra.Command, flags *GetFlags)
- func RegisterListFlags(cmd *cobra.Command, flags *ListFlags)
- func WriteDefinitionFile(path string, data interface{}) error
- func WriteToStdout(format string, data interface{}) error
- type CommonFlags
- type DeleteFlags
- type FileInputFlags
- type GetFlags
- type ImportAction
- type ImportResult
- func ImportCheckRule(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportDashboard(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportNotificationChannel(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportRecordingRule(ctx context.Context, apiClient dash0api.Client, rule *dash0api.RecordingRule, ...) (ImportResult, error)
- func ImportSpamFilter(ctx context.Context, apiClient dash0api.Client, filter *dash0api.SpamFilter, ...) (ImportResult, error)
- func ImportSpamFilterV1Alpha2(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportSyntheticCheck(ctx context.Context, apiClient dash0api.Client, ...) (ImportResult, error)
- func ImportView(ctx context.Context, apiClient dash0api.Client, view *dash0api.ViewDefinition, ...) (ImportResult, error)
- type ListFlags
Constants ¶
This section is empty.
Variables ¶
var SpamFilterSupportedAPIVersions = []string{ string(dash0api.SpamFilterApiVersionV1Alpha1V1alpha1), string(dash0api.V1alpha2), }
SpamFilterSupportedAPIVersions lists the spam filter apiVersion values the CLI understands. Exported so callers can render the supported list in their own error messages.
Functions ¶
func CarryRecordingRuleVersion ¶ added in v1.11.0
func CarryRecordingRuleVersion(src, dst *dash0api.RecordingRule)
CarryRecordingRuleVersion copies the version label from src to dst so that update requests include the optimistic-locking version the API currently requires.
func DetectSpamFilterAPIVersion ¶ added in v1.12.2
DetectSpamFilterAPIVersion peeks at the apiVersion field on a YAML or JSON spam filter document so the caller can route to the matching client method. A missing value defaults to v1alpha1, matching the API client's decodeSpamFilterObject behavior. An unsupported value is rejected with the list of supported versions so the user knows what to fix.
func KindDisplayName ¶ added in v1.1.0
KindDisplayName returns the human-readable name for an asset kind. Multi-word kinds like "CheckRule" become "Check rule" and "SyntheticCheck" becomes "Synthetic check".
func PrintDiff ¶ added in v1.7.0
PrintDiff computes a unified diff between the before and after states of an asset and writes it to w. If there are no changes, a "no changes" message is printed instead.
func PrometheusRuleHasAlerts ¶ added in v1.12.2
func PrometheusRuleHasAlerts(crd *dash0api.RecordingRule) bool
PrometheusRuleHasAlerts reports whether any rule in the CRD is an alerting rule (has `alert:` set). Used by apply to decide whether to dispatch to the check-rule import path.
func ReadDefinition ¶
ReadDefinition reads a YAML or JSON definition from a file or stdin. If path is "-" or empty, it reads from stdin (assumes YAML format). Otherwise, it reads from the file at the given path.
func ReadDefinitionFile ¶
ReadDefinitionFile reads a YAML or JSON file and unmarshals into the target. It auto-detects the format based on file extension, falling back to YAML first.
func ReadRawInput ¶ added in v1.1.0
ReadRawInput reads raw bytes from a file or stdin without unmarshalling. If path is "-" or empty, it reads from stdin.
func RecordingOnlyPrometheusRule ¶ added in v1.12.2
func RecordingOnlyPrometheusRule(crd *dash0api.RecordingRule) *dash0api.RecordingRule
RecordingOnlyPrometheusRule returns a copy of the input PrometheusRule CRD stripped of alerting rules so it can be sent to the recording-rules API. Returns nil if the input contains no recording rules. Empty groups (after filtering) are dropped.
func RegisterCommonFlags ¶
func RegisterCommonFlags(cmd *cobra.Command, flags *CommonFlags)
RegisterCommonFlags adds common flags to a command
func RegisterDeleteFlags ¶
func RegisterDeleteFlags(cmd *cobra.Command, flags *DeleteFlags)
RegisterDeleteFlags adds delete-specific flags to a command
func RegisterFileInputFlags ¶
func RegisterFileInputFlags(cmd *cobra.Command, flags *FileInputFlags)
RegisterFileInputFlags adds file input flags to a command and marks -f as required
func RegisterGetFlags ¶
RegisterGetFlags adds get-specific flags to a command
func RegisterListFlags ¶
RegisterListFlags adds list-specific flags to a command
func WriteDefinitionFile ¶
WriteDefinitionFile writes data to a YAML or JSON file. It auto-detects the format based on file extension, defaulting to YAML.
func WriteToStdout ¶
WriteToStdout writes data to stdout in the specified format. Format can be "yaml", "yml", or "json".
Types ¶
type CommonFlags ¶
CommonFlags holds common flag values used across all asset commands
type DeleteFlags ¶
type DeleteFlags struct {
CommonFlags
Force bool
}
DeleteFlags holds flags specific to delete commands
type FileInputFlags ¶
type FileInputFlags struct {
CommonFlags
File string
DryRun bool
}
FileInputFlags holds flags for file-based input operations (create, update, apply)
type ImportAction ¶ added in v1.1.0
type ImportAction string
ImportAction indicates whether an asset was created or updated.
const ( ActionCreated ImportAction = "created" ActionUpdated ImportAction = "updated" )
type ImportResult ¶ added in v1.1.0
type ImportResult struct {
Name string
ID string
Action ImportAction
Before any // asset state before update (nil for creates)
After any // asset state after update/create
}
ImportResult holds the outcome of importing an asset.
func ImportCheckRule ¶ added in v1.1.0
func ImportCheckRule(ctx context.Context, apiClient dash0api.Client, rule *dash0api.PrometheusAlertRule, dataset *string) (ImportResult, error)
ImportCheckRule creates or updates a check rule via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the rule already exists. When the input has no ID, CREATE is used and the server assigns an ID.
func ImportDashboard ¶ added in v1.1.0
func ImportDashboard(ctx context.Context, apiClient dash0api.Client, dashboard *dash0api.DashboardDefinition, dataset *string) (ImportResult, error)
ImportDashboard creates or updates a dashboard via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the dashboard already exists. When the input has no ID, CREATE is used and the server assigns an ID.
func ImportNotificationChannel ¶ added in v1.9.0
func ImportNotificationChannel(ctx context.Context, apiClient dash0api.Client, channel *dash0api.NotificationChannelDefinition) (ImportResult, error)
ImportNotificationChannel creates or updates a notification channel via the standard CRUD APIs. When the input has a user-defined ID (via dash0.com/origin label), UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the channel already exists. When the input has no origin, CREATE is used and the server assigns an ID.
func ImportRecordingRule ¶ added in v1.11.0
func ImportRecordingRule(ctx context.Context, apiClient dash0api.Client, rule *dash0api.RecordingRule, dataset *string) (ImportResult, error)
ImportRecordingRule creates or updates a recording rule via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the rule already exists. When the input has no ID, CREATE is used and the server assigns an ID.
func ImportSpamFilter ¶ added in v1.12.0
func ImportSpamFilter(ctx context.Context, apiClient dash0api.Client, filter *dash0api.SpamFilter, dataset *string) (ImportResult, error)
ImportSpamFilter creates or updates a v1alpha1 spam filter via the standard CRUD APIs.
Upsert key selection — important quirk of the spam filter API:
- If the input has a user-defined origin (label `dash0.com/origin`), the origin is used as the upsert key. PUT to /spam-filters/{origin} creates the asset on first call and updates it on subsequent calls. This is the only reliable path to idempotent `apply`.
- If the input has a user-defined ID (label `dash0.com/id`) but no origin, the ID is used as the upsert key. The server only honors this when a record already exists at that ID — a PUT to a brand-new ID generates a fresh server-side ID, so user-defined-id-only flows do not get true idempotency.
- Otherwise, CREATE is used and the server assigns an ID.
dash0.com/id is captured before StripSpamFilterServerFields runs because that helper clears the id label along with the server source label.
func ImportSpamFilterV1Alpha2 ¶ added in v1.12.2
func ImportSpamFilterV1Alpha2(ctx context.Context, apiClient dash0api.Client, filter *dash0api.SpamFilterV1Alpha2, dataset *string) (ImportResult, error)
ImportSpamFilterV1Alpha2 mirrors ImportSpamFilter for the v1alpha2 schema. The v1alpha2 type carries spec.context (scalar) instead of spec.contexts (array); the rest of the lifecycle — upsert-key selection (origin first, ID fallback), existence check via GetSpamFilter, create-vs-update routing — is identical. See ImportSpamFilter for the rationale.
func ImportSyntheticCheck ¶ added in v1.1.0
func ImportSyntheticCheck(ctx context.Context, apiClient dash0api.Client, check *dash0api.SyntheticCheckDefinition, dataset *string) (ImportResult, error)
ImportSyntheticCheck creates or updates a synthetic check via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the check already exists. When the input has no ID, CREATE is used and the server assigns an ID.
func ImportView ¶ added in v1.1.0
func ImportView(ctx context.Context, apiClient dash0api.Client, view *dash0api.ViewDefinition, dataset *string) (ImportResult, error)
ImportView creates or updates a view via the standard CRUD APIs. When the input has a user-defined ID, UPDATE is always used — PUT has create-or-replace semantics, so this is idempotent regardless of whether the view already exists. When the input has no ID, CREATE is used and the server assigns an ID.