czerasz/go-blockinfile

Makes sure provided content block is inside the specified file

★ 1Forks 0GoGitHub ↗Compare

README

test lint

Blockinfile the Golang version

Makes sure provided content block is inside the specified file.

NOTE
The logic uses a very primitive approach. Do NOT use with large files.

Usage

Basic Usage

  • view initial config.yml content:

    $ cat config.yml
    image: nginx:latest
  • run blockinfile:

    blockinfile -path config.yml -content 'name: app'
  • examine content:

    $ cat config.yml
    image: nginx:latest
    # BEGIN MANAGED BLOCK
    name: app
    # END MANAGED BLOCK
  • run blockinfile again:

    blockinfile -path config.yml -content 'name: server'
  • examine updated content:

    $ cat config.yml
    image: nginx:latest
    # BEGIN MANAGED BLOCK
    name: server
    # END MANAGED BLOCK

Use with Pipe

terraform-docs markdown table . | blockinfile -path README.md -marker '# {{ .Mark }} TERRAFORM DOCS' -content -

Contributors

czeraszsemantic-release-bot

Issues