hapistrano icon indicating copy to clipboard operation
hapistrano copied to clipboard

Single configuration file

Open sestrella opened this issue 6 years ago • 10 comments

Most of the settings across different deployment scripts such as staging.yaml and production.yaml are the same. Usually, they only differ in the name of the branch, therefore I would like to propose to use a single configuration file with different sections instead of separate files, the format might look like:

repo: [email protected]:<org>/<repo>
build_script:
   - stack setup
   - stack build
restart_command: <restart command>

staging:
  revision: origin/master

production:
  revision: origin/production

Then we could change the CLI to take a section as an argument:

$ stack exec hap -- deploy staging
$ stack exec hap -- deploy production
``

sestrella avatar Aug 08 '17 15:08 sestrella

@sestrella Although, I'm totally aware that staging ideally should be a carbon copy of the production environment. I also think that sometimes we need flexibility and that a user may not be able to have the ideal scenario. In that sense, how would you suggest that we should handle the case when there is a difference between the necessary scripts between both. Also, it may exist the case when a project has more than one environment in continuos integration & delivery pipeline, g.e. development -> staging -> qa -> production. In those scenarios we would still need another yaml file

juanpaucar avatar Sep 05 '17 17:09 juanpaucar

Maybe this could be achieved using TOML files @sestrella? https://kowainik.github.io/posts/2019-01-14-tomland#prefix-tree

ibarrae avatar Aug 11 '22 15:08 ibarrae

@ibarrae sorry for the late response. I would suggest start taking a look at Dhall, perhaps? It looks promising and has Haskell support. @CristhianMotoche, @DavidMazarro any thoughts?

sestrella avatar Sep 14 '22 19:09 sestrella

@sestrella @ibarrae Why do you want to include a new notation for the build script? Is it impossible to accomplish this only with YAML? Please, let me know your thoughts.

CristhianMotoche avatar Sep 14 '22 20:09 CristhianMotoche

I haven't used Dhall but have known it for a while. Despite looking interesting, I think the sort of config users are doing with Hapistrano isn't complex enough to justify defaulting to Dhall (unless we want to support both languages for deployment scripts?). It might just make Hapistrano a bit harder to use for people unfamiliar with Dhall.

I would try to review if this can be done in YAML directly like @CristhianMotoche says, but I don't recall it can be done off the top of my head. In that case, TOML is a good pick IMO: it looks like it supports that feature, and is as simple/easy to use as YAML.

DavidMazarro avatar Sep 15 '22 08:09 DavidMazarro

Hey @sestrella I think we could accomplish this defining a new file version. Like some tools (e.g. CircleCI, GH Actions) do it. I think something like:

---
version: 2
repo: [email protected]:<org>/<repo>
build_script:
   - stack setup
   - stack build
restart_command: <restart command>

targets:
  - staging:
      revision: origin/master
  - production:
      revision: origin/production

If version is not given it will take the current version (let's call it 1). Would that make sense?

CristhianMotoche avatar Mar 20 '23 17:03 CristhianMotoche

@CristhianMotoche yes, I think versioning the configuration file is required here to ensure backward compatibility. Additionally, maybe we could add a command to scaffold configuration files? I think that would make it easier for current users to familiarize themselves with the new schema:

> hap init -v1 # outputs an example configuration file using the current schema
> hap init -v2 # outputs an example configuration file with the proposed schema

sestrella avatar Mar 20 '23 18:03 sestrella

I like that idea @sestrella Thanks for the suggestion! I propose to solve the new version of this issue first and then create a follow up issue with the command that you suggest.

CristhianMotoche avatar Apr 03 '23 16:04 CristhianMotoche

Hey team! I'm assigning @well1791 to this issue since he wants to give it a try. Let me know @well1791 if there is anything that you need from my end.

CristhianMotoche avatar Jul 24 '23 16:07 CristhianMotoche

Hello @well1791 I was wondering if everything is clear with this issue. Do you need any help to review it? Let me know.

CristhianMotoche avatar Aug 15 '23 16:08 CristhianMotoche