envsync

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2019 License: Apache-2.0 Imports: 10 Imported by: 1

README

Build Status codecov Go Report Card Documentation

Envsync

Description

Envsync is a tool to synchronize source env and target env file.

Installation

  1. Download the executable file in the given link below. Open the given link via your favorite browser. Choose envsync_linux_amd64 for linux or envsync_darwin_amd64 for OSX.

    https://github.com/bukalapak/envsync/releases/latest
    
  2. For the next steps, please, change OS with "linux" or "darwin" (depend on what you have downloaded before).

  3. Give the executable file the permission to execute.

    chmod +x ~/Downloads/envsync_[OS]_amd64
    
  4. Move to /usr/local/bin.

    mv ~/Downloads/envsync_[OS]_amd64 /usr/local/bin/envsync
    

Usage

  • With flag -s and -t (Optional Flags)
envsync -s <source file> -t <target file>
  • Without flag, by default will use file env.sample as source and .env as a target on current directory.
envsync

Documentation

Index

Constants

View Source
const VERSION = "1.1.2"

VERSION is envsync version

Variables

View Source
var (
	//ExecCommand cmd executor
	ExecCommand = exec.Command
	//IOWriteString alias command to write string
	IOWriteString = io.WriteString
)

Functions

This section is empty.

Types

type EnvSyncer

type EnvSyncer interface {
	// Sync synchronizes source and target.
	// Source is the default env or the sample env.
	// Target is the actual env.
	// Both source and target are string and indicate the location of the files.
	//
	// Any values in source that aren't in target will be written to target.
	// Any values in source that are in target won't be written to target.
	Sync(source, target string) error
}

EnvSyncer describes some contracts to synchronize env.

type Syncer

type Syncer struct {
}

Syncer implements EnvSyncer.

func (*Syncer) Sync

func (s *Syncer) Sync(source, target string) error

Sync implements EnvSyncer. Sync will read the file line by line. It will read the first '=' character. All characters prior to the first '=' character is considered as the key. All characters after the first '=' character until a newline character is considered as the value.

e.g: FOO=bar. FOO is the key and bar is the value.

Before the synchronization process, it will create .bak from target file as backup. During the synchronization process, there may be an error. If error occurred, target file will be restored from previously created .bak file. If the synchronization succeed, the key-values will be sorted and header will be added based on key's prefix e.g: for FOO_BAR, '#FOO' header will be added before the first key of FOO_

Directories

Path Synopsis
app
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL