go-udc

command module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

README

Universal Datera Config (Golang)

The Universal Datera Config (UDC) is a config that can be specified in a number of ways:

  • JSON file with any of the following names: [.datera-config, datera-config, .datera-config.json, dateraconfig.json]
  • The JSON file has the following configuration:
     {"mgmt_ip": "1.1.1.1",
      "username": "admin",
      "password": "password",
      "tenant": "/root",
      "api_version": "2.2",
      "ldap": ""}
  • The file can be in any of the following places. This is also the lookup order for config files: current directory --> home directory --> home/config directory --> /etc/datera
  • If no datera config file is found and a cinder.conf file is present, the config parser will try and pull connection credentials from the cinder.conf
  • Instead of a JSON file, environment variables can be used.
    • DAT_MGMT
    • DAT_USER
    • DAT_PASS
    • DAT_TENANT
    • DAT_API
    • DAT_LDAP
  • Most tools built to use the Datera Universal Config will also allow for providing/overriding any of the config values via command line flags.
    • -hostname
    • -username
    • -password
    • -tenant
    • -api-version
    • -ldap

Developing with Universal Datera Config

The Golang UDC is the following struct:

type UDC struct {
    Username   string `json:"username"`
    Password   string `json:"password"`
    MgmtIp     string `json:"mgmt_ip"`
    Tenant     string `json:"tenant"`
    ApiVersion string `json:"api_version"`
    Ldap       string `json:"ldap"`
}

To use UDC in a new python tool is very simple just add the following to your Go main package

import (
    udc "github.com/Datera/go-udc/pkg/udc"
)

func main() {
    conf, err := udc.GetConfig()
    if err != nil {
        fmt.Println(err)
        return
    }
    fmt.Printf("Datera MgmtIp: %s\n", conf.MgmtIp)
}

If you can print the supported environment variables with the following:

import (
    udc "github.com/Datera/go-udc/pkg/udc"
)

func main() {
    udc.PrintEnvs()
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
pkg
udc

Jump to

Keyboard shortcuts

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