2022-05-05 13:25:50 +00:00
|
|
|
// Copyright 2022 Cloudbase Solutions SRL
|
|
|
|
|
//
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
|
|
|
// not use this file except in compliance with the License. You may obtain
|
|
|
|
|
// a copy of the License at
|
|
|
|
|
//
|
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
//
|
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
|
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
|
// License for the specific language governing permissions and limitations
|
|
|
|
|
// under the License.
|
|
|
|
|
|
2022-04-25 00:03:26 +00:00
|
|
|
package common
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2022-05-04 11:44:10 +00:00
|
|
|
"garm/params"
|
2022-04-25 00:03:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Store interface {
|
2022-04-28 16:13:20 +00:00
|
|
|
CreateRepository(ctx context.Context, owner, name, credentialsName, webhookSecret string) (params.Repository, error)
|
2022-04-26 20:29:58 +00:00
|
|
|
GetRepository(ctx context.Context, owner, name string) (params.Repository, error)
|
2022-04-29 14:18:22 +00:00
|
|
|
GetRepositoryByID(ctx context.Context, repoID string) (params.Repository, error)
|
2022-04-25 00:03:26 +00:00
|
|
|
ListRepositories(ctx context.Context) ([]params.Repository, error)
|
2022-05-04 21:57:08 +00:00
|
|
|
DeleteRepository(ctx context.Context, repoID string) error
|
2022-04-29 14:18:22 +00:00
|
|
|
UpdateRepository(ctx context.Context, repoID string, param params.UpdateRepositoryParams) (params.Repository, error)
|
2022-04-25 00:03:26 +00:00
|
|
|
|
2022-04-28 16:13:20 +00:00
|
|
|
CreateOrganization(ctx context.Context, name, credentialsName, webhookSecret string) (params.Organization, error)
|
2022-04-26 20:29:58 +00:00
|
|
|
GetOrganization(ctx context.Context, name string) (params.Organization, error)
|
2022-05-04 13:15:27 +00:00
|
|
|
GetOrganizationByID(ctx context.Context, orgID string) (params.Organization, error)
|
2022-04-25 00:03:26 +00:00
|
|
|
ListOrganizations(ctx context.Context) ([]params.Organization, error)
|
2022-05-04 21:57:08 +00:00
|
|
|
DeleteOrganization(ctx context.Context, orgID string) error
|
2022-05-04 13:15:27 +00:00
|
|
|
UpdateOrganization(ctx context.Context, orgID string, param params.UpdateRepositoryParams) (params.Organization, error)
|
2022-04-25 00:03:26 +00:00
|
|
|
|
|
|
|
|
CreateRepositoryPool(ctx context.Context, repoId string, param params.CreatePoolParams) (params.Pool, error)
|
|
|
|
|
CreateOrganizationPool(ctx context.Context, orgId string, param params.CreatePoolParams) (params.Pool, error)
|
|
|
|
|
|
|
|
|
|
GetRepositoryPool(ctx context.Context, repoID, poolID string) (params.Pool, error)
|
|
|
|
|
GetOrganizationPool(ctx context.Context, orgID, poolID string) (params.Pool, error)
|
|
|
|
|
|
2022-04-29 14:18:22 +00:00
|
|
|
ListRepoPools(ctx context.Context, repoID string) ([]params.Pool, error)
|
|
|
|
|
ListOrgPools(ctx context.Context, orgID string) ([]params.Pool, error)
|
2022-05-05 13:07:06 +00:00
|
|
|
// Probably a bad idea without some king of filter or at least pagination
|
|
|
|
|
// TODO: add filter/pagination
|
|
|
|
|
ListAllPools(ctx context.Context) ([]params.Pool, error)
|
|
|
|
|
GetPoolByID(ctx context.Context, poolID string) (params.Pool, error)
|
|
|
|
|
DeletePoolByID(ctx context.Context, poolID string) error
|
2022-04-29 14:18:22 +00:00
|
|
|
|
2022-04-25 00:03:26 +00:00
|
|
|
DeleteRepositoryPool(ctx context.Context, repoID, poolID string) error
|
|
|
|
|
DeleteOrganizationPool(ctx context.Context, orgID, poolID string) error
|
|
|
|
|
|
2022-04-26 20:29:58 +00:00
|
|
|
UpdateRepositoryPool(ctx context.Context, repoID, poolID string, param params.UpdatePoolParams) (params.Pool, error)
|
|
|
|
|
UpdateOrganizationPool(ctx context.Context, orgID, poolID string, param params.UpdatePoolParams) (params.Pool, error)
|
|
|
|
|
|
|
|
|
|
FindRepositoryPoolByTags(ctx context.Context, repoID string, tags []string) (params.Pool, error)
|
|
|
|
|
FindOrganizationPoolByTags(ctx context.Context, orgID string, tags []string) (params.Pool, error)
|
|
|
|
|
|
|
|
|
|
CreateInstance(ctx context.Context, poolID string, param params.CreateInstanceParams) (params.Instance, error)
|
|
|
|
|
DeleteInstance(ctx context.Context, poolID string, instanceID string) error
|
|
|
|
|
UpdateInstance(ctx context.Context, instanceID string, param params.UpdateInstanceParams) (params.Instance, error)
|
|
|
|
|
|
2022-05-05 13:07:06 +00:00
|
|
|
ListPoolInstances(ctx context.Context, poolID string) ([]params.Instance, error)
|
2022-04-26 20:29:58 +00:00
|
|
|
ListRepoInstances(ctx context.Context, repoID string) ([]params.Instance, error)
|
|
|
|
|
ListOrgInstances(ctx context.Context, orgID string) ([]params.Instance, error)
|
|
|
|
|
|
2022-05-13 23:34:16 +00:00
|
|
|
PoolInstanceCount(ctx context.Context, poolID string) (int64, error)
|
|
|
|
|
|
2022-05-05 13:07:06 +00:00
|
|
|
// Probably a bad idea without some king of filter or at least pagination
|
|
|
|
|
// TODO: add filter/pagination
|
|
|
|
|
ListAllInstances(ctx context.Context) ([]params.Instance, error)
|
|
|
|
|
|
2022-04-29 23:43:37 +00:00
|
|
|
GetPoolInstanceByName(ctx context.Context, poolID string, instanceName string) (params.Instance, error)
|
|
|
|
|
GetInstanceByName(ctx context.Context, instanceName string) (params.Instance, error)
|
2022-05-03 19:49:14 +00:00
|
|
|
AddInstanceStatusMessage(ctx context.Context, instanceID string, statusMessage string) error
|
2022-04-28 16:13:20 +00:00
|
|
|
|
|
|
|
|
GetUser(ctx context.Context, user string) (params.User, error)
|
2022-04-29 14:18:22 +00:00
|
|
|
GetUserByID(ctx context.Context, userID string) (params.User, error)
|
|
|
|
|
|
|
|
|
|
CreateUser(ctx context.Context, user params.NewUserParams) (params.User, error)
|
2022-04-28 16:13:20 +00:00
|
|
|
UpdateUser(ctx context.Context, user string, param params.UpdateUserParams) (params.User, error)
|
|
|
|
|
HasAdminUser(ctx context.Context) bool
|
|
|
|
|
|
|
|
|
|
ControllerInfo() (params.ControllerInfo, error)
|
|
|
|
|
InitController() (params.ControllerInfo, error)
|
2022-04-25 00:03:26 +00:00
|
|
|
}
|