config

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 12 Imported by: 1

README

Config

Services have specific endpoints per region. Thisconfig API helps you discover the available services and their settings. Since the data is machine readable this enables auto configuration of endpoints.

Canonical source

The canonical source for configuration is: https://github.com/philips-software/go-hsdp-api/blob/master/config/hsdp.json

Example

Determine the IAM base URL of a region and environment

package main

import (
	"fmt"

	"github.com/philips-software/go-hsdp-api/config"
)

func main() {
	c, err := config.New()
	if err != nil {
		fmt.Printf("error loading: %v\n", err)
		return
	}
	baseIAMURLInUSEastClientTest := c.Region("us-east").Env("client-test").Service("iam").URL
	fmt.Printf("IAM Base URL: %s\n", baseIAMURLInUSEastClientTest)
}

Documentation

Overview

Code generated for package config by go-bindata DO NOT EDIT. (@generated) sources: hsdp.json

Index

Constants

View Source
const (
	// CanonicalURL is the source of truth
	CanonicalURL = "https://raw.githubusercontent.com/philips-software/go-hsdp-api/master/config/hsdp.json"
)

Variables

View Source
var (
	ErrMissingConfig                     = errors.New("missing config")
	ErrNotFound                          = errors.New("not found")
	ErrUnreachableOrOutdatedConfigSource = errors.New("unreachable or outdated config source")
)

Functions

func Asset added in v0.20.0

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir added in v0.20.0

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo added in v0.20.0

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames added in v0.20.0

func AssetNames() []string

AssetNames returns the names of the assets.

func MustAsset added in v0.20.0

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset added in v0.26.0

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets added in v0.26.0

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config holds the state of a Config instance

func New

func New(opts ...OptionFunc) (*Config, error)

New returns a Config Instance. You can pass a list OptionFunc to cater the Config to your needs

func (*Config) Env

func (c *Config) Env(environment string) *Config

Env returns a new Config instance with environment set

func (*Config) Region

func (c *Config) Region(region string) *Config

Region returns a new Config instance with region set

func (*Config) Regions added in v0.20.0

func (c *Config) Regions() []string

Regions returns the known regions

func (*Config) Service

func (c *Config) Service(service string) *Service

Service returns an instance scoped to the service in the region and environment

func (*Config) Services

func (c *Config) Services() []string

Services returns a list of available services in the region

type Environment added in v0.26.0

type Environment struct {
	Services map[string]Service `json:"service,omitempty"`
}

type OptionFunc

type OptionFunc func(*Config) error

func FromReader

func FromReader(reader io.Reader) OptionFunc

FromReader option specifies the JSON source to read If this option is not provided the canonical source hosted on Github will be used. See CanonicalURL

func WithEnv

func WithEnv(env string) OptionFunc

WithEnv sets the environment of the newly created Config instance

func WithRegion

func WithRegion(region string) OptionFunc

WithRegion sets the region of the newly created Config instance

type Region added in v0.26.0

type Region struct {
	Environments map[string]Environment `json:"env,omitempty"`
	Services     map[string]Service     `json:"service,omitempty"`
}

type Service

type Service struct {
	URL    string `json:"url,omitempty"`
	Domain string `json:"domain,omitempty"`
	Host   string `json:"host,omitempty"`
}

Service holds the relevant data for a service

type World added in v0.26.0

type World struct {
	Regions map[string]Region `json:"region"`
}

Jump to

Keyboard shortcuts

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