biz

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

README

Biz

Documentation

Overview

Package biz is a generated GoMock package.

Index

Constants

View Source
const (
	SecretPath   = "default"
	SecretEngine = "pki"
)
View Source
const (
	SecretsEngine = "git"
	SecretsKey    = "deploykey"
)
View Source
const (
	PROJECT_NOT_FOUND  = "PROJECT_NOT_FOUND"
	GROUP_NOT_FOUND    = "GROUP_NOT_FOUND"
	NODE_NOT_FOUND     = "NODE_NOT_FOUND"
	RESOURCE_NOT_FOUND = "RESOURCE_NOT_FOUND"
	RESOURCE_NOT_MATCH = "RESOURCE_NOT_MATCH"
	NO_AUTHORIZATION   = "NO_AUTHORIZATION"
)

Variables

View Source
var (
	ErrorProjectNotFound = errors.New(404, PROJECT_NOT_FOUND, "the project path is not found")
	ErrorGroupNotFound   = errors.New(404, GROUP_NOT_FOUND, "the group path is not found")
	ErrorNodetNotFound   = errors.New(404, NODE_NOT_FOUND, "the node is not found")
	ErrorResourceNoFound = errors.New(404, RESOURCE_NOT_FOUND, "the resource is not found")
	ErrorResourceNoMatch = errors.New(500, RESOURCE_NOT_MATCH, "the resource is not match")
	ErrorNoAuth          = errors.New(403, NO_AUTHORIZATION, "no access to the code repository")
)

ProviderSet is biz providers.

Functions

func GetCluster

func GetCluster(filename string) (*resourcev1alpha1.Cluster, error)

func GetClusterTemplateHttpsURL

func GetClusterTemplateHttpsURL(configs *nautesconfigs.Config) string

func SpliceCodeRepoResourceName

func SpliceCodeRepoResourceName(id int) string

Types

type BizOptions

type BizOptions struct {
	ResouceName       string
	ProductName       string
	InsecureSkipCheck bool
}

type CloneRepositoryParam

type CloneRepositoryParam struct {
	URL   string
	User  string
	Email string
}

type ClusterData

type ClusterData struct {
	ClusterName string
	ApiServer   string
	ClusterType string
	Usage       string
	HostCluster string
}

type ClusterUsecase

type ClusterUsecase struct {
	// contains filtered or unexported fields
}

func NewClusterUsecase

func NewClusterUsecase(logger log.Logger, codeRepo CodeRepo, secretRepo Secretrepo, resourcesUsecase *ResourcesUsecase, configs *nautesconfigs.Config, client client.Client, cluster cluster.ClusterRegistrationOperator, dex DexRepo) *ClusterUsecase

func (*ClusterUsecase) CloneRepository

func (c *ClusterUsecase) CloneRepository(ctx context.Context, url string) (string, error)

func (*ClusterUsecase) ConvertKubeconfig

func (r *ClusterUsecase) ConvertKubeconfig(config, server string) (string, error)

func (*ClusterUsecase) DeleteCluster

func (c *ClusterUsecase) DeleteCluster(ctx context.Context, clusterName string) error

func (*ClusterUsecase) DeleteDexConfig

func (c *ClusterUsecase) DeleteDexConfig(param *cluster.ClusterRegistrationParam) error

func (*ClusterUsecase) GetCacert

func (c *ClusterUsecase) GetCacert(ctx context.Context) (string, error)

func (*ClusterUsecase) GetTenantRepository

func (c *ClusterUsecase) GetTenantRepository(ctx context.Context) (*Project, error)

func (*ClusterUsecase) SaveCluster

func (c *ClusterUsecase) SaveCluster(ctx context.Context, param *cluster.ClusterRegistrationParam, kubeconfig string) error

func (*ClusterUsecase) SaveDexConfig

func (c *ClusterUsecase) SaveDexConfig(param *cluster.ClusterRegistrationParam, teantLocalPath string) error

func (*ClusterUsecase) SaveKubeconfig

func (c *ClusterUsecase) SaveKubeconfig(ctx context.Context, id, server, config string) error

type CodeRepo

type CodeRepo interface {
	GetCurrentUser(ctx context.Context) (user string, email string, err error)
	CreateCodeRepo(ctx context.Context, gid int, options *GitCodeRepoOptions) (*Project, error)
	UpdateCodeRepo(ctx context.Context, pid interface{}, options *GitCodeRepoOptions) (*Project, error)
	DeleteCodeRepo(ctx context.Context, pid interface{}) error
	GetCodeRepo(ctx context.Context, pid interface{}) (*Project, error)
	ListDeployKeys(ctx context.Context, pid interface{}, opt *ListOptions) ([]*ProjectDeployKey, error)
	GetDeployKey(ctx context.Context, pid interface{}, deployKeyID int) (*ProjectDeployKey, error)
	SaveDeployKey(ctx context.Context, publicKey []byte, project *Project) (*ProjectDeployKey, error)
	DeleteDeployKey(ctx context.Context, pid interface{}, deployKey int) error
	CreateGroup(ctx context.Context, gitOptions *GitGroupOptions) (*Group, error)
	DeleteGroup(ctx context.Context, gid interface{}) error
	UpdateGroup(ctx context.Context, gid interface{}, git *GitGroupOptions) (*Group, error)
	GetGroup(ctx context.Context, gid interface{}) (*Group, error)
	ListAllGroups(ctx context.Context) ([]*Group, error)
	ListGroupCodeRepos(ctx context.Context, gid interface{}, opts ...interface{}) ([]*Project, error)
}

type CodeRepoAndProject

type CodeRepoAndProject struct {
	CodeRepo *resourcev1alpha1.CodeRepo
	Project  *Project
}

type CodeRepoData

type CodeRepoData struct {
	Name string
	Spec resourcev1alpha1.CodeRepoSpec
}

type CodeRepoUsecase

type CodeRepoUsecase struct {
	// contains filtered or unexported fields
}

func NewCodeRepoUsecase

func NewCodeRepoUsecase(logger log.Logger, codeRepo CodeRepo, secretRepo Secretrepo, nodestree nodestree.NodesTree, config *nautesconfigs.Config, resourcesUsecase *ResourcesUsecase, client client.Client) *CodeRepoUsecase

func (*CodeRepoUsecase) AddDeployKeyAndRemoveInvalidDeployKey

func (c *CodeRepoUsecase) AddDeployKeyAndRemoveInvalidDeployKey(ctx context.Context, project *Project) error

func (*CodeRepoUsecase) CheckReference

func (c *CodeRepoUsecase) CheckReference(options nodestree.CompareOptions, node *nodestree.Node, k8sClient client.Client) (bool, error)

func (*CodeRepoUsecase) CreateNode

func (c *CodeRepoUsecase) CreateNode(path string, data interface{}) (*nodestree.Node, error)

func (*CodeRepoUsecase) CreateResource

func (c *CodeRepoUsecase) CreateResource(kind string) interface{}

func (*CodeRepoUsecase) DeleteCodeRepo

func (c *CodeRepoUsecase) DeleteCodeRepo(ctx context.Context, options *BizOptions) error

func (*CodeRepoUsecase) GetCodeRepo

func (c *CodeRepoUsecase) GetCodeRepo(ctx context.Context, codeRepoName, productName string) (*resourcev1alpha1.CodeRepo, *Project, error)

func (*CodeRepoUsecase) GetDeployKeyFromSecretRepo

func (c *CodeRepoUsecase) GetDeployKeyFromSecretRepo(ctx context.Context, repoName string) (*DeployKeySecretData, error)

func (*CodeRepoUsecase) ListCodeRepos

func (c *CodeRepoUsecase) ListCodeRepos(ctx context.Context, productName string) ([]*CodeRepoAndProject, error)

func (*CodeRepoUsecase) SaveCodeRepo

func (c *CodeRepoUsecase) SaveCodeRepo(ctx context.Context, options *BizOptions, data *CodeRepoData, gitOptions *GitCodeRepoOptions) error

func (*CodeRepoUsecase) SaveDeployKey

func (c *CodeRepoUsecase) SaveDeployKey(ctx context.Context, pid interface{}, project *Project) error

func (*CodeRepoUsecase) UpdateNode

func (c *CodeRepoUsecase) UpdateNode(resourceNode *nodestree.Node, data interface{}) (*nodestree.Node, error)

type DeployKeySecretData

type DeployKeySecretData struct {
	ID          int
	Fingerprint string
}

type DeploymentRuntimeData

type DeploymentRuntimeData struct {
	Name string
	Spec resourcev1alpha1.DeploymentRuntimeSpec
}

type DeploymentRuntimeUsecase

type DeploymentRuntimeUsecase struct {
	// contains filtered or unexported fields
}

func NewDeploymentRuntimeUsecase

func NewDeploymentRuntimeUsecase(logger log.Logger, codeRepo CodeRepo, nodestree nodestree.NodesTree, resourcesUsecase *ResourcesUsecase) *DeploymentRuntimeUsecase

func (*DeploymentRuntimeUsecase) CheckReference

func (d *DeploymentRuntimeUsecase) CheckReference(options nodestree.CompareOptions, node *nodestree.Node, k8sClient client.Client) (bool, error)

func (*DeploymentRuntimeUsecase) CreateNode

func (e *DeploymentRuntimeUsecase) CreateNode(path string, data interface{}) (*nodestree.Node, error)

func (*DeploymentRuntimeUsecase) CreateResource

func (d *DeploymentRuntimeUsecase) CreateResource(kind string) interface{}

func (*DeploymentRuntimeUsecase) DeleteDeploymentRuntime

func (d *DeploymentRuntimeUsecase) DeleteDeploymentRuntime(ctx context.Context, options *BizOptions) error

func (*DeploymentRuntimeUsecase) GetDeploymentRuntime

func (d *DeploymentRuntimeUsecase) GetDeploymentRuntime(ctx context.Context, deploymentRuntimeName, productName string) (*resourcev1alpha1.DeploymentRuntime, error)

func (*DeploymentRuntimeUsecase) ListDeploymentRuntimes

func (d *DeploymentRuntimeUsecase) ListDeploymentRuntimes(ctx context.Context, productName string) ([]*resourcev1alpha1.DeploymentRuntime, error)

func (*DeploymentRuntimeUsecase) SaveDeploymentRuntime

func (d *DeploymentRuntimeUsecase) SaveDeploymentRuntime(ctx context.Context, options *BizOptions, data *DeploymentRuntimeData) error

func (*DeploymentRuntimeUsecase) UpdateNode

func (e *DeploymentRuntimeUsecase) UpdateNode(resourceNode *nodestree.Node, data interface{}) (*nodestree.Node, error)

type DexRepo

type DexRepo interface {
	UpdateRedirectURIs(redirectURI string) error
	RemoveRedirectURIs(redirectURIs string) error
}

type EnviromentData

type EnviromentData struct {
	Name string
	Spec resourcev1alpha1.EnvironmentSpec
}

type EnvironmentUsecase

type EnvironmentUsecase struct {
	// contains filtered or unexported fields
}

func NewEnviromentUsecase

func NewEnviromentUsecase(logger log.Logger, config *nautesconfigs.Config, codeRepo CodeRepo, nodestree nodestree.NodesTree, resourcesUsecase *ResourcesUsecase) *EnvironmentUsecase

func (*EnvironmentUsecase) CheckReference

func (e *EnvironmentUsecase) CheckReference(options nodestree.CompareOptions, node *nodestree.Node, k8sClient client.Client) (bool, error)

func (*EnvironmentUsecase) CreateNode

func (e *EnvironmentUsecase) CreateNode(path string, data interface{}) (*nodestree.Node, error)

func (*EnvironmentUsecase) CreateResource

func (e *EnvironmentUsecase) CreateResource(kind string) interface{}

func (*EnvironmentUsecase) DeleteEnvironment

func (e *EnvironmentUsecase) DeleteEnvironment(ctx context.Context, options *BizOptions) error

func (*EnvironmentUsecase) GetEnvironment

func (e *EnvironmentUsecase) GetEnvironment(ctx context.Context, enviromentName, productName string) (*resourcev1alpha1.Environment, error)

func (*EnvironmentUsecase) ListEnvironments

func (e *EnvironmentUsecase) ListEnvironments(ctx context.Context, productName string) ([]*resourcev1alpha1.Environment, error)

func (*EnvironmentUsecase) SaveEnvironment

func (e *EnvironmentUsecase) SaveEnvironment(ctx context.Context, options *BizOptions, data *EnviromentData) error

func (*EnvironmentUsecase) UpdateNode

func (e *EnvironmentUsecase) UpdateNode(resourceNode *nodestree.Node, data interface{}) (*nodestree.Node, error)

type GitCodeRepoOptions

type GitCodeRepoOptions struct {
	Gitlab *GitlabCodeRepoOptions
	Github interface{}
}

type GitGroupOptions

type GitGroupOptions struct {
	Github *GroupOptions
	Gitlab *GroupOptions
}

type GitRepo

type GitRepo interface {
	Commit(path, message string) error
	SaveConfig(ctx context.Context, path string) error
	Clone(ctx context.Context, param *CloneRepositoryParam) (string, error)
	Merge(ctx context.Context, path string) (string, error)
	Push(ctx context.Context, path string, command ...string) error
	Diff(ctx context.Context, path string, command ...string) (string, error)
	Fetch(ctx context.Context, path string, command ...string) (string, error)
}

type GitlabCodeRepoOptions

type GitlabCodeRepoOptions struct {
	Name        string `json:"name,omitempty"`
	Path        string `json:"path,omitempty"`
	Visibility  string `json:"visibility,omitempty"`
	Description string `json:"description,omitempty"`
	NamespaceID int32  `json:"namespace_id,omitempty"`
}

type Group

type Group struct {
	Id          int32
	Name        string
	Visibility  string
	Description string
	Path        string
	WebUrl      string
	ParentId    int32
}

func CreateGroup

func CreateGroup(ctx context.Context, codeRepo CodeRepo, gitOptions *GitGroupOptions) (group *Group, err error)

func GetGroup

func GetGroup(ctx context.Context, codeRepo CodeRepo, gid interface{}) (group *Group, err error)

func UpdateGroup

func UpdateGroup(ctx context.Context, codeRepo CodeRepo, configClient *nautesconfigs.Config, gid int, git *GitGroupOptions) (group *Group, err error)

type GroupAndProjectItem

type GroupAndProjectItem struct {
	Group   *Group
	Project *Project
}

type GroupOptions

type GroupOptions struct {
	Name        string `json:"name,omitempty"`
	Path        string `json:"path,omitempty"`
	Visibility  string `json:"visibility,omitempty"`
	Description string `json:"description,omitempty"`
	ParentId    int32  `json:"parent_id,omitempty"`
}

type ListOptions

type ListOptions struct {
	Page    int `url:"page,omitempty" json:"page,omitempty"`
	PerPage int `url:"per_page,omitempty" json:"per_page,omitempty"`
}

type MockCodeRepo

type MockCodeRepo struct {
	// contains filtered or unexported fields
}

MockCodeRepo is a mock of CodeRepo interface.

func NewMockCodeRepo

func NewMockCodeRepo(ctrl *gomock.Controller) *MockCodeRepo

NewMockCodeRepo creates a new mock instance.

func (*MockCodeRepo) CreateCodeRepo

func (m *MockCodeRepo) CreateCodeRepo(ctx context.Context, gid int, options *GitCodeRepoOptions) (*Project, error)

CreateCodeRepo mocks base method.

func (*MockCodeRepo) CreateGroup

func (m *MockCodeRepo) CreateGroup(ctx context.Context, gitOptions *GitGroupOptions) (*Group, error)

CreateGroup mocks base method.

func (*MockCodeRepo) DeleteCodeRepo

func (m *MockCodeRepo) DeleteCodeRepo(ctx context.Context, pid interface{}) error

DeleteCodeRepo mocks base method.

func (*MockCodeRepo) DeleteDeployKey

func (m *MockCodeRepo) DeleteDeployKey(ctx context.Context, pid interface{}, deployKey int) error

DeleteDeployKey mocks base method.

func (*MockCodeRepo) DeleteGroup

func (m *MockCodeRepo) DeleteGroup(ctx context.Context, gid interface{}) error

DeleteGroup mocks base method.

func (*MockCodeRepo) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCodeRepo) GetCodeRepo

func (m *MockCodeRepo) GetCodeRepo(ctx context.Context, pid interface{}) (*Project, error)

GetCodeRepo mocks base method.

func (*MockCodeRepo) GetCurrentUser

func (m *MockCodeRepo) GetCurrentUser(ctx context.Context) (string, string, error)

GetCurrentUser mocks base method.

func (*MockCodeRepo) GetDeployKey

func (m *MockCodeRepo) GetDeployKey(ctx context.Context, pid interface{}, deployKeyID int) (*ProjectDeployKey, error)

GetDeployKey mocks base method.

func (*MockCodeRepo) GetGroup

func (m *MockCodeRepo) GetGroup(ctx context.Context, gid interface{}) (*Group, error)

GetGroup mocks base method.

func (*MockCodeRepo) ListAllGroups

func (m *MockCodeRepo) ListAllGroups(ctx context.Context) ([]*Group, error)

ListAllGroups mocks base method.

func (*MockCodeRepo) ListDeployKeys

func (m *MockCodeRepo) ListDeployKeys(ctx context.Context, pid interface{}, opt *ListOptions) ([]*ProjectDeployKey, error)

ListDeployKeys mocks base method.

func (*MockCodeRepo) ListGroupCodeRepos

func (m *MockCodeRepo) ListGroupCodeRepos(ctx context.Context, gid interface{}, opts ...interface{}) ([]*Project, error)

ListGroupCodeRepos mocks base method.

func (*MockCodeRepo) SaveDeployKey

func (m *MockCodeRepo) SaveDeployKey(ctx context.Context, publicKey []byte, project *Project) (*ProjectDeployKey, error)

SaveDeployKey mocks base method.

func (*MockCodeRepo) UpdateCodeRepo

func (m *MockCodeRepo) UpdateCodeRepo(ctx context.Context, pid interface{}, options *GitCodeRepoOptions) (*Project, error)

UpdateCodeRepo mocks base method.

func (*MockCodeRepo) UpdateGroup

func (m *MockCodeRepo) UpdateGroup(ctx context.Context, gid interface{}, git *GitGroupOptions) (*Group, error)

UpdateGroup mocks base method.

type MockCodeRepoMockRecorder

type MockCodeRepoMockRecorder struct {
	// contains filtered or unexported fields
}

MockCodeRepoMockRecorder is the mock recorder for MockCodeRepo.

func (*MockCodeRepoMockRecorder) CreateCodeRepo

func (mr *MockCodeRepoMockRecorder) CreateCodeRepo(ctx, gid, options interface{}) *gomock.Call

CreateCodeRepo indicates an expected call of CreateCodeRepo.

func (*MockCodeRepoMockRecorder) CreateGroup

func (mr *MockCodeRepoMockRecorder) CreateGroup(ctx, gitOptions interface{}) *gomock.Call

CreateGroup indicates an expected call of CreateGroup.

func (*MockCodeRepoMockRecorder) DeleteCodeRepo

func (mr *MockCodeRepoMockRecorder) DeleteCodeRepo(ctx, pid interface{}) *gomock.Call

DeleteCodeRepo indicates an expected call of DeleteCodeRepo.

func (*MockCodeRepoMockRecorder) DeleteDeployKey

func (mr *MockCodeRepoMockRecorder) DeleteDeployKey(ctx, pid, deployKey interface{}) *gomock.Call

DeleteDeployKey indicates an expected call of DeleteDeployKey.

func (*MockCodeRepoMockRecorder) DeleteGroup

func (mr *MockCodeRepoMockRecorder) DeleteGroup(ctx, gid interface{}) *gomock.Call

DeleteGroup indicates an expected call of DeleteGroup.

func (*MockCodeRepoMockRecorder) GetCodeRepo

func (mr *MockCodeRepoMockRecorder) GetCodeRepo(ctx, pid interface{}) *gomock.Call

GetCodeRepo indicates an expected call of GetCodeRepo.

func (*MockCodeRepoMockRecorder) GetCurrentUser

func (mr *MockCodeRepoMockRecorder) GetCurrentUser(ctx interface{}) *gomock.Call

GetCurrentUser indicates an expected call of GetCurrentUser.

func (*MockCodeRepoMockRecorder) GetDeployKey

func (mr *MockCodeRepoMockRecorder) GetDeployKey(ctx, pid, deployKeyID interface{}) *gomock.Call

GetDeployKey indicates an expected call of GetDeployKey.

func (*MockCodeRepoMockRecorder) GetGroup

func (mr *MockCodeRepoMockRecorder) GetGroup(ctx, gid interface{}) *gomock.Call

GetGroup indicates an expected call of GetGroup.

func (*MockCodeRepoMockRecorder) ListAllGroups

func (mr *MockCodeRepoMockRecorder) ListAllGroups(ctx interface{}) *gomock.Call

ListAllGroups indicates an expected call of ListAllGroups.

func (*MockCodeRepoMockRecorder) ListDeployKeys

func (mr *MockCodeRepoMockRecorder) ListDeployKeys(ctx, pid, opt interface{}) *gomock.Call

ListDeployKeys indicates an expected call of ListDeployKeys.

func (*MockCodeRepoMockRecorder) ListGroupCodeRepos

func (mr *MockCodeRepoMockRecorder) ListGroupCodeRepos(ctx, gid interface{}, opts ...interface{}) *gomock.Call

ListGroupCodeRepos indicates an expected call of ListGroupCodeRepos.

func (*MockCodeRepoMockRecorder) SaveDeployKey

func (mr *MockCodeRepoMockRecorder) SaveDeployKey(ctx, publicKey, project interface{}) *gomock.Call

SaveDeployKey indicates an expected call of SaveDeployKey.

func (*MockCodeRepoMockRecorder) UpdateCodeRepo

func (mr *MockCodeRepoMockRecorder) UpdateCodeRepo(ctx, pid, options interface{}) *gomock.Call

UpdateCodeRepo indicates an expected call of UpdateCodeRepo.

func (*MockCodeRepoMockRecorder) UpdateGroup

func (mr *MockCodeRepoMockRecorder) UpdateGroup(ctx, gid, git interface{}) *gomock.Call

UpdateGroup indicates an expected call of UpdateGroup.

type MockDexRepo

type MockDexRepo struct {
	// contains filtered or unexported fields
}

MockDexRepo is a mock of DexRepo interface.

func NewMockDexRepo

func NewMockDexRepo(ctrl *gomock.Controller) *MockDexRepo

NewMockDexRepo creates a new mock instance.

func (*MockDexRepo) EXPECT

func (m *MockDexRepo) EXPECT() *MockDexRepoMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDexRepo) RemoveRedirectURIs

func (m *MockDexRepo) RemoveRedirectURIs(redirectURIs string) error

RemoveRedirectURIs mocks base method.

func (*MockDexRepo) UpdateRedirectURIs

func (m *MockDexRepo) UpdateRedirectURIs(redirectURI string) error

UpdateRedirectURIs mocks base method.

type MockDexRepoMockRecorder

type MockDexRepoMockRecorder struct {
	// contains filtered or unexported fields
}

MockDexRepoMockRecorder is the mock recorder for MockDexRepo.

func (*MockDexRepoMockRecorder) RemoveRedirectURIs

func (mr *MockDexRepoMockRecorder) RemoveRedirectURIs(redirectURIs interface{}) *gomock.Call

RemoveRedirectURIs indicates an expected call of RemoveRedirectURIs.

func (*MockDexRepoMockRecorder) UpdateRedirectURIs

func (mr *MockDexRepoMockRecorder) UpdateRedirectURIs(redirectURI interface{}) *gomock.Call

UpdateRedirectURIs indicates an expected call of UpdateRedirectURIs.

type MockGitRepo

type MockGitRepo struct {
	// contains filtered or unexported fields
}

MockGitRepo is a mock of GitRepo interface.

func NewMockGitRepo

func NewMockGitRepo(ctrl *gomock.Controller) *MockGitRepo

NewMockGitRepo creates a new mock instance.

func (*MockGitRepo) Clone

func (m *MockGitRepo) Clone(ctx context.Context, param *CloneRepositoryParam) (string, error)

Clone mocks base method.

func (*MockGitRepo) Commit

func (m *MockGitRepo) Commit(path, message string) error

Commit mocks base method.

func (*MockGitRepo) Diff

func (m *MockGitRepo) Diff(ctx context.Context, path string, command ...string) (string, error)

Diff mocks base method.

func (*MockGitRepo) EXPECT

func (m *MockGitRepo) EXPECT() *MockGitRepoMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockGitRepo) Fetch

func (m *MockGitRepo) Fetch(ctx context.Context, path string, command ...string) (string, error)

Fetch mocks base method.

func (*MockGitRepo) Merge

func (m *MockGitRepo) Merge(ctx context.Context, path string) (string, error)

Merge mocks base method.

func (*MockGitRepo) Push

func (m *MockGitRepo) Push(ctx context.Context, path string, command ...string) error

Push mocks base method.

func (*MockGitRepo) SaveConfig

func (m *MockGitRepo) SaveConfig(ctx context.Context, path string) error

SaveConfig mocks base method.

type MockGitRepoMockRecorder

type MockGitRepoMockRecorder struct {
	// contains filtered or unexported fields
}

MockGitRepoMockRecorder is the mock recorder for MockGitRepo.

func (*MockGitRepoMockRecorder) Clone

func (mr *MockGitRepoMockRecorder) Clone(ctx, param interface{}) *gomock.Call

Clone indicates an expected call of Clone.

func (*MockGitRepoMockRecorder) Commit

func (mr *MockGitRepoMockRecorder) Commit(path, message interface{}) *gomock.Call

Commit indicates an expected call of Commit.

func (*MockGitRepoMockRecorder) Diff

func (mr *MockGitRepoMockRecorder) Diff(ctx, path interface{}, command ...interface{}) *gomock.Call

Diff indicates an expected call of Diff.

func (*MockGitRepoMockRecorder) Fetch

func (mr *MockGitRepoMockRecorder) Fetch(ctx, path interface{}, command ...interface{}) *gomock.Call

Fetch indicates an expected call of Fetch.

func (*MockGitRepoMockRecorder) Merge

func (mr *MockGitRepoMockRecorder) Merge(ctx, path interface{}) *gomock.Call

Merge indicates an expected call of Merge.

func (*MockGitRepoMockRecorder) Push

func (mr *MockGitRepoMockRecorder) Push(ctx, path interface{}, command ...interface{}) *gomock.Call

Push indicates an expected call of Push.

func (*MockGitRepoMockRecorder) SaveConfig

func (mr *MockGitRepoMockRecorder) SaveConfig(ctx, path interface{}) *gomock.Call

SaveConfig indicates an expected call of SaveConfig.

type MockSecretrepo

type MockSecretrepo struct {
	// contains filtered or unexported fields
}

MockSecretrepo is a mock of Secretrepo interface.

func NewMockSecretrepo

func NewMockSecretrepo(ctrl *gomock.Controller) *MockSecretrepo

NewMockSecretrepo creates a new mock instance.

func (*MockSecretrepo) AuthorizationSecret

func (m *MockSecretrepo) AuthorizationSecret(ctx context.Context, id int, destUser string) error

AuthorizationSecret mocks base method.

func (*MockSecretrepo) DeleteSecret

func (m *MockSecretrepo) DeleteSecret(ctx context.Context, id int) error

DeleteSecret mocks base method.

func (*MockSecretrepo) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockSecretrepo) GetDeployKey

func (m *MockSecretrepo) GetDeployKey(ctx context.Context, secretOptions *SecretOptions) (*DeployKeySecretData, error)

GetDeployKey mocks base method.

func (*MockSecretrepo) GetSecret

func (m *MockSecretrepo) GetSecret(ctx context.Context, secretOptions *SecretOptions) (string, error)

GetSecret mocks base method.

func (*MockSecretrepo) SaveClusterConfig

func (m *MockSecretrepo) SaveClusterConfig(ctx context.Context, id, config string) error

SaveClusterConfig mocks base method.

func (*MockSecretrepo) SaveDeployKey

func (m *MockSecretrepo) SaveDeployKey(ctx context.Context, id int, key string, extendKVs map[string]string) error

SaveDeployKey mocks base method.

type MockSecretrepoMockRecorder

type MockSecretrepoMockRecorder struct {
	// contains filtered or unexported fields
}

MockSecretrepoMockRecorder is the mock recorder for MockSecretrepo.

func (*MockSecretrepoMockRecorder) AuthorizationSecret

func (mr *MockSecretrepoMockRecorder) AuthorizationSecret(ctx, id, destUser interface{}) *gomock.Call

AuthorizationSecret indicates an expected call of AuthorizationSecret.

func (*MockSecretrepoMockRecorder) DeleteSecret

func (mr *MockSecretrepoMockRecorder) DeleteSecret(ctx, id interface{}) *gomock.Call

DeleteSecret indicates an expected call of DeleteSecret.

func (*MockSecretrepoMockRecorder) GetDeployKey

func (mr *MockSecretrepoMockRecorder) GetDeployKey(ctx, secretOptions interface{}) *gomock.Call

GetDeployKey indicates an expected call of GetDeployKey.

func (*MockSecretrepoMockRecorder) GetSecret

func (mr *MockSecretrepoMockRecorder) GetSecret(ctx, secretOptions interface{}) *gomock.Call

GetSecret indicates an expected call of GetSecret.

func (*MockSecretrepoMockRecorder) SaveClusterConfig

func (mr *MockSecretrepoMockRecorder) SaveClusterConfig(ctx, id, config interface{}) *gomock.Call

SaveClusterConfig indicates an expected call of SaveClusterConfig.

func (*MockSecretrepoMockRecorder) SaveDeployKey

func (mr *MockSecretrepoMockRecorder) SaveDeployKey(ctx, id, key, extendKVs interface{}) *gomock.Call

SaveDeployKey indicates an expected call of SaveDeployKey.

type ProductUsecase

type ProductUsecase struct {
	// contains filtered or unexported fields
}

ProductUsecase is a Product usecase.

func NewProductUsecase

func NewProductUsecase(logger log.Logger, codeRepo CodeRepo, secretRepo Secretrepo, gitRepo GitRepo, configs *nautesconfigs.Config, resourcesUsecase *ResourcesUsecase, codeRepoUsecase *CodeRepoUsecase) *ProductUsecase

func (*ProductUsecase) AddDeployKey

func (p *ProductUsecase) AddDeployKey(ctx context.Context, project *Project, publicKey, privateKey []byte) error

func (*ProductUsecase) DeleteProduct

func (p *ProductUsecase) DeleteProduct(ctx context.Context, productID string) error

func (*ProductUsecase) GetGroupAndDefaultProject

func (p *ProductUsecase) GetGroupAndDefaultProject(ctx context.Context, productName string) (*GroupAndProjectItem, error)

func (*ProductUsecase) GetProduct

func (p *ProductUsecase) GetProduct(ctx context.Context, productName string) (*GroupAndProjectItem, error)

func (*ProductUsecase) ListProducts

func (p *ProductUsecase) ListProducts(ctx context.Context) ([]*GroupAndProjectItem, error)

func (*ProductUsecase) SaveProduct

func (p *ProductUsecase) SaveProduct(ctx context.Context, productName string, gitOptions *GitGroupOptions) (group *Group, project *Project, err error)

type Project

type Project struct {
	Id                int32
	Name              string
	Visibility        string
	Description       string
	Path              string
	WebUrl            string
	SshUrlToRepo      string
	HttpUrlToRepo     string
	PathWithNamespace string
}

func GetProject

func GetProject(ctx context.Context, codeRepo CodeRepo, pid interface{}) (project *Project, err error)

type ProjectData

type ProjectData struct {
	ProjectName string
	ProductName string
	Language    string
}

type ProjectDeployKey

type ProjectDeployKey struct {
	ID        int        `json:"id"`
	Title     string     `json:"title"`
	Key       string     `json:"key"`
	CreatedAt *time.Time `json:"created_at"`
	CanPush   bool       `json:"can_push"`
}

type ProjectPipelineRuntimeData

type ProjectPipelineRuntimeData struct {
	Name string
	Spec resourcev1alpha1.ProjectPipelineRuntimeSpec
}

type ProjectPipelineRuntimeUsecase

type ProjectPipelineRuntimeUsecase struct {
	// contains filtered or unexported fields
}

func NewProjectPipelineRuntimeUsecase

func NewProjectPipelineRuntimeUsecase(logger log.Logger, codeRepo CodeRepo, nodestree nodestree.NodesTree, resourcesUsecase *ResourcesUsecase) *ProjectPipelineRuntimeUsecase

func (*ProjectPipelineRuntimeUsecase) CheckReference

func (p *ProjectPipelineRuntimeUsecase) CheckReference(options nodestree.CompareOptions, node *nodestree.Node, k8sClient client.Client) (bool, error)

func (*ProjectPipelineRuntimeUsecase) CreateNode

func (p *ProjectPipelineRuntimeUsecase) CreateNode(path string, data interface{}) (*nodestree.Node, error)

func (*ProjectPipelineRuntimeUsecase) CreateResource

func (p *ProjectPipelineRuntimeUsecase) CreateResource(kind string) interface{}

func (*ProjectPipelineRuntimeUsecase) DeleteProjectPipelineRuntime

func (p *ProjectPipelineRuntimeUsecase) DeleteProjectPipelineRuntime(ctx context.Context, options *BizOptions) error

func (*ProjectPipelineRuntimeUsecase) GetProjectPipelineRuntime

func (p *ProjectPipelineRuntimeUsecase) GetProjectPipelineRuntime(ctx context.Context, projectPipelineName, productName string) (*resourcev1alpha1.ProjectPipelineRuntime, error)

func (*ProjectPipelineRuntimeUsecase) ListProjectPipelineRuntimes

func (p *ProjectPipelineRuntimeUsecase) ListProjectPipelineRuntimes(ctx context.Context, productName string) ([]*resourcev1alpha1.ProjectPipelineRuntime, error)

func (*ProjectPipelineRuntimeUsecase) SaveProjectPipelineRuntime

func (p *ProjectPipelineRuntimeUsecase) SaveProjectPipelineRuntime(ctx context.Context, options *BizOptions, data *ProjectPipelineRuntimeData) error

func (*ProjectPipelineRuntimeUsecase) UpdateNode

func (p *ProjectPipelineRuntimeUsecase) UpdateNode(node *nodestree.Node, data interface{}) (*nodestree.Node, error)

type ProjectUsecase

type ProjectUsecase struct {
	// contains filtered or unexported fields
}

func NewProjectUsecase

func NewProjectUsecase(logger log.Logger, codeRepo CodeRepo, secretRepo Secretrepo, nodestree nodestree.NodesTree, configs *nautesconfigs.Config, resourcesUsecase *ResourcesUsecase) *ProjectUsecase

func (*ProjectUsecase) CheckReference

func (p *ProjectUsecase) CheckReference(options nodestree.CompareOptions, node *nodestree.Node, k8sClient client.Client) (bool, error)

func (*ProjectUsecase) CreateNode

func (p *ProjectUsecase) CreateNode(path string, data interface{}) (*nodestree.Node, error)

func (*ProjectUsecase) CreateResource

func (p *ProjectUsecase) CreateResource(kind string) interface{}

func (*ProjectUsecase) DeleteProject

func (p *ProjectUsecase) DeleteProject(ctx context.Context, options *BizOptions) error

func (*ProjectUsecase) GetProject

func (p *ProjectUsecase) GetProject(ctx context.Context, projectName, productName string) (*resourcev1alpha1.Project, error)

func (*ProjectUsecase) ListProjects

func (p *ProjectUsecase) ListProjects(ctx context.Context, productName string) ([]*resourcev1alpha1.Project, error)

func (*ProjectUsecase) SaveProject

func (p *ProjectUsecase) SaveProject(ctx context.Context, options *BizOptions, data *ProjectData) error

func (*ProjectUsecase) UpdateNode

func (p *ProjectUsecase) UpdateNode(resourceNode *nodestree.Node, data interface{}) (*nodestree.Node, error)

type ResourcesUsecase

type ResourcesUsecase struct {
	// contains filtered or unexported fields
}

func NewResourcesUsecase

func NewResourcesUsecase(log log.Logger, codeRepo CodeRepo, secretRepo Secretrepo, gitRepo GitRepo, nodestree nodestree.NodesTree, configs *nautesconfigs.Config) *ResourcesUsecase

func (*ResourcesUsecase) CloneCodeRepo

func (r *ResourcesUsecase) CloneCodeRepo(ctx context.Context, url string) (path string, err error)

func (*ResourcesUsecase) Delete

func (r *ResourcesUsecase) Delete(ctx context.Context, resourceOptions *resourceOptions, getResourceName getResouceName) error

func (*ResourcesUsecase) Get

func (r *ResourcesUsecase) Get(ctx context.Context, resourceKind, productName string, operator nodestree.NodesOperator, getResourceName getResouceName) (*nodestree.Node, error)

func (*ResourcesUsecase) GetCodeRepo

func (r *ResourcesUsecase) GetCodeRepo(ctx context.Context, ProductName, codeRepoName string) (*Project, error)

GetCodeRepoName The name of the codeRepo resource must be prefixed with repo-, eg: repo-1

func (*ResourcesUsecase) GetNode

func (r *ResourcesUsecase) GetNode(nodes *nodestree.Node, kind, resourceName string) *nodestree.Node

GetNode get specifial node accroding to resource kind and name

func (*ResourcesUsecase) GetProductAndCodeRepo

func (r *ResourcesUsecase) GetProductAndCodeRepo(ctx context.Context, ProductName string) (*Group, *Project, error)

func (*ResourcesUsecase) InsertNodes

func (r *ResourcesUsecase) InsertNodes(nodestree nodestree.NodesTree, nodes, resource *nodestree.Node) (*nodestree.Node, error)

func (*ResourcesUsecase) List

func (r *ResourcesUsecase) List(ctx context.Context, productName string, operator nodestree.NodesOperator) (*nodestree.Node, error)

func (*ResourcesUsecase) RemoveNode

func (r *ResourcesUsecase) RemoveNode(nodes, node *nodestree.Node) (*nodestree.Node, error)

RemoveNode delete the specified node accroding to the path

func (*ResourcesUsecase) Save

func (r *ResourcesUsecase) Save(ctx context.Context, resourceOptions *resourceOptions, data interface{}) error

Save create or update config to git platform

func (*ResourcesUsecase) SaveConfig

func (r *ResourcesUsecase) SaveConfig(ctx context.Context, path string) error

SaveConfig Save project resource config to git platform If automatic merge fails will retry three times

func (*ResourcesUsecase) SaveDeployConfig

func (r *ResourcesUsecase) SaveDeployConfig(nodes *nodestree.Node, path string) error

func (*ResourcesUsecase) WriteResource

func (r *ResourcesUsecase) WriteResource(node *nodestree.Node) (err error)

WriteResource Write project resource content to a file

type RretryCountType

type RretryCountType string
const (
	KustomizationFileName                 = "kustomization.yaml"
	RretryCount           RretryCountType = "RretryCount"
)

type SecretData

type SecretData struct {
	ID   int    `json:"id"`
	Data string `json:"key"`
}

type SecretOptions

type SecretOptions struct {
	SecretPath   string
	SecretEngine string
	SecretKey    string
}

type Secretrepo

type Secretrepo interface {
	GetSecret(ctx context.Context, secretOptions *SecretOptions) (string, error)
	GetDeployKey(ctx context.Context, secretOptions *SecretOptions) (*DeployKeySecretData, error)
	SaveDeployKey(ctx context.Context, id int, key string, extendKVs map[string]string) error
	SaveClusterConfig(ctx context.Context, id, config string) error
	DeleteSecret(ctx context.Context, id int) error
	AuthorizationSecret(ctx context.Context, id int, destUser string) error
}

Jump to

Keyboard shortcuts

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