@Summary get argocd connection detail @Description Get ArgoCD connection detail @Tags plugins/argocd CreateDefaultScopeConfig ensures a default scope config exists
(connectionId uint64)
| 173 | |
| 174 | // CreateDefaultScopeConfig ensures a default scope config exists |
| 175 | func 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" |
no test coverage detected