util

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AutotypeList

func AutotypeList(input []interface{}) []interface{}

*

  • Processes the values of the given slice and tries some best-effort type-casting

func AutotypeMap

func AutotypeMap(input map[string]interface{}) map[string]interface{}

*

  • Processes the values of the given map and tries some best-effort type-casting

func AutotypeValue

func AutotypeValue(input interface{}) interface{}

*

  • Best-effort auto-typing of strings that follow the given patterns: *
  • 1) Numeric values --> float64
  • 2) "true" / "false" --> bool
  • 3) "null" --> nil
  • 5) <anything else> --> string

func CleanupJSON

func CleanupJSON(input interface{}) interface{}

*

  • Remove empty strings, nulls, empty arrays and empty objects from the given dict

func DCOSHTTPClient

func DCOSHTTPClient(client *dcos.APIClient) *http.Client

func DCOSNewRequest

func DCOSNewRequest(client *dcos.APIClient, method, url string, body io.Reader) (*http.Request, error)

func DefaultJSONFromSchema

func DefaultJSONFromSchema(inputSchema map[string]interface{}) (map[string]map[string]interface{}, error)

*

  • Processes the given JSON schema and extracts the default values into a
  • configuration JSON object

func FlatToNestedMap

func FlatToNestedMap(input map[string]interface{}) (map[string]map[string]interface{}, error)

*

  • FlatToNestedMap converts a map of interfaces to a map of map of interfaces

func GetDictDiff

func GetDictDiff(reference map[string]interface{}, input map[string]interface{}) map[string]interface{}

*

  • GetDictDiff Returns a map with all the different keys in `input`, compared to `reference`

func GetVerboseCosmosError

func GetVerboseCosmosError(error error, resp *http.Response) string

*

  • GetVerboseCosmosError collects as much information as possible from the error
  • and the HTTP response in order to provide enough information to the user,
  • explaining the error that occurred.

func HashDict

func HashDict(input map[string]interface{}) (string, error)

*

  • Normalizes and hashes

func InterfaceSliceInt32

func InterfaceSliceInt32(s []interface{}) (r []int32, ok bool)

InterfaceSliceInt32 transforms a []interface{} into []int32

func InterfaceSliceString

func InterfaceSliceString(s []interface{}) (r []string, ok bool)

InterfaceSliceString transforms a []interface{} into []string

func NestedToFlatMap

func NestedToFlatMap(input map[string]map[string]interface{}) map[string]interface{}

*

  • NestedToFlatMap converts a map of map of interfaces to a map of interfaces

func NormalizeJSON

func NormalizeJSON(inputJson string) (string, error)

*

  • Parses the given JSON string, sorts the keys and re-encodes to JSON

func PrintJSON

func PrintJSON(anyJson interface{}) string

*

  • Converts the given input object to a JSON string, even if there are errors

Types

type DCOSVersionSpec

type DCOSVersionSpec struct {
	Version         string `json:"version,omitempty"`
	DcosVariant     string `json:"dcos-variant,omitempty"`
	DcosImageCommit string `json:"dcos-image-commit,omitempty"`
	BootstrapId     string `json:"bootstrap-id,omitempty"`
}

func DCOSGetVersion

func DCOSGetVersion(client *dcos.APIClient) (DCOSVersionSpec, error)

*

  • Get the DC/OS version from /dcos-metadata/dcos-version.json

type PlanPhase

type PlanPhase struct {
	Id       string     `json:"id"`
	Name     string     `json:"name"`
	Steps    []PlanStep `json:"steps"`
	Strategy string     `json:"strategy"`
	Status   string     `json:"status"`
}

type PlanRestartRequest

type PlanRestartRequest struct {
	Phase string `json:"phase"`
	Step  string `json:"step"`
}

type PlanStep

type PlanStep struct {
	Id      string `json:"id"`
	Status  string `json:"status"`
	Name    string `json:"name"`
	Message string `json:"message"`
}

type PlansListResponse

type PlansListResponse struct {
	Phases   []PlanPhase `json:"phases"`
	Strategy string      `json:"strategy"`
	Status   string      `json:"status"`
}

type SDKApiClient

type SDKApiClient struct {
	AppID      string
	ClusterURL string
	Client     *http.Client
	Headers    map[string]string
}

func CreateSDKAPIClient

func CreateSDKAPIClient(client *dcos.APIClient, appId string) *SDKApiClient

*

  • CreateSDKAPIClientFor initializes an SDKApiClient API

func (*SDKApiClient) GetAllMeta

func (client *SDKApiClient) GetAllMeta() (map[string]interface{}, error)

*

  • GetAllMeta returns a map with all the stored configuration properties for this SDK app

func (*SDKApiClient) GetMeta

func (client *SDKApiClient) GetMeta(key string, defaultValue interface{}) (interface{}, error)

*

  • GetMeta returns a single meta-data parameter value

func (*SDKApiClient) PlanGetStatus

func (client *SDKApiClient) PlanGetStatus(plan string) (*PlansListResponse, error)

*

  • Describe package

func (*SDKApiClient) PlanRestart

func (client *SDKApiClient) PlanRestart(plan string) error

*

  • Describe package

func (*SDKApiClient) SetAllMeta

func (client *SDKApiClient) SetAllMeta(meta map[string]interface{}) error

*

  • SetAllMeta replaces the entire configuration properties of the SDK app

func (*SDKApiClient) SetMeta

func (client *SDKApiClient) SetMeta(key string, value interface{}) error

*

  • SetMeta updates a single meta-data parameter value

Jump to

Keyboard shortcuts

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