mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-23 21:19:17 +02:00
* feat: adding support to push artifacts to AWS S3,Azure Blob and Google Cloud Storage readme for blob publisher test: add unit test for blob using testify and mockery test: add unit test for publish method fix: openbucket instance initialization remove unwanted packages: go mod tidy test: add missing unit test for publish method * doc: add missing comment for func * fix: add accidental delete file * fix : add missing Snapcrafts project * fix: unit test for Azure blob * fmt: rewrite if-else-if-else chain to switch statement and fix golangci-lint reporeted issue * fmt: fix linter reporeted issues fmt: rewrite if-else-if-else chain to switch statement and fix golangci-lint reporeted issue fmt: linter fix * test: fix typo in test error string * feat: add support to provider folder inside bucket, resolves discussed comments
52 lines
1006 B
Go
52 lines
1006 B
Go
package blob
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"strings"
|
|
)
|
|
|
|
// Check required ENV variables based on Blob Provider
|
|
func checkProvider(provider string) error {
|
|
|
|
switch provider {
|
|
case "azblob":
|
|
return checkEnv("AZURE_STORAGE_ACCOUNT", "AZURE_STORAGE_KEY")
|
|
case "gs":
|
|
return checkEnv("GOOGLE_APPLICATION_CREDENTIALS")
|
|
case "s3":
|
|
return checkEnv("AWS_ACCESS_KEY", "AWS_SECRET_KEY", "AWS_REGION")
|
|
default:
|
|
return fmt.Errorf("unknown provider [%v],currently supported providers: [azblob, gs, s3]", provider)
|
|
}
|
|
|
|
}
|
|
|
|
func checkEnv(envs ...string) error {
|
|
|
|
var missingEnv []string
|
|
|
|
for _, env := range envs {
|
|
s := os.Getenv(env)
|
|
if s == "" {
|
|
missingEnv = append(missingEnv, env)
|
|
}
|
|
}
|
|
|
|
if len(missingEnv) != 0 {
|
|
return fmt.Errorf("missing %v", strings.Join(missingEnv, ","))
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Check if error contains specific string
|
|
func errorContains(err error, subs ...string) bool {
|
|
|
|
for _, sub := range subs {
|
|
if strings.Contains(err.Error(), sub) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|