// GetPublishedStorage returns instance of PublishedStorage func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedStorage { publishedStorage, ok := context.publishedStorages[name] if !ok { if name == "" { publishedStorage = files.NewPublishedStorage(context.Config().RootDir) } else if strings.HasPrefix(name, "s3:") { params, ok := context.Config().S3PublishRoots[name[3:]] if !ok { Fatal(fmt.Errorf("published S3 storage %v not configured", name[3:])) } var err error publishedStorage, err = s3.NewPublishedStorage(params.AccessKeyID, params.SecretAccessKey, params.Region, params.Bucket, params.ACL, params.Prefix) if err != nil { Fatal(err) } } else { Fatal(fmt.Errorf("unknown published storage format: %v", name)) } context.publishedStorages[name] = publishedStorage } return publishedStorage }
// GetPublishedStorage returns instance of PublishedStorage func (context *AptlyContext) GetPublishedStorage(name string) aptly.PublishedStorage { context.Lock() defer context.Unlock() publishedStorage, ok := context.publishedStorages[name] if !ok { if name == "" { publishedStorage = files.NewPublishedStorage(context.config().RootDir) } else if strings.HasPrefix(name, "s3:") { params, ok := context.config().S3PublishRoots[name[3:]] if !ok { Fatal(fmt.Errorf("published S3 storage %v not configured", name[3:])) } var err error publishedStorage, err = s3.NewPublishedStorage( params.AccessKeyID, params.SecretAccessKey, params.SessionToken, params.Region, params.Endpoint, params.Bucket, params.ACL, params.Prefix, params.StorageClass, params.EncryptionMethod, params.PlusWorkaround, params.DisableMultiDel, params.ForceSigV2, params.Debug) if err != nil { Fatal(err) } } else if strings.HasPrefix(name, "swift:") { params, ok := context.config().SwiftPublishRoots[name[6:]] if !ok { Fatal(fmt.Errorf("published Swift storage %v not configured", name[6:])) } var err error publishedStorage, err = swift.NewPublishedStorage(params.UserName, params.Password, params.AuthURL, params.Tenant, params.TenantID, params.Domain, params.DomainID, params.TenantDomain, params.TenantDomainID, params.Container, params.Prefix) if err != nil { Fatal(err) } } else { Fatal(fmt.Errorf("unknown published storage format: %v", name)) } context.publishedStorages[name] = publishedStorage } return publishedStorage }