models

package
v0.0.0-...-5342816 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(conn string, driver string, name string) error

InitDB regists the orm db driver and regists to the database

func QueryReposList

func QueryReposList() ([]string, error)

QueryReposList returns the repos list

func QueryTagsList

func QueryTagsList(reponame string, proto string, protoVerion string) ([]string, error)

QueryTagsList returns the tags list by 'reponame, proto and proto version'

Types

type ContainerImage

type ContainerImage struct {
	ID     int    `orm:"column(id);auto"`
	Tag    string `orm:"column(tag);size(255);null"`
	Size   int64  `orm:"column(size);null"`
	RepoID int    `orm:"column(repo_id);null"`

	// docker, oci, rkt...
	Proto        string `orm:"column(proto);size(15);null"`
	ProtoVersion string `orm:"column(proto_version);size(15);null"`
}

ContainerImage defines the container image struct.

func AddImage

func AddImage(reponame string, tags string, proto string, protoVerion string) (*ContainerImage, error)

AddImage adds an image to the database. If the target repo is not exist, it will create a repo. TODO: lots of rollback

func QueryImage

func QueryImage(repoid int, tag string, proto string, protoVerion string) (*ContainerImage, error)

QueryImage returns a container image by 'repoid, tag, proto and proto version'

type ContainerRepo

type ContainerRepo struct {
	ID          int    `orm:"column(id);auto"`
	Name        string `orm:"unique;column(name);size(255);null"`
	Star        int    `orm:"column(star);null"`
	DownloadNum int    `orm:"column(download_num);null"`
	Description string `orm:"column(description);null"`
}

ContainerRepo defines the container repo struct, will support dockerv2, ociv1.

func AddRepo

func AddRepo(reponame string) (*ContainerRepo, error)

AddRepo adds a repo to the database

type Pkg

type Pkg struct {
	ID int64 `orm:"column(id);auto"`
	// Name is not unique
	Name      string `orm:"column(name);size(255);null"`
	Size      int64  `orm:"column(size);null"`
	RepoID    int64  `orm:"column(repo_id);null"`
	Downloads int64  `orm:"column(downloads);null"`

	// rpm, iso, ...
	Type string `orm:"column(type);size(15);null"`
}

Pkg defines the pkg pkg struct.

func AddPkg

func AddPkg(reponame string, name string, size int64, pkgType string) (*Pkg, error)

AddPkg adds a package to the database. If the target repo is not exist, it will create a repo. TODO: lots of rollback

func PkgDownloadInc

func PkgDownloadInc(reponame string, name string) (*Pkg, error)

PkgDownloadInc increases the download count by one TODO: lock/unlock the db item TODO: add a detailed pkg download info, like ip, date?

func QueryPkgByID

func QueryPkgByID(repoid int64, name string) (*Pkg, error)

QueryPkgByID returns a package by 'repoid, name'

func QueryPkgByName

func QueryPkgByName(repoName string, name string) (*Pkg, error)

QueryPkgByName returns a package by 'repoName, name'

func QueryPkgListByRepoName

func QueryPkgListByRepoName(reponame string) ([]Pkg, error)

QueryPkgListByRepoName returns the package list by 'reponame'

type PkgInfo

type PkgInfo struct {
	Name      string
	Downloads int64
	Type      string
}

PkgInfo defines the information which could public for users

func PkgInfoNew

func PkgInfoNew(pkg *Pkg) PkgInfo

PkgInfoNew get a pkginfo from pkg

type PkgRepo

type PkgRepo struct {
	ID int64 `orm:"column(id);auto"`
	// More like a directory here
	Name        string `orm:"unique;column(name);size(255);null"`
	Star        int64  `orm:"column(star);null"`
	Description string `orm:"column(description);null"`
}

PkgRepo defines the meta data of a package repository. For example, the create data, the star counts and the etc..

func AddPkgRepo

func AddPkgRepo(reponame string) (*PkgRepo, error)

AddPkgRepo adds a repo to the database

Jump to

Keyboard shortcuts

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