github.com/jfrog/jfrog-cli-go@v1.22.1-0.20200318093948-4826ef344ffd/artifactory/commands/repository/repository.go (about) 1 package repository 2 3 import ( 4 "encoding/json" 5 "errors" 6 "github.com/jfrog/jfrog-cli-go/artifactory/commands/utils" 7 rtUtils "github.com/jfrog/jfrog-cli-go/artifactory/utils" 8 "github.com/jfrog/jfrog-cli-go/utils/cliutils" 9 "github.com/jfrog/jfrog-cli-go/utils/config" 10 "github.com/jfrog/jfrog-client-go/artifactory" 11 "github.com/jfrog/jfrog-client-go/artifactory/services" 12 "github.com/jfrog/jfrog-client-go/utils/errorutils" 13 "github.com/jfrog/jfrog-client-go/utils/io/fileutils" 14 "strconv" 15 "strings" 16 ) 17 18 type RepoCommand struct { 19 rtDetails *config.ArtifactoryDetails 20 templatePath string 21 vars string 22 } 23 24 func (rc *RepoCommand) PerformRepoCmd(isUpdate bool) (err error) { 25 // Read the template file 26 content, err := fileutils.ReadFile(rc.templatePath) 27 if errorutils.CheckError(err) != nil { 28 return 29 } 30 // Replace vars string-by-string if needed 31 if len(rc.vars) > 0 { 32 templateVars := cliutils.SpecVarsStringToMap(rc.vars) 33 content = cliutils.ReplaceVars(content, templateVars) 34 } 35 // Unmarshal template to a map 36 var repoConfigMap map[string]interface{} 37 err = json.Unmarshal(content, &repoConfigMap) 38 if errorutils.CheckError(err) != nil { 39 return 40 } 41 // All the values in the template are strings 42 // Go over the the confMap and write the values with the correct type using the writersMap 43 for key, value := range repoConfigMap { 44 writersMap[key](&repoConfigMap, key, value.(string)) 45 } 46 // Write a JSON with the correct values 47 content, err = json.Marshal(repoConfigMap) 48 49 servicesManager, err := rtUtils.CreateServiceManager(rc.rtDetails, false) 50 if err != nil { 51 return err 52 } 53 // Rclass and packgeType are mandatory keys in our templates 54 // Using their values we'll pick the suitable handler from one of the handler maps to create/update a repository 55 switch repoConfigMap[Rclass] { 56 case Local: 57 err = localRepoHandlers[repoConfigMap[PackageType].(string)](servicesManager, content, isUpdate) 58 case Remote: 59 err = remoteRepoHandlers[repoConfigMap[PackageType].(string)](servicesManager, content, isUpdate) 60 case Virtual: 61 err = virtualRepoHandlers[repoConfigMap[PackageType].(string)](servicesManager, content, isUpdate) 62 default: 63 return errorutils.CheckError(errors.New("unsupported rclass")) 64 } 65 return err 66 } 67 68 var writersMap = map[string]utils.AnswerWriter{ 69 Key: utils.WriteStringAnswer, 70 Rclass: utils.WriteStringAnswer, 71 PackageType: utils.WriteStringAnswer, 72 MandatoryUrl: utils.WriteStringAnswer, 73 Url: utils.WriteStringAnswer, 74 Description: utils.WriteStringAnswer, 75 Notes: utils.WriteStringAnswer, 76 IncludePatterns: utils.WriteStringAnswer, 77 ExcludePatterns: utils.WriteStringAnswer, 78 RepoLayoutRef: utils.WriteStringAnswer, 79 HandleReleases: utils.WriteBoolAnswer, 80 HandleSnapshots: utils.WriteBoolAnswer, 81 MaxUniqueSnapshots: utils.WriteIntAnswer, 82 SuppressPomConsistencyChecks: utils.WriteBoolAnswer, 83 BlackedOut: utils.WriteBoolAnswer, 84 DownloadRedirect: utils.WriteBoolAnswer, 85 BlockPushingSchema1: utils.WriteBoolAnswer, 86 DebianTrivialLayout: utils.WriteBoolAnswer, 87 ExternalDependenciesEnabled: utils.WriteBoolAnswer, 88 ExternalDependenciesPatterns: utils.WriteStringArrayAnswer, 89 ChecksumPolicyType: utils.WriteStringAnswer, 90 MaxUniqueTags: utils.WriteIntAnswer, 91 SnapshotVersionBehavior: utils.WriteStringAnswer, 92 XrayIndex: utils.WriteBoolAnswer, 93 PropertySets: utils.WriteStringArrayAnswer, 94 ArchiveBrowsingEnabled: utils.WriteBoolAnswer, 95 CalculateYumMetadata: utils.WriteBoolAnswer, 96 YumRootDepth: utils.WriteIntAnswer, 97 DockerApiVersion: utils.WriteStringAnswer, 98 EnableFileListsIndexing: utils.WriteBoolAnswer, 99 OptionalIndexCompressionFormats: utils.WriteStringAnswer, 100 Username: utils.WriteStringAnswer, 101 Password: utils.WriteStringAnswer, 102 Proxy: utils.WriteStringAnswer, 103 RemoteRepoChecksumPolicyType: utils.WriteStringAnswer, 104 HardFail: utils.WriteBoolAnswer, 105 Offline: utils.WriteBoolAnswer, 106 StoreArtifactsLocally: utils.WriteBoolAnswer, 107 SocketTimeoutMillis: utils.WriteIntAnswer, 108 LocalAddress: utils.WriteStringAnswer, 109 RetrievalCachePeriodSecs: utils.WriteIntAnswer, 110 FailedRetrievalCachePeriodSecs: utils.WriteIntAnswer, 111 MissedRetrievalCachePeriodSecs: utils.WriteIntAnswer, 112 UnusedArtifactsCleanupEnabled: utils.WriteBoolAnswer, 113 UnusedArtifactsCleanupPeriodHours: utils.WriteIntAnswer, 114 AssumedOfflinePeriodSecs: utils.WriteIntAnswer, 115 FetchJarsEagerly: utils.WriteBoolAnswer, 116 FetchSourcesEagerly: utils.WriteBoolAnswer, 117 ShareConfiguration: utils.WriteBoolAnswer, 118 SynchronizeProperties: utils.WriteBoolAnswer, 119 BlockMismatchingMimeTypes: utils.WriteBoolAnswer, 120 AllowAnyHostAuth: utils.WriteBoolAnswer, 121 EnableCookieManagement: utils.WriteBoolAnswer, 122 BowerRegistryUrl: utils.WriteStringAnswer, 123 ComposerRegistryUrl: utils.WriteStringAnswer, 124 PyPIRegistryUrl: utils.WriteStringAnswer, 125 VcsType: utils.WriteStringAnswer, 126 VcsGitProvider: utils.WriteStringAnswer, 127 VcsGitDownloadUrl: utils.WriteStringAnswer, 128 BypassHeadRequests: utils.WriteBoolAnswer, 129 ClientTlsCertificate: utils.WriteStringAnswer, 130 FeedContextPath: utils.WriteStringAnswer, 131 DownloadContextPath: utils.WriteStringAnswer, 132 V3FeedUrl: utils.WriteStringAnswer, 133 ContentSynchronisation: writeContentSynchronisation, 134 ListRemoteFolderItems: utils.WriteBoolAnswer, 135 RejectInvalidJars: utils.WriteBoolAnswer, 136 PodsSpecsRepoUrl: utils.WriteStringAnswer, 137 EnableTokenAuthentication: utils.WriteBoolAnswer, 138 Repositories: utils.WriteStringArrayAnswer, 139 ArtifactoryRequestsCanRetrieveRemoteArtifacts: utils.WriteBoolAnswer, 140 KeyPair: utils.WriteStringAnswer, 141 PomRepositoryReferencesCleanupPolicy: utils.WriteStringAnswer, 142 DefaultDeploymentRepo: utils.WriteStringAnswer, 143 ForceMavenAuthentication: utils.WriteBoolAnswer, 144 ExternalDependenciesRemoteRepo: utils.WriteStringAnswer, 145 } 146 147 func writeContentSynchronisation(resultMap *map[string]interface{}, key, value string) error { 148 answerArray := strings.Split(value, ",") 149 if len(answerArray) != 4 { 150 return errors.New("invalid value for Content Synchronisation") 151 } 152 var cs services.ContentSynchronisation 153 cs.Enabled, _ = strconv.ParseBool(answerArray[0]) 154 cs.Statistics.Enabled, _ = strconv.ParseBool(answerArray[1]) 155 cs.Properties.Enabled, _ = strconv.ParseBool(answerArray[2]) 156 cs.Source.OriginAbsenceDetection, _ = strconv.ParseBool(answerArray[3]) 157 158 (*resultMap)[key] = cs 159 return nil 160 161 } 162 163 // repoHandler is a function that gets serviceManager, JSON configuration content and a flag indicates is the operation in an update operation 164 // Each handler unmarshal the JSOn content into the jfrog-client's unique rclass-pkgType param struct, and run the operation service 165 type repoHandler func(*artifactory.ArtifactoryServicesManager, []byte, bool) error 166 167 var localRepoHandlers = map[string]repoHandler{ 168 Maven: localMavenHandler, 169 Gradle: localGradleHandler, 170 Ivy: localIvyHandles, 171 Sbt: localSbtHandler, 172 Helm: localHelmHandler, 173 Cocoapods: localCocoapodsHandler, 174 Opkg: localOpkgHandler, 175 Rpm: localRpmHandler, 176 Nuget: localNugetHandler, 177 Cran: localCranHandler, 178 Gems: localGemsHandler, 179 Npm: localNpmHandler, 180 Bower: localBowerHandler, 181 Debian: localDebianHandler, 182 Composer: localComposerHandler, 183 Pypi: localPypiHandler, 184 Docker: localDockerHandler, 185 Vagrant: localVagrantHandler, 186 Gitlfs: localGitlfsHandler, 187 Go: localGoHandler, 188 Yum: localYumHandler, 189 Conan: localConanHandler, 190 Chef: localChefHandler, 191 Puppet: localPuppetHandler, 192 Generic: localGenericHandler, 193 } 194 195 func localMavenHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 196 params := services.NewMavenLocalRepositoryParams() 197 err := json.Unmarshal(jsonConfig, ¶ms) 198 if errorutils.CheckError(err) != nil { 199 return err 200 } 201 if isUpdate { 202 err = servicesManager.UpdateLocalRepository().Maven(params) 203 } else { 204 err = servicesManager.CreateLocalRepository().Maven(params) 205 } 206 return err 207 } 208 209 func localGradleHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 210 params := services.NewGradleLocalRepositoryParams() 211 err := json.Unmarshal(jsonConfig, ¶ms) 212 if errorutils.CheckError(err) != nil { 213 return err 214 } 215 if isUpdate { 216 err = servicesManager.UpdateLocalRepository().Gradle(params) 217 } else { 218 err = servicesManager.CreateLocalRepository().Gradle(params) 219 } 220 return err 221 } 222 223 func localIvyHandles(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 224 params := services.NewIvyLocalRepositoryParams() 225 err := json.Unmarshal(jsonConfig, ¶ms) 226 if errorutils.CheckError(err) != nil { 227 return err 228 } 229 if isUpdate { 230 err = servicesManager.UpdateLocalRepository().Ivy(params) 231 } else { 232 err = servicesManager.CreateLocalRepository().Ivy(params) 233 } 234 return err 235 } 236 237 func localSbtHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 238 params := services.NewSbtLocalRepositoryParams() 239 err := json.Unmarshal(jsonConfig, ¶ms) 240 if errorutils.CheckError(err) != nil { 241 return err 242 } 243 if isUpdate { 244 err = servicesManager.UpdateLocalRepository().Sbt(params) 245 } else { 246 err = servicesManager.CreateLocalRepository().Sbt(params) 247 } 248 return err 249 } 250 251 func localHelmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 252 params := services.NewHelmLocalRepositoryParams() 253 err := json.Unmarshal(jsonConfig, ¶ms) 254 if errorutils.CheckError(err) != nil { 255 return err 256 } 257 if isUpdate { 258 err = servicesManager.UpdateLocalRepository().Helm(params) 259 } else { 260 err = servicesManager.CreateLocalRepository().Helm(params) 261 } 262 return err 263 } 264 265 func localCocoapodsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 266 params := services.NewCocoapodsLocalRepositoryParams() 267 err := json.Unmarshal(jsonConfig, ¶ms) 268 if errorutils.CheckError(err) != nil { 269 return err 270 } 271 if isUpdate { 272 err = servicesManager.UpdateLocalRepository().Cocoapods(params) 273 } else { 274 err = servicesManager.CreateLocalRepository().Cocoapods(params) 275 } 276 return err 277 } 278 279 func localOpkgHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 280 params := services.NewOpkgLocalRepositoryParams() 281 err := json.Unmarshal(jsonConfig, ¶ms) 282 if errorutils.CheckError(err) != nil { 283 return err 284 } 285 if isUpdate { 286 err = servicesManager.UpdateLocalRepository().Opkg(params) 287 } else { 288 err = servicesManager.CreateLocalRepository().Opkg(params) 289 } 290 return err 291 } 292 293 func localRpmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 294 params := services.NewRpmLocalRepositoryParams() 295 err := json.Unmarshal(jsonConfig, ¶ms) 296 if errorutils.CheckError(err) != nil { 297 return err 298 } 299 if isUpdate { 300 err = servicesManager.UpdateLocalRepository().Rpm(params) 301 } else { 302 err = servicesManager.CreateLocalRepository().Rpm(params) 303 } 304 return err 305 } 306 307 func localNugetHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 308 params := services.NewNugetLocalRepositoryParams() 309 err := json.Unmarshal(jsonConfig, ¶ms) 310 if errorutils.CheckError(err) != nil { 311 return err 312 } 313 if isUpdate { 314 err = servicesManager.UpdateLocalRepository().Nuget(params) 315 } else { 316 err = servicesManager.CreateLocalRepository().Nuget(params) 317 } 318 return err 319 } 320 321 func localCranHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 322 params := services.NewCranLocalRepositoryParams() 323 err := json.Unmarshal(jsonConfig, ¶ms) 324 if errorutils.CheckError(err) != nil { 325 return err 326 } 327 if isUpdate { 328 err = servicesManager.UpdateLocalRepository().Cran(params) 329 } else { 330 err = servicesManager.CreateLocalRepository().Cran(params) 331 } 332 return err 333 } 334 335 func localGemsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 336 params := services.NewGemsLocalRepositoryParams() 337 err := json.Unmarshal(jsonConfig, ¶ms) 338 if errorutils.CheckError(err) != nil { 339 return err 340 } 341 if isUpdate { 342 err = servicesManager.UpdateLocalRepository().Gems(params) 343 } else { 344 err = servicesManager.CreateLocalRepository().Gems(params) 345 } 346 return err 347 } 348 349 func localNpmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 350 params := services.NewNpmLocalRepositoryParams() 351 err := json.Unmarshal(jsonConfig, ¶ms) 352 if errorutils.CheckError(err) != nil { 353 return err 354 } 355 if isUpdate { 356 err = servicesManager.UpdateLocalRepository().Npm(params) 357 } else { 358 err = servicesManager.CreateLocalRepository().Npm(params) 359 } 360 return err 361 } 362 363 func localBowerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 364 params := services.NewBowerLocalRepositoryParams() 365 err := json.Unmarshal(jsonConfig, ¶ms) 366 if errorutils.CheckError(err) != nil { 367 return err 368 } 369 if isUpdate { 370 err = servicesManager.UpdateLocalRepository().Bower(params) 371 } else { 372 err = servicesManager.CreateLocalRepository().Bower(params) 373 } 374 return err 375 } 376 377 func localDebianHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 378 params := services.NewDebianLocalRepositoryParams() 379 err := json.Unmarshal(jsonConfig, ¶ms) 380 if errorutils.CheckError(err) != nil { 381 return err 382 } 383 if isUpdate { 384 err = servicesManager.UpdateLocalRepository().Debian(params) 385 } else { 386 err = servicesManager.CreateLocalRepository().Debian(params) 387 } 388 return err 389 } 390 391 func localComposerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 392 params := services.NewComposerLocalRepositoryParams() 393 err := json.Unmarshal(jsonConfig, ¶ms) 394 if errorutils.CheckError(err) != nil { 395 return err 396 } 397 if isUpdate { 398 err = servicesManager.UpdateLocalRepository().Composer(params) 399 } else { 400 err = servicesManager.CreateLocalRepository().Composer(params) 401 } 402 return err 403 } 404 405 func localPypiHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 406 params := services.NewPypiLocalRepositoryParams() 407 err := json.Unmarshal(jsonConfig, ¶ms) 408 if errorutils.CheckError(err) != nil { 409 return err 410 } 411 if isUpdate { 412 err = servicesManager.UpdateLocalRepository().Pypi(params) 413 } else { 414 err = servicesManager.CreateLocalRepository().Pypi(params) 415 } 416 return err 417 } 418 419 func localDockerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 420 params := services.NewDockerLocalRepositoryParams() 421 err := json.Unmarshal(jsonConfig, ¶ms) 422 if errorutils.CheckError(err) != nil { 423 return err 424 } 425 if isUpdate { 426 err = servicesManager.UpdateLocalRepository().Docker(params) 427 } else { 428 err = servicesManager.CreateLocalRepository().Docker(params) 429 } 430 return err 431 } 432 433 func localVagrantHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 434 params := services.NewVagrantLocalRepositoryParams() 435 err := json.Unmarshal(jsonConfig, ¶ms) 436 if errorutils.CheckError(err) != nil { 437 return err 438 } 439 if isUpdate { 440 err = servicesManager.UpdateLocalRepository().Vagrant(params) 441 } else { 442 err = servicesManager.CreateLocalRepository().Vagrant(params) 443 } 444 return err 445 } 446 447 func localGitlfsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 448 params := services.NewGitlfsLocalRepositoryParams() 449 err := json.Unmarshal(jsonConfig, ¶ms) 450 if errorutils.CheckError(err) != nil { 451 return err 452 } 453 if isUpdate { 454 err = servicesManager.UpdateLocalRepository().Gitlfs(params) 455 } else { 456 err = servicesManager.CreateLocalRepository().Gitlfs(params) 457 } 458 return err 459 } 460 461 func localGoHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 462 params := services.NewGoLocalRepositoryParams() 463 err := json.Unmarshal(jsonConfig, ¶ms) 464 if errorutils.CheckError(err) != nil { 465 return err 466 } 467 if isUpdate { 468 err = servicesManager.UpdateLocalRepository().Go(params) 469 } else { 470 err = servicesManager.CreateLocalRepository().Go(params) 471 } 472 return err 473 } 474 475 func localYumHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 476 params := services.NewYumLocalRepositoryParams() 477 err := json.Unmarshal(jsonConfig, ¶ms) 478 if errorutils.CheckError(err) != nil { 479 return err 480 } 481 if isUpdate { 482 err = servicesManager.UpdateLocalRepository().Yum(params) 483 } else { 484 err = servicesManager.CreateLocalRepository().Yum(params) 485 } 486 return err 487 } 488 489 func localConanHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 490 params := services.NewConanLocalRepositoryParams() 491 err := json.Unmarshal(jsonConfig, ¶ms) 492 if errorutils.CheckError(err) != nil { 493 return err 494 } 495 if isUpdate { 496 err = servicesManager.UpdateLocalRepository().Conan(params) 497 } else { 498 err = servicesManager.CreateLocalRepository().Conan(params) 499 } 500 return err 501 } 502 503 func localChefHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 504 params := services.NewChefLocalRepositoryParams() 505 err := json.Unmarshal(jsonConfig, ¶ms) 506 if errorutils.CheckError(err) != nil { 507 return err 508 } 509 if isUpdate { 510 err = servicesManager.UpdateLocalRepository().Chef(params) 511 } else { 512 err = servicesManager.CreateLocalRepository().Chef(params) 513 } 514 return err 515 } 516 517 func localPuppetHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 518 params := services.NewPuppetLocalRepositoryParams() 519 err := json.Unmarshal(jsonConfig, ¶ms) 520 if errorutils.CheckError(err) != nil { 521 return err 522 } 523 if isUpdate { 524 err = servicesManager.UpdateLocalRepository().Puppet(params) 525 } else { 526 err = servicesManager.CreateLocalRepository().Puppet(params) 527 } 528 return err 529 } 530 531 func localGenericHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 532 params := services.NewGenericLocalRepositoryParams() 533 err := json.Unmarshal(jsonConfig, ¶ms) 534 if errorutils.CheckError(err) != nil { 535 return err 536 } 537 538 if isUpdate { 539 err = servicesManager.UpdateLocalRepository().Generic(params) 540 } else { 541 err = servicesManager.CreateLocalRepository().Generic(params) 542 } 543 return err 544 } 545 546 var remoteRepoHandlers = map[string]repoHandler{ 547 Maven: remoteMavenHandler, 548 Gradle: remoteGradleHandler, 549 Ivy: remoteIvyHandler, 550 Sbt: remoteSbtHandler, 551 Helm: remoteHelmHandler, 552 Cocoapods: remoteCocoapodsHandler, 553 Opkg: remoteOpkgHandler, 554 Rpm: remoteRpmHandler, 555 Nuget: remoteNugetHandler, 556 Cran: remoteCranHandler, 557 Gems: remoteGemsHandler, 558 Npm: remoteNpmHandler, 559 Bower: remoteBowerHandler, 560 Debian: remoteDebianHandler, 561 Composer: remoteComposerHandler, 562 Pypi: remotelPypiHandler, 563 Docker: remoteDockerHandler, 564 Gitlfs: remoteGitlfsHandler, 565 Go: remoteGoHandler, 566 Yum: remoteYumHandler, 567 Conan: remoteConanHandler, 568 Chef: remoteChefHandler, 569 Puppet: remotePuppetHandler, 570 Conda: remoteCondaHandler, 571 P2: remoteP2Handler, 572 Vcs: remoteVcsHandler, 573 Generic: remoteGenericHandler, 574 } 575 576 func remoteMavenHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 577 params := services.NewMavenRemoteRepositoryParams() 578 err := json.Unmarshal(jsonConfig, ¶ms) 579 if errorutils.CheckError(err) != nil { 580 return err 581 } 582 if isUpdate { 583 err = servicesManager.UpdateRemoteRepository().Maven(params) 584 } else { 585 err = servicesManager.CreateRemoteRepository().Maven(params) 586 } 587 return err 588 } 589 590 func remoteGradleHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 591 params := services.NewGradleRemoteRepositoryParams() 592 err := json.Unmarshal(jsonConfig, ¶ms) 593 if errorutils.CheckError(err) != nil { 594 return err 595 } 596 if isUpdate { 597 err = servicesManager.UpdateRemoteRepository().Gradle(params) 598 } else { 599 err = servicesManager.CreateRemoteRepository().Gradle(params) 600 } 601 return err 602 } 603 604 func remoteIvyHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 605 params := services.NewIvyRemoteRepositoryParams() 606 err := json.Unmarshal(jsonConfig, ¶ms) 607 if errorutils.CheckError(err) != nil { 608 return err 609 } 610 if isUpdate { 611 err = servicesManager.UpdateRemoteRepository().Ivy(params) 612 } else { 613 err = servicesManager.CreateRemoteRepository().Ivy(params) 614 } 615 return err 616 } 617 618 func remoteSbtHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 619 params := services.NewSbtRemoteRepositoryParams() 620 err := json.Unmarshal(jsonConfig, ¶ms) 621 if errorutils.CheckError(err) != nil { 622 return err 623 } 624 if isUpdate { 625 err = servicesManager.UpdateRemoteRepository().Sbt(params) 626 } else { 627 err = servicesManager.CreateRemoteRepository().Sbt(params) 628 } 629 return err 630 } 631 632 func remoteHelmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 633 params := services.NewHelmRemoteRepositoryParams() 634 err := json.Unmarshal(jsonConfig, ¶ms) 635 if errorutils.CheckError(err) != nil { 636 return err 637 } 638 if isUpdate { 639 err = servicesManager.UpdateRemoteRepository().Helm(params) 640 } else { 641 err = servicesManager.CreateRemoteRepository().Helm(params) 642 } 643 return err 644 } 645 646 func remoteCocoapodsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 647 params := services.NewCocoapodsRemoteRepositoryParams() 648 err := json.Unmarshal(jsonConfig, ¶ms) 649 if errorutils.CheckError(err) != nil { 650 return err 651 } 652 if isUpdate { 653 err = servicesManager.UpdateRemoteRepository().Cocoapods(params) 654 } else { 655 err = servicesManager.CreateRemoteRepository().Cocoapods(params) 656 } 657 return err 658 } 659 660 func remoteOpkgHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 661 params := services.NewOpkgRemoteRepositoryParams() 662 err := json.Unmarshal(jsonConfig, ¶ms) 663 if errorutils.CheckError(err) != nil { 664 return err 665 } 666 if isUpdate { 667 err = servicesManager.UpdateRemoteRepository().Opkg(params) 668 } else { 669 err = servicesManager.CreateRemoteRepository().Opkg(params) 670 } 671 return err 672 } 673 674 func remoteRpmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 675 params := services.NewRpmRemoteRepositoryParams() 676 err := json.Unmarshal(jsonConfig, ¶ms) 677 if errorutils.CheckError(err) != nil { 678 return err 679 } 680 if isUpdate { 681 err = servicesManager.UpdateRemoteRepository().Rpm(params) 682 } else { 683 err = servicesManager.CreateRemoteRepository().Rpm(params) 684 } 685 return err 686 } 687 688 func remoteNugetHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 689 params := services.NewNugetRemoteRepositoryParams() 690 err := json.Unmarshal(jsonConfig, ¶ms) 691 if errorutils.CheckError(err) != nil { 692 return err 693 } 694 if isUpdate { 695 err = servicesManager.UpdateRemoteRepository().Nuget(params) 696 } else { 697 err = servicesManager.CreateRemoteRepository().Nuget(params) 698 } 699 return err 700 } 701 702 func remoteCranHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 703 params := services.NewCranRemoteRepositoryParams() 704 err := json.Unmarshal(jsonConfig, ¶ms) 705 if errorutils.CheckError(err) != nil { 706 return err 707 } 708 if isUpdate { 709 err = servicesManager.UpdateRemoteRepository().Cran(params) 710 } else { 711 err = servicesManager.CreateRemoteRepository().Cran(params) 712 } 713 return err 714 } 715 716 func remoteGemsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 717 params := services.NewGemsRemoteRepositoryParams() 718 err := json.Unmarshal(jsonConfig, ¶ms) 719 if errorutils.CheckError(err) != nil { 720 return err 721 } 722 if isUpdate { 723 err = servicesManager.UpdateRemoteRepository().Gems(params) 724 } else { 725 err = servicesManager.CreateRemoteRepository().Gems(params) 726 } 727 return err 728 } 729 730 func remoteNpmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 731 params := services.NewNpmRemoteRepositoryParams() 732 err := json.Unmarshal(jsonConfig, ¶ms) 733 if errorutils.CheckError(err) != nil { 734 return err 735 } 736 if isUpdate { 737 err = servicesManager.UpdateRemoteRepository().Npm(params) 738 } else { 739 err = servicesManager.CreateRemoteRepository().Npm(params) 740 } 741 return err 742 } 743 744 func remoteBowerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 745 params := services.NewBowerRemoteRepositoryParams() 746 err := json.Unmarshal(jsonConfig, ¶ms) 747 if errorutils.CheckError(err) != nil { 748 return err 749 } 750 if isUpdate { 751 err = servicesManager.UpdateRemoteRepository().Bower(params) 752 } else { 753 err = servicesManager.CreateRemoteRepository().Bower(params) 754 } 755 return err 756 } 757 758 func remoteDebianHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 759 params := services.NewDebianRemoteRepositoryParams() 760 err := json.Unmarshal(jsonConfig, ¶ms) 761 if errorutils.CheckError(err) != nil { 762 return err 763 } 764 if isUpdate { 765 err = servicesManager.UpdateRemoteRepository().Debian(params) 766 } else { 767 err = servicesManager.CreateRemoteRepository().Debian(params) 768 } 769 return err 770 } 771 772 func remoteComposerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 773 params := services.NewComposerRemoteRepositoryParams() 774 err := json.Unmarshal(jsonConfig, ¶ms) 775 if errorutils.CheckError(err) != nil { 776 return err 777 } 778 if isUpdate { 779 err = servicesManager.UpdateRemoteRepository().Composer(params) 780 } else { 781 err = servicesManager.CreateRemoteRepository().Composer(params) 782 } 783 return err 784 } 785 786 func remotelPypiHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 787 params := services.NewPypiRemoteRepositoryParams() 788 err := json.Unmarshal(jsonConfig, ¶ms) 789 if errorutils.CheckError(err) != nil { 790 return err 791 } 792 if isUpdate { 793 err = servicesManager.UpdateRemoteRepository().Pypi(params) 794 } else { 795 err = servicesManager.CreateRemoteRepository().Pypi(params) 796 } 797 return err 798 } 799 800 func remoteDockerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 801 params := services.NewDockerRemoteRepositoryParams() 802 err := json.Unmarshal(jsonConfig, ¶ms) 803 if errorutils.CheckError(err) != nil { 804 return err 805 } 806 if isUpdate { 807 err = servicesManager.UpdateRemoteRepository().Docker(params) 808 } else { 809 err = servicesManager.CreateRemoteRepository().Docker(params) 810 } 811 return err 812 } 813 814 func remoteGitlfsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 815 params := services.NewGitlfsRemoteRepositoryParams() 816 err := json.Unmarshal(jsonConfig, ¶ms) 817 if errorutils.CheckError(err) != nil { 818 return err 819 } 820 if isUpdate { 821 err = servicesManager.UpdateRemoteRepository().Gitlfs(params) 822 } else { 823 err = servicesManager.CreateRemoteRepository().Gitlfs(params) 824 } 825 return err 826 } 827 828 func remoteGoHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 829 params := services.NewGoRemoteRepositoryParams() 830 err := json.Unmarshal(jsonConfig, ¶ms) 831 if errorutils.CheckError(err) != nil { 832 return err 833 } 834 if isUpdate { 835 err = servicesManager.UpdateRemoteRepository().Go(params) 836 } else { 837 err = servicesManager.CreateRemoteRepository().Go(params) 838 } 839 return err 840 } 841 842 func remoteConanHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 843 params := services.NewConanRemoteRepositoryParams() 844 err := json.Unmarshal(jsonConfig, ¶ms) 845 if errorutils.CheckError(err) != nil { 846 return err 847 } 848 if isUpdate { 849 err = servicesManager.UpdateRemoteRepository().Conan(params) 850 } else { 851 err = servicesManager.CreateRemoteRepository().Conan(params) 852 } 853 return err 854 } 855 856 func remoteChefHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 857 params := services.NewChefRemoteRepositoryParams() 858 err := json.Unmarshal(jsonConfig, ¶ms) 859 if errorutils.CheckError(err) != nil { 860 return err 861 } 862 if isUpdate { 863 err = servicesManager.UpdateRemoteRepository().Chef(params) 864 } else { 865 err = servicesManager.CreateRemoteRepository().Chef(params) 866 } 867 return err 868 } 869 870 func remotePuppetHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 871 params := services.NewPuppetRemoteRepositoryParams() 872 err := json.Unmarshal(jsonConfig, ¶ms) 873 if errorutils.CheckError(err) != nil { 874 return err 875 } 876 if isUpdate { 877 err = servicesManager.UpdateRemoteRepository().Puppet(params) 878 } else { 879 err = servicesManager.CreateRemoteRepository().Puppet(params) 880 } 881 return err 882 } 883 884 func remoteVcsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 885 params := services.NewVcsRemoteRepositoryParams() 886 err := json.Unmarshal(jsonConfig, ¶ms) 887 if errorutils.CheckError(err) != nil { 888 return err 889 } 890 if isUpdate { 891 err = servicesManager.UpdateRemoteRepository().Vcs(params) 892 } else { 893 err = servicesManager.CreateRemoteRepository().Vcs(params) 894 } 895 return err 896 } 897 898 func remoteP2Handler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 899 params := services.NewP2RemoteRepositoryParams() 900 err := json.Unmarshal(jsonConfig, ¶ms) 901 if errorutils.CheckError(err) != nil { 902 return err 903 } 904 if isUpdate { 905 err = servicesManager.UpdateRemoteRepository().P2(params) 906 } else { 907 err = servicesManager.CreateRemoteRepository().P2(params) 908 } 909 return err 910 } 911 912 func remoteCondaHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 913 params := services.NewCondaRemoteRepositoryParams() 914 err := json.Unmarshal(jsonConfig, ¶ms) 915 if errorutils.CheckError(err) != nil { 916 return err 917 } 918 if isUpdate { 919 err = servicesManager.UpdateRemoteRepository().Conda(params) 920 } else { 921 err = servicesManager.CreateRemoteRepository().Conda(params) 922 } 923 return err 924 } 925 926 func remoteYumHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 927 params := services.NewYumRemoteRepositoryParams() 928 err := json.Unmarshal(jsonConfig, ¶ms) 929 if errorutils.CheckError(err) != nil { 930 return err 931 } 932 if isUpdate { 933 err = servicesManager.UpdateRemoteRepository().Yum(params) 934 } else { 935 err = servicesManager.CreateRemoteRepository().Yum(params) 936 } 937 return err 938 } 939 940 func remoteGenericHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 941 params := services.NewGenericRemoteRepositoryParams() 942 err := json.Unmarshal(jsonConfig, ¶ms) 943 if errorutils.CheckError(err) != nil { 944 return err 945 } 946 if isUpdate { 947 err = servicesManager.UpdateRemoteRepository().Generic(params) 948 } else { 949 err = servicesManager.CreateRemoteRepository().Generic(params) 950 } 951 return err 952 } 953 954 var virtualRepoHandlers = map[string]repoHandler{ 955 Maven: virtualMavenHandler, 956 Gradle: virtualGradleHandler, 957 Ivy: virtualIvyHandler, 958 Sbt: virtualSbtHandler, 959 Helm: virtualHelmHandler, 960 Rpm: virtualRpmHandler, 961 Nuget: virtualNugetHandler, 962 Cran: virtualCranHandler, 963 Gems: virtualGemsHandler, 964 Npm: virtualNpmHandler, 965 Bower: virtualBowerHandler, 966 Debian: virtualDebianHandler, 967 Pypi: virtualPypiHandler, 968 Docker: virtualDockerHandler, 969 Gitlfs: virtualGitlfsHandler, 970 Go: virtualGoHandler, 971 Yum: virtualYumHandler, 972 Conan: virtualConanHandler, 973 Chef: virtualChefHandler, 974 Puppet: virtualPuppetHandler, 975 Conda: virtualCondaHandler, 976 P2: virtualP2Handler, 977 Generic: virtualGenericHandler, 978 } 979 980 func virtualMavenHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 981 params := services.NewMavenVirtualRepositoryParams() 982 err := json.Unmarshal(jsonConfig, ¶ms) 983 if errorutils.CheckError(err) != nil { 984 return err 985 } 986 if isUpdate { 987 err = servicesManager.UpdateVirtualRepository().Maven(params) 988 } else { 989 err = servicesManager.CreateVirtualRepository().Maven(params) 990 } 991 return err 992 } 993 994 func virtualGradleHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 995 params := services.NewGradleVirtualRepositoryParams() 996 err := json.Unmarshal(jsonConfig, ¶ms) 997 if errorutils.CheckError(err) != nil { 998 return err 999 } 1000 if isUpdate { 1001 err = servicesManager.UpdateVirtualRepository().Gradle(params) 1002 } else { 1003 err = servicesManager.CreateVirtualRepository().Gradle(params) 1004 } 1005 return err 1006 } 1007 1008 func virtualIvyHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1009 params := services.NewIvyVirtualRepositoryParams() 1010 err := json.Unmarshal(jsonConfig, ¶ms) 1011 if errorutils.CheckError(err) != nil { 1012 return err 1013 } 1014 if isUpdate { 1015 err = servicesManager.UpdateVirtualRepository().Ivy(params) 1016 } else { 1017 err = servicesManager.CreateVirtualRepository().Ivy(params) 1018 } 1019 return err 1020 } 1021 1022 func virtualSbtHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1023 params := services.NewSbtVirtualRepositoryParams() 1024 err := json.Unmarshal(jsonConfig, ¶ms) 1025 if errorutils.CheckError(err) != nil { 1026 return err 1027 } 1028 if isUpdate { 1029 err = servicesManager.UpdateVirtualRepository().Sbt(params) 1030 } else { 1031 err = servicesManager.CreateVirtualRepository().Sbt(params) 1032 } 1033 return err 1034 } 1035 1036 func virtualHelmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1037 params := services.NewHelmVirtualRepositoryParams() 1038 err := json.Unmarshal(jsonConfig, ¶ms) 1039 if errorutils.CheckError(err) != nil { 1040 return err 1041 } 1042 if isUpdate { 1043 err = servicesManager.UpdateVirtualRepository().Helm(params) 1044 } else { 1045 err = servicesManager.CreateVirtualRepository().Helm(params) 1046 } 1047 return err 1048 } 1049 1050 func virtualRpmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1051 params := services.NewRpmVirtualRepositoryParams() 1052 err := json.Unmarshal(jsonConfig, ¶ms) 1053 if errorutils.CheckError(err) != nil { 1054 return err 1055 } 1056 if isUpdate { 1057 err = servicesManager.UpdateVirtualRepository().Rpm(params) 1058 } else { 1059 err = servicesManager.CreateVirtualRepository().Rpm(params) 1060 } 1061 return err 1062 } 1063 1064 func virtualNugetHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1065 params := services.NewNugetVirtualRepositoryParams() 1066 err := json.Unmarshal(jsonConfig, ¶ms) 1067 if errorutils.CheckError(err) != nil { 1068 return err 1069 } 1070 if isUpdate { 1071 err = servicesManager.UpdateVirtualRepository().Nuget(params) 1072 } else { 1073 err = servicesManager.CreateVirtualRepository().Nuget(params) 1074 } 1075 return err 1076 } 1077 1078 func virtualCranHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1079 params := services.NewCranVirtualRepositoryParams() 1080 err := json.Unmarshal(jsonConfig, ¶ms) 1081 if errorutils.CheckError(err) != nil { 1082 return err 1083 } 1084 if isUpdate { 1085 err = servicesManager.UpdateVirtualRepository().Cran(params) 1086 } else { 1087 err = servicesManager.CreateVirtualRepository().Cran(params) 1088 } 1089 return err 1090 } 1091 1092 func virtualGemsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1093 params := services.NewGemsVirtualRepositoryParams() 1094 err := json.Unmarshal(jsonConfig, ¶ms) 1095 if errorutils.CheckError(err) != nil { 1096 return err 1097 } 1098 if isUpdate { 1099 err = servicesManager.UpdateVirtualRepository().Gems(params) 1100 } else { 1101 err = servicesManager.CreateVirtualRepository().Gems(params) 1102 } 1103 return err 1104 } 1105 1106 func virtualNpmHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1107 params := services.NewNpmVirtualRepositoryParams() 1108 err := json.Unmarshal(jsonConfig, ¶ms) 1109 if errorutils.CheckError(err) != nil { 1110 return err 1111 } 1112 if isUpdate { 1113 err = servicesManager.UpdateVirtualRepository().Npm(params) 1114 } else { 1115 err = servicesManager.CreateVirtualRepository().Npm(params) 1116 } 1117 return err 1118 } 1119 1120 func virtualBowerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1121 params := services.NewBowerVirtualRepositoryParams() 1122 err := json.Unmarshal(jsonConfig, ¶ms) 1123 if errorutils.CheckError(err) != nil { 1124 return err 1125 } 1126 if isUpdate { 1127 err = servicesManager.UpdateVirtualRepository().Bower(params) 1128 } else { 1129 err = servicesManager.CreateVirtualRepository().Bower(params) 1130 } 1131 return err 1132 } 1133 1134 func virtualDebianHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1135 params := services.NewDebianVirtualRepositoryParams() 1136 err := json.Unmarshal(jsonConfig, ¶ms) 1137 if errorutils.CheckError(err) != nil { 1138 return err 1139 } 1140 if isUpdate { 1141 err = servicesManager.UpdateVirtualRepository().Debian(params) 1142 } else { 1143 err = servicesManager.CreateVirtualRepository().Debian(params) 1144 } 1145 return err 1146 } 1147 1148 func virtualPypiHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1149 params := services.NewPypiVirtualRepositoryParams() 1150 err := json.Unmarshal(jsonConfig, ¶ms) 1151 if errorutils.CheckError(err) != nil { 1152 return err 1153 } 1154 if isUpdate { 1155 err = servicesManager.UpdateVirtualRepository().Pypi(params) 1156 } else { 1157 err = servicesManager.CreateVirtualRepository().Pypi(params) 1158 } 1159 return err 1160 } 1161 1162 func virtualDockerHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1163 params := services.NewDockerVirtualRepositoryParams() 1164 err := json.Unmarshal(jsonConfig, ¶ms) 1165 if errorutils.CheckError(err) != nil { 1166 return err 1167 } 1168 if isUpdate { 1169 err = servicesManager.UpdateVirtualRepository().Docker(params) 1170 } else { 1171 err = servicesManager.CreateVirtualRepository().Docker(params) 1172 } 1173 return err 1174 } 1175 1176 func virtualGitlfsHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1177 params := services.NewGitlfsVirtualRepositoryParams() 1178 err := json.Unmarshal(jsonConfig, ¶ms) 1179 if errorutils.CheckError(err) != nil { 1180 return err 1181 } 1182 if isUpdate { 1183 err = servicesManager.UpdateVirtualRepository().Gitlfs(params) 1184 } else { 1185 err = servicesManager.CreateVirtualRepository().Gitlfs(params) 1186 } 1187 return err 1188 } 1189 1190 func virtualGoHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1191 params := services.NewGoVirtualRepositoryParams() 1192 err := json.Unmarshal(jsonConfig, ¶ms) 1193 if errorutils.CheckError(err) != nil { 1194 return err 1195 } 1196 if isUpdate { 1197 err = servicesManager.UpdateVirtualRepository().Go(params) 1198 } else { 1199 err = servicesManager.CreateVirtualRepository().Go(params) 1200 } 1201 return err 1202 } 1203 1204 func virtualConanHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1205 params := services.NewConanVirtualRepositoryParams() 1206 err := json.Unmarshal(jsonConfig, ¶ms) 1207 if errorutils.CheckError(err) != nil { 1208 return err 1209 } 1210 if isUpdate { 1211 err = servicesManager.UpdateVirtualRepository().Conan(params) 1212 } else { 1213 err = servicesManager.CreateVirtualRepository().Conan(params) 1214 } 1215 return err 1216 } 1217 1218 func virtualChefHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1219 params := services.NewChefVirtualRepositoryParams() 1220 err := json.Unmarshal(jsonConfig, ¶ms) 1221 if errorutils.CheckError(err) != nil { 1222 return err 1223 } 1224 if isUpdate { 1225 err = servicesManager.UpdateVirtualRepository().Chef(params) 1226 } else { 1227 err = servicesManager.CreateVirtualRepository().Chef(params) 1228 } 1229 return err 1230 } 1231 1232 func virtualPuppetHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1233 params := services.NewPuppetVirtualRepositoryParams() 1234 err := json.Unmarshal(jsonConfig, ¶ms) 1235 if errorutils.CheckError(err) != nil { 1236 return err 1237 } 1238 if isUpdate { 1239 err = servicesManager.UpdateVirtualRepository().Puppet(params) 1240 } else { 1241 err = servicesManager.CreateVirtualRepository().Puppet(params) 1242 } 1243 return err 1244 } 1245 1246 func virtualYumHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1247 params := services.NewYumVirtualRepositoryParams() 1248 err := json.Unmarshal(jsonConfig, ¶ms) 1249 if errorutils.CheckError(err) != nil { 1250 return err 1251 } 1252 if isUpdate { 1253 err = servicesManager.UpdateVirtualRepository().Yum(params) 1254 } else { 1255 err = servicesManager.CreateVirtualRepository().Yum(params) 1256 } 1257 return err 1258 } 1259 1260 func virtualP2Handler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1261 params := services.NewP2VirtualRepositoryParams() 1262 err := json.Unmarshal(jsonConfig, ¶ms) 1263 if errorutils.CheckError(err) != nil { 1264 return err 1265 } 1266 if isUpdate { 1267 err = servicesManager.UpdateVirtualRepository().P2(params) 1268 } else { 1269 err = servicesManager.CreateVirtualRepository().P2(params) 1270 } 1271 return err 1272 } 1273 1274 func virtualCondaHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1275 params := services.NewCondaVirtualRepositoryParams() 1276 err := json.Unmarshal(jsonConfig, ¶ms) 1277 if errorutils.CheckError(err) != nil { 1278 return err 1279 } 1280 if isUpdate { 1281 err = servicesManager.UpdateVirtualRepository().Conda(params) 1282 } else { 1283 err = servicesManager.CreateVirtualRepository().Conda(params) 1284 } 1285 return err 1286 } 1287 1288 func virtualGenericHandler(servicesManager *artifactory.ArtifactoryServicesManager, jsonConfig []byte, isUpdate bool) error { 1289 params := services.NewGenericVirtualRepositoryParams() 1290 err := json.Unmarshal(jsonConfig, ¶ms) 1291 if errorutils.CheckError(err) != nil { 1292 return err 1293 } 1294 if isUpdate { 1295 err = servicesManager.UpdateVirtualRepository().Generic(params) 1296 } else { 1297 err = servicesManager.CreateVirtualRepository().Generic(params) 1298 } 1299 return err 1300 }