MCPcopy Create free account
hub / github.com/aptly-dev/aptly / GetPublishedStorage

Method GetPublishedStorage

context/context.go:417–504  ·  view source on GitHub ↗

GetPublishedStorage returns instance of PublishedStorage, or an error if the storage is not configured

(name string)

Source from the content-addressed store, hash-verified

415
416// GetPublishedStorage returns instance of PublishedStorage, or an error if the storage is not configured
417func (context *AptlyContext) GetPublishedStorage(name string) (aptly.PublishedStorage, error) {
418 context.Lock()
419 defer context.Unlock()
420
421 publishedStorage, ok := context.publishedStorages[name]
422 if !ok {
423 if name == "" {
424 publishedStorage = files.NewPublishedStorage(filepath.Join(context.config().GetRootDir(), "public"), "hardlink", "")
425 } else if strings.HasPrefix(name, "filesystem:") {
426 params, ok := context.config().FileSystemPublishRoots[name[11:]]
427 if !ok {
428 return nil, fmt.Errorf("published local storage %v not configured", name[11:])
429 }
430
431 publishedStorage = files.NewPublishedStorage(params.RootDir, params.LinkMethod, params.VerifyMethod)
432 } else if strings.HasPrefix(name, "s3:") {
433 params, ok := context.config().S3PublishRoots[name[3:]]
434 if !ok {
435 return nil, fmt.Errorf("published S3 storage %v not configured", name[3:])
436 }
437
438 var err error
439 publishedStorage, err = s3.NewPublishedStorage(
440 params.AccessKeyID, params.SecretAccessKey, params.SessionToken,
441 params.Region, params.Endpoint, params.Bucket, params.ACL, params.Prefix, params.StorageClass,
442 params.EncryptionMethod, params.PlusWorkaround, params.DisableMultiDel,
443 params.ForceSigV2, params.ForceVirtualHostedStyle, params.Debug)
444 if err != nil {
445 return nil, err
446 }
447 } else if strings.HasPrefix(name, "gcs:") {
448 params, ok := context.config().GCSPublishRoots[name[4:]]
449 if !ok {
450 return nil, fmt.Errorf("published GCS storage %v not configured", name[4:])
451 }
452
453 var err error
454 publishedStorage, err = gcs.NewPublishedStorage(
455 params.Bucket, params.Prefix, params.CredentialsFile, params.ServiceAccountJSON,
456 params.Project, params.Endpoint, params.ACL, params.StorageClass, params.EncryptionKey,
457 params.DisableMultiDel, params.Debug)
458 if err != nil {
459 return nil, err
460 }
461 } else if strings.HasPrefix(name, "swift:") {
462 params, ok := context.config().SwiftPublishRoots[name[6:]]
463 if !ok {
464 return nil, fmt.Errorf("published Swift storage %v not configured", name[6:])
465 }
466
467 var err error
468 publishedStorage, err = swift.NewPublishedStorage(params.UserName, params.Password,
469 params.AuthURL, params.Tenant, params.TenantID, params.Domain, params.DomainID, params.TenantDomain, params.TenantDomainID, params.Container, params.Prefix)
470 if err != nil {
471 return nil, err
472 }
473 } else if strings.HasPrefix(name, "azure:") {
474 params, ok := context.config().AzurePublishRoots[name[6:]]

Callers

nothing calls this directly

Calls 9

configMethod · 0.95
NewPublishedStorageFunction · 0.92
NewPublishedStorageFunction · 0.92
NewPublishedStorageFunction · 0.92
NewPublishedStorageFunction · 0.92
NewPublishedStorageFunction · 0.92
NewPublishedStorageFunction · 0.92
GetRootDirMethod · 0.80
HasPrefixMethod · 0.65

Tested by

no test coverage detected