service

package
v0.0.0-...-6cdb919 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ChildTypeGroup used to indicate the 'Child' is a group
	ChildTypeGroup = "group"
	// ChildTypeApplication ...
	ChildTypeApplication = "application"
	// ChildTypeCluster ...
	ChildTypeCluster = "cluster"

	ChildTypeTemplate = "template"

	ChildTypeRelease = "release"
	// RootGroupID id of the root group, which is not actually exists in the group table
	RootGroupID = 0
)

Variables

This section is empty.

Functions

func GenerateIDToFull

func GenerateIDToFull(groups []*models.Group) map[uint]*Full

GenerateIDToFull assuming we have 3 groups, group one: {id: 1, name: "a", path: "w"} group two: {id: 2, name: "b", path: "r"} group three: {id: 3, name: "c", path: "j"}

after the function executed, we get a map:

{
  1: {
    fullName: "a",
    fullPath: "/w"
  },
  2: {
    fullName: "a/b",
    fullPath: "/w/r"
  },
  3: {
    fullName: "a/b/c",
    fullPath: "/w/r/j"
  },
}

func GenerateIDToGroup

func GenerateIDToGroup(groups []*models.Group) map[uint]*models.Group

GenerateIDToGroup map id to group

Types

type Child

type Child struct {
	ID              uint      `json:"id"`
	Name            string    `json:"name"`
	Path            string    `json:"path"`
	VisibilityLevel string    `json:"visibilityLevel"`
	Description     string    `json:"description"`
	ParentID        uint      `json:"parentID"`
	TraversalIDs    string    `json:"traversalIDs"`
	UpdatedAt       time.Time `json:"updatedAt"`
	FullName        string    `json:"fullName"`
	FullPath        string    `json:"fullPath"`
	Type            string    `json:"type"`
	ChildrenCount   int       `json:"childrenCount"`
	Children        []*Child  `json:"children"`
}

Child subResource of a group, including group & application

func ConvertApplicationToChild

func ConvertApplicationToChild(app *appmodels.Application, full *Full) *Child

func ConvertClusterToChild

func ConvertClusterToChild(cluster *clustermodels.Cluster, full *Full) *Child

func ConvertGroupOrApplicationToChild

func ConvertGroupOrApplicationToChild(groupOrApplication *models.GroupOrApplication, full *Full) *Child

ConvertGroupOrApplicationToChild format Child based on groupOrApplication

func ConvertGroupToChild

func ConvertGroupToChild(group *models.Group, full *Full) *Child

ConvertGroupToChild format Child based on group model、fullName、fullPath and resourceType

func ConvertReleaseToChild

func ConvertReleaseToChild(release *trmodels.TemplateRelease, full *Full) *Child

func ConvertTemplateToChild

func ConvertTemplateToChild(template *tmodels.Template, full *Full) *Child

type Full

type Full struct {
	FullName string `json:"fullName"`
	FullPath string `json:"fullPath"`
}

Full is the fullName&fullPath for a group/application/applicationInstance

func GenerateFullFromGroups

func GenerateFullFromGroups(groups []*models.Group) *Full

GenerateFullFromGroups generate fullPath which looks like /a/b/c, and fullName which looks like 1 / 2

type Service

type Service interface {
	// GetChildByID get a child by id
	GetChildByID(ctx context.Context, id uint) (*Child, error)
	// GetChildrenByIDs returns children map according to group ids
	GetChildrenByIDs(ctx context.Context, ids []uint) (map[uint]*Child, error)
}

func NewService

func NewService(manager *managerparam.Manager) Service

Jump to

Keyboard shortcuts

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