config

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 3 Imported by: 1

README

Config

Services have specific endpoints per region. This config 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

Package world provides info on HSDP services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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