Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loader not found for file extension #37

Open
sweepies opened this issue Mar 2, 2021 · 0 comments
Open

loader not found for file extension #37

sweepies opened this issue Mar 2, 2021 · 0 comments

Comments

@sweepies
Copy link

sweepies commented Mar 2, 2021

When trying to load config files, I'm getting this errors like this:

loader not found for file extension '..yml'

Here's the code in question:

package configuration

import (
	goConfig "github.com/pcelvng/go-config"
	"github.com/rs/zerolog/log"
)

// Config is the main config type
type Config struct {
	S3                  S3Configuration `env:"S3" flag:"s3" validate:"required"`
	PublicFetchURL      string          `env:"PUBLIC_FETCH_URL" flag:"url" help:"The URL to fetch from instead of using the S3 API" validate:"omitempty,url"`
	SetPublicACL        bool            `env:"SET_PUBLIC_ACL" flag:"acl" help:"Whether or not to set a public read ACL on objects" validate:"omitempty"`
	DefaultCacheControl string          `env:"CACHE_CONTROL" flag:"cache" help:"Cache-Control string to use" validate:"required"`
}

// S3Configuration is the S3 config type
type S3Configuration struct {
	Endpoint string `env:"ENDPOINT" flag:"endpoint" help:"The S3 endpoint e.g. s3.amazonaws.com" validate:"required,fqdn"`
	Region   string `env:"REGION" flag:"region" help:"The S3 region e.g. us-east-1" validate:"required"`
	Bucket   string `env:"BUCKET" flag:"bucket" help:"The S3 bucket" validate:"required"`
}

// Configure loads the application configuration
func Configure() Config {
	config := Config{
		S3: S3Configuration{
			Endpoint: "s3.amazonaws.com",
			Region:   "us-east-1",
		},
		SetPublicACL:        false,
		DefaultCacheControl: "public, max-age=31536000",
	}

	if err := goConfig.Load(&config); err != nil {
		log.Fatal().Err(err).Msg("Error loading config")
	}

	return config
}

And the command:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant