Skip to content

adamjace/cfg

Repository files navigation

cfg

A simple config analysis tool aimed to help keep configuration files in sync by scanning for missing keys and determining key/value equality between files.

This package currently supports json and env config types.

Usage

Compare local files

Scan

  c := cfg.Config{
    WorkingPath: "config/.env",
    MasterPath:  "config/.env.example",
  }

  keys, _ := cfg.ScanEnv(c)

  for _, k := range keys {
    log.Printf("Uh oh! Found a missing key: %s", k)
  }

Print

  c := cfg.Config{
    WorkingPath: "config/.env",
    MasterPath:  "config/.env.example",
  }

  cfg.PrintEnv(c)

  // (!) found missing keys in config/.env: [foo bar]

Compare local with remote

Scan

  c := cfg.Config{
    WorkingPath: "config.json",
    MasterPath:  "/home/ubuntu/app/config.json",
    HostAlias:   "host-alias",
  }

  keys, _ := cfg.ScanEnv(c)

  for _, k := range keys {
    log.Printf("Uh oh! Found a missing key: %s", k)
  }

Print

  c := cfg.Config{
    WorkingPath: "config.json",
    MasterPath:  "/home/ubuntu/app/config.json",
    HostAlias:   "host-alias",
  }

  cfg.PrintJson(c);

  // (!) found missing keys in config.json: [foo bar]

About

A simple config analysis tool for Golang projects

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages