File gitrepo_cluster.go
has 1601 lines of code (exceeds 500 allowed). Consider refactoring.
Method clusterGitopsRepo.UpgradeCluster
has 314 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) UpgradeCluster(ctx context.Context,
param *UpgradeValuesParam) (string, error) {
const op = "cluster git repo: upgrade cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.UpgradeCluster
has a Cognitive Complexity of 72 (exceeds 20 allowed). Consider refactoring.
func (g *clusterGitopsRepo) UpgradeCluster(ctx context.Context,
param *UpgradeValuesParam) (string, error) {
const op = "cluster git repo: upgrade cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.GetCluster
has a Cognitive Complexity of 45 (exceeds 20 allowed). Consider refactoring.
func (g *clusterGitopsRepo) GetCluster(ctx context.Context,
application, cluster, templateName string) (_ *ClusterFiles, err error) {
const op = "cluster git repo: get cluster"
defer wlog.Start(ctx, op).StopPrint()
clusterGitopsRepo
has 33 methods (exceeds 20 allowed). Consider refactoring.
type clusterGitopsRepo struct {
gitlabLib gitlablib.Interface
clustersGroup *gitlab.Group
recyclingClustersGroup *gitlab.Group
templateRepo templaterepo.TemplateRepo
Method clusterGitopsRepo.GetCluster
has 120 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) GetCluster(ctx context.Context,
application, cluster, templateName string) (_ *ClusterFiles, err error) {
const op = "cluster git repo: get cluster"
defer wlog.Start(ctx, op).StopPrint()
Method clusterGitopsRepo.CreateCluster
has 117 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) CreateCluster(ctx context.Context, params *CreateClusterParams) (err error) {
const op = "cluster git repo: create cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.UpdateCluster
has 102 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) UpdateCluster(ctx context.Context, params *UpdateClusterParams) error {
const op = "cluster git repo: update cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.UpdateCluster
has a Cognitive Complexity of 34 (exceeds 20 allowed). Consider refactoring.
func (g *clusterGitopsRepo) UpdateCluster(ctx context.Context, params *UpdateClusterParams) error {
const op = "cluster git repo: update cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.UpgradeCluster
has 25 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) UpgradeCluster(ctx context.Context,
param *UpgradeValuesParam) (string, error) {
const op = "cluster git repo: upgrade cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.GetCluster
has 21 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) GetCluster(ctx context.Context,
application, cluster, templateName string) (_ *ClusterFiles, err error) {
const op = "cluster git repo: get cluster"
defer wlog.Start(ctx, op).StopPrint()
Method clusterGitopsRepo.GetClusterValueFiles
has 60 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) GetClusterValueFiles(ctx context.Context,
application, cluster string) (_ []ClusterValueFile, err error) {
const op = "cluster git repo: get cluster value files"
defer wlog.Start(ctx, op).StopPrint()
Method clusterGitopsRepo.UpdatePipelineOutput
has 60 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) UpdatePipelineOutput(ctx context.Context, application, cluster, template string,
pipelineOutput interface{}) (commitID string, err error) {
const op = "cluster git repo: update pipeline output"
defer wlog.Start(ctx, op).StopPrint()
Method clusterGitopsRepo.Rollback
has 55 lines of code (exceeds 50 allowed). Consider refactoring.
func (g *clusterGitopsRepo) Rollback(ctx context.Context, application, cluster, commit string) (_ string, err error) {
const op = "cluster git repo: rollback"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.UpdatePipelineOutput
has 11 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) UpdatePipelineOutput(ctx context.Context, application, cluster, template string,
pipelineOutput interface{}) (commitID string, err error) {
const op = "cluster git repo: update pipeline output"
defer wlog.Start(ctx, op).StopPrint()
Method clusterGitopsRepo.UpdateCluster
has 10 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) UpdateCluster(ctx context.Context, params *UpdateClusterParams) error {
const op = "cluster git repo: update cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.CreateCluster
has 9 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) CreateCluster(ctx context.Context, params *CreateClusterParams) (err error) {
const op = "cluster git repo: create cluster"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Function NewClusterGitlabRepo
has 6 arguments (exceeds 4 allowed). Consider refactoring.
func NewClusterGitlabRepo(ctx context.Context, rootGroup *gitlab.Group,
templateRepo templaterepo.TemplateRepo,
gitlabLib gitlablib.Interface, defaultBranch string, defaultVisibility string) (ClusterGitRepo, error) {
Method clusterGitopsRepo.getPipelineOutput
has 6 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) getPipelineOutput(ctx context.Context,
application, cluster string) (map[string]map[string]interface{}, error) {
pid := fmt.Sprintf("%v/%v/%v", g.clustersGroup.FullPath, application, cluster)
content, err := g.gitlabLib.GetFile(ctx, pid, GitOpsBranch, common.GitopsFilePipelineOutput)
if err != nil {
Method clusterGitopsRepo.Rollback
has 6 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) Rollback(ctx context.Context, application, cluster, commit string) (_ string, err error) {
const op = "cluster git repo: rollback"
defer wlog.Start(ctx, op).StopPrint()
currentUser, err := common.UserFromContext(ctx)
Method clusterGitopsRepo.GetManifest
has 6 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) GetManifest(ctx context.Context, application,
cluster string, commit *string) (*pkgcommon.Manifest, error) {
const op = "cluster git repo: get manifest"
defer wlog.Start(ctx, op).StopPrint()
Method clusterGitopsRepo.revertAction
has 6 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) revertAction(ctx context.Context, application, cluster,
commit string, diff gitlab.Diff) (*gitlablib.CommitAction, error) {
if diff.DeletedFile {
return &gitlablib.CommitAction{
Method clusterGitopsRepo.GetRestartTime
has 5 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) GetRestartTime(ctx context.Context, application, cluster string,
template string) (string, error) {
ret := make(map[string]map[string]string)
pid := fmt.Sprintf("%v/%v/%v", g.clustersGroup.FullPath, application, cluster)
content, err := g.gitlabLib.GetFile(ctx, pid, g.defaultBranch, common.GitopsFileRestart)
Method clusterGitopsRepo.GetPipelineOutput
has 5 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) GetPipelineOutput(ctx context.Context, application, cluster string,
template string) (interface{}, error) {
ret := make(map[string]interface{})
pid := fmt.Sprintf("%v/%v/%v", g.clustersGroup.FullPath, application, cluster)
content, err := g.gitlabLib.GetFile(ctx, pid, GitOpsBranch, common.GitopsFilePipelineOutput)
Method clusterGitopsRepo.manifestVersionChanged
has 5 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) manifestVersionChanged(ctx context.Context, application,
cluster string, commit string) (bool, error) {
currentManifest, err1 := g.GetManifest(ctx, application, cluster, nil)
if err1 != nil {
if _, ok := perror.Cause(err1).(*herrors.HorizonErrNotFound); !ok {
Method clusterGitopsRepo.MergeBranch
has 5 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) MergeBranch(ctx context.Context, application, cluster,
sourceBranch, targetBranch string, pipelineRunID *uint) (_ string, err error) {
removeSourceBranch := false
pid := fmt.Sprintf("%v/%v/%v", g.clustersGroup.FullPath, application, cluster)
Method clusterGitopsRepo.UpdateTags
has 5 return statements (exceeds 4 allowed).
func (g *clusterGitopsRepo) UpdateTags(ctx context.Context, application, cluster, templateName string,
tags []*tagmodels.Tag) (err error) {
const op = "cluster git repo: update tags"
defer wlog.Start(ctx, op).StopPrint()
Similar blocks of code found in 2 locations. Consider refactoring.
go func() {
defer wg.Done()
pipelineBytes, err1 = g.gitlabLib.GetFile(ctx, pid, GitOpsBranch, common.GitopsFilePipeline)
if err1 != nil {
return
Similar blocks of code found in 2 locations. Consider refactoring.
go func() {
defer wg.Done()
applicationBytes, err2 = g.gitlabLib.GetFile(ctx, pid, GitOpsBranch, common.GitopsFileApplication)
if err2 != nil {
return
Similar blocks of code found in 2 locations. Consider refactoring.
commitMsg := angular.CommitMessage("cluster", angular.Subject{
Operator: currentUser.GetName(),
Action: "update cluster",
Cluster: angular.StringPtr(params.Cluster),
}, struct {
Similar blocks of code found in 2 locations. Consider refactoring.
commitMsg := angular.CommitMessage("cluster", angular.Subject{
Operator: currentUser.GetName(),
Action: "create cluster",
Cluster: angular.StringPtr(params.Cluster),
}, struct {
There are no issues that match your filters.