model

package
v0.0.0-...-600007b Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APITypeOpenAPI  = "openapi"
	APITypeAsyncAPI = "asyncapi"
	APITypeGraphQL  = "graphql"
	APITypeGRPC     = "grpc"

	APILifecycleExperimental = "experimental"
	APILifecycleProduction   = "production"
	APILifecycleDeprecated   = "deprecated"
)
View Source
const (
	ComponentTypeService = "service"
	ComponentTypeWebsite = "website"
	ComponentTypeLibrary = "library"

	ComponentLifecycleExperimental = "experimental"
	ComponentLifecycleProduction   = "production"
	ComponentLifecycleDeprecated   = "deprecated"
)
View Source
const (
	KindAPI       = "api"
	KindComponent = "component"
	KindGroup     = "group"
	KindResource  = "resource"
	KindSystem    = "system"
	KindUser      = "user"
)

Variables

View Source
var (
	TestOwnerEntityRef = EntityRef{
		Kind:      KindUser,
		Namespace: "default",
		Name:      "owner",
	}
	TestOwner2EntityRef = EntityRef{
		Kind:      KindUser,
		Namespace: "default",
		Name:      "owner2",
	}
	TestSystemEntityRef = EntityRef{
		Kind:      KindSystem,
		Namespace: "default",
		Name:      "down",
	}
	TestSystem2EntityRef = EntityRef{
		Kind:      KindSystem,
		Namespace: "default",
		Name:      "shock",
	}
	TestComponentEntityRef = EntityRef{
		Kind:      KindComponent,
		Namespace: "default",
		Name:      "component",
	}
	TestComponent2EntityRef = EntityRef{
		Kind:      KindComponent,
		Namespace: "default",
		Name:      "component2",
	}
	TestAPI1EntityRef = EntityRef{
		Kind:      KindAPI,
		Namespace: "default",
		Name:      "api1",
	}
	TestAPI2EntityRef = EntityRef{
		Kind:      KindAPI,
		Namespace: "default",
		Name:      "api2",
	}
	TestUser2EntityRef = EntityRef{
		Kind:      KindUser,
		Namespace: "default",
		Name:      "user2",
	}
	TestGroupEntityRef = EntityRef{
		Kind:      KindGroup,
		Namespace: "default",
		Name:      "group",
	}
	TestGroup2EntityRef = EntityRef{
		Kind:      KindGroup,
		Namespace: "default",
		Name:      "group2",
	}
	TestResource1EntityRef = EntityRef{
		Kind:      KindResource,
		Namespace: "default",
		Name:      "resource1",
	}
	TestResource2EntityRef = EntityRef{
		Kind:      KindResource,
		Namespace: "default",
		Name:      "resource2",
	}

	TestFullEntity = Entity{
		APIVersion: "backstage.io/v1alpha1",
		Kind:       "unknown",
		Metadata: Metadata{
			Name:        "my-service",
			Namespace:   "my-namespace",
			Title:       "my-title",
			Description: "my-description",
			Labels: map[string]string{
				"key1": "value1",
				"key2": "value2",
				"key3": "value3",
			},
			Annotations: map[string]string{
				"keya": "valuea",
				"keyb": "valueb",
				"keyc": "valuec",
			},
			Tags: []string{"tag1", "tag2", "tag3"},
			Links: []Link{
				{
					URL:   "http://example.com/url1",
					Title: "link1",
					Icon:  "icon1",
					Type:  "linktype1",
				},
				{
					URL:   "http://example.com/url2",
					Title: "link2",
					Icon:  "icon2",
					Type:  "linktype2",
				},
			},
		},
	}
	TestFullComponent = Component{
		Entity: TestFullEntity,
		Spec: ComponentSpec{
			Type:           ComponentTypeService,
			Lifecycle:      ComponentLifecycleExperimental,
			Owner:          TestOwnerEntityRef,
			System:         TestSystemEntityRef,
			SubcomponentOf: TestComponentEntityRef,
			ProvidesAPIs: []EntityRef{
				TestAPI1EntityRef,
			},
			ConsumesAPIs: []EntityRef{
				TestAPI2EntityRef,
			},
			DependsOn: []EntityRef{
				TestResource1EntityRef,
			},
			DependencyOf: []EntityRef{
				TestResource2EntityRef,
			},
		},
	}
	TestFullAPI = API{
		Entity: TestFullEntity,
		Spec: APISpec{
			Type:       APITypeOpenAPI,
			Lifecycle:  APILifecycleExperimental,
			Owner:      TestOwnerEntityRef,
			System:     TestSystemEntityRef,
			Definition: "definition",
		},
	}
	TestFullUser = User{
		Entity: TestFullEntity,
		Spec: UserSpec{
			Profile: UserProfile{
				DisplayName: "displayName",
				Email:       "email",
				Picture:     "picture",
			},
			MemberOf: []EntityRef{
				TestGroupEntityRef,
			},
		},
	}
	TestFullGroup = Group{
		Entity: TestFullEntity,
		Spec: GroupSpec{
			Type: "team",
			Profile: GroupProfile{
				DisplayName: "displayName",
				Email:       "email",
				Picture:     "picture",
			},
			Parent: TestGroupEntityRef,
			Children: []EntityRef{
				{
					Kind:      KindGroup,
					Namespace: "default",
					Name:      "child",
				},
			},
			Members: []EntityRef{
				TestFullUser.EntityRef(),
			},
		},
	}

	TestMinimalEntity = Entity{
		APIVersion: "backstage.io/v1alpha1",
		Kind:       KindAPI,
		Metadata: Metadata{
			Name:      "my-service",
			Namespace: "my-namespace",
		},
	}
)

Functions

This section is empty.

Types

type API

type API struct {
	Entity `yaml:"entity,inline"`
	Spec   APISpec `yaml:"spec"`
}

type APISpec

type APISpec struct {
	Type       string    `yaml:"type"`
	Lifecycle  string    `yaml:"lifecycle"`
	Owner      EntityRef `yaml:"owner"`
	System     EntityRef `yaml:"system,omitempty"`
	Definition string    `yaml:"definition"`
}

type Component

type Component struct {
	Entity `yaml:"entity,inline"`
	Spec   ComponentSpec `yaml:"spec"`
}

type ComponentSpec

type ComponentSpec struct {
	Type           string      `yaml:"type"`
	Lifecycle      string      `yaml:"lifecycle"`
	Owner          EntityRef   `yaml:"owner"`
	System         EntityRef   `yaml:"system,omitempty"`
	SubcomponentOf EntityRef   `yaml:"subcomponentOf,omitempty"`
	ProvidesAPIs   []EntityRef `yaml:"providesApis,omitempty"`
	ConsumesAPIs   []EntityRef `yaml:"consumesApis,omitempty"`
	DependsOn      []EntityRef `yaml:"dependsOn,omitempty"`
	DependencyOf   []EntityRef `yaml:"dependencyOf,omitempty"`
}

type Entity

type Entity struct {
	ID         int64    `yaml:"-"`
	APIVersion string   `yaml:"apiVersion"`
	Kind       string   `yaml:"kind"`
	Metadata   Metadata `yaml:"metadata"`
}

func (Entity) EntityRef

func (e Entity) EntityRef() EntityRef

type EntityRef

type EntityRef struct {
	Kind      string
	Namespace string
	Name      string
}

func MakeEntityRef

func MakeEntityRef(s string) (EntityRef, error)

func (EntityRef) Empty

func (e EntityRef) Empty() bool

func (EntityRef) MarshalYAML

func (e EntityRef) MarshalYAML() (any, error)

func (*EntityRef) Scan

func (e *EntityRef) Scan(src any) error

func (EntityRef) String

func (e EntityRef) String() string

func (*EntityRef) UnmarshalYAML

func (e *EntityRef) UnmarshalYAML(value *yaml.Node) error

func (EntityRef) Value

func (e EntityRef) Value() (driver.Value, error)

type EntityRefs

type EntityRefs struct {
	// contains filtered or unexported fields
}

func MakeEntityRefs

func MakeEntityRefs(items []EntityRef) EntityRefs

func (EntityRefs) Items

func (es EntityRefs) Items() []EntityRef

func (*EntityRefs) Scan

func (es *EntityRefs) Scan(src any) error

func (EntityRefs) Value

func (e EntityRefs) Value() (driver.Value, error)

type Group

type Group struct {
	Entity
	Spec GroupSpec `yaml:"spec"`
}

type GroupProfile

type GroupProfile struct {
	DisplayName string `yaml:"displayName,omitempty"`
	Email       string `yaml:"email,omitempty"`
	Picture     string `yaml:"picture,omitempty"`
}

type GroupSpec

type GroupSpec struct {
	Type     string       `yaml:"type"`
	Profile  GroupProfile `yaml:"profile,omitempty"`
	Parent   EntityRef    `yaml:"parent,omitempty"`
	Children []EntityRef  `yaml:"children"`
	Members  []EntityRef  `yaml:"members,omitempty"`
}
type Link struct {
	URL   string `yaml:"url"`
	Title string `yaml:"title,omitempty"`
	Icon  string `yaml:"icon,omitempty"`
	Type  string `yaml:"type,omitempty"`
}

type Metadata

type Metadata struct {
	Name        string            `yaml:"name"`
	Namespace   string            `yaml:"namespace"`
	Title       string            `yaml:"title,omitempty"`
	Description string            `yaml:"description,omitempty"`
	Labels      map[string]string `yaml:"labels,omitempty"`
	Annotations map[string]string `yaml:"annotations,omitempty"`
	Tags        []string          `yaml:"tags,omitempty"`
	Links       []Link            `yaml:"links,omitempty"`
}

type SearchResults

type SearchResults struct {
	Results    []EntityRef `json:"results"`
	Limit      int         `json:"limit"`
	NextOffset int         `json:"nextOffset"`
}

type User

type User struct {
	Entity
	Spec UserSpec `yaml:"spec"`
}

type UserProfile

type UserProfile struct {
	DisplayName string `yaml:"displayName,omitempty"`
	Email       string `yaml:"email,omitempty"`
	Picture     string `yaml:"picture,omitempty"`
}

type UserSpec

type UserSpec struct {
	Profile  UserProfile `yaml:"profile,omitempty"`
	MemberOf []EntityRef `yaml:"memberOf"`
}

Jump to

Keyboard shortcuts

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