annotation

package
v0.90.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package annotation defines Annotation object definitions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Annotation

type Annotation struct {
	APIVersion manifest.Version `json:"apiVersion"`
	Kind       manifest.Kind    `json:"kind"`
	Metadata   Metadata         `json:"metadata"`
	Spec       Spec             `json:"spec"`
	Status     *Status          `json:"status,omitempty"`

	Organization   string `json:"organization,omitempty"`
	ManifestSource string `json:"manifestSrc,omitempty"`
}
Example
package main

import (
	"context"
	"log"
	"time"

	"github.com/nobl9/nobl9-go/internal/examples"
	"github.com/nobl9/nobl9-go/manifest"
	"github.com/nobl9/nobl9-go/manifest/v1alpha/annotation"
)

func main() {
	// Create the object:
	myAnnotation := annotation.New(
		annotation.Metadata{
			Name:    "my-annotation",
			Project: "my-project",
		},
		annotation.Spec{
			Slo:           "existing-slo",
			ObjectiveName: "existing-slo-objective-1",
			Description:   "Example annotation",
			StartTime:     time.Date(2023, 5, 1, 17, 10, 5, 0, time.UTC),
			EndTime:       time.Date(2023, 5, 2, 17, 10, 5, 0, time.UTC),
		},
	)
	// Verify the object:
	if err := myAnnotation.Validate(); err != nil {
		log.Fatalf("annotation validation failed, err: %v", err)
	}
	// Apply the object:
	client := examples.GetOfflineEchoClient()
	if err := client.Objects().V1().Apply(context.Background(), []manifest.Object{myAnnotation}); err != nil {
		log.Fatalf("failed to apply annotation, err: %v", err)
	}
}
Output:

apiVersion: n9/v1alpha
kind: Annotation
metadata:
  name: my-annotation
  project: my-project
spec:
  slo: existing-slo
  objectiveName: existing-slo-objective-1
  description: Example annotation
  startTime: 2023-05-01T17:10:05Z
  endTime: 2023-05-02T17:10:05Z

func New

func New(metadata Metadata, spec Spec) Annotation

New creates a new Annotation based on provided Metadata nad Spec.

func (Annotation) GetKind

func (a Annotation) GetKind() manifest.Kind

func (Annotation) GetManifestSource

func (a Annotation) GetManifestSource() string

func (Annotation) GetName

func (a Annotation) GetName() string

func (Annotation) GetOrganization

func (a Annotation) GetOrganization() string

func (Annotation) GetProject

func (a Annotation) GetProject() string

func (Annotation) GetValidator added in v0.82.0

func (a Annotation) GetValidator() govy.Validator[Annotation]

func (Annotation) GetVersion

func (a Annotation) GetVersion() manifest.Version

func (Annotation) SetManifestSource

func (a Annotation) SetManifestSource(src string) manifest.Object

func (Annotation) SetOrganization

func (a Annotation) SetOrganization(org string) manifest.Object

func (Annotation) SetProject

func (a Annotation) SetProject(project string) manifest.Object

func (Annotation) Validate

func (a Annotation) Validate() error

type Metadata

type Metadata struct {
	Name    string `json:"name"`
	Project string `json:"project,omitempty"`
}

type Spec

type Spec struct {
	Slo           string    `json:"slo"`
	ObjectiveName string    `json:"objectiveName,omitempty"`
	Description   string    `json:"description"`
	StartTime     time.Time `json:"startTime"`
	EndTime       time.Time `json:"endTime"`
	Category      string    `json:"category,omitempty"`
}

type Status

type Status struct {
	UpdatedAt string `json:"updatedAt"`
	IsSystem  bool   `json:"isSystem"`
}

Status represents content of Status optional for Annotation Object

Jump to

Keyboard shortcuts

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