laurilehmijoki / s3_website

Manage an S3 website: sync, deliver via CloudFront, benefit from advanced S3 website features.
Other
2.25k stars 186 forks source link

Suggestion: add '--env' flag to 's3_website push' command #289

Open zulhfreelancer opened 7 years ago

zulhfreelancer commented 7 years ago

I would like to suggest that we have this inside the _s3website.yml file:

production:
    s3_id: ...
    s3_secret: ...
    s3_bucket: ...

staging:
    s3_id: ...
    s3_secret: ...
    s3_bucket: ...

And, when deploying the site, we can use --env flag like this:

s3_website push --env staging
s3_website push --env production

I know that we can use ERB inside the YAML file and use dotenv to set different S3 credentials. But, having if and else inside the YAML file make it look longer and less elegant.

I know, by having if and else inside the YAML file, we can simply deploy with this style:

ENV=staging s3_website push
ENV=production s3_website push

I still prefer to use --env flag. I can help with this. I just need some guide/reference/tutorial resources. Please share the resources here if you have it.

laurilehmijoki commented 7 years ago

Hello @zulhfreelancer, at the moment we support alternative configurations with the --config-dir command-line option.

For example, if you would have the files staging/s3_website.yml and production/s3_website.yml, the --config-dir option allows you to say

s3_website push --config-dir=staging
s3_website push --config-dir=production

Now that I look at the README, this feature seems not to be properly documented – we could clearly improve the docs on this matter.

I do agree that there are benefits in having alternative configurations in the same file. For example, it would allow you examine all the alternative configs by looking at the same file.

zulhfreelancer commented 7 years ago

Thanks. Can we add --env flag too like what I proposed here?

laurilehmijoki commented 7 years ago

I find the flag redundant, because the config-dir flag can be used in place of it. I think it's better to be unambiguous when it comes to command-line options. Maybe I'm not seeing some important point of view. What others think?

Instead of adding the flag, maybe we can improve the documentation by adding an example of how to use the config-dir option to specify alternative configurations?

zulhfreelancer commented 7 years ago

I found that creating 2 s3_website.yml files are tedious. It's better to just have 1 s3_website.yml file and put production and staging block inside it.

And, s3_website push --env staging command is shorter than s3_website push --config-dir=staging.

justinperkins commented 7 years ago

With Jekyll, we have to maintain multiple config files for different environments and this syntax aligns with that usage (--config). I don't mind it as-is.

rafilkmp3 commented 6 years ago

@zulhfreelancer How do you define the blocks, can you give me a example