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

Multiple env settings in asset container YAML are ignored #1769

markdavies opened this Issue Feb 6, 2018 · 1 comment


None yet
4 participants

markdavies commented Feb 6, 2018

Expected behaviour

When setting more than one env value in an asset container yaml file, all env values should be parsed properly

Actual behaviour

Only the first env value that is found is parsed before being handed to the yaml parser.

Steps to reproduce

  1. Create a new asset container yaml file, say for S3
  2. Set the key, secret, and bucket to all use an .env value (we need all three as the extendWithS3Driver method will explicitly parse key and secret later.
  3. Asset management breaks when Statamic tries to use literal strings to retrieve assets from, or send assets to S3.

This update to the assetContainers method in Statamic\Providers\FilesystemServiceProvider should solve the issue:

    private function assetContainers()

        return collect(
            Folder::disk('content')->getFilesByType('assets', 'yaml')
        )->map(function ($path) {

            $data = File::disk('content')->get($path);

            while($data != Parse::env($data)) {
                $data = Parse::env($data);

            return [
                'id'   => substr($path, 7, -5),
                'data' => YAML::parse($data)

        })->pluck('data', 'id');

This comment has been minimized.

rdarcy1 commented May 4, 2018

Thanks for this, took me a long time to figure out why my asset yaml files weren't parsing env values correctly. Seems like quite an important issue to solve for people who don't want their API credentials stored in the codebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment