exchange

package
v3.2.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AgbotAddBusinessPolicy

func AgbotAddBusinessPolicy(org, userPw, agbot, polOrg string)

Add the business policy to the agot supporting list. Currently all the patterns are open to all the nodes within the same organization.

func AgbotAddPattern

func AgbotAddPattern(org, userPw, agbot, patternOrg, pattern, nodeOrg string)

func AgbotList

func AgbotList(org string, userPw string, agbot string, namesOnly bool)

func AgbotListBusinessPolicy

func AgbotListBusinessPolicy(org, userPw, agbot string)

func AgbotListPatterns

func AgbotListPatterns(org, userPw, agbot, patternOrg, pattern, nodeOrg string)

func AgbotRemoveBusinessPolicy

func AgbotRemoveBusinessPolicy(org, userPw, agbot, PolOrg string)

Remove the business policy from the agot supporting list. Currently only supporting removing all the policies from a organization.

func AgbotRemovePattern

func AgbotRemovePattern(org, userPw, agbot, patternOrg, pattern, nodeOrg string)

func BusinessAddPolicy

func BusinessAddPolicy(org string, credToUse string, policy string, jsonFilePath string)

BusinessAddPolicy will add a new policy or overwrite an existing policy byt he same name in the Horizon Exchange

func BusinessListPolicy

func BusinessListPolicy(org string, credToUse string, policy string, namesOnly bool)

BusinessListPolicy lists all the policies in the org or only the specified policy if one is given

func BusinessNewPolicy

func BusinessNewPolicy()

Display an empty business policy template as an object.

func BusinessRemovePolicy

func BusinessRemovePolicy(org string, credToUse string, policy string, force bool)

BusinessRemovePolicy will remove an existing business policy in the Horizon Exchange

func BusinessUpdatePolicy

func BusinessUpdatePolicy(org string, credToUse string, policyName string, filePath string)

BusinessUpdatePolicy will replace a single attribute of a business policy in the Horizon Exchange

func CatalogPatternList

func CatalogPatternList(credOrg string, userPw string, displayShort bool, displayLong bool)

List the public pattern resources for orgType:IBM.

func CatalogServiceList

func CatalogServiceList(credOrg string, userPw string, displayShort bool, displayLong bool)

List the public service resources for orgType:IBM. The userPw can be the userId:password auth or the nodeId:token auth.

func NodeAddPolicy

func NodeAddPolicy(org string, credToUse string, node string, jsonFilePath string)

func NodeConfirm

func NodeConfirm(org, node, token string, nodeIdTok string)

func NodeCreate

func NodeCreate(org, nodeIdTok, node, token, userPw, email string, arch string, nodeName string)

func NodeList

func NodeList(org string, credToUse string, node string, namesOnly bool)

func NodeListErrors

func NodeListErrors(org string, credToUse string, node string, long bool)

NodeListErrors Displays the node errors currently surfaced to the exchange

func NodeListPolicy

func NodeListPolicy(org string, credToUse string, node string)

func NodeRemove

func NodeRemove(org, credToUse, node string, force bool)

func NodeRemovePolicy

func NodeRemovePolicy(org, credToUse, node string, force bool)

func NodeSetToken

func NodeSetToken(org, credToUse, node, token string)

func NodeUpdate

func NodeUpdate(org string, credToUse string, node string, filePath string)

func NodeUpdatePolicy

func NodeUpdatePolicy(org, credToUse, node string, jsonfile string)

func PatternList

func PatternList(org string, userPw string, pattern string, namesOnly bool)

List the pattern resources for the given org. The userPw can be the userId:password auth or the nodeId:token auth.

func PatternListKey

func PatternListKey(org, userPw, pattern, keyName string)

List the public keys that can be used to verify the deployment_overrides_signature for a pattern. The userPw can be the userId:password auth or the nodeId:token auth.

func PatternPublish

func PatternPublish(org, userPw, jsonFilePath, keyFilePath, pubKeyFilePath, patName string)

PatternPublish signs the MS def and puts it in the exchange

func PatternRemove

func PatternRemove(org, userPw, pattern string, force bool)

func PatternRemoveKey

func PatternRemoveKey(org, userPw, pattern, keyName string)

func PatternUpdate

func PatternUpdate(org string, userPw string, pattern string, filePath string)

func PatternVerify

func PatternVerify(org, userPw, pattern, keyFilePath string)

Verify that the deployment_overrides_signature is valid for the given key. The userPw can be the userId:password auth or the nodeId:token auth.

func ServiceAddPolicy

func ServiceAddPolicy(org string, credToUse string, service string, jsonFilePath string)

ServiceAddPolicy adds a policy or replaces an existing policy for the service in the Horizon Exchange

func ServiceList

func ServiceList(credOrg, userPw, service string, namesOnly bool)

List the the service resources for the given org. The userPw can be the userId:password auth or the nodeId:token auth.

func ServiceListAuth

func ServiceListAuth(org, userPw, service string, authId uint)

List the docker auth that can be used to get the images for the service The userPw can be the userId:password auth or the nodeId:token auth.

func ServiceListKey

func ServiceListKey(org, userPw, service, keyName string)

List the public keys for a service that can be used to verify the deployment signature for the service The userPw can be the userId:password auth or the nodeId:token auth.

func ServiceListPolicy

func ServiceListPolicy(org string, credToUse string, service string)

ServiceListPolicy lists the policy for the service in the Horizon Exchange

func ServiceNewPolicy

func ServiceNewPolicy()

Display an empty service policy template as an object.

func ServicePublish

func ServicePublish(org, userPw, jsonFilePath, keyFilePath, pubKeyFilePath string, dontTouchImage bool, pullImage bool, registryTokens []string, overwrite bool, servicePolicyFilePath string)

ServicePublish signs the MS def and puts it in the exchange

func ServiceRemove

func ServiceRemove(org, userPw, service string, force bool)

func ServiceRemoveAuth

func ServiceRemoveAuth(org, userPw, service string, authId uint)

func ServiceRemoveKey

func ServiceRemoveKey(org, userPw, service, keyName string)

func ServiceRemovePolicy

func ServiceRemovePolicy(org string, credToUse string, service string, force bool)

ServiceRemovePolicy removes the service policy in the exchange

func ServiceVerify

func ServiceVerify(org, userPw, service, keyFilePath string)

ServiceVerify verifies the deployment strings of the specified service resource in the exchange. The userPw can be the userId:password auth or the nodeId:token auth.

func Status

func Status(org, userPw string)

func UserCreate

func UserCreate(org, userPwCreds, user, pw, email string, isAdmin bool)

func UserList

func UserList(org, userPwCreds, theUser string, allUsers, namesOnly bool)

func UserRemove

func UserRemove(org, userPwCreds, user string, force bool)

func UserSetAdmin

func UserSetAdmin(org, userPwCreds, user string, isAdmin bool)

func Version

func Version(org, userPw string)

Types

type AbstractServiceFile

type AbstractServiceFile interface {
	GetOrg() string
	GetURL() string
	GetVersion() string
	GetArch() string
	GetUserInputs() []exchange.UserInput
}

type CatalogPatternWithMediumInfo

type CatalogPatternWithMediumInfo struct {
	Description string `json:"description"`
}

type CatalogServiceWithMediumInfo

type CatalogServiceWithMediumInfo struct {
	Description   string `json:"description"`
	Documentation string `json:"documentation"`
}

type DeploymentConfig

type DeploymentConfig struct {
	Services map[string]*containermessage.Service `json:"services"`
}

func ConvertToDeploymentConfig

func ConvertToDeploymentConfig(deployment interface{}) *DeploymentConfig

Take the deployment field, which we have told the json unmarshaller was unknown type (so we can handle both escaped string and struct) and turn it into the DeploymentConfig struct we really want.

func (DeploymentConfig) CLIString

func (dc DeploymentConfig) CLIString() string

func (DeploymentConfig) CanStartStop

func (dc DeploymentConfig) CanStartStop() error

A validation method. Is there enough info in the deployment config to start a container? If not, the missing info is returned in the error message. Note that when there is a complete absence of deployment config metadata, that's ok too for services.

func (DeploymentConfig) HasAnyServices

func (dc DeploymentConfig) HasAnyServices() bool

func (DeploymentConfig) String

func (dc DeploymentConfig) String() string

type DeploymentOverrides

type DeploymentOverrides struct {
	Services map[string]ServiceOverrides `json:"services"`
}

func ConvertToDeploymentOverrides

func ConvertToDeploymentOverrides(deployment interface{}) *DeploymentOverrides

Take the deployment overrides field, which we have told the json unmarshaller was unknown type (so we can handle both escaped string and struct) and turn it into the DeploymentOverrides struct we really want.

type EventLog

type EventLog struct {
	Id         string           `json:"record_id"` // unique primary key for records
	Timestamp  string           `json:"timestamp"` // converted to "yyyy-mm-dd hh:mm:ss" format
	Severity   string           `json:"severity"`  // info, warning or error
	Message    string           `json:"message"`
	EventCode  string           `json:"event_code"`
	SourceType string           `json:"source_type"`  // the type of the source. It can be agreement, service, image, workload etc.
	Source     *json.RawMessage `json:"event_source"` // source involved for this event.
}

Format for outputting eventlog objects

type ExchangeAgbotPatterns

type ExchangeAgbotPatterns struct {
	Patterns map[string]interface{} `json:"patterns"`
}

type ExchangeAgbots

type ExchangeAgbots struct {
	LastIndex int                    `json:"lastIndex"`
	Agbots    map[string]interface{} `json:"agbots"`
}

We only care about handling the agbot names, so the rest is left as interface{} and will be passed from the exchange to the display

type ExchangeNodes

type ExchangeNodes struct {
	LastIndex int                    `json:"lastIndex"`
	Nodes     map[string]interface{} `json:"nodes"`
}

We only care about handling the node names, so the rest is left as interface{} and will be passed from the exchange to the display

type ExchangePatterns

type ExchangePatterns struct {
	Patterns  map[string]PatternOutput `json:"patterns"`
	LastIndex int                      `json:"lastIndex"`
}

todo: only using these instead of exchange.GetPatternResponse because exchange.Pattern is missing the LastUpdated field

type ExchangeUsers

type ExchangeUsers struct {
	Users     map[string]interface{} `json:"users"`
	ListIndex int                    `json:"lastIndex"`
}

type GetServicesResponse

type GetServicesResponse struct {
	Services  map[string]ServiceExch `json:"services"`
	LastIndex int                    `json:"lastIndex"`
}

type NodeExchangePatchToken

type NodeExchangePatchToken struct {
	Token string `json:"token"`
}

type PatternFile

type PatternFile struct {
	Name               string                       `json:"name,omitempty"`
	Org                string                       `json:"org,omitempty"` // optional
	Label              string                       `json:"label"`
	Description        string                       `json:"description,omitempty"`
	Public             bool                         `json:"public"`
	Services           []ServiceReferenceFile       `json:"services"`
	AgreementProtocols []exchange.AgreementProtocol `json:"agreementProtocols,omitempty"`
	UserInput          []policy.UserInput           `json:"userInput,omitempty"`
}

type PatternInput

type PatternInput struct {
	Label              string                       `json:"label"`
	Description        string                       `json:"description,omitempty"`
	Public             bool                         `json:"public"`
	Services           []ServiceReference           `json:"services,omitempty"`
	AgreementProtocols []exchange.AgreementProtocol `json:"agreementProtocols,omitempty"`
	UserInput          []policy.UserInput           `json:"userInput,omitempty"`
}

type PatternOutput

type PatternOutput struct {
	Owner              string                       `json:"owner"`
	Label              string                       `json:"label"`
	Description        string                       `json:"description"`
	Public             bool                         `json:"public"`
	Services           []ServiceReference           `json:"services"`
	AgreementProtocols []exchange.AgreementProtocol `json:"agreementProtocols"`
	UserInput          []policy.UserInput           `json:"userInput,omitempty"`
	LastUpdated        string                       `json:"lastUpdated"`
}

type ServedBusinessPolicy

type ServedBusinessPolicy struct {
	BusinessPolOrg string `json:"businessPolOrgid"` // defaults to nodeOrgid
	BusinessPol    string `json:"businessPol"`      // '*' means all
	NodeOrg        string `json:"nodeOrgid"`
	LastUpdated    string `json:"lastUpdated"`
}

type ServedPattern

type ServedPattern struct {
	PatternOrg string `json:"patternOrgid"`
	Pattern    string `json:"pattern"`
	NodeOrg    string `json:"nodeOrgid"`
}

type ServiceChoice

type ServiceChoice struct {
	Version                      string                    `json:"version"`            // the version of the service
	Priority                     exchange.WorkloadPriority `json:"priority,omitempty"` // the highest priority service is tried first for an agreement, if it fails, the next priority is tried. Priority 1 is the highest, priority 2 is next, etc.
	Upgrade                      exchange.UpgradePolicy    `json:"upgradePolicy,omitempty"`
	DeploymentOverrides          string                    `json:"deployment_overrides,omitempty"`           // env var overrides for the service
	DeploymentOverridesSignature string                    `json:"deployment_overrides_signature,omitempty"` // signature of env var overrides
}

type ServiceChoiceFile

type ServiceChoiceFile struct {
	Version                      string                     `json:"version"`            // the version of the service
	Priority                     *exchange.WorkloadPriority `json:"priority,omitempty"` // the highest priority service is tried first for an agreement, if it fails, the next priority is tried. Priority 1 is the highest, priority 2 is next, etc.
	Upgrade                      *exchange.UpgradePolicy    `json:"upgradePolicy,omitempty"`
	DeploymentOverrides          interface{}                `json:"deployment_overrides,omitempty"`           // env var overrides for the service
	DeploymentOverridesSignature string                     `json:"deployment_overrides_signature,omitempty"` // signature of env var overrides
}

type ServiceDockAuthExch

type ServiceDockAuthExch struct {
	Registry string `json:"registry"`
	UserName string `json:"username"`
	Token    string `json:"token"`
}

type ServiceExch

type ServiceExch struct {
	Owner               string                       `json:"owner,omitempty"`
	Label               string                       `json:"label"`
	Description         string                       `json:"description"`
	Public              bool                         `json:"public"`
	Documentation       string                       `json:"documentation"`
	URL                 string                       `json:"url"`
	Version             string                       `json:"version"`
	Arch                string                       `json:"arch"`
	Sharable            string                       `json:"sharable"`
	MatchHardware       map[string]interface{}       `json:"matchHardware"`
	RequiredServices    []exchange.ServiceDependency `json:"requiredServices"`
	UserInputs          []exchange.UserInput         `json:"userInput"`
	Deployment          string                       `json:"deployment"`
	DeploymentSignature string                       `json:"deploymentSignature"`
	LastUpdated         string                       `json:"lastUpdated,omitempty"`
}

This is used as the input/output to the exchange to create/read the service. The main differences are: no org, deployment is an escaped string, and optional owner and last updated

type ServiceFile

type ServiceFile struct {
	Org                 string                       `json:"org"` // optional
	Label               string                       `json:"label"`
	Description         string                       `json:"description"`
	Public              bool                         `json:"public"`
	Documentation       string                       `json:"documentation"`
	URL                 string                       `json:"url"`
	Version             string                       `json:"version"`
	Arch                string                       `json:"arch"`
	Sharable            string                       `json:"sharable"`
	MatchHardware       map[string]interface{}       `json:"matchHardware,omitempty"`
	RequiredServices    []exchange.ServiceDependency `json:"requiredServices"`
	UserInputs          []exchange.UserInput         `json:"userInput"`
	Deployment          interface{}                  `json:"deployment"` // interface{} because pre-signed services can be stringified json
	DeploymentSignature string                       `json:"deploymentSignature,omitempty"`
}

This is used when reading json file the user gives us as input to create the service struct

func (*ServiceFile) ConvertToDeploymentDescription

func (sf *ServiceFile) ConvertToDeploymentDescription(agreementService bool) (*DeploymentConfig, *containermessage.DeploymentDescription, error)

Convert the Deployment Configuration to a full Deployment Description.

func (*ServiceFile) DefinesVariable

func (sf *ServiceFile) DefinesVariable(name string) string

Returns true if the service definition userinputs define the variable.

func (*ServiceFile) GetArch

func (sf *ServiceFile) GetArch() string

func (*ServiceFile) GetOrg

func (sf *ServiceFile) GetOrg() string

func (*ServiceFile) GetURL

func (sf *ServiceFile) GetURL() string

func (*ServiceFile) GetUserInputs

func (sf *ServiceFile) GetUserInputs() []exchange.UserInput

func (*ServiceFile) GetVersion

func (sf *ServiceFile) GetVersion() string

func (*ServiceFile) HasDependencies

func (sf *ServiceFile) HasDependencies() bool

Returns true if the service definition has required services.

func (*ServiceFile) IsDependent

func (sf *ServiceFile) IsDependent(deps []exchange.ServiceDependency) bool

Return true if the service definition is a dependency in the input list of service references.

func (*ServiceFile) RequiredVariablesAreSet

func (sf *ServiceFile) RequiredVariablesAreSet(setVars map[string]interface{}) error

Verify that non default user inputs are set in the input map.

func (*ServiceFile) SignAndPublish

func (sf *ServiceFile) SignAndPublish(org, userPw, jsonFilePath, keyFilePath, pubKeyFilePath string, dontTouchImage bool, pullImage bool, registryTokens []string, promptForOverwrite bool)

Sign and publish the service definition. This is a function that is reusable across different hzn commands.

func (*ServiceFile) SupportVersionRange

func (sf *ServiceFile) SupportVersionRange()

type ServiceOverrides

type ServiceOverrides struct {
	Environment []string `json:"environment,omitempty"`
}

These 5 structs are used when reading json file the user gives us as input to create the pattern struct

type ServicePolicyFile

type ServicePolicyFile struct {
	Properties  externalpolicy.PropertyList         `json:"properties"`
	Constraints externalpolicy.ConstraintExpression `json:"constraints"`
}

type ServiceReference

type ServiceReference struct {
	ServiceURL      string                    `json:"serviceUrl"`                 // refers to a service definition in the exchange
	ServiceOrg      string                    `json:"serviceOrgid"`               // the org holding the service definition
	ServiceArch     string                    `json:"serviceArch"`                // the hardware architecture of the service definition
	AgreementLess   bool                      `json:"agreementLess,omitempty"`    // a special case where this service will also be required by others
	ServiceVersions []ServiceChoice           `json:"serviceVersions,omitempty"`  // a list of service version for rollback
	DataVerify      exchange.DataVerification `json:"dataVerification,omitempty"` // policy for verifying that the node is sending data
	NodeH           *exchange.NodeHealth      `json:"nodeHealth,omitempty"`       // this needs to be a ptr so it will be omitted if not specified, so exchange will default it
}

type ServiceReferenceFile

type ServiceReferenceFile struct {
	ServiceURL      string                     `json:"serviceUrl"`                 // refers to a service definition in the exchange
	ServiceOrg      string                     `json:"serviceOrgid"`               // the org holding the service definition
	ServiceArch     string                     `json:"serviceArch"`                // the hardware architecture of the service definition
	AgreementLess   bool                       `json:"agreementLess,omitempty"`    // a special case where this service will also be required by others
	ServiceVersions []ServiceChoiceFile        `json:"serviceVersions"`            // a list of service version for rollback
	DataVerify      *exchange.DataVerification `json:"dataVerification,omitempty"` // policy for verifying that the node is sending data
	NodeH           *exchange.NodeHealth       `json:"nodeHealth,omitempty"`       // this needs to be a ptr so it will be omitted if not specified, so exchange will default it
}

type UserExchangePatchAdmin

type UserExchangePatchAdmin struct {
	Admin bool `json:"admin"`
}

Jump to

Keyboard shortcuts

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