export

package
v0.7.17-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const GetChartListFunc = "getChartListFunc"
View Source
const GetChartsByteFunc = "getChartsByteFunc"

Variables

This section is empty.

Functions

func Chart

func Chart(item command.OperationItem) command.RunErr

Chart 批量下载chart

func GetChartList

func GetChartList(executor *ChartExecutor) ([]byte, error)

func GetChartsByte

func GetChartsByte(list []ChartItem, executor *ChartExecutor) (map[string][]byte, error)

func HarborImageList

func HarborImageList(item command.OperationItem) command.RunErr

HarborImageList harbor镜像列表导出

func LocalImageList

func LocalImageList()

LocalImageList 本地镜像tag列表

Types

type Artifact

type Artifact struct {
	AdditionLinks struct {
		BuildHistory struct {
			Absolute bool   `json:"absolute"`
			Href     string `json:"href"`
		} `json:"build_history"`
		Vulnerabilities struct {
			Absolute bool   `json:"absolute"`
			Href     string `json:"href"`
		} `json:"vulnerabilities"`
	} `json:"addition_links"`
	Digest     string `json:"digest"`
	ExtraAttrs struct {
		Architecture string      `json:"architecture"`
		Author       interface{} `json:"author"`
		Created      time.Time   `json:"created"`
		Os           string      `json:"os"`
	} `json:"extra_attrs"`
	Icon              string        `json:"icon"`
	Id                int           `json:"id"`
	Labels            interface{}   `json:"labels"`
	ManifestMediaType string        `json:"manifest_media_type"`
	MediaType         string        `json:"media_type"`
	ProjectId         int           `json:"project_id"`
	PullTime          time.Time     `json:"pull_time"`
	PushTime          time.Time     `json:"push_time"`
	References        interface{}   `json:"references"`
	RepositoryId      int           `json:"repository_id"`
	Size              int           `json:"size"`
	Tags              []TagExternel `json:"tags"`
	Type              string        `json:"type"`
}

Artifact 用于反序列化制品属性

type ChartExecutor

type ChartExecutor struct {
	Config         ChartRepoConfig
	Logger         *logrus.Logger
	ChartListFunc  getChartListFunc
	ChartsByteFunc getChartsByteFunc
}

ChartExecutor 与helm仓库交互的执行器

func (*ChartExecutor) List

func (executor *ChartExecutor) List() ([]ChartItem, error)

List 获取chart列表

func (*ChartExecutor) Save

func (executor *ChartExecutor) Save(list []ChartItem) error

Save 保存chart列表

type ChartItem

type ChartItem struct {
	Name          string    `json:"name"`
	TotalVersions int       `json:"total_versions"`
	LatestVersion string    `json:"latest_version"`
	Created       time.Time `json:"created"`
	Updated       time.Time `json:"updated"`
	Icon          string    `json:"icon"`
	Home          string    `json:"home"`
	Deprecated    bool      `json:"deprecated"`
}

ChartItem chart对象,用于反序列化

type ChartRepoConfig

type ChartRepoConfig struct {
	HelmRepo HelmRepo `yaml:"helm-Repository"`
}

ChartRepoConfig chart仓库实体

type ChartService

type ChartService interface {
	List() ([]ChartItem, error)
}

type HarborConfig

type HarborConfig struct {
	Schema      string
	Address     string
	Domain      string
	User        string
	Password    string
	PreserveDir string
	Projects    []string
	Excludes    []string
}

HarborConfig harbor-repo对象配置,用于内部使用

type HarborConfigExternel

type HarborConfigExternel struct {
	HarborRepo struct {
		Schema      string   `yaml:"schema"`
		Address     string   `yaml:"address"`
		Domain      string   `yaml:"domain"`
		User        string   `yaml:"user"`
		Password    string   `yaml:"password"`
		PreserveDir string   `yaml:"preserve-dir"`
		Projects    []string `yaml:"projects"`
		Excludes    []string `yaml:"excludes"`
	} `yaml:"harbor-repo"`
}

HarborConfigExternel 用于反序列化harbor-repo对象配置

type HarborExecutor

type HarborExecutor struct {
	HarborConfig   HarborConfig
	Logger         *logrus.Logger
	ProjectSlice   []ProjectInternel
	ReposInProject map[string][]string // 项目下镜像repo集合
	TagsInProject  map[string][]string // 项目下镜像tag集合
}

HarborExecutor 与harbor交互的执行器

func ParseHarborConfig

func ParseHarborConfig(b []byte, logger *logrus.Logger) (*HarborExecutor, error)

ParseHarborConfig 解析harbor配置

func (*HarborExecutor) AllProjects

func (executor *HarborExecutor) AllProjects() error

AllProjects 获取harbor所有projects

func (*HarborExecutor) FilterProjects

func (executor *HarborExecutor) FilterProjects() error

FilterProjects 过滤排除的project

func (*HarborExecutor) GenerateImageList

func (executor *HarborExecutor) GenerateImageList() error

GenerateImageList 生成文件

func (*HarborExecutor) ListRepoByPage

func (executor *HarborExecutor) ListRepoByPage(page int, projectName string) ([]Repository, error)

ListRepoByPage 调用harbor api获取project列表,根据project name获取repo列表

func (*HarborExecutor) ProjectList

func (executor *HarborExecutor) ProjectList() error

ProjectList 获取所有projects

func (*HarborExecutor) ProjectsByName

func (executor *HarborExecutor) ProjectsByName(projectName string) (ProjectInternel, error)

ProjectsByName 按名称获取harbor内的项目

func (*HarborExecutor) ProjectsByNames

func (executor *HarborExecutor) ProjectsByNames(projectsName []string) error

ProjectsByNames 按名称集合获取harbor内的项目

func (*HarborExecutor) ProjectsByPage

func (executor *HarborExecutor) ProjectsByPage(page int) ([]ProjectInternel, error)

ProjectsByPage 按页查询harbor内project

func (*HarborExecutor) ReposWithinProject

func (executor *HarborExecutor) ReposWithinProject(projectName string) error

ReposWithinProject 获取项目下repo列表

func (*HarborExecutor) ReposWithinProjects

func (executor *HarborExecutor) ReposWithinProjects() error

ReposWithinProjects 获取多个项目内repo集合

func (*HarborExecutor) TagsWithinProject

func (executor *HarborExecutor) TagsWithinProject(projectName string) ([]string, error)

TagsWithinProject 按`project name + Repository name`查询所有镜像tag

func (*HarborExecutor) TagsWithinProjects

func (executor *HarborExecutor) TagsWithinProjects() error

TagsWithinProjects 获取项目下镜像tag列表

func (*HarborExecutor) TagsWithinRepo

func (executor *HarborExecutor) TagsWithinRepo(projectName string, repoName string) ([]string, error)

TagsWithinRepo 按`project name + Repository name`查询所有镜像tag

func (*HarborExecutor) TagsWithinRepoByPage

func (executor *HarborExecutor) TagsWithinRepoByPage(page int, projectName string, repoName string) ([]string, error)

TagsWithinRepoByPage 获取repo的全部tag

type HelmRepo

type HelmRepo struct {
	Endpoint    string `yaml:"endpoint"`
	Username    string `yaml:"username"`
	Password    string `yaml:"password"`
	PreserveDir string `yaml:"preserveDir"`
	Package     bool   `yaml:"package"`
	RepoName    string `yaml:"Repository-name"`
}

HelmRepo helm仓库配置

type ProjectExternel

type ProjectExternel struct {
	CreationTime       time.Time `json:"creation_time"`
	CurrentUserRoleId  int       `json:"current_user_role_id"`
	CurrentUserRoleIds []int     `json:"current_user_role_ids"`
	CveAllowlist       struct {
		CreationTime time.Time     `json:"creation_time"`
		Id           int           `json:"id"`
		Items        []interface{} `json:"items"`
		ProjectId    int           `json:"project_id"`
		UpdateTime   time.Time     `json:"update_time"`
	} `json:"cve_allowlist"`
	Metadata struct {
		Public               string `json:"public"`
		RetentionId          string `json:"retention_id,omitempty"`
		AutoScan             string `json:"auto_scan,omitempty"`
		EnableContentTrust   string `json:"enable_content_trust,omitempty"`
		PreventVul           string `json:"prevent_vul,omitempty"`
		ReuseSysCveAllowlist string `json:"reuse_sys_cve_allowlist,omitempty"`
		Severity             string `json:"severity,omitempty"`
	} `json:"metadata"`
	Name       string    `json:"name"`
	OwnerId    int       `json:"owner_id"`
	OwnerName  string    `json:"owner_name"`
	ProjectId  int       `json:"project_id"`
	RepoCount  int       `json:"repo_count,omitempty"`
	UpdateTime time.Time `json:"update_time"`
	ChartCount int       `json:"chart_count,omitempty"`
}

ProjectExternel harbor project外部对象,用于反序列化

type ProjectInternel

type ProjectInternel struct {
	Name      string
	ProjectId int
}

ProjectInternel harbor project内部对象,包含部分必需属性

type Repository

type Repository struct {
	Name string `json:"name"`
}

Repository harbor repo外部对象,用于反序列化

type SearchResult

type SearchResult struct {
	Project    []ProjectExternel `json:"project"`
	Repository []struct {
	} `json:"repository"`
	Chart []struct {
		Name  string `json:"Name"`
		Score int    `json:"Score"`
		Chart struct {
			Name        string    `json:"name"`
			Version     string    `json:"version"`
			Description string    `json:"description"`
			ApiVersion  string    `json:"apiVersion"`
			AppVersion  string    `json:"appVersion"`
			Type        string    `json:"type"`
			Urls        []string  `json:"urls"`
			Created     time.Time `json:"created"`
			Digest      string    `json:"digest"`
		} `json:"Chart"`
	} `json:"chart"`
}

SearchResult 用于反序列化 查询harbor结果的对象结果集

type TagExternel

type TagExternel struct {
	ArtifactId   int       `json:"artifact_id"`
	Id           int       `json:"id"`
	Immutable    bool      `json:"immutable"`
	Name         string    `json:"name"`
	PullTime     time.Time `json:"pull_time"`
	PushTime     time.Time `json:"push_time"`
	RepositoryId int       `json:"repository_id"`
	Signed       bool      `json:"signed"`
}

TagExternel 用于反序列化repo tag等

Jump to

Keyboard shortcuts

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