Documentation
¶
Overview ¶
Package key providers the database.Model implementation for the Key entity.
Index ¶
- func InitEvent(dis event.Dispatcher) queue.InitFunc
- func LoadRelations(loaders *database.Loaders, kk ...*Key) error
- func Model(kk []*Key) func(int) database.Model
- type Event
- type Form
- type Key
- type Store
- func (s *Store) All(opts ...query.Option) ([]*Key, error)
- func (s *Store) Bind(mm ...database.Model)
- func (s *Store) Chown(from, to int64) error
- func (s *Store) Create(authorId int64, name, key, config string) (*Key, error)
- func (s *Store) Delete(ids ...int64) error
- func (s *Store) Get(opts ...query.Option) (*Key, error)
- func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Key, database.Paginator, error)
- func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *Store) New() *Key
- func (s *Store) Paginate(page int64, opts ...query.Option) (database.Paginator, error)
- func (s *Store) Update(id int64, config string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadRelations ¶
LoadRelations loads all of the available relations for the given Key models using the given loaders available.
Types ¶
type Form ¶
type Form struct { namespace.Resource Key *Key `schema:"-"` Keys *Store `schema:"-"` Name string `schema:"name" json:"name"` PrivateKey string `schema:"key" json:"key"` Config string `schema:"config" json:"config"` }
Form is the type that represents input data for adding a new SSH key.
type Key ¶
type Key struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` AuthorID int64 `db:"author_id"` NamespaceID sql.NullInt64 `db:"namespace_id"` Name string `db:"name"` Key []byte `db:"key"` Config string `db:"config"` CreatedAt time.Time `db:"created_at"` UpdatedAt time.Time `db:"updated_at"` Author *user.User `db:"-"` User *user.User `db:"-"` Namespace *namespace.Namespace `db:"-"` }
Key is the type that represents an SSH key that can be placed in the build environment.
func FromContext ¶
FromContext returns the Key model from the given context, if any.
func (*Key) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User or namespace.Namespace.
func (*Key) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Image values under each key. If any of the User, or Namespace bound models exist on the Artifact, then the JSON representation of these models will be in the returned map, under the user, and namespace keys respectively.
func (*Key) SetPrimary ¶
SetPrimary implements the database.Model interface.
type Store ¶
type Store struct { database.Store // User is the bound user.User model. If not nil this will bind the // user.User model to any Image models that are created. If not nil this // will append a WHERE clause on the user_id column for all SELECT queries // performed. User *user.User // Namespace is the bound namespace.Namespace model. If not nil this will // bind the namespace.Namespace model to any Image models that are created. // If not nil this will append a WHERE clause on the namespace_id column for // all SELECT queries performed. Namespace *namespace.Namespace // contains filtered or unexported fields }
Store is the type for creating and modifying Key models in the database. The Store type can have an underlying crypto.AESGCM for encrypting the SSH keys that are stored.
func NewStore ¶
NewStore returns a new Store for querying the keys table. Each model passed to this function will be bound to the returned Store.
func NewStoreWithCrypto ¶ added in v1.1.0
NewStoreWithCrypto is functionally the same as NewStore, however it sets the crypto.AESGCM to use on the returned Store. This will allow for encryption of keys during creation.
func (*Store) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User or namespace.Namespace.
func (*Store) Create ¶
Create creates a new key with the given name and config. The given key string should be the contents of the key itself, this will be encrypted with the underlying crypto.AESGCM that is set on the Store. If no crypto.AESGCM is set on the Store then this will error.
func (*Store) Index ¶
Index returns the paginated results from the keys table depending on the values that are present in url.Values. Detailed below are the values that are used from the given url.Values,
search - This applies the database.Search query.Option using the value of name
func (*Store) Load ¶
func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Key models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls Store.All under the hood, so any bound models will impact the models being loaded.