asset

package
v1.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToCheckRule added in v1.1.0

func ConvertToCheckRule(rule *PrometheusAlertingRule, groupInterval string, ruleID string) *dash0api.PrometheusAlertRule

ConvertToCheckRule converts a Prometheus alerting rule to a Dash0 CheckRule

func DeeplinkURL added in v1.2.0

func DeeplinkURL(apiUrl, assetType, assetID string) string

DeeplinkURL constructs a deeplink URL for the given asset type and ID. The base URL is derived from the API URL by extracting the domain suffix (e.g. "dash0.com" from "api.us-west-2.aws.dash0.com") and prepending "app.". Returns an empty string if the API URL is empty or cannot be parsed.

func DetectKind added in v1.1.0

func DetectKind(data []byte) string

DetectKind extracts the "kind" field from raw YAML/JSON bytes. When the document has no explicit "kind" (e.g. a check rule exported via `check-rules get -o yaml`), the kind is inferred from the document structure: the "expression" field is required for check rules and absent in all other asset types.

func ExtractDashboardDisplayName added in v1.1.0

func ExtractDashboardDisplayName(dashboard *dash0api.DashboardDefinition) string

ExtractDashboardDisplayName extracts the display name from a dashboard definition.

func KindDisplayName added in v1.1.0

func KindDisplayName(kind string) string

KindDisplayName returns the human-readable name for an asset kind. Multi-word kinds like "CheckRule" become "Check rule" and "SyntheticCheck" becomes "Synthetic check".

func ReadDefinition

func ReadDefinition(path string, target interface{}, stdin io.Reader) error

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

func ReadDefinitionFile(path string, target interface{}) error

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

func ReadRawInput(path string, stdin io.Reader) ([]byte, error)

ReadRawInput reads raw bytes from a file or stdin without unmarshalling. If path is "-" or empty, it reads from stdin.

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

func RegisterGetFlags(cmd *cobra.Command, flags *GetFlags)

RegisterGetFlags adds get-specific flags to a command

func RegisterListFlags

func RegisterListFlags(cmd *cobra.Command, flags *ListFlags)

RegisterListFlags adds list-specific flags to a command

func ViewDeeplinkURL added in v1.5.1

func ViewDeeplinkURL(apiUrl, viewType, assetID string) string

ViewDeeplinkURL constructs a deeplink URL for a view, using the view's type to determine the correct path (e.g. /goto/spans for span views, /goto/logs for log views). Returns an empty string if the API URL is empty, cannot be parsed, or the view type is unknown.

func WriteDefinitionFile

func WriteDefinitionFile(path string, data interface{}) error

WriteDefinitionFile writes data to a YAML or JSON file. It auto-detects the format based on file extension, defaulting to YAML.

func WriteToStdout

func WriteToStdout(format string, data interface{}) error

WriteToStdout writes data to stdout in the specified format. Format can be "yaml", "yml", or "json".

Types

type CommonFlags

type CommonFlags struct {
	ApiUrl    string
	AuthToken string
	Dataset   string
	Output    string
}

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 GetFlags

type GetFlags struct {
	CommonFlags
}

GetFlags holds flags specific to get commands

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
}

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 checks existence by rule ID, strips the ID when the asset is not found, and calls the import API.

func ImportDashboard added in v1.1.0

func ImportDashboard(ctx context.Context, apiClient dash0api.Client, dashboard *dash0api.DashboardDefinition, dataset *string) (ImportResult, error)

ImportDashboard checks existence by dash0Extensions.id, strips server-generated fields when the asset is not found, and calls the import API. The import API uses dash0Extensions.id as the upsert key; when the input has no id, a fresh UUID is generated so re-applying the exported YAML updates the dashboard instead of creating a duplicate.

func ImportPrometheusRule added in v1.1.0

func ImportPrometheusRule(ctx context.Context, apiClient dash0api.Client, promRule *PrometheusRule, dataset *string) ([]ImportResult, error)

ImportPrometheusRule extracts alerting rules from a PrometheusRule CRD, converts each to a Dash0 CheckRule, and imports them. Returns one result per rule. On partial failure, returns the successfully imported results along with the error.

func ImportSyntheticCheck added in v1.1.0

func ImportSyntheticCheck(ctx context.Context, apiClient dash0api.Client, check *dash0api.SyntheticCheckDefinition, dataset *string) (ImportResult, error)

ImportSyntheticCheck checks existence by Dash0Comid, strips server-generated fields, and calls the import API.

func ImportView added in v1.1.0

func ImportView(ctx context.Context, apiClient dash0api.Client, view *dash0api.ViewDefinition, dataset *string) (ImportResult, error)

ImportView checks existence by Dash0Comid, strips server-generated fields, and calls the import API.

type ListFlags

type ListFlags struct {
	CommonFlags
	Limit      int
	All        bool
	SkipHeader bool
}

ListFlags holds flags specific to list commands

type PrometheusAlertingRule added in v1.1.0

type PrometheusAlertingRule struct {
	Alert       string            `yaml:"alert,omitempty" json:"alert,omitempty"`
	Expr        string            `yaml:"expr" json:"expr"`
	For         string            `yaml:"for,omitempty" json:"for,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
}

PrometheusAlertingRule represents an individual alerting rule within a group

type PrometheusRule added in v1.1.0

type PrometheusRule struct {
	APIVersion string                 `yaml:"apiVersion" json:"apiVersion"`
	Kind       string                 `yaml:"kind" json:"kind"`
	Metadata   PrometheusRuleMetadata `yaml:"metadata" json:"metadata"`
	Spec       PrometheusRuleSpec     `yaml:"spec" json:"spec"`
}

PrometheusRule represents the Prometheus Operator PrometheusRule CRD

type PrometheusRuleGroup added in v1.1.0

type PrometheusRuleGroup struct {
	Name     string                   `yaml:"name" json:"name"`
	Interval string                   `yaml:"interval,omitempty" json:"interval,omitempty"`
	Rules    []PrometheusAlertingRule `yaml:"rules" json:"rules"`
}

PrometheusRuleGroup represents a group of alerting rules

type PrometheusRuleMetadata added in v1.1.0

type PrometheusRuleMetadata struct {
	Name        string            `yaml:"name,omitempty" json:"name,omitempty"`
	Namespace   string            `yaml:"namespace,omitempty" json:"namespace,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty" json:"annotations,omitempty"`
}

PrometheusRuleMetadata contains metadata for a PrometheusRule

type PrometheusRuleSpec added in v1.1.0

type PrometheusRuleSpec struct {
	Groups []PrometheusRuleGroup `yaml:"groups" json:"groups"`
}

PrometheusRuleSpec contains the spec for a PrometheusRule

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL