MCPcopy Create free account
hub / github.com/apache/devlake / CreateDefaultScopeConfig

Function CreateDefaultScopeConfig

backend/plugins/argocd/api/connection_api.go:175–197  ·  view source on GitHub ↗

@Summary get argocd connection detail @Description Get ArgoCD connection detail @Tags plugins/argocd CreateDefaultScopeConfig ensures a default scope config exists

(connectionId uint64)

Source from the content-addressed store, hash-verified

173
174// CreateDefaultScopeConfig ensures a default scope config exists
175func CreateDefaultScopeConfig(connectionId uint64) (*models.ArgocdScopeConfig, errors.Error) {
176 if dsHelper.ScopeConfigSrv == nil {
177 return nil, nil
178 }
179 existing, _ := dsHelper.ScopeConfigSrv.GetAllByConnectionId(connectionId)
180 if len(existing) > 0 {
181 return existing[0], nil
182 }
183 cfg := &models.ArgocdScopeConfig{
184 ScopeConfig: models.ArgocdScopeConfig{}.ScopeConfig, // zero
185 DeploymentPattern: ".*",
186 ProductionPattern: "(?i)(prod|production)",
187 EnvNamePattern: "(?i)prod(.*)",
188 }
189 cfg.ConnectionId = connectionId
190 cfg.Name = "default"
191 cfg.Entities = []string{"CICD"}
192 err := dsHelper.ScopeConfigSrv.Create(cfg)
193 if err != nil {
194 return nil, err
195 }
196 return cfg, nil
197}
198
199// @Success 200 {object} models.ArgocdConnection
200// @Failure 400 {string} errcode.Error "Bad Request"

Callers 3

PutScopesFunction · 0.85
PostConnectionsFunction · 0.85

Calls 2

GetAllByConnectionIdMethod · 0.80
CreateMethod · 0.65

Tested by

no test coverage detected