diff --git a/go.sum b/go.sum index 4ce6080d5..843969e0a 100644 --- a/go.sum +++ b/go.sum @@ -687,6 +687,7 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -770,10 +771,12 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -783,6 +786,7 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/pkg/config/azureblob.go b/pkg/config/azureblob.go index bbff569f7..5935db957 100644 --- a/pkg/config/azureblob.go +++ b/pkg/config/azureblob.go @@ -2,7 +2,7 @@ package config // AzureBlobConfig specifies the properties required to use Azure as the storage backend. type AzureBlobConfig struct { - AccountName string `validate:"required" envconfig:"ATHENS_AZURE_ACCOUNT_NAME"` - AccountKey string `validate:"required" envconfig:"ATHENS_AZURE_ACCOUNT_KEY"` - ContainerName string `validate:"required" envconfig:"ATHENS_AZURE_CONTAINER_NAME"` + AccountName string `envconfig:"ATHENS_AZURE_ACCOUNT_NAME" validate:"required"` + AccountKey string `envconfig:"ATHENS_AZURE_ACCOUNT_KEY" validate:"required"` + ContainerName string `envconfig:"ATHENS_AZURE_CONTAINER_NAME" validate:"required"` } diff --git a/pkg/config/config.go b/pkg/config/config.go index 9f070e5b1..9caed7fee 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -21,22 +21,22 @@ const defaultConfigFile = "athens.toml" // Config provides configuration values for all components. type Config struct { TimeoutConf - GoEnv string `validate:"required" envconfig:"GO_ENV"` - GoBinary string `validate:"required" envconfig:"GO_BINARY_PATH"` + GoEnv string `envconfig:"GO_ENV" validate:"required"` + GoBinary string `envconfig:"GO_BINARY_PATH" validate:"required"` GoBinaryEnvVars EnvList `envconfig:"ATHENS_GO_BINARY_ENV_VARS"` - GoGetWorkers int `validate:"required" envconfig:"ATHENS_GOGET_WORKERS"` + GoGetWorkers int `envconfig:"ATHENS_GOGET_WORKERS" validate:"required"` GoGetDir string `envconfig:"ATHENS_GOGET_DIR"` - ProtocolWorkers int `validate:"required" envconfig:"ATHENS_PROTOCOL_WORKERS"` - LogLevel string `validate:"required" envconfig:"ATHENS_LOG_LEVEL"` - LogFormat string `validate:"oneof='' 'json' 'plain'" envconfig:"ATHENS_LOG_FORMAT"` - CloudRuntime string `validate:"required_without=LogFormat" envconfig:"ATHENS_CLOUD_RUNTIME"` + ProtocolWorkers int `envconfig:"ATHENS_PROTOCOL_WORKERS" validate:"required"` + LogLevel string `envconfig:"ATHENS_LOG_LEVEL" validate:"required"` + LogFormat string `envconfig:"ATHENS_LOG_FORMAT" validate:"oneof='' 'json' 'plain'"` + CloudRuntime string `envconfig:"ATHENS_CLOUD_RUNTIME" validate:"required_without=LogFormat"` EnablePprof bool `envconfig:"ATHENS_ENABLE_PPROF"` PprofPort string `envconfig:"ATHENS_PPROF_PORT"` FilterFile string `envconfig:"ATHENS_FILTER_FILE"` TraceExporterURL string `envconfig:"ATHENS_TRACE_EXPORTER_URL"` TraceExporter string `envconfig:"ATHENS_TRACE_EXPORTER"` StatsExporter string `envconfig:"ATHENS_STATS_EXPORTER"` - StorageType string `validate:"required" envconfig:"ATHENS_STORAGE_TYPE"` + StorageType string `envconfig:"ATHENS_STORAGE_TYPE" validate:"required"` GlobalEndpoint string `envconfig:"ATHENS_GLOBAL_ENDPOINT"` // This feature is not yet implemented Port string `envconfig:"ATHENS_PORT"` UnixSocket string `envconfig:"ATHENS_UNIX_SOCKET"` @@ -55,11 +55,11 @@ type Config struct { NoSumPatterns []string `envconfig:"ATHENS_GONOSUM_PATTERNS"` DownloadMode mode.Mode `envconfig:"ATHENS_DOWNLOAD_MODE"` DownloadURL string `envconfig:"ATHENS_DOWNLOAD_URL"` - NetworkMode string `validate:"oneof=strict offline fallback" envconfig:"ATHENS_NETWORK_MODE"` + NetworkMode string `envconfig:"ATHENS_NETWORK_MODE" validate:"oneof=strict offline fallback"` SingleFlightType string `envconfig:"ATHENS_SINGLE_FLIGHT_TYPE"` RobotsFile string `envconfig:"ATHENS_ROBOTS_FILE"` IndexType string `envconfig:"ATHENS_INDEX_TYPE"` - ShutdownTimeout int `validate:"min=0" envconfig:"ATHENS_SHUTDOWN_TIMEOUT"` + ShutdownTimeout int `envconfig:"ATHENS_SHUTDOWN_TIMEOUT" validate:"min=0"` SingleFlight *SingleFlight Storage *Storage Index *Index diff --git a/pkg/config/disk.go b/pkg/config/disk.go index 2db42f222..cb867d654 100644 --- a/pkg/config/disk.go +++ b/pkg/config/disk.go @@ -2,5 +2,5 @@ package config // DiskConfig specifies the properties required to use Disk as the storage backend. type DiskConfig struct { - RootPath string `validate:"required" envconfig:"ATHENS_DISK_STORAGE_ROOT"` + RootPath string `envconfig:"ATHENS_DISK_STORAGE_ROOT" validate:"required"` } diff --git a/pkg/config/external.go b/pkg/config/external.go index ff5f563fa..574a4ede2 100644 --- a/pkg/config/external.go +++ b/pkg/config/external.go @@ -2,5 +2,5 @@ package config // External specifies configuration for an external http storage. type External struct { - URL string `validate:"required" envconfig:"ATHENS_EXTERNAL_STORAGE_URL"` + URL string `envconfig:"ATHENS_EXTERNAL_STORAGE_URL" validate:"required"` } diff --git a/pkg/config/gcp.go b/pkg/config/gcp.go index 26f7343af..4ae634d95 100644 --- a/pkg/config/gcp.go +++ b/pkg/config/gcp.go @@ -3,6 +3,6 @@ package config // GCPConfig specifies the properties required to use GCP as the storage backend. type GCPConfig struct { ProjectID string `envconfig:"GOOGLE_CLOUD_PROJECT"` - Bucket string `validate:"required" envconfig:"ATHENS_STORAGE_GCP_BUCKET"` + Bucket string `envconfig:"ATHENS_STORAGE_GCP_BUCKET" validate:"required"` JSONKey string `envconfig:"ATHENS_STORAGE_GCP_JSON_KEY"` } diff --git a/pkg/config/minio.go b/pkg/config/minio.go index ee6243820..4147a577b 100644 --- a/pkg/config/minio.go +++ b/pkg/config/minio.go @@ -3,10 +3,10 @@ package config // MinioConfig specifies the properties required to use Minio or DigitalOcean Spaces // as the storage backend. type MinioConfig struct { - Endpoint string `validate:"required" envconfig:"ATHENS_MINIO_ENDPOINT"` - Key string `validate:"required" envconfig:"ATHENS_MINIO_ACCESS_KEY_ID"` - Secret string `validate:"required" envconfig:"ATHENS_MINIO_SECRET_ACCESS_KEY"` - Bucket string `validate:"required" envconfig:"ATHENS_MINIO_BUCKET_NAME"` + Endpoint string `envconfig:"ATHENS_MINIO_ENDPOINT" validate:"required"` + Key string `envconfig:"ATHENS_MINIO_ACCESS_KEY_ID" validate:"required"` + Secret string `envconfig:"ATHENS_MINIO_SECRET_ACCESS_KEY" validate:"required"` + Bucket string `envconfig:"ATHENS_MINIO_BUCKET_NAME" validate:"required"` Region string `envconfig:"ATHENS_MINIO_REGION"` EnableSSL bool `envconfig:"ATHENS_MINIO_USE_SSL"` } diff --git a/pkg/config/mongo.go b/pkg/config/mongo.go index 91f6f6549..527773344 100644 --- a/pkg/config/mongo.go +++ b/pkg/config/mongo.go @@ -2,9 +2,9 @@ package config // MongoConfig specifies the properties required to use MongoDB as the storage backend. type MongoConfig struct { - URL string `validate:"required" envconfig:"ATHENS_MONGO_STORAGE_URL"` - DefaultDBName string `envconfig:"ATHENS_MONGO_DEFAULT_DATABASE" default:"athens"` - DefaultCollectionName string `envconfig:"ATHENS_MONGO_DEFAULT_COLLECTION" default:"modules"` + URL string `envconfig:"ATHENS_MONGO_STORAGE_URL" validate:"required"` + DefaultDBName string `default:"athens" envconfig:"ATHENS_MONGO_DEFAULT_DATABASE"` + DefaultCollectionName string `default:"modules" envconfig:"ATHENS_MONGO_DEFAULT_COLLECTION"` CertPath string `envconfig:"ATHENS_MONGO_CERT_PATH"` InsecureConn bool `envconfig:"ATHENS_MONGO_INSECURE"` } diff --git a/pkg/config/mysql.go b/pkg/config/mysql.go index 46e5c959f..83b86be98 100644 --- a/pkg/config/mysql.go +++ b/pkg/config/mysql.go @@ -2,11 +2,11 @@ package config // MySQL config. type MySQL struct { - Protocol string `validate:"required" envconfig:"ATHENS_INDEX_MYSQL_PROTOCOL"` - Host string `validate:"required" envconfig:"ATHENS_INDEX_MYSQL_HOST"` - Port int `validate:"" envconfig:"ATHENS_INDEX_MYSQL_PORT"` - User string `validate:"required" envconfig:"ATHENS_INDEX_MYSQL_USER"` - Password string `validate:"" envconfig:"ATHENS_INDEX_MYSQL_PASSWORD"` - Database string `validate:"required" envconfig:"ATHENS_INDEX_MYSQL_DATABASE"` - Params map[string]string `validate:"required" envconfig:"ATHENS_INDEX_MYSQL_PARAMS"` + Protocol string `envconfig:"ATHENS_INDEX_MYSQL_PROTOCOL" validate:"required"` + Host string `envconfig:"ATHENS_INDEX_MYSQL_HOST" validate:"required"` + Port int `envconfig:"ATHENS_INDEX_MYSQL_PORT" validate:""` + User string `envconfig:"ATHENS_INDEX_MYSQL_USER" validate:"required"` + Password string `envconfig:"ATHENS_INDEX_MYSQL_PASSWORD" validate:""` + Database string `envconfig:"ATHENS_INDEX_MYSQL_DATABASE" validate:"required"` + Params map[string]string `envconfig:"ATHENS_INDEX_MYSQL_PARAMS" validate:"required"` } diff --git a/pkg/config/postgres.go b/pkg/config/postgres.go index ee2827f15..aa56f4176 100644 --- a/pkg/config/postgres.go +++ b/pkg/config/postgres.go @@ -2,10 +2,10 @@ package config // Postgres config. type Postgres struct { - Host string `validate:"required" envconfig:"ATHENS_INDEX_POSTGRES_HOST"` - Port int `validate:"required" envconfig:"ATHENS_INDEX_POSTGRES_PORT"` - User string `validate:"required" envconfig:"ATHENS_INDEX_POSTGRES_USER"` - Password string `validate:"" envconfig:"ATHENS_INDEX_POSTGRES_PASSWORD"` - Database string `validate:"required" envconfig:"ATHENS_INDEX_POSTGRES_DATABASE"` - Params map[string]string `validate:"required" envconfig:"ATHENS_INDEX_POSTGRES_PARAMS"` + Host string `envconfig:"ATHENS_INDEX_POSTGRES_HOST" validate:"required"` + Port int `envconfig:"ATHENS_INDEX_POSTGRES_PORT" validate:"required"` + User string `envconfig:"ATHENS_INDEX_POSTGRES_USER" validate:"required"` + Password string `envconfig:"ATHENS_INDEX_POSTGRES_PASSWORD" validate:""` + Database string `envconfig:"ATHENS_INDEX_POSTGRES_DATABASE" validate:"required"` + Params map[string]string `envconfig:"ATHENS_INDEX_POSTGRES_PARAMS" validate:"required"` } diff --git a/pkg/config/s3.go b/pkg/config/s3.go index f72faefd1..63d3fa1cc 100644 --- a/pkg/config/s3.go +++ b/pkg/config/s3.go @@ -2,11 +2,11 @@ package config // S3Config specifies the properties required to use S3 as the storage backend. type S3Config struct { - Region string `validate:"required" envconfig:"AWS_REGION"` + Region string `envconfig:"AWS_REGION" validate:"required"` Key string `envconfig:"AWS_ACCESS_KEY_ID"` Secret string `envconfig:"AWS_SECRET_ACCESS_KEY"` Token string `envconfig:"AWS_SESSION_TOKEN"` - Bucket string `validate:"required" envconfig:"ATHENS_S3_BUCKET_NAME"` + Bucket string `envconfig:"ATHENS_S3_BUCKET_NAME" validate:"required"` UseDefaultConfiguration bool `envconfig:"AWS_USE_DEFAULT_CONFIGURATION"` ForcePathStyle bool `envconfig:"AWS_FORCE_PATH_STYLE"` CredentialsEndpoint string `envconfig:"AWS_CREDENTIALS_ENDPOINT"` diff --git a/pkg/storage/s3/cataloger.go b/pkg/storage/s3/cataloger.go index fac0d429e..83706e180 100644 --- a/pkg/storage/s3/cataloger.go +++ b/pkg/storage/s3/cataloger.go @@ -5,10 +5,9 @@ import ( "fmt" "strings" - "github.com/aws/aws-sdk-go-v2/service/s3/types" - "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/gomods/athens/pkg/config" "github.com/gomods/athens/pkg/errors" "github.com/gomods/athens/pkg/observ" diff --git a/pkg/storage/s3/checker.go b/pkg/storage/s3/checker.go index 59d3b11fe..faa0f2f7b 100644 --- a/pkg/storage/s3/checker.go +++ b/pkg/storage/s3/checker.go @@ -4,10 +4,9 @@ import ( "context" "sync" - "github.com/aws/smithy-go" - "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/smithy-go" "github.com/gomods/athens/pkg/config" "github.com/gomods/athens/pkg/errors" "github.com/gomods/athens/pkg/observ" diff --git a/pkg/storage/s3/getter.go b/pkg/storage/s3/getter.go index 1c14a1bcb..cedd1393d 100644 --- a/pkg/storage/s3/getter.go +++ b/pkg/storage/s3/getter.go @@ -5,10 +5,9 @@ import ( "fmt" "io" - "github.com/aws/aws-sdk-go-v2/service/s3/types" - "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/gomods/athens/pkg/config" "github.com/gomods/athens/pkg/errors" "github.com/gomods/athens/pkg/observ" diff --git a/pkg/storage/s3/lister.go b/pkg/storage/s3/lister.go index 15590e8ce..43c29c4ce 100644 --- a/pkg/storage/s3/lister.go +++ b/pkg/storage/s3/lister.go @@ -4,10 +4,9 @@ import ( "context" "strings" - "github.com/aws/aws-sdk-go-v2/service/s3/types" - "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/gomods/athens/pkg/errors" "github.com/gomods/athens/pkg/observ" ) diff --git a/pkg/storage/s3/saver.go b/pkg/storage/s3/saver.go index 951c90ec6..cbf6b5d8c 100644 --- a/pkg/storage/s3/saver.go +++ b/pkg/storage/s3/saver.go @@ -5,9 +5,8 @@ import ( "context" "io" - "github.com/aws/aws-sdk-go-v2/service/s3" - "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/gomods/athens/pkg/errors" "github.com/gomods/athens/pkg/observ" moduploader "github.com/gomods/athens/pkg/storage/module"