repo
stringlengths
5
67
path
stringlengths
4
218
func_name
stringlengths
0
151
original_string
stringlengths
52
373k
language
stringclasses
6 values
code
stringlengths
52
373k
code_tokens
listlengths
10
512
docstring
stringlengths
3
47.2k
docstring_tokens
listlengths
3
234
sha
stringlengths
40
40
url
stringlengths
85
339
partition
stringclasses
3 values
cloudfoundry/cli
actor/v2action/domain.go
GetDomain
func (actor Actor) GetDomain(domainGUID string) (Domain, Warnings, error) { var allWarnings Warnings domain, warnings, err := actor.GetSharedDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil case actionerror.DomainNotFoundError: default: return Domain{}, allWarnings, err } domain, warnings, err = actor.GetPrivateDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil default: return Domain{}, allWarnings, err } }
go
func (actor Actor) GetDomain(domainGUID string) (Domain, Warnings, error) { var allWarnings Warnings domain, warnings, err := actor.GetSharedDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil case actionerror.DomainNotFoundError: default: return Domain{}, allWarnings, err } domain, warnings, err = actor.GetPrivateDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil default: return Domain{}, allWarnings, err } }
[ "func", "(", "actor", "Actor", ")", "GetDomain", "(", "domainGUID", "string", ")", "(", "Domain", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "domain", ",", "warnings", ",", "err", ":=", "actor", ".", "GetSharedDomain", "(", "domainGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "domain", ",", "allWarnings", ",", "nil", "\n", "case", "actionerror", ".", "DomainNotFoundError", ":", "default", ":", "return", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "domain", ",", "warnings", ",", "err", "=", "actor", ".", "GetPrivateDomain", "(", "domainGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "domain", ",", "allWarnings", ",", "nil", "\n", "default", ":", "return", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "}" ]
// GetDomain returns the shared or private domain associated with the provided // Domain GUID.
[ "GetDomain", "returns", "the", "shared", "or", "private", "domain", "associated", "with", "the", "provided", "Domain", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L45-L66
train
cloudfoundry/cli
actor/v2action/domain.go
GetDomainsByNameAndOrganization
func (actor Actor) GetDomainsByNameAndOrganization(domainNames []string, orgGUID string) ([]Domain, Warnings, error) { if len(domainNames) == 0 { return nil, nil, nil } var domains []Domain var allWarnings Warnings // TODO: If the following causes URI length problems, break domainNames into // batched (based on character length?) and loop over them. sharedDomains, warnings, err := actor.CloudControllerClient.GetSharedDomains(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range sharedDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } privateDomains, warnings, err := actor.CloudControllerClient.GetOrganizationPrivateDomains( orgGUID, ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range privateDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } return domains, allWarnings, err }
go
func (actor Actor) GetDomainsByNameAndOrganization(domainNames []string, orgGUID string) ([]Domain, Warnings, error) { if len(domainNames) == 0 { return nil, nil, nil } var domains []Domain var allWarnings Warnings // TODO: If the following causes URI length problems, break domainNames into // batched (based on character length?) and loop over them. sharedDomains, warnings, err := actor.CloudControllerClient.GetSharedDomains(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range sharedDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } privateDomains, warnings, err := actor.CloudControllerClient.GetOrganizationPrivateDomains( orgGUID, ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range privateDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } return domains, allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "GetDomainsByNameAndOrganization", "(", "domainNames", "[", "]", "string", ",", "orgGUID", "string", ")", "(", "[", "]", "Domain", ",", "Warnings", ",", "error", ")", "{", "if", "len", "(", "domainNames", ")", "==", "0", "{", "return", "nil", ",", "nil", ",", "nil", "\n", "}", "\n", "var", "domains", "[", "]", "Domain", "\n", "var", "allWarnings", "Warnings", "\n", "sharedDomains", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSharedDomains", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "InOperator", ",", "Values", ":", "domainNames", ",", "}", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "domain", ":=", "range", "sharedDomains", "{", "domains", "=", "append", "(", "domains", ",", "Domain", "(", "domain", ")", ")", "\n", "actor", ".", "saveDomain", "(", "domain", ")", "\n", "}", "\n", "privateDomains", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetOrganizationPrivateDomains", "(", "orgGUID", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "InOperator", ",", "Values", ":", "domainNames", ",", "}", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "domain", ":=", "range", "privateDomains", "{", "domains", "=", "append", "(", "domains", ",", "Domain", "(", "domain", ")", ")", "\n", "actor", ".", "saveDomain", "(", "domain", ")", "\n", "}", "\n", "return", "domains", ",", "allWarnings", ",", "err", "\n", "}" ]
// GetDomainsByNameAndOrganization returns back a list of domains given a list // of domains names and the organization GUID. If no domains are given, than this // command will not lookup any domains.
[ "GetDomainsByNameAndOrganization", "returns", "back", "a", "list", "of", "domains", "given", "a", "list", "of", "domains", "names", "and", "the", "organization", "GUID", ".", "If", "no", "domains", "are", "given", "than", "this", "command", "will", "not", "lookup", "any", "domains", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L71-L115
train
cloudfoundry/cli
actor/v2action/domain.go
GetSharedDomain
func (actor Actor) GetSharedDomain(domainGUID string) (Domain, Warnings, error) { if domain, found := actor.loadDomain(domainGUID); found { log.WithFields(log.Fields{ "domain": domain.Name, "GUID": domain.GUID, }).Debug("using domain from cache") return domain, nil, nil } domain, warnings, err := actor.CloudControllerClient.GetSharedDomain(domainGUID) if isResourceNotFoundError(err) { return Domain{}, Warnings(warnings), actionerror.DomainNotFoundError{GUID: domainGUID} } actor.saveDomain(domain) return Domain(domain), Warnings(warnings), err }
go
func (actor Actor) GetSharedDomain(domainGUID string) (Domain, Warnings, error) { if domain, found := actor.loadDomain(domainGUID); found { log.WithFields(log.Fields{ "domain": domain.Name, "GUID": domain.GUID, }).Debug("using domain from cache") return domain, nil, nil } domain, warnings, err := actor.CloudControllerClient.GetSharedDomain(domainGUID) if isResourceNotFoundError(err) { return Domain{}, Warnings(warnings), actionerror.DomainNotFoundError{GUID: domainGUID} } actor.saveDomain(domain) return Domain(domain), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetSharedDomain", "(", "domainGUID", "string", ")", "(", "Domain", ",", "Warnings", ",", "error", ")", "{", "if", "domain", ",", "found", ":=", "actor", ".", "loadDomain", "(", "domainGUID", ")", ";", "found", "{", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"domain\"", ":", "domain", ".", "Name", ",", "\"GUID\"", ":", "domain", ".", "GUID", ",", "}", ")", ".", "Debug", "(", "\"using domain from cache\"", ")", "\n", "return", "domain", ",", "nil", ",", "nil", "\n", "}", "\n", "domain", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSharedDomain", "(", "domainGUID", ")", "\n", "if", "isResourceNotFoundError", "(", "err", ")", "{", "return", "Domain", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "DomainNotFoundError", "{", "GUID", ":", "domainGUID", "}", "\n", "}", "\n", "actor", ".", "saveDomain", "(", "domain", ")", "\n", "return", "Domain", "(", "domain", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetSharedDomain returns the shared domain associated with the provided // Domain GUID.
[ "GetSharedDomain", "returns", "the", "shared", "domain", "associated", "with", "the", "provided", "Domain", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L146-L162
train
cloudfoundry/cli
actor/v2action/domain.go
GetOrganizationDomains
func (actor Actor) GetOrganizationDomains(orgGUID string) ([]Domain, Warnings, error) { var ( allWarnings Warnings allDomains []Domain ) domains, warnings, err := actor.CloudControllerClient.GetSharedDomains() allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } domains, warnings, err = actor.CloudControllerClient.GetOrganizationPrivateDomains(orgGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } return allDomains, allWarnings, nil }
go
func (actor Actor) GetOrganizationDomains(orgGUID string) ([]Domain, Warnings, error) { var ( allWarnings Warnings allDomains []Domain ) domains, warnings, err := actor.CloudControllerClient.GetSharedDomains() allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } domains, warnings, err = actor.CloudControllerClient.GetOrganizationPrivateDomains(orgGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } return allDomains, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetOrganizationDomains", "(", "orgGUID", "string", ")", "(", "[", "]", "Domain", ",", "Warnings", ",", "error", ")", "{", "var", "(", "allWarnings", "Warnings", "\n", "allDomains", "[", "]", "Domain", "\n", ")", "\n", "domains", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSharedDomains", "(", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "domain", ":=", "range", "domains", "{", "allDomains", "=", "append", "(", "allDomains", ",", "Domain", "(", "domain", ")", ")", "\n", "}", "\n", "domains", ",", "warnings", ",", "err", "=", "actor", ".", "CloudControllerClient", ".", "GetOrganizationPrivateDomains", "(", "orgGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "domain", ":=", "range", "domains", "{", "allDomains", "=", "append", "(", "allDomains", ",", "Domain", "(", "domain", ")", ")", "\n", "}", "\n", "return", "allDomains", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetOrganizationDomains returns the shared and private domains associated // with an organization.
[ "GetOrganizationDomains", "returns", "the", "shared", "and", "private", "domains", "associated", "with", "an", "organization", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L186-L213
train
cloudfoundry/cli
actor/v7action/process_instance.go
StartTime
func (instance *ProcessInstance) StartTime() time.Time { return time.Now().Add(-instance.Uptime) }
go
func (instance *ProcessInstance) StartTime() time.Time { return time.Now().Add(-instance.Uptime) }
[ "func", "(", "instance", "*", "ProcessInstance", ")", "StartTime", "(", ")", "time", ".", "Time", "{", "return", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "instance", ".", "Uptime", ")", "\n", "}" ]
// StartTime returns the time that the instance started.
[ "StartTime", "returns", "the", "time", "that", "the", "instance", "started", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/process_instance.go#L21-L23
train
cloudfoundry/cli
command/plugin/shared/new_client.go
NewClient
func NewClient(config command.Config, ui command.UI, skipSSLValidation bool) *plugin.Client { verbose, location := config.Verbose() pluginClient := plugin.NewClient(plugin.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), DialTimeout: config.DialTimeout(), SkipSSLValidation: skipSSLValidation, }) if verbose { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } pluginClient.WrapConnection(wrapper.NewRetryRequest(config.RequestRetryCount())) return pluginClient }
go
func NewClient(config command.Config, ui command.UI, skipSSLValidation bool) *plugin.Client { verbose, location := config.Verbose() pluginClient := plugin.NewClient(plugin.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), DialTimeout: config.DialTimeout(), SkipSSLValidation: skipSSLValidation, }) if verbose { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } pluginClient.WrapConnection(wrapper.NewRetryRequest(config.RequestRetryCount())) return pluginClient }
[ "func", "NewClient", "(", "config", "command", ".", "Config", ",", "ui", "command", ".", "UI", ",", "skipSSLValidation", "bool", ")", "*", "plugin", ".", "Client", "{", "verbose", ",", "location", ":=", "config", ".", "Verbose", "(", ")", "\n", "pluginClient", ":=", "plugin", ".", "NewClient", "(", "plugin", ".", "Config", "{", "AppName", ":", "config", ".", "BinaryName", "(", ")", ",", "AppVersion", ":", "config", ".", "BinaryVersion", "(", ")", ",", "DialTimeout", ":", "config", ".", "DialTimeout", "(", ")", ",", "SkipSSLValidation", ":", "skipSSLValidation", ",", "}", ")", "\n", "if", "verbose", "{", "pluginClient", ".", "WrapConnection", "(", "wrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "pluginClient", ".", "WrapConnection", "(", "wrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n", "pluginClient", ".", "WrapConnection", "(", "wrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n", "return", "pluginClient", "\n", "}" ]
// NewClient creates a new V2 Cloud Controller client and UAA client using the // passed in config.
[ "NewClient", "creates", "a", "new", "V2", "Cloud", "Controller", "client", "and", "UAA", "client", "using", "the", "passed", "in", "config", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/plugin/shared/new_client.go#L11-L32
train
cloudfoundry/cli
api/uaa/resources.go
SetupResources
func (client *Client) SetupResources(bootstrapURL string) error { request, err := client.newRequest(requestOptions{ Method: http.MethodGet, URL: fmt.Sprintf("%s/login", bootstrapURL), }) if err != nil { return err } info := NewInfo(bootstrapURL) response := Response{ Result: &info, } err = client.connection.Make(request, &response) if err != nil { return err } resources := map[string]string{ "uaa": info.UAALink(), "authorization_endpoint": bootstrapURL, } client.router = internal.NewRouter(internal.APIRoutes, resources) client.Info = info client.config.SetUAAEndpoint(info.UAALink()) return nil }
go
func (client *Client) SetupResources(bootstrapURL string) error { request, err := client.newRequest(requestOptions{ Method: http.MethodGet, URL: fmt.Sprintf("%s/login", bootstrapURL), }) if err != nil { return err } info := NewInfo(bootstrapURL) response := Response{ Result: &info, } err = client.connection.Make(request, &response) if err != nil { return err } resources := map[string]string{ "uaa": info.UAALink(), "authorization_endpoint": bootstrapURL, } client.router = internal.NewRouter(internal.APIRoutes, resources) client.Info = info client.config.SetUAAEndpoint(info.UAALink()) return nil }
[ "func", "(", "client", "*", "Client", ")", "SetupResources", "(", "bootstrapURL", "string", ")", "error", "{", "request", ",", "err", ":=", "client", ".", "newRequest", "(", "requestOptions", "{", "Method", ":", "http", ".", "MethodGet", ",", "URL", ":", "fmt", ".", "Sprintf", "(", "\"%s/login\"", ",", "bootstrapURL", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "info", ":=", "NewInfo", "(", "bootstrapURL", ")", "\n", "response", ":=", "Response", "{", "Result", ":", "&", "info", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "resources", ":=", "map", "[", "string", "]", "string", "{", "\"uaa\"", ":", "info", ".", "UAALink", "(", ")", ",", "\"authorization_endpoint\"", ":", "bootstrapURL", ",", "}", "\n", "client", ".", "router", "=", "internal", ".", "NewRouter", "(", "internal", ".", "APIRoutes", ",", "resources", ")", "\n", "client", ".", "Info", "=", "info", "\n", "client", ".", "config", ".", "SetUAAEndpoint", "(", "info", ".", "UAALink", "(", ")", ")", "\n", "return", "nil", "\n", "}" ]
// SetupResources configures the client to use the specified settings and diescopers the UAA and Authentication resources
[ "SetupResources", "configures", "the", "client", "to", "use", "the", "specified", "settings", "and", "diescopers", "the", "UAA", "and", "Authentication", "resources" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/resources.go#L11-L42
train
cloudfoundry/cli
actor/sharedaction/help.go
CommandInfoByName
func (Actor) CommandInfoByName(commandList interface{}, commandName string) (CommandInfo, error) { field, found := reflect.TypeOf(commandList).FieldByNameFunc( func(fieldName string) bool { field, _ := reflect.TypeOf(commandList).FieldByName(fieldName) return field.Tag.Get("command") == commandName || field.Tag.Get("alias") == commandName }, ) if !found { return CommandInfo{}, actionerror.InvalidCommandError{CommandName: commandName} } tag := field.Tag cmd := CommandInfo{ Name: tag.Get("command"), Description: tag.Get("description"), Alias: tag.Get("alias"), Flags: []CommandFlag{}, Environment: []EnvironmentVariable{}, } command := field.Type for i := 0; i < command.NumField(); i++ { fieldTag := command.Field(i).Tag if fieldTag.Get("hidden") != "" { continue } if fieldTag.Get("usage") != "" { cmd.Usage = fieldTag.Get("usage") continue } if fieldTag.Get("related_commands") != "" { relatedCommands := strings.Split(fieldTag.Get("related_commands"), ", ") sort.Slice(relatedCommands, sorting.SortAlphabeticFunc(relatedCommands)) cmd.RelatedCommands = relatedCommands continue } if fieldTag.Get("description") != "" { cmd.Flags = append(cmd.Flags, CommandFlag{ Short: fieldTag.Get("short"), Long: fieldTag.Get("long"), Description: fieldTag.Get("description"), Default: fieldTag.Get("default"), }) } if fieldTag.Get("environmentName") != "" { cmd.Environment = append(cmd.Environment, EnvironmentVariable{ Name: fieldTag.Get("environmentName"), DefaultValue: fieldTag.Get("environmentDefault"), Description: fieldTag.Get("environmentDescription"), }) } } return cmd, nil }
go
func (Actor) CommandInfoByName(commandList interface{}, commandName string) (CommandInfo, error) { field, found := reflect.TypeOf(commandList).FieldByNameFunc( func(fieldName string) bool { field, _ := reflect.TypeOf(commandList).FieldByName(fieldName) return field.Tag.Get("command") == commandName || field.Tag.Get("alias") == commandName }, ) if !found { return CommandInfo{}, actionerror.InvalidCommandError{CommandName: commandName} } tag := field.Tag cmd := CommandInfo{ Name: tag.Get("command"), Description: tag.Get("description"), Alias: tag.Get("alias"), Flags: []CommandFlag{}, Environment: []EnvironmentVariable{}, } command := field.Type for i := 0; i < command.NumField(); i++ { fieldTag := command.Field(i).Tag if fieldTag.Get("hidden") != "" { continue } if fieldTag.Get("usage") != "" { cmd.Usage = fieldTag.Get("usage") continue } if fieldTag.Get("related_commands") != "" { relatedCommands := strings.Split(fieldTag.Get("related_commands"), ", ") sort.Slice(relatedCommands, sorting.SortAlphabeticFunc(relatedCommands)) cmd.RelatedCommands = relatedCommands continue } if fieldTag.Get("description") != "" { cmd.Flags = append(cmd.Flags, CommandFlag{ Short: fieldTag.Get("short"), Long: fieldTag.Get("long"), Description: fieldTag.Get("description"), Default: fieldTag.Get("default"), }) } if fieldTag.Get("environmentName") != "" { cmd.Environment = append(cmd.Environment, EnvironmentVariable{ Name: fieldTag.Get("environmentName"), DefaultValue: fieldTag.Get("environmentDefault"), Description: fieldTag.Get("environmentDescription"), }) } } return cmd, nil }
[ "func", "(", "Actor", ")", "CommandInfoByName", "(", "commandList", "interface", "{", "}", ",", "commandName", "string", ")", "(", "CommandInfo", ",", "error", ")", "{", "field", ",", "found", ":=", "reflect", ".", "TypeOf", "(", "commandList", ")", ".", "FieldByNameFunc", "(", "func", "(", "fieldName", "string", ")", "bool", "{", "field", ",", "_", ":=", "reflect", ".", "TypeOf", "(", "commandList", ")", ".", "FieldByName", "(", "fieldName", ")", "\n", "return", "field", ".", "Tag", ".", "Get", "(", "\"command\"", ")", "==", "commandName", "||", "field", ".", "Tag", ".", "Get", "(", "\"alias\"", ")", "==", "commandName", "\n", "}", ",", ")", "\n", "if", "!", "found", "{", "return", "CommandInfo", "{", "}", ",", "actionerror", ".", "InvalidCommandError", "{", "CommandName", ":", "commandName", "}", "\n", "}", "\n", "tag", ":=", "field", ".", "Tag", "\n", "cmd", ":=", "CommandInfo", "{", "Name", ":", "tag", ".", "Get", "(", "\"command\"", ")", ",", "Description", ":", "tag", ".", "Get", "(", "\"description\"", ")", ",", "Alias", ":", "tag", ".", "Get", "(", "\"alias\"", ")", ",", "Flags", ":", "[", "]", "CommandFlag", "{", "}", ",", "Environment", ":", "[", "]", "EnvironmentVariable", "{", "}", ",", "}", "\n", "command", ":=", "field", ".", "Type", "\n", "for", "i", ":=", "0", ";", "i", "<", "command", ".", "NumField", "(", ")", ";", "i", "++", "{", "fieldTag", ":=", "command", ".", "Field", "(", "i", ")", ".", "Tag", "\n", "if", "fieldTag", ".", "Get", "(", "\"hidden\"", ")", "!=", "\"\"", "{", "continue", "\n", "}", "\n", "if", "fieldTag", ".", "Get", "(", "\"usage\"", ")", "!=", "\"\"", "{", "cmd", ".", "Usage", "=", "fieldTag", ".", "Get", "(", "\"usage\"", ")", "\n", "continue", "\n", "}", "\n", "if", "fieldTag", ".", "Get", "(", "\"related_commands\"", ")", "!=", "\"\"", "{", "relatedCommands", ":=", "strings", ".", "Split", "(", "fieldTag", ".", "Get", "(", "\"related_commands\"", ")", ",", "\", \"", ")", "\n", "sort", ".", "Slice", "(", "relatedCommands", ",", "sorting", ".", "SortAlphabeticFunc", "(", "relatedCommands", ")", ")", "\n", "cmd", ".", "RelatedCommands", "=", "relatedCommands", "\n", "continue", "\n", "}", "\n", "if", "fieldTag", ".", "Get", "(", "\"description\"", ")", "!=", "\"\"", "{", "cmd", ".", "Flags", "=", "append", "(", "cmd", ".", "Flags", ",", "CommandFlag", "{", "Short", ":", "fieldTag", ".", "Get", "(", "\"short\"", ")", ",", "Long", ":", "fieldTag", ".", "Get", "(", "\"long\"", ")", ",", "Description", ":", "fieldTag", ".", "Get", "(", "\"description\"", ")", ",", "Default", ":", "fieldTag", ".", "Get", "(", "\"default\"", ")", ",", "}", ")", "\n", "}", "\n", "if", "fieldTag", ".", "Get", "(", "\"environmentName\"", ")", "!=", "\"\"", "{", "cmd", ".", "Environment", "=", "append", "(", "cmd", ".", "Environment", ",", "EnvironmentVariable", "{", "Name", ":", "fieldTag", ".", "Get", "(", "\"environmentName\"", ")", ",", "DefaultValue", ":", "fieldTag", ".", "Get", "(", "\"environmentDefault\"", ")", ",", "Description", ":", "fieldTag", ".", "Get", "(", "\"environmentDescription\"", ")", ",", "}", ")", "\n", "}", "\n", "}", "\n", "return", "cmd", ",", "nil", "\n", "}" ]
// CommandInfoByName returns the help information for a particular commandName in // the commandList.
[ "CommandInfoByName", "returns", "the", "help", "information", "for", "a", "particular", "commandName", "in", "the", "commandList", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/help.go#L60-L120
train
cloudfoundry/cli
actor/sharedaction/help.go
CommandInfos
func (Actor) CommandInfos(commandList interface{}) map[string]CommandInfo { handler := reflect.TypeOf(commandList) infos := make(map[string]CommandInfo, handler.NumField()) for i := 0; i < handler.NumField(); i++ { fieldTag := handler.Field(i).Tag commandName := fieldTag.Get("command") infos[commandName] = CommandInfo{ Name: commandName, Description: fieldTag.Get("description"), Alias: fieldTag.Get("alias"), } } return infos }
go
func (Actor) CommandInfos(commandList interface{}) map[string]CommandInfo { handler := reflect.TypeOf(commandList) infos := make(map[string]CommandInfo, handler.NumField()) for i := 0; i < handler.NumField(); i++ { fieldTag := handler.Field(i).Tag commandName := fieldTag.Get("command") infos[commandName] = CommandInfo{ Name: commandName, Description: fieldTag.Get("description"), Alias: fieldTag.Get("alias"), } } return infos }
[ "func", "(", "Actor", ")", "CommandInfos", "(", "commandList", "interface", "{", "}", ")", "map", "[", "string", "]", "CommandInfo", "{", "handler", ":=", "reflect", ".", "TypeOf", "(", "commandList", ")", "\n", "infos", ":=", "make", "(", "map", "[", "string", "]", "CommandInfo", ",", "handler", ".", "NumField", "(", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "handler", ".", "NumField", "(", ")", ";", "i", "++", "{", "fieldTag", ":=", "handler", ".", "Field", "(", "i", ")", ".", "Tag", "\n", "commandName", ":=", "fieldTag", ".", "Get", "(", "\"command\"", ")", "\n", "infos", "[", "commandName", "]", "=", "CommandInfo", "{", "Name", ":", "commandName", ",", "Description", ":", "fieldTag", ".", "Get", "(", "\"description\"", ")", ",", "Alias", ":", "fieldTag", ".", "Get", "(", "\"alias\"", ")", ",", "}", "\n", "}", "\n", "return", "infos", "\n", "}" ]
// CommandInfos returns a slice of CommandInfo that only fills in // the Name and Description for all the commands in commandList
[ "CommandInfos", "returns", "a", "slice", "of", "CommandInfo", "that", "only", "fills", "in", "the", "Name", "and", "Description", "for", "all", "the", "commands", "in", "commandList" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/help.go#L124-L139
train
cloudfoundry/cli
api/cloudcontroller/ccv3/resource.go
UnmarshalJSON
func (r *Resource) UnmarshalJSON(data []byte) error { var ccResource struct { FilePath string `json:"path,omitempty"` Mode string `json:"mode,omitempty"` Checksum Checksum `json:"checksum"` SizeInBytes int64 `json:"size_in_bytes"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.FilePath = ccResource.FilePath r.SizeInBytes = ccResource.SizeInBytes r.Checksum = ccResource.Checksum mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
go
func (r *Resource) UnmarshalJSON(data []byte) error { var ccResource struct { FilePath string `json:"path,omitempty"` Mode string `json:"mode,omitempty"` Checksum Checksum `json:"checksum"` SizeInBytes int64 `json:"size_in_bytes"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.FilePath = ccResource.FilePath r.SizeInBytes = ccResource.SizeInBytes r.Checksum = ccResource.Checksum mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
[ "func", "(", "r", "*", "Resource", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccResource", "struct", "{", "FilePath", "string", "`json:\"path,omitempty\"`", "\n", "Mode", "string", "`json:\"mode,omitempty\"`", "\n", "Checksum", "Checksum", "`json:\"checksum\"`", "\n", "SizeInBytes", "int64", "`json:\"size_in_bytes\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccResource", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r", ".", "FilePath", "=", "ccResource", ".", "FilePath", "\n", "r", ".", "SizeInBytes", "=", "ccResource", ".", "SizeInBytes", "\n", "r", ".", "Checksum", "=", "ccResource", ".", "Checksum", "\n", "mode", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "ccResource", ".", "Mode", ",", "8", ",", "32", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r", ".", "Mode", "=", "os", ".", "FileMode", "(", "mode", ")", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Resource response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Resource", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/resource.go#L58-L81
train
cloudfoundry/cli
api/cloudcontroller/ccv3/job_url.go
DeleteApplication
func (client *Client) DeleteApplication(appGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteApplicationRequest, URIParams: internal.Params{"app_guid": appGUID}, }) if err != nil { return "", nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
go
func (client *Client) DeleteApplication(appGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteApplicationRequest, URIParams: internal.Params{"app_guid": appGUID}, }) if err != nil { return "", nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteApplication", "(", "appGUID", "string", ")", "(", "JobURL", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteApplicationRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"app_guid\"", ":", "appGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "nil", ",", "err", "\n", "}", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "JobURL", "(", "response", ".", "ResourceLocationURL", ")", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteApplication deletes the app with the given app GUID. Returns back a // resulting job URL to poll.
[ "DeleteApplication", "deletes", "the", "app", "with", "the", "given", "app", "GUID", ".", "Returns", "back", "a", "resulting", "job", "URL", "to", "poll", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job_url.go#L14-L27
train
cloudfoundry/cli
api/cloudcontroller/ccv3/job_url.go
UpdateApplicationApplyManifest
func (client *Client) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionApplyManifest, URIParams: map[string]string{"app_guid": appGUID}, Body: bytes.NewReader(rawManifest), }) if err != nil { return "", nil, err } request.Header.Set("Content-Type", "application/x-yaml") response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
go
func (client *Client) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionApplyManifest, URIParams: map[string]string{"app_guid": appGUID}, Body: bytes.NewReader(rawManifest), }) if err != nil { return "", nil, err } request.Header.Set("Content-Type", "application/x-yaml") response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateApplicationApplyManifest", "(", "appGUID", "string", ",", "rawManifest", "[", "]", "byte", ")", "(", "JobURL", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationActionApplyManifest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"app_guid\"", ":", "appGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "rawManifest", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "nil", ",", "err", "\n", "}", "\n", "request", ".", "Header", ".", "Set", "(", "\"Content-Type\"", ",", "\"application/x-yaml\"", ")", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "JobURL", "(", "response", ".", "ResourceLocationURL", ")", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateApplicationApplyManifest applies the manifest to the given // application. Returns back a resulting job URL to poll.
[ "UpdateApplicationApplyManifest", "applies", "the", "manifest", "to", "the", "given", "application", ".", "Returns", "back", "a", "resulting", "job", "URL", "to", "poll", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job_url.go#L31-L48
train
cloudfoundry/cli
util/ui/i18n.go
GetTranslationFunc
func GetTranslationFunc(reader LocaleReader) (TranslateFunc, error) { locale, err := determineLocale(reader) if err != nil { locale = defaultLocale } rawTranslation, err := loadAssetFromResources(locale) if err != nil { rawTranslation, err = loadAssetFromResources(defaultLocale) if err != nil { return nil, err } } return generateTranslationFunc(rawTranslation) }
go
func GetTranslationFunc(reader LocaleReader) (TranslateFunc, error) { locale, err := determineLocale(reader) if err != nil { locale = defaultLocale } rawTranslation, err := loadAssetFromResources(locale) if err != nil { rawTranslation, err = loadAssetFromResources(defaultLocale) if err != nil { return nil, err } } return generateTranslationFunc(rawTranslation) }
[ "func", "GetTranslationFunc", "(", "reader", "LocaleReader", ")", "(", "TranslateFunc", ",", "error", ")", "{", "locale", ",", "err", ":=", "determineLocale", "(", "reader", ")", "\n", "if", "err", "!=", "nil", "{", "locale", "=", "defaultLocale", "\n", "}", "\n", "rawTranslation", ",", "err", ":=", "loadAssetFromResources", "(", "locale", ")", "\n", "if", "err", "!=", "nil", "{", "rawTranslation", ",", "err", "=", "loadAssetFromResources", "(", "defaultLocale", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "return", "generateTranslationFunc", "(", "rawTranslation", ")", "\n", "}" ]
// GetTranslationFunc will return back a function that can be used to translate // strings into the currently set locale.
[ "GetTranslationFunc", "will", "return", "back", "a", "function", "that", "can", "be", "used", "to", "translate", "strings", "into", "the", "currently", "set", "locale", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/i18n.go#L48-L63
train
cloudfoundry/cli
integration/helpers/user.go
GetUsers
func GetUsers() []User { var userPagesResponse struct { NextURL *string `json:"next_url"` Resources []struct { Metadata struct { GUID string `json:"guid"` CreatedAt time.Time `json:"created_at"` } `json:"metadata"` Entity struct { Username string `json:"username"` } `json:"entity"` } `json:"resources"` } var allUsers []User nextURL := "/v2/users?results-per-page=50" for { session := CF("curl", nextURL) Eventually(session).Should(Exit(0)) err := json.Unmarshal(session.Out.Contents(), &userPagesResponse) Expect(err).NotTo(HaveOccurred()) for _, resource := range userPagesResponse.Resources { allUsers = append(allUsers, User{ GUID: resource.Metadata.GUID, CreatedAt: resource.Metadata.CreatedAt, Username: resource.Entity.Username, }) } if userPagesResponse.NextURL == nil { break } nextURL = *userPagesResponse.NextURL } return allUsers }
go
func GetUsers() []User { var userPagesResponse struct { NextURL *string `json:"next_url"` Resources []struct { Metadata struct { GUID string `json:"guid"` CreatedAt time.Time `json:"created_at"` } `json:"metadata"` Entity struct { Username string `json:"username"` } `json:"entity"` } `json:"resources"` } var allUsers []User nextURL := "/v2/users?results-per-page=50" for { session := CF("curl", nextURL) Eventually(session).Should(Exit(0)) err := json.Unmarshal(session.Out.Contents(), &userPagesResponse) Expect(err).NotTo(HaveOccurred()) for _, resource := range userPagesResponse.Resources { allUsers = append(allUsers, User{ GUID: resource.Metadata.GUID, CreatedAt: resource.Metadata.CreatedAt, Username: resource.Entity.Username, }) } if userPagesResponse.NextURL == nil { break } nextURL = *userPagesResponse.NextURL } return allUsers }
[ "func", "GetUsers", "(", ")", "[", "]", "User", "{", "var", "userPagesResponse", "struct", "{", "NextURL", "*", "string", "`json:\"next_url\"`", "\n", "Resources", "[", "]", "struct", "{", "Metadata", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "CreatedAt", "time", ".", "Time", "`json:\"created_at\"`", "\n", "}", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Username", "string", "`json:\"username\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "`json:\"resources\"`", "\n", "}", "\n", "var", "allUsers", "[", "]", "User", "\n", "nextURL", ":=", "\"/v2/users?results-per-page=50\"", "\n", "for", "{", "session", ":=", "CF", "(", "\"curl\"", ",", "nextURL", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "0", ")", ")", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "session", ".", "Out", ".", "Contents", "(", ")", ",", "&", "userPagesResponse", ")", "\n", "Expect", "(", "err", ")", ".", "NotTo", "(", "HaveOccurred", "(", ")", ")", "\n", "for", "_", ",", "resource", ":=", "range", "userPagesResponse", ".", "Resources", "{", "allUsers", "=", "append", "(", "allUsers", ",", "User", "{", "GUID", ":", "resource", ".", "Metadata", ".", "GUID", ",", "CreatedAt", ":", "resource", ".", "Metadata", ".", "CreatedAt", ",", "Username", ":", "resource", ".", "Entity", ".", "Username", ",", "}", ")", "\n", "}", "\n", "if", "userPagesResponse", ".", "NextURL", "==", "nil", "{", "break", "\n", "}", "\n", "nextURL", "=", "*", "userPagesResponse", ".", "NextURL", "\n", "}", "\n", "return", "allUsers", "\n", "}" ]
// GetUsers returns all the users in the targeted environment
[ "GetUsers", "returns", "all", "the", "users", "in", "the", "targeted", "environment" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/user.go#L18-L56
train
cloudfoundry/cli
api/cloudcontroller/ccv3/info.go
rootResponse
func (client *Client) rootResponse() (Info, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ Method: http.MethodGet, URL: client.cloudControllerURL, }) if err != nil { return Info{}, nil, err } var rootResponse Info response := cloudcontroller.Response{ DecodeJSONResponseInto: &rootResponse, } err = client.connection.Make(request, &response) if unknownSourceErr, ok := err.(ccerror.UnknownHTTPSourceError); ok && unknownSourceErr.StatusCode == http.StatusNotFound { return Info{}, nil, ccerror.APINotFoundError{URL: client.cloudControllerURL} } return rootResponse, response.Warnings, err }
go
func (client *Client) rootResponse() (Info, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ Method: http.MethodGet, URL: client.cloudControllerURL, }) if err != nil { return Info{}, nil, err } var rootResponse Info response := cloudcontroller.Response{ DecodeJSONResponseInto: &rootResponse, } err = client.connection.Make(request, &response) if unknownSourceErr, ok := err.(ccerror.UnknownHTTPSourceError); ok && unknownSourceErr.StatusCode == http.StatusNotFound { return Info{}, nil, ccerror.APINotFoundError{URL: client.cloudControllerURL} } return rootResponse, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "rootResponse", "(", ")", "(", "Info", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "Method", ":", "http", ".", "MethodGet", ",", "URL", ":", "client", ".", "cloudControllerURL", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Info", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "rootResponse", "Info", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "rootResponse", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "unknownSourceErr", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "UnknownHTTPSourceError", ")", ";", "ok", "&&", "unknownSourceErr", ".", "StatusCode", "==", "http", ".", "StatusNotFound", "{", "return", "Info", "{", "}", ",", "nil", ",", "ccerror", ".", "APINotFoundError", "{", "URL", ":", "client", ".", "cloudControllerURL", "}", "\n", "}", "\n", "return", "rootResponse", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// rootResponse returns the CC API root document.
[ "rootResponse", "returns", "the", "CC", "API", "root", "document", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/info.go#L135-L155
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
MarshalJSON
func (a Application) MarshalJSON() ([]byte, error) { ccApp := ccApplication{ Name: a.Name, Relationships: a.Relationships, Metadata: a.Metadata, } if a.LifecycleType == constant.AppLifecycleTypeDocker { ccApp.setDockerLifecycle() } else if a.LifecycleType == constant.AppLifecycleTypeBuildpack { if len(a.LifecycleBuildpacks) > 0 || a.StackName != "" { if a.hasAutodetectedBuildpack() { ccApp.setAutodetectedBuildpackLifecycle(a) } else { ccApp.setBuildpackLifecycle(a) } } } return json.Marshal(ccApp) }
go
func (a Application) MarshalJSON() ([]byte, error) { ccApp := ccApplication{ Name: a.Name, Relationships: a.Relationships, Metadata: a.Metadata, } if a.LifecycleType == constant.AppLifecycleTypeDocker { ccApp.setDockerLifecycle() } else if a.LifecycleType == constant.AppLifecycleTypeBuildpack { if len(a.LifecycleBuildpacks) > 0 || a.StackName != "" { if a.hasAutodetectedBuildpack() { ccApp.setAutodetectedBuildpackLifecycle(a) } else { ccApp.setBuildpackLifecycle(a) } } } return json.Marshal(ccApp) }
[ "func", "(", "a", "Application", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ccApp", ":=", "ccApplication", "{", "Name", ":", "a", ".", "Name", ",", "Relationships", ":", "a", ".", "Relationships", ",", "Metadata", ":", "a", ".", "Metadata", ",", "}", "\n", "if", "a", ".", "LifecycleType", "==", "constant", ".", "AppLifecycleTypeDocker", "{", "ccApp", ".", "setDockerLifecycle", "(", ")", "\n", "}", "else", "if", "a", ".", "LifecycleType", "==", "constant", ".", "AppLifecycleTypeBuildpack", "{", "if", "len", "(", "a", ".", "LifecycleBuildpacks", ")", ">", "0", "||", "a", ".", "StackName", "!=", "\"\"", "{", "if", "a", ".", "hasAutodetectedBuildpack", "(", ")", "{", "ccApp", ".", "setAutodetectedBuildpackLifecycle", "(", "a", ")", "\n", "}", "else", "{", "ccApp", ".", "setBuildpackLifecycle", "(", "a", ")", "\n", "}", "\n", "}", "\n", "}", "\n", "return", "json", ".", "Marshal", "(", "ccApp", ")", "\n", "}" ]
// MarshalJSON converts an Application into a Cloud Controller Application.
[ "MarshalJSON", "converts", "an", "Application", "into", "a", "Cloud", "Controller", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L34-L54
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
GetApplications
func (client *Client) GetApplications(query ...Query) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullAppsList []Application warnings, err := client.paginate(request, Application{}, func(item interface{}) error { if app, ok := item.(Application); ok { fullAppsList = append(fullAppsList, app) } else { return ccerror.UnknownObjectInListError{ Expected: Application{}, Unexpected: item, } } return nil }) return fullAppsList, warnings, err }
go
func (client *Client) GetApplications(query ...Query) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullAppsList []Application warnings, err := client.paginate(request, Application{}, func(item interface{}) error { if app, ok := item.(Application); ok { fullAppsList = append(fullAppsList, app) } else { return ccerror.UnknownObjectInListError{ Expected: Application{}, Unexpected: item, } } return nil }) return fullAppsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplications", "(", "query", "...", "Query", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetApplicationsRequest", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullAppsList", "[", "]", "Application", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Application", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "app", ",", "ok", ":=", "item", ".", "(", "Application", ")", ";", "ok", "{", "fullAppsList", "=", "append", "(", "fullAppsList", ",", "app", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Application", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullAppsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetApplications lists applications with optional queries.
[ "GetApplications", "lists", "applications", "with", "optional", "queries", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L156-L179
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
UpdateApplication
func (client *Client) UpdateApplication(app Application) (Application, Warnings, error) { bodyBytes, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchApplicationRequest, Body: bytes.NewReader(bodyBytes), URIParams: map[string]string{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
go
func (client *Client) UpdateApplication(app Application) (Application, Warnings, error) { bodyBytes, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchApplicationRequest, Body: bytes.NewReader(bodyBytes), URIParams: map[string]string{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "app", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchApplicationRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"app_guid\"", ":", "app", ".", "GUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "responseApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseApp", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateApplication updates an application with the given settings.
[ "UpdateApplication", "updates", "an", "application", "with", "the", "given", "settings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L182-L204
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
UpdateApplicationRestart
func (client *Client) UpdateApplicationRestart(appGUID string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionRestartRequest, URIParams: map[string]string{"app_guid": appGUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
go
func (client *Client) UpdateApplicationRestart(appGUID string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionRestartRequest, URIParams: map[string]string{"app_guid": appGUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateApplicationRestart", "(", "appGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationActionRestartRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"app_guid\"", ":", "appGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "responseApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseApp", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateApplicationRestart restarts the given application.
[ "UpdateApplicationRestart", "restarts", "the", "given", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L207-L223
train
cloudfoundry/cli
actor/v2action/application.go
CalculatedBuildpack
func (application Application) CalculatedBuildpack() string { if application.Buildpack.IsSet { return application.Buildpack.Value } return application.DetectedBuildpack.Value }
go
func (application Application) CalculatedBuildpack() string { if application.Buildpack.IsSet { return application.Buildpack.Value } return application.DetectedBuildpack.Value }
[ "func", "(", "application", "Application", ")", "CalculatedBuildpack", "(", ")", "string", "{", "if", "application", ".", "Buildpack", ".", "IsSet", "{", "return", "application", ".", "Buildpack", ".", "Value", "\n", "}", "\n", "return", "application", ".", "DetectedBuildpack", ".", "Value", "\n", "}" ]
// CalculatedBuildpack returns the buildpack that will be used.
[ "CalculatedBuildpack", "returns", "the", "buildpack", "that", "will", "be", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L25-L31
train
cloudfoundry/cli
actor/v2action/application.go
CalculatedCommand
func (application Application) CalculatedCommand() string { if application.Command.IsSet { return application.Command.Value } return application.DetectedStartCommand.Value }
go
func (application Application) CalculatedCommand() string { if application.Command.IsSet { return application.Command.Value } return application.DetectedStartCommand.Value }
[ "func", "(", "application", "Application", ")", "CalculatedCommand", "(", ")", "string", "{", "if", "application", ".", "Command", ".", "IsSet", "{", "return", "application", ".", "Command", ".", "Value", "\n", "}", "\n", "return", "application", ".", "DetectedStartCommand", ".", "Value", "\n", "}" ]
// CalculatedCommand returns the command that will be used.
[ "CalculatedCommand", "returns", "the", "command", "that", "will", "be", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L34-L40
train
cloudfoundry/cli
actor/v2action/application.go
StagingFailedMessage
func (application Application) StagingFailedMessage() string { if application.StagingFailedDescription != "" { return application.StagingFailedDescription } return application.StagingFailedReason }
go
func (application Application) StagingFailedMessage() string { if application.StagingFailedDescription != "" { return application.StagingFailedDescription } return application.StagingFailedReason }
[ "func", "(", "application", "Application", ")", "StagingFailedMessage", "(", ")", "string", "{", "if", "application", ".", "StagingFailedDescription", "!=", "\"\"", "{", "return", "application", ".", "StagingFailedDescription", "\n", "}", "\n", "return", "application", ".", "StagingFailedReason", "\n", "}" ]
// StagingFailedMessage returns the verbose description of the failure or // the reason if the verbose description is empty.
[ "StagingFailedMessage", "returns", "the", "verbose", "description", "of", "the", "failure", "or", "the", "reason", "if", "the", "verbose", "description", "is", "empty", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L64-L70
train
cloudfoundry/cli
actor/v2action/application.go
CreateApplication
func (actor Actor) CreateApplication(application Application) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.CreateApplication(ccv2.Application(application)) return Application(app), Warnings(warnings), err }
go
func (actor Actor) CreateApplication(application Application) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.CreateApplication(ccv2.Application(application)) return Application(app), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "CreateApplication", "(", "application", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateApplication", "(", "ccv2", ".", "Application", "(", "application", ")", ")", "\n", "return", "Application", "(", "app", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// CreateApplication creates an application.
[ "CreateApplication", "creates", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L115-L118
train
cloudfoundry/cli
actor/v2action/application.go
GetApplication
func (actor Actor) GetApplication(guid string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplication(guid) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{GUID: guid} } return Application(app), Warnings(warnings), err }
go
func (actor Actor) GetApplication(guid string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplication(guid) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{GUID: guid} } return Application(app), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetApplication", "(", "guid", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplication", "(", "guid", ")", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "ok", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ApplicationNotFoundError", "{", "GUID", ":", "guid", "}", "\n", "}", "\n", "return", "Application", "(", "app", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetApplication returns the application.
[ "GetApplication", "returns", "the", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L121-L129
train
cloudfoundry/cli
actor/v2action/application.go
GetApplicationByNameAndSpace
func (actor Actor) GetApplicationByNameAndSpace(name string, spaceGUID string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplications( ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{name}, }, ccv2.Filter{ Type: constant.SpaceGUIDFilter, Operator: constant.EqualOperator, Values: []string{spaceGUID}, }, ) if err != nil { return Application{}, Warnings(warnings), err } if len(app) == 0 { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{ Name: name, } } return Application(app[0]), Warnings(warnings), nil }
go
func (actor Actor) GetApplicationByNameAndSpace(name string, spaceGUID string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplications( ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{name}, }, ccv2.Filter{ Type: constant.SpaceGUIDFilter, Operator: constant.EqualOperator, Values: []string{spaceGUID}, }, ) if err != nil { return Application{}, Warnings(warnings), err } if len(app) == 0 { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{ Name: name, } } return Application(app[0]), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetApplicationByNameAndSpace", "(", "name", "string", ",", "spaceGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplications", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "name", "}", ",", "}", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "SpaceGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "spaceGUID", "}", ",", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "if", "len", "(", "app", ")", "==", "0", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ApplicationNotFoundError", "{", "Name", ":", "name", ",", "}", "\n", "}", "\n", "return", "Application", "(", "app", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetApplicationByNameAndSpace returns an application with matching name in // the space.
[ "GetApplicationByNameAndSpace", "returns", "an", "application", "with", "matching", "name", "in", "the", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L133-L158
train
cloudfoundry/cli
actor/v2action/application.go
GetRouteApplications
func (actor Actor) GetRouteApplications(routeGUID string) ([]Application, Warnings, error) { apps, warnings, err := actor.CloudControllerClient.GetRouteApplications(routeGUID) if err != nil { return nil, Warnings(warnings), err } allApplications := []Application{} for _, app := range apps { allApplications = append(allApplications, Application(app)) } return allApplications, Warnings(warnings), nil }
go
func (actor Actor) GetRouteApplications(routeGUID string) ([]Application, Warnings, error) { apps, warnings, err := actor.CloudControllerClient.GetRouteApplications(routeGUID) if err != nil { return nil, Warnings(warnings), err } allApplications := []Application{} for _, app := range apps { allApplications = append(allApplications, Application(app)) } return allApplications, Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetRouteApplications", "(", "routeGUID", "string", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "apps", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetRouteApplications", "(", "routeGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "allApplications", ":=", "[", "]", "Application", "{", "}", "\n", "for", "_", ",", "app", ":=", "range", "apps", "{", "allApplications", "=", "append", "(", "allApplications", ",", "Application", "(", "app", ")", ")", "\n", "}", "\n", "return", "allApplications", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetRouteApplications returns a list of apps associated with the provided // Route GUID.
[ "GetRouteApplications", "returns", "a", "list", "of", "apps", "associated", "with", "the", "provided", "Route", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L184-L194
train
cloudfoundry/cli
actor/v2action/application.go
SetApplicationHealthCheckTypeByNameAndSpace
func (actor Actor) SetApplicationHealthCheckTypeByNameAndSpace(name string, spaceGUID string, healthCheckType constant.ApplicationHealthCheckType, httpEndpoint string) (Application, Warnings, error) { if httpEndpoint != "/" && healthCheckType != constant.ApplicationHealthCheckHTTP { return Application{}, nil, actionerror.HTTPHealthCheckInvalidError{} } var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(name, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return Application{}, allWarnings, err } if app.HealthCheckType != healthCheckType || healthCheckType == constant.ApplicationHealthCheckHTTP && app.HealthCheckHTTPEndpoint != httpEndpoint { var healthCheckEndpoint string if healthCheckType == constant.ApplicationHealthCheckHTTP { healthCheckEndpoint = httpEndpoint } updatedApp, apiWarnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, HealthCheckType: healthCheckType, HealthCheckHTTPEndpoint: healthCheckEndpoint, }) allWarnings = append(allWarnings, Warnings(apiWarnings)...) return Application(updatedApp), allWarnings, err } return app, allWarnings, nil }
go
func (actor Actor) SetApplicationHealthCheckTypeByNameAndSpace(name string, spaceGUID string, healthCheckType constant.ApplicationHealthCheckType, httpEndpoint string) (Application, Warnings, error) { if httpEndpoint != "/" && healthCheckType != constant.ApplicationHealthCheckHTTP { return Application{}, nil, actionerror.HTTPHealthCheckInvalidError{} } var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(name, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return Application{}, allWarnings, err } if app.HealthCheckType != healthCheckType || healthCheckType == constant.ApplicationHealthCheckHTTP && app.HealthCheckHTTPEndpoint != httpEndpoint { var healthCheckEndpoint string if healthCheckType == constant.ApplicationHealthCheckHTTP { healthCheckEndpoint = httpEndpoint } updatedApp, apiWarnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, HealthCheckType: healthCheckType, HealthCheckHTTPEndpoint: healthCheckEndpoint, }) allWarnings = append(allWarnings, Warnings(apiWarnings)...) return Application(updatedApp), allWarnings, err } return app, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "SetApplicationHealthCheckTypeByNameAndSpace", "(", "name", "string", ",", "spaceGUID", "string", ",", "healthCheckType", "constant", ".", "ApplicationHealthCheckType", ",", "httpEndpoint", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "if", "httpEndpoint", "!=", "\"/\"", "&&", "healthCheckType", "!=", "constant", ".", "ApplicationHealthCheckHTTP", "{", "return", "Application", "{", "}", ",", "nil", ",", "actionerror", ".", "HTTPHealthCheckInvalidError", "{", "}", "\n", "}", "\n", "var", "allWarnings", "Warnings", "\n", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "name", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "if", "app", ".", "HealthCheckType", "!=", "healthCheckType", "||", "healthCheckType", "==", "constant", ".", "ApplicationHealthCheckHTTP", "&&", "app", ".", "HealthCheckHTTPEndpoint", "!=", "httpEndpoint", "{", "var", "healthCheckEndpoint", "string", "\n", "if", "healthCheckType", "==", "constant", ".", "ApplicationHealthCheckHTTP", "{", "healthCheckEndpoint", "=", "httpEndpoint", "\n", "}", "\n", "updatedApp", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplication", "(", "ccv2", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "HealthCheckType", ":", "healthCheckType", ",", "HealthCheckHTTPEndpoint", ":", "healthCheckEndpoint", ",", "}", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "Warnings", "(", "apiWarnings", ")", "...", ")", "\n", "return", "Application", "(", "updatedApp", ")", ",", "allWarnings", ",", "err", "\n", "}", "\n", "return", "app", ",", "allWarnings", ",", "nil", "\n", "}" ]
// SetApplicationHealthCheckTypeByNameAndSpace updates an application's health // check type if it is not already the desired type.
[ "SetApplicationHealthCheckTypeByNameAndSpace", "updates", "an", "application", "s", "health", "check", "type", "if", "it", "is", "not", "already", "the", "desired", "type", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L198-L230
train
cloudfoundry/cli
actor/v2action/application.go
StartApplication
func (actor Actor) StartApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients if app.PackageState != constant.ApplicationPackageStaged { appState <- ApplicationStateStaging } updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, State: constant.ApplicationStarted, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(updatedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
go
func (actor Actor) StartApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients if app.PackageState != constant.ApplicationPackageStaged { appState <- ApplicationStateStaging } updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, State: constant.ApplicationStarted, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(updatedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
[ "func", "(", "actor", "Actor", ")", "StartApplication", "(", "app", "Application", ",", "client", "NOAAClient", ")", "(", "<-", "chan", "*", "LogMessage", ",", "<-", "chan", "error", ",", "<-", "chan", "ApplicationStateChange", ",", "<-", "chan", "string", ",", "<-", "chan", "error", ")", "{", "messages", ",", "logErrs", ":=", "actor", ".", "GetStreamingLogs", "(", "app", ".", "GUID", ",", "client", ")", "\n", "appState", ":=", "make", "(", "chan", "ApplicationStateChange", ")", "\n", "allWarnings", ":=", "make", "(", "chan", "string", ")", "\n", "errs", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "defer", "close", "(", "appState", ")", "\n", "defer", "close", "(", "allWarnings", ")", "\n", "defer", "close", "(", "errs", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "if", "app", ".", "PackageState", "!=", "constant", ".", "ApplicationPackageStaged", "{", "appState", "<-", "ApplicationStateStaging", "\n", "}", "\n", "updatedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplication", "(", "ccv2", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "State", ":", "constant", ".", "ApplicationStarted", ",", "}", ")", "\n", "for", "_", ",", "warning", ":=", "range", "warnings", "{", "allWarnings", "<-", "warning", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "errs", "<-", "err", "\n", "return", "\n", "}", "\n", "actor", ".", "waitForApplicationStageAndStart", "(", "Application", "(", "updatedApp", ")", ",", "client", ",", "appState", ",", "allWarnings", ",", "errs", ")", "\n", "}", "(", ")", "\n", "return", "messages", ",", "logErrs", ",", "appState", ",", "allWarnings", ",", "errs", "\n", "}" ]
// StartApplication restarts a given application. If already stopped, no stop // call will be sent.
[ "StartApplication", "restarts", "a", "given", "application", ".", "If", "already", "stopped", "no", "stop", "call", "will", "be", "sent", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L234-L267
train
cloudfoundry/cli
actor/v2action/application.go
RestageApplication
func (actor Actor) RestageApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients appState <- ApplicationStateStaging restagedApp, warnings, err := actor.CloudControllerClient.RestageApplication(ccv2.Application{ GUID: app.GUID, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(restagedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
go
func (actor Actor) RestageApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients appState <- ApplicationStateStaging restagedApp, warnings, err := actor.CloudControllerClient.RestageApplication(ccv2.Application{ GUID: app.GUID, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(restagedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
[ "func", "(", "actor", "Actor", ")", "RestageApplication", "(", "app", "Application", ",", "client", "NOAAClient", ")", "(", "<-", "chan", "*", "LogMessage", ",", "<-", "chan", "error", ",", "<-", "chan", "ApplicationStateChange", ",", "<-", "chan", "string", ",", "<-", "chan", "error", ")", "{", "messages", ",", "logErrs", ":=", "actor", ".", "GetStreamingLogs", "(", "app", ".", "GUID", ",", "client", ")", "\n", "appState", ":=", "make", "(", "chan", "ApplicationStateChange", ")", "\n", "allWarnings", ":=", "make", "(", "chan", "string", ")", "\n", "errs", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "defer", "close", "(", "appState", ")", "\n", "defer", "close", "(", "allWarnings", ")", "\n", "defer", "close", "(", "errs", ")", "\n", "defer", "client", ".", "Close", "(", ")", "\n", "appState", "<-", "ApplicationStateStaging", "\n", "restagedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "RestageApplication", "(", "ccv2", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "}", ")", "\n", "for", "_", ",", "warning", ":=", "range", "warnings", "{", "allWarnings", "<-", "warning", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "errs", "<-", "err", "\n", "return", "\n", "}", "\n", "actor", ".", "waitForApplicationStageAndStart", "(", "Application", "(", "restagedApp", ")", ",", "client", ",", "appState", ",", "allWarnings", ",", "errs", ")", "\n", "}", "(", ")", "\n", "return", "messages", ",", "logErrs", ",", "appState", ",", "allWarnings", ",", "errs", "\n", "}" ]
// RestageApplication restarts a given application. If already stopped, no stop // call will be sent.
[ "RestageApplication", "restarts", "a", "given", "application", ".", "If", "already", "stopped", "no", "stop", "call", "will", "be", "sent", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L323-L352
train
cloudfoundry/cli
api/router/router_group.go
GetRouterGroupByName
func (client *Client) GetRouterGroupByName(name string) (RouterGroup, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouterGroups, Query: url.Values{"name": []string{name}}, }) if err != nil { return RouterGroup{}, err } var routerGroups []RouterGroup var response = Response{ Result: &routerGroups, } err = client.connection.Make(request, &response) if err != nil { return RouterGroup{}, err } for _, routerGroup := range routerGroups { if routerGroup.Name == name { return routerGroup, nil } } return RouterGroup{}, routererror.ResourceNotFoundError{} }
go
func (client *Client) GetRouterGroupByName(name string) (RouterGroup, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouterGroups, Query: url.Values{"name": []string{name}}, }) if err != nil { return RouterGroup{}, err } var routerGroups []RouterGroup var response = Response{ Result: &routerGroups, } err = client.connection.Make(request, &response) if err != nil { return RouterGroup{}, err } for _, routerGroup := range routerGroups { if routerGroup.Name == name { return routerGroup, nil } } return RouterGroup{}, routererror.ResourceNotFoundError{} }
[ "func", "(", "client", "*", "Client", ")", "GetRouterGroupByName", "(", "name", "string", ")", "(", "RouterGroup", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouterGroups", ",", "Query", ":", "url", ".", "Values", "{", "\"name\"", ":", "[", "]", "string", "{", "name", "}", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RouterGroup", "{", "}", ",", "err", "\n", "}", "\n", "var", "routerGroups", "[", "]", "RouterGroup", "\n", "var", "response", "=", "Response", "{", "Result", ":", "&", "routerGroups", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RouterGroup", "{", "}", ",", "err", "\n", "}", "\n", "for", "_", ",", "routerGroup", ":=", "range", "routerGroups", "{", "if", "routerGroup", ".", "Name", "==", "name", "{", "return", "routerGroup", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "RouterGroup", "{", "}", ",", "routererror", ".", "ResourceNotFoundError", "{", "}", "\n", "}" ]
// GetRouterGroupByName returns a list of RouterGroups.
[ "GetRouterGroupByName", "returns", "a", "list", "of", "RouterGroups", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/router_group.go#L19-L46
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
MarshalJSON
func (b Build) MarshalJSON() ([]byte, error) { var ccBuild struct { Package struct { GUID string `json:"guid"` } `json:"package"` } ccBuild.Package.GUID = b.PackageGUID return json.Marshal(ccBuild) }
go
func (b Build) MarshalJSON() ([]byte, error) { var ccBuild struct { Package struct { GUID string `json:"guid"` } `json:"package"` } ccBuild.Package.GUID = b.PackageGUID return json.Marshal(ccBuild) }
[ "func", "(", "b", "Build", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "ccBuild", "struct", "{", "Package", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "`json:\"package\"`", "\n", "}", "\n", "ccBuild", ".", "Package", ".", "GUID", "=", "b", ".", "PackageGUID", "\n", "return", "json", ".", "Marshal", "(", "ccBuild", ")", "\n", "}" ]
// MarshalJSON converts a Build into a Cloud Controller Application.
[ "MarshalJSON", "converts", "a", "Build", "into", "a", "Cloud", "Controller", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L31-L41
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
UnmarshalJSON
func (b *Build) UnmarshalJSON(data []byte) error { var ccBuild struct { CreatedAt string `json:"created_at,omitempty"` GUID string `json:"guid,omitempty"` Error string `json:"error"` Package struct { GUID string `json:"guid"` } `json:"package"` State constant.BuildState `json:"state,omitempty"` Droplet struct { GUID string `json:"guid"` } `json:"droplet"` } err := cloudcontroller.DecodeJSON(data, &ccBuild) if err != nil { return err } b.GUID = ccBuild.GUID b.CreatedAt = ccBuild.CreatedAt b.Error = ccBuild.Error b.PackageGUID = ccBuild.Package.GUID b.State = ccBuild.State b.DropletGUID = ccBuild.Droplet.GUID return nil }
go
func (b *Build) UnmarshalJSON(data []byte) error { var ccBuild struct { CreatedAt string `json:"created_at,omitempty"` GUID string `json:"guid,omitempty"` Error string `json:"error"` Package struct { GUID string `json:"guid"` } `json:"package"` State constant.BuildState `json:"state,omitempty"` Droplet struct { GUID string `json:"guid"` } `json:"droplet"` } err := cloudcontroller.DecodeJSON(data, &ccBuild) if err != nil { return err } b.GUID = ccBuild.GUID b.CreatedAt = ccBuild.CreatedAt b.Error = ccBuild.Error b.PackageGUID = ccBuild.Package.GUID b.State = ccBuild.State b.DropletGUID = ccBuild.Droplet.GUID return nil }
[ "func", "(", "b", "*", "Build", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccBuild", "struct", "{", "CreatedAt", "string", "`json:\"created_at,omitempty\"`", "\n", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "Error", "string", "`json:\"error\"`", "\n", "Package", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "`json:\"package\"`", "\n", "State", "constant", ".", "BuildState", "`json:\"state,omitempty\"`", "\n", "Droplet", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "`json:\"droplet\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccBuild", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "b", ".", "GUID", "=", "ccBuild", ".", "GUID", "\n", "b", ".", "CreatedAt", "=", "ccBuild", ".", "CreatedAt", "\n", "b", ".", "Error", "=", "ccBuild", ".", "Error", "\n", "b", ".", "PackageGUID", "=", "ccBuild", ".", "Package", ".", "GUID", "\n", "b", ".", "State", "=", "ccBuild", ".", "State", "\n", "b", ".", "DropletGUID", "=", "ccBuild", ".", "Droplet", ".", "GUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Build response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Build", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L44-L71
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
CreateBuild
func (client *Client) CreateBuild(build Build) (Build, Warnings, error) { bodyBytes, err := json.Marshal(build) if err != nil { return Build{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostBuildRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
go
func (client *Client) CreateBuild(build Build) (Build, Warnings, error) { bodyBytes, err := json.Marshal(build) if err != nil { return Build{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostBuildRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateBuild", "(", "build", "Build", ")", "(", "Build", ",", "Warnings", ",", "error", ")", "{", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "build", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Build", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostBuildRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Build", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "responseBuild", "Build", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseBuild", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseBuild", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateBuild creates the given build, requires Package GUID to be set on the // build.
[ "CreateBuild", "creates", "the", "given", "build", "requires", "Package", "GUID", "to", "be", "set", "on", "the", "build", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L75-L96
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
GetBuild
func (client *Client) GetBuild(guid string) (Build, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetBuildRequest, URIParams: internal.Params{"build_guid": guid}, }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
go
func (client *Client) GetBuild(guid string) (Build, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetBuildRequest, URIParams: internal.Params{"build_guid": guid}, }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetBuild", "(", "guid", "string", ")", "(", "Build", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetBuildRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"build_guid\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Build", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "responseBuild", "Build", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseBuild", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseBuild", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetBuild gets the build with the given GUID.
[ "GetBuild", "gets", "the", "build", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L99-L115
train
cloudfoundry/cli
actor/v3action/environment_variable.go
GetEnvironmentVariablesByApplicationNameAndSpace
func (actor *Actor) GetEnvironmentVariablesByApplicationNameAndSpace(appName string, spaceGUID string) (EnvironmentVariableGroups, Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return EnvironmentVariableGroups{}, warnings, appErr } ccEnvGroups, v3Warnings, apiErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, v3Warnings...) return EnvironmentVariableGroups(ccEnvGroups), warnings, apiErr }
go
func (actor *Actor) GetEnvironmentVariablesByApplicationNameAndSpace(appName string, spaceGUID string) (EnvironmentVariableGroups, Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return EnvironmentVariableGroups{}, warnings, appErr } ccEnvGroups, v3Warnings, apiErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, v3Warnings...) return EnvironmentVariableGroups(ccEnvGroups), warnings, apiErr }
[ "func", "(", "actor", "*", "Actor", ")", "GetEnvironmentVariablesByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ")", "(", "EnvironmentVariableGroups", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "appErr", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "appErr", "!=", "nil", "{", "return", "EnvironmentVariableGroups", "{", "}", ",", "warnings", ",", "appErr", "\n", "}", "\n", "ccEnvGroups", ",", "v3Warnings", ",", "apiErr", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationEnvironment", "(", "app", ".", "GUID", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "v3Warnings", "...", ")", "\n", "return", "EnvironmentVariableGroups", "(", "ccEnvGroups", ")", ",", "warnings", ",", "apiErr", "\n", "}" ]
// GetEnvironmentVariablesByApplicationNameAndSpace returns the environment // variables for an application.
[ "GetEnvironmentVariablesByApplicationNameAndSpace", "returns", "the", "environment", "variables", "for", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/environment_variable.go#L20-L29
train
cloudfoundry/cli
actor/v3action/environment_variable.go
SetEnvironmentVariableByApplicationNameAndSpace
func (actor *Actor) SetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, envPair EnvironmentVariablePair) (Warnings, error) { app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return warnings, err } _, v3Warnings, apiErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ envPair.Key: {Value: envPair.Value, IsSet: true}, }) warnings = append(warnings, v3Warnings...) return warnings, apiErr }
go
func (actor *Actor) SetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, envPair EnvironmentVariablePair) (Warnings, error) { app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return warnings, err } _, v3Warnings, apiErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ envPair.Key: {Value: envPair.Value, IsSet: true}, }) warnings = append(warnings, v3Warnings...) return warnings, apiErr }
[ "func", "(", "actor", "*", "Actor", ")", "SetEnvironmentVariableByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "envPair", "EnvironmentVariablePair", ")", "(", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "warnings", ",", "err", "\n", "}", "\n", "_", ",", "v3Warnings", ",", "apiErr", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationEnvironmentVariables", "(", "app", ".", "GUID", ",", "ccv3", ".", "EnvironmentVariables", "{", "envPair", ".", "Key", ":", "{", "Value", ":", "envPair", ".", "Value", ",", "IsSet", ":", "true", "}", ",", "}", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "v3Warnings", "...", ")", "\n", "return", "warnings", ",", "apiErr", "\n", "}" ]
// SetEnvironmentVariableByApplicationNameAndSpace adds an // EnvironmentVariablePair to an application. It must be restarted for changes // to take effect.
[ "SetEnvironmentVariableByApplicationNameAndSpace", "adds", "an", "EnvironmentVariablePair", "to", "an", "application", ".", "It", "must", "be", "restarted", "for", "changes", "to", "take", "effect", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/environment_variable.go#L34-L47
train
cloudfoundry/cli
actor/v3action/environment_variable.go
UnsetEnvironmentVariableByApplicationNameAndSpace
func (actor *Actor) UnsetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, environmentVariableName string) (Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return warnings, appErr } envGroups, getWarnings, getErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, getWarnings...) if getErr != nil { return warnings, getErr } if _, ok := envGroups.EnvironmentVariables[environmentVariableName]; !ok { return warnings, actionerror.EnvironmentVariableNotSetError{EnvironmentVariableName: environmentVariableName} } _, patchWarnings, patchErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ environmentVariableName: {Value: "", IsSet: false}, }) warnings = append(warnings, patchWarnings...) return warnings, patchErr }
go
func (actor *Actor) UnsetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, environmentVariableName string) (Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return warnings, appErr } envGroups, getWarnings, getErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, getWarnings...) if getErr != nil { return warnings, getErr } if _, ok := envGroups.EnvironmentVariables[environmentVariableName]; !ok { return warnings, actionerror.EnvironmentVariableNotSetError{EnvironmentVariableName: environmentVariableName} } _, patchWarnings, patchErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ environmentVariableName: {Value: "", IsSet: false}, }) warnings = append(warnings, patchWarnings...) return warnings, patchErr }
[ "func", "(", "actor", "*", "Actor", ")", "UnsetEnvironmentVariableByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "environmentVariableName", "string", ")", "(", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "appErr", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "appErr", "!=", "nil", "{", "return", "warnings", ",", "appErr", "\n", "}", "\n", "envGroups", ",", "getWarnings", ",", "getErr", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationEnvironment", "(", "app", ".", "GUID", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "getWarnings", "...", ")", "\n", "if", "getErr", "!=", "nil", "{", "return", "warnings", ",", "getErr", "\n", "}", "\n", "if", "_", ",", "ok", ":=", "envGroups", ".", "EnvironmentVariables", "[", "environmentVariableName", "]", ";", "!", "ok", "{", "return", "warnings", ",", "actionerror", ".", "EnvironmentVariableNotSetError", "{", "EnvironmentVariableName", ":", "environmentVariableName", "}", "\n", "}", "\n", "_", ",", "patchWarnings", ",", "patchErr", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationEnvironmentVariables", "(", "app", ".", "GUID", ",", "ccv3", ".", "EnvironmentVariables", "{", "environmentVariableName", ":", "{", "Value", ":", "\"\"", ",", "IsSet", ":", "false", "}", ",", "}", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "patchWarnings", "...", ")", "\n", "return", "warnings", ",", "patchErr", "\n", "}" ]
// UnsetEnvironmentVariableByApplicationNameAndSpace removes an enviornment // variable from an application. It must be restarted for changes to take // effect.
[ "UnsetEnvironmentVariableByApplicationNameAndSpace", "removes", "an", "enviornment", "variable", "from", "an", "application", ".", "It", "must", "be", "restarted", "for", "changes", "to", "take", "effect", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/environment_variable.go#L52-L74
train
cloudfoundry/cli
util/ui/prompt.go
DisplayBoolPrompt
func (ui *UI) DisplayBoolPrompt(defaultResponse bool, template string, templateValues ...map[string]interface{}) (bool, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() response := defaultResponse interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(&response) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return response, err }
go
func (ui *UI) DisplayBoolPrompt(defaultResponse bool, template string, templateValues ...map[string]interface{}) (bool, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() response := defaultResponse interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(&response) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return response, err }
[ "func", "(", "ui", "*", "UI", ")", "DisplayBoolPrompt", "(", "defaultResponse", "bool", ",", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "response", ":=", "defaultResponse", "\n", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "&", "response", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "return", "response", ",", "err", "\n", "}" ]
// DisplayBoolPrompt outputs the prompt and waits for user input. It only // allows for a boolean response. A default boolean response can be set with // defaultResponse.
[ "DisplayBoolPrompt", "outputs", "the", "prompt", "and", "waits", "for", "user", "input", ".", "It", "only", "allows", "for", "a", "boolean", "response", ".", "A", "default", "boolean", "response", "can", "be", "set", "with", "defaultResponse", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L36-L49
train
cloudfoundry/cli
util/ui/prompt.go
DisplayPasswordPrompt
func (ui *UI) DisplayPasswordPrompt(template string, templateValues ...map[string]interface{}) (string, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() var password interact.Password interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&password)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return string(password), err }
go
func (ui *UI) DisplayPasswordPrompt(template string, templateValues ...map[string]interface{}) (string, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() var password interact.Password interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&password)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return string(password), err }
[ "func", "(", "ui", "*", "UI", ")", "DisplayPasswordPrompt", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "var", "password", "interact", ".", "Password", "\n", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "interact", ".", "Required", "(", "&", "password", ")", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "return", "string", "(", "password", ")", ",", "err", "\n", "}" ]
// DisplayPasswordPrompt outputs the prompt and waits for user input. Hides // user's response from the screen.
[ "DisplayPasswordPrompt", "outputs", "the", "prompt", "and", "waits", "for", "user", "input", ".", "Hides", "user", "s", "response", "from", "the", "screen", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L66-L79
train
cloudfoundry/cli
util/ui/prompt.go
DisplayTextMenu
func (ui *UI) DisplayTextMenu(choices []string, promptTemplate string, templateValues ...map[string]interface{}) (string, error) { for i, c := range choices { t := fmt.Sprintf("%d. %s", i+1, c) ui.DisplayText(t) } translatedPrompt := ui.TranslateText(promptTemplate, templateValues...) interactivePrompt := ui.Interactor.NewInteraction(translatedPrompt) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) var value string = "enter to skip" err := interactivePrompt.Resolve(&value) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } if err != nil { return "", err } if value == "enter to skip" { return "", nil } i, err := strconv.Atoi(value) if err != nil { if contains(choices, value) { return value, nil } return "", InvalidChoiceError{Choice: value} } if i > len(choices) || i <= 0 { return "", ErrInvalidIndex } return choices[i-1], nil }
go
func (ui *UI) DisplayTextMenu(choices []string, promptTemplate string, templateValues ...map[string]interface{}) (string, error) { for i, c := range choices { t := fmt.Sprintf("%d. %s", i+1, c) ui.DisplayText(t) } translatedPrompt := ui.TranslateText(promptTemplate, templateValues...) interactivePrompt := ui.Interactor.NewInteraction(translatedPrompt) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) var value string = "enter to skip" err := interactivePrompt.Resolve(&value) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } if err != nil { return "", err } if value == "enter to skip" { return "", nil } i, err := strconv.Atoi(value) if err != nil { if contains(choices, value) { return value, nil } return "", InvalidChoiceError{Choice: value} } if i > len(choices) || i <= 0 { return "", ErrInvalidIndex } return choices[i-1], nil }
[ "func", "(", "ui", "*", "UI", ")", "DisplayTextMenu", "(", "choices", "[", "]", "string", ",", "promptTemplate", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "for", "i", ",", "c", ":=", "range", "choices", "{", "t", ":=", "fmt", ".", "Sprintf", "(", "\"%d. %s\"", ",", "i", "+", "1", ",", "c", ")", "\n", "ui", ".", "DisplayText", "(", "t", ")", "\n", "}", "\n", "translatedPrompt", ":=", "ui", ".", "TranslateText", "(", "promptTemplate", ",", "templateValues", "...", ")", "\n", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "translatedPrompt", ")", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "var", "value", "string", "=", "\"enter to skip\"", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "&", "value", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "if", "value", "==", "\"enter to skip\"", "{", "return", "\"\"", ",", "nil", "\n", "}", "\n", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "if", "contains", "(", "choices", ",", "value", ")", "{", "return", "value", ",", "nil", "\n", "}", "\n", "return", "\"\"", ",", "InvalidChoiceError", "{", "Choice", ":", "value", "}", "\n", "}", "\n", "if", "i", ">", "len", "(", "choices", ")", "||", "i", "<=", "0", "{", "return", "\"\"", ",", "ErrInvalidIndex", "\n", "}", "\n", "return", "choices", "[", "i", "-", "1", "]", ",", "nil", "\n", "}" ]
// DisplayTextMenu lets the user choose from a list of options, either by name // or by number.
[ "DisplayTextMenu", "lets", "the", "user", "choose", "from", "a", "list", "of", "options", "either", "by", "name", "or", "by", "number", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L83-L123
train
cloudfoundry/cli
util/ui/prompt.go
DisplayTextPrompt
func (ui *UI) DisplayTextPrompt(template string, templateValues ...map[string]interface{}) (string, error) { interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) var value string interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&value)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return value, err }
go
func (ui *UI) DisplayTextPrompt(template string, templateValues ...map[string]interface{}) (string, error) { interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) var value string interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&value)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return value, err }
[ "func", "(", "ui", "*", "UI", ")", "DisplayTextPrompt", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "var", "value", "string", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "interact", ".", "Required", "(", "&", "value", ")", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "return", "value", ",", "err", "\n", "}" ]
// DisplayTextPrompt outputs the prompt and waits for user input.
[ "DisplayTextPrompt", "outputs", "the", "prompt", "and", "waits", "for", "user", "input", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L126-L136
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
UnmarshalJSON
func (route *Route) UnmarshalJSON(data []byte) error { var ccRoute struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Host string `json:"host"` Path string `json:"path"` Port types.NullInt `json:"port"` DomainGUID string `json:"domain_guid"` SpaceGUID string `json:"space_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccRoute) if err != nil { return err } route.GUID = ccRoute.Metadata.GUID route.Host = ccRoute.Entity.Host route.Path = ccRoute.Entity.Path route.Port = ccRoute.Entity.Port route.DomainGUID = ccRoute.Entity.DomainGUID route.SpaceGUID = ccRoute.Entity.SpaceGUID return nil }
go
func (route *Route) UnmarshalJSON(data []byte) error { var ccRoute struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Host string `json:"host"` Path string `json:"path"` Port types.NullInt `json:"port"` DomainGUID string `json:"domain_guid"` SpaceGUID string `json:"space_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccRoute) if err != nil { return err } route.GUID = ccRoute.Metadata.GUID route.Host = ccRoute.Entity.Host route.Path = ccRoute.Entity.Path route.Port = ccRoute.Entity.Port route.DomainGUID = ccRoute.Entity.DomainGUID route.SpaceGUID = ccRoute.Entity.SpaceGUID return nil }
[ "func", "(", "route", "*", "Route", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccRoute", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Host", "string", "`json:\"host\"`", "\n", "Path", "string", "`json:\"path\"`", "\n", "Port", "types", ".", "NullInt", "`json:\"port\"`", "\n", "DomainGUID", "string", "`json:\"domain_guid\"`", "\n", "SpaceGUID", "string", "`json:\"space_guid\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccRoute", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "route", ".", "GUID", "=", "ccRoute", ".", "Metadata", ".", "GUID", "\n", "route", ".", "Host", "=", "ccRoute", ".", "Entity", ".", "Host", "\n", "route", ".", "Path", "=", "ccRoute", ".", "Entity", ".", "Path", "\n", "route", ".", "Port", "=", "ccRoute", ".", "Entity", ".", "Port", "\n", "route", ".", "DomainGUID", "=", "ccRoute", ".", "Entity", ".", "DomainGUID", "\n", "route", ".", "SpaceGUID", "=", "ccRoute", ".", "Entity", ".", "SpaceGUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Route response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Route", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L39-L62
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
CheckRoute
func (client *Client) CheckRoute(route Route) (bool, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteReservedRequest, URIParams: map[string]string{"domain_guid": route.DomainGUID}, }) if err != nil { return false, nil, err } queryParams := url.Values{} if route.Host != "" { queryParams.Add("host", route.Host) } if route.Path != "" { queryParams.Add("path", route.Path) } if route.Port.IsSet { queryParams.Add("port", fmt.Sprint(route.Port.Value)) } request.URL.RawQuery = queryParams.Encode() var response cloudcontroller.Response err = client.connection.Make(request, &response) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return false, response.Warnings, nil } return response.HTTPResponse.StatusCode == http.StatusNoContent, response.Warnings, err }
go
func (client *Client) CheckRoute(route Route) (bool, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteReservedRequest, URIParams: map[string]string{"domain_guid": route.DomainGUID}, }) if err != nil { return false, nil, err } queryParams := url.Values{} if route.Host != "" { queryParams.Add("host", route.Host) } if route.Path != "" { queryParams.Add("path", route.Path) } if route.Port.IsSet { queryParams.Add("port", fmt.Sprint(route.Port.Value)) } request.URL.RawQuery = queryParams.Encode() var response cloudcontroller.Response err = client.connection.Make(request, &response) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return false, response.Warnings, nil } return response.HTTPResponse.StatusCode == http.StatusNoContent, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CheckRoute", "(", "route", "Route", ")", "(", "bool", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouteReservedRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"domain_guid\"", ":", "route", ".", "DomainGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "nil", ",", "err", "\n", "}", "\n", "queryParams", ":=", "url", ".", "Values", "{", "}", "\n", "if", "route", ".", "Host", "!=", "\"\"", "{", "queryParams", ".", "Add", "(", "\"host\"", ",", "route", ".", "Host", ")", "\n", "}", "\n", "if", "route", ".", "Path", "!=", "\"\"", "{", "queryParams", ".", "Add", "(", "\"path\"", ",", "route", ".", "Path", ")", "\n", "}", "\n", "if", "route", ".", "Port", ".", "IsSet", "{", "queryParams", ".", "Add", "(", "\"port\"", ",", "fmt", ".", "Sprint", "(", "route", ".", "Port", ".", "Value", ")", ")", "\n", "}", "\n", "request", ".", "URL", ".", "RawQuery", "=", "queryParams", ".", "Encode", "(", ")", "\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "ok", "{", "return", "false", ",", "response", ".", "Warnings", ",", "nil", "\n", "}", "\n", "return", "response", ".", "HTTPResponse", ".", "StatusCode", "==", "http", ".", "StatusNoContent", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CheckRoute returns true if the route exists in the CF instance.
[ "CheckRoute", "returns", "true", "if", "the", "route", "exists", "in", "the", "CF", "instance", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L65-L93
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
DeleteRouteApplication
func (client *Client) DeleteRouteApplication(routeGUID string, appGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteRouteApplication(routeGUID string, appGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteRouteApplication", "(", "routeGUID", "string", ",", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteRouteAppRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"app_guid\"", ":", "appGUID", ",", "\"route_guid\"", ":", "routeGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteRouteApplication removes the link between the route and application.
[ "DeleteRouteApplication", "removes", "the", "link", "between", "the", "route", "and", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L146-L161
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
DeleteSpaceUnmappedRoutes
func (client *Client) DeleteSpaceUnmappedRoutes(spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceUnmappedRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteSpaceUnmappedRoutes(spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceUnmappedRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteSpaceUnmappedRoutes", "(", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteSpaceUnmappedRoutesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"space_guid\"", ":", "spaceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteSpaceUnmappedRoutes deletes Routes within a specified Space not mapped // to an Application
[ "DeleteSpaceUnmappedRoutes", "deletes", "Routes", "within", "a", "specified", "Space", "not", "mapped", "to", "an", "Application" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L165-L177
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
GetRoute
func (client *Client) GetRoute(guid string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteRequest, URIParams: Params{"route_guid": guid}, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
go
func (client *Client) GetRoute(guid string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteRequest, URIParams: Params{"route_guid": guid}, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetRoute", "(", "guid", "string", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouteRequest", ",", "URIParams", ":", "Params", "{", "\"route_guid\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Route", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "route", "Route", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "route", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "route", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetRoute returns a route with the provided guid.
[ "GetRoute", "returns", "a", "route", "with", "the", "provided", "guid", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L208-L224
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
GetRoutes
func (client *Client) GetRoutes(filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRoutesRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
go
func (client *Client) GetRoutes(filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRoutesRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetRoutes", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRoutesRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullRoutesList", "[", "]", "Route", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Route", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "route", ",", "ok", ":=", "item", ".", "(", "Route", ")", ";", "ok", "{", "fullRoutesList", "=", "append", "(", "fullRoutesList", ",", "route", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Route", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullRoutesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetRoutes returns a list of Routes based off of the provided filters.
[ "GetRoutes", "returns", "a", "list", "of", "Routes", "based", "off", "of", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L227-L250
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
GetSpaceRoutes
func (client *Client) GetSpaceRoutes(spaceGUID string, filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
go
func (client *Client) GetSpaceRoutes(spaceGUID string, filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceRoutes", "(", "spaceGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpaceRoutesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"space_guid\"", ":", "spaceGUID", "}", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullRoutesList", "[", "]", "Route", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Route", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "route", ",", "ok", ":=", "item", ".", "(", "Route", ")", ";", "ok", "{", "fullRoutesList", "=", "append", "(", "fullRoutesList", ",", "route", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Route", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullRoutesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSpaceRoutes returns a list of Routes associated with the provided Space // GUID, and filtered by the provided filters.
[ "GetSpaceRoutes", "returns", "a", "list", "of", "Routes", "associated", "with", "the", "provided", "Space", "GUID", "and", "filtered", "by", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L254-L278
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
UpdateRouteApplication
func (client *Client) UpdateRouteApplication(routeGUID string, appGUID string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
go
func (client *Client) UpdateRouteApplication(routeGUID string, appGUID string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateRouteApplication", "(", "routeGUID", "string", ",", "appGUID", "string", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutRouteAppRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"app_guid\"", ":", "appGUID", ",", "\"route_guid\"", ":", "routeGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Route", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "route", "Route", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "route", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "route", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateRouteApplication creates a link between the route and application.
[ "UpdateRouteApplication", "creates", "a", "link", "between", "the", "route", "and", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L281-L300
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process.go
CreateApplicationProcessScale
func (client *Client) CreateApplicationProcessScale(appGUID string, process Process) (Process, Warnings, error) { body, err := json.Marshal(process) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationProcessActionScaleRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"app_guid": appGUID, "type": process.Type}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
go
func (client *Client) CreateApplicationProcessScale(appGUID string, process Process) (Process, Warnings, error) { body, err := json.Marshal(process) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationProcessActionScaleRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"app_guid": appGUID, "type": process.Type}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateApplicationProcessScale", "(", "appGUID", "string", ",", "process", "Process", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "process", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationProcessActionScaleRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"app_guid\"", ":", "appGUID", ",", "\"type\"", ":", "process", ".", "Type", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "responseProcess", "Process", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseProcess", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseProcess", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateApplicationProcessScale updates process instances count, memory or disk
[ "CreateApplicationProcessScale", "updates", "process", "instances", "count", "memory", "or", "disk" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process.go#L81-L102
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process.go
GetApplicationProcessByType
func (client *Client) GetApplicationProcessByType(appGUID string, processType string) (Process, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationProcessRequest, URIParams: map[string]string{ "app_guid": appGUID, "type": processType, }, }) if err != nil { return Process{}, nil, err } var process Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &process, } err = client.connection.Make(request, &response) return process, response.Warnings, err }
go
func (client *Client) GetApplicationProcessByType(appGUID string, processType string) (Process, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationProcessRequest, URIParams: map[string]string{ "app_guid": appGUID, "type": processType, }, }) if err != nil { return Process{}, nil, err } var process Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &process, } err = client.connection.Make(request, &response) return process, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplicationProcessByType", "(", "appGUID", "string", ",", "processType", "string", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetApplicationProcessRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"app_guid\"", ":", "appGUID", ",", "\"type\"", ":", "processType", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "process", "Process", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "process", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "process", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetApplicationProcessByType returns application process of specified type
[ "GetApplicationProcessByType", "returns", "application", "process", "of", "specified", "type" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process.go#L105-L123
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process.go
UpdateProcess
func (client *Client) UpdateProcess(process Process) (Process, Warnings, error) { body, err := json.Marshal(Process{ Command: process.Command, HealthCheckType: process.HealthCheckType, HealthCheckEndpoint: process.HealthCheckEndpoint, HealthCheckTimeout: process.HealthCheckTimeout, HealthCheckInvocationTimeout: process.HealthCheckInvocationTimeout, }) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchProcessRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"process_guid": process.GUID}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
go
func (client *Client) UpdateProcess(process Process) (Process, Warnings, error) { body, err := json.Marshal(Process{ Command: process.Command, HealthCheckType: process.HealthCheckType, HealthCheckEndpoint: process.HealthCheckEndpoint, HealthCheckTimeout: process.HealthCheckTimeout, HealthCheckInvocationTimeout: process.HealthCheckInvocationTimeout, }) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchProcessRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"process_guid": process.GUID}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateProcess", "(", "process", "Process", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "Process", "{", "Command", ":", "process", ".", "Command", ",", "HealthCheckType", ":", "process", ".", "HealthCheckType", ",", "HealthCheckEndpoint", ":", "process", ".", "HealthCheckEndpoint", ",", "HealthCheckTimeout", ":", "process", ".", "HealthCheckTimeout", ",", "HealthCheckInvocationTimeout", ":", "process", ".", "HealthCheckInvocationTimeout", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchProcessRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"process_guid\"", ":", "process", ".", "GUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "responseProcess", "Process", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseProcess", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseProcess", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateProcess updates the process's command or health check settings. GUID // is always required; HealthCheckType is only required when updating health // check settings.
[ "UpdateProcess", "updates", "the", "process", "s", "command", "or", "health", "check", "settings", ".", "GUID", "is", "always", "required", ";", "HealthCheckType", "is", "only", "required", "when", "updating", "health", "check", "settings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process.go#L155-L182
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance_shared_to.go
GetServiceInstanceSharedTos
func (client *Client) GetServiceInstanceSharedTos(serviceInstanceGUID string) ([]ServiceInstanceSharedTo, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedToRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return nil, nil, err } var fullSharedToList []ServiceInstanceSharedTo warnings, err := client.paginate(request, ServiceInstanceSharedTo{}, func(item interface{}) error { if instance, ok := item.(ServiceInstanceSharedTo); ok { fullSharedToList = append(fullSharedToList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceInstanceSharedTo{}, Unexpected: item, } } return nil }) return fullSharedToList, warnings, err }
go
func (client *Client) GetServiceInstanceSharedTos(serviceInstanceGUID string) ([]ServiceInstanceSharedTo, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedToRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return nil, nil, err } var fullSharedToList []ServiceInstanceSharedTo warnings, err := client.paginate(request, ServiceInstanceSharedTo{}, func(item interface{}) error { if instance, ok := item.(ServiceInstanceSharedTo); ok { fullSharedToList = append(fullSharedToList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceInstanceSharedTo{}, Unexpected: item, } } return nil }) return fullSharedToList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceInstanceSharedTos", "(", "serviceInstanceGUID", "string", ")", "(", "[", "]", "ServiceInstanceSharedTo", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceInstanceSharedToRequest", ",", "URIParams", ":", "Params", "{", "\"service_instance_guid\"", ":", "serviceInstanceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullSharedToList", "[", "]", "ServiceInstanceSharedTo", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ServiceInstanceSharedTo", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "instance", ",", "ok", ":=", "item", ".", "(", "ServiceInstanceSharedTo", ")", ";", "ok", "{", "fullSharedToList", "=", "append", "(", "fullSharedToList", ",", "instance", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ServiceInstanceSharedTo", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullSharedToList", ",", "warnings", ",", "err", "\n", "}" ]
// GetServiceInstanceSharedTos returns a list of ServiceInstanceSharedTo objects.
[ "GetServiceInstanceSharedTos", "returns", "a", "list", "of", "ServiceInstanceSharedTo", "objects", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance_shared_to.go#L29-L53
train
cloudfoundry/cli
api/uaa/uaa_connection.go
NewConnection
func NewConnection(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration) *UAAConnection { tr := &http.Transport{ DialContext: (&net.Dialer{ KeepAlive: 30 * time.Second, Timeout: dialTimeout, }).DialContext, DisableKeepAlives: disableKeepAlives, Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{ InsecureSkipVerify: skipSSLValidation, }, } return &UAAConnection{ HTTPClient: &http.Client{ Transport: tr, CheckRedirect: func(_ *http.Request, _ []*http.Request) error { // This prevents redirects. When making a request to /oauth/authorize, // the client should not follow redirects in order to obtain the ssh // passcode. return http.ErrUseLastResponse }, }, } }
go
func NewConnection(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration) *UAAConnection { tr := &http.Transport{ DialContext: (&net.Dialer{ KeepAlive: 30 * time.Second, Timeout: dialTimeout, }).DialContext, DisableKeepAlives: disableKeepAlives, Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{ InsecureSkipVerify: skipSSLValidation, }, } return &UAAConnection{ HTTPClient: &http.Client{ Transport: tr, CheckRedirect: func(_ *http.Request, _ []*http.Request) error { // This prevents redirects. When making a request to /oauth/authorize, // the client should not follow redirects in order to obtain the ssh // passcode. return http.ErrUseLastResponse }, }, } }
[ "func", "NewConnection", "(", "skipSSLValidation", "bool", ",", "disableKeepAlives", "bool", ",", "dialTimeout", "time", ".", "Duration", ")", "*", "UAAConnection", "{", "tr", ":=", "&", "http", ".", "Transport", "{", "DialContext", ":", "(", "&", "net", ".", "Dialer", "{", "KeepAlive", ":", "30", "*", "time", ".", "Second", ",", "Timeout", ":", "dialTimeout", ",", "}", ")", ".", "DialContext", ",", "DisableKeepAlives", ":", "disableKeepAlives", ",", "Proxy", ":", "http", ".", "ProxyFromEnvironment", ",", "TLSClientConfig", ":", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "skipSSLValidation", ",", "}", ",", "}", "\n", "return", "&", "UAAConnection", "{", "HTTPClient", ":", "&", "http", ".", "Client", "{", "Transport", ":", "tr", ",", "CheckRedirect", ":", "func", "(", "_", "*", "http", ".", "Request", ",", "_", "[", "]", "*", "http", ".", "Request", ")", "error", "{", "return", "http", ".", "ErrUseLastResponse", "\n", "}", ",", "}", ",", "}", "\n", "}" ]
// NewConnection returns a pointer to a new UAA Connection
[ "NewConnection", "returns", "a", "pointer", "to", "a", "new", "UAA", "Connection" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/uaa_connection.go#L21-L45
train
cloudfoundry/cli
api/uaa/uaa_connection.go
Make
func (connection *UAAConnection) Make(request *http.Request, passedResponse *Response) error { // In case this function is called from a retry, passedResponse may already // be populated with a previous response. We reset in case there's an HTTP // error and we don't repopulate it in populateResponse. passedResponse.reset() response, err := connection.HTTPClient.Do(request) if err != nil { return connection.processRequestErrors(request, err) } return connection.populateResponse(response, passedResponse) }
go
func (connection *UAAConnection) Make(request *http.Request, passedResponse *Response) error { // In case this function is called from a retry, passedResponse may already // be populated with a previous response. We reset in case there's an HTTP // error and we don't repopulate it in populateResponse. passedResponse.reset() response, err := connection.HTTPClient.Do(request) if err != nil { return connection.processRequestErrors(request, err) } return connection.populateResponse(response, passedResponse) }
[ "func", "(", "connection", "*", "UAAConnection", ")", "Make", "(", "request", "*", "http", ".", "Request", ",", "passedResponse", "*", "Response", ")", "error", "{", "passedResponse", ".", "reset", "(", ")", "\n", "response", ",", "err", ":=", "connection", ".", "HTTPClient", ".", "Do", "(", "request", ")", "\n", "if", "err", "!=", "nil", "{", "return", "connection", ".", "processRequestErrors", "(", "request", ",", "err", ")", "\n", "}", "\n", "return", "connection", ".", "populateResponse", "(", "response", ",", "passedResponse", ")", "\n", "}" ]
// Make takes a passedRequest, converts it into an HTTP request and then // executes it. The response is then injected into passedResponse.
[ "Make", "takes", "a", "passedRequest", "converts", "it", "into", "an", "HTTP", "request", "and", "then", "executes", "it", ".", "The", "response", "is", "then", "injected", "into", "passedResponse", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/uaa_connection.go#L49-L61
train
cloudfoundry/cli
api/cloudcontroller/ccv2/event.go
UnmarshalJSON
func (event *Event) UnmarshalJSON(data []byte) error { var ccEvent struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Type string `json:"type,omitempty"` ActorGUID string `json:"actor,omitempty"` ActorType string `json:"actor_type,omitempty"` ActorName string `json:"actor_name,omitempty"` ActeeGUID string `json:"actee,omitempty"` ActeeType string `json:"actee_type,omitempty"` ActeeName string `json:"actee_name,omitempty"` Timestamp *time.Time `json:"timestamp"` Metadata map[string]interface{} `json:"metadata"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccEvent) if err != nil { return err } event.GUID = ccEvent.Metadata.GUID event.Type = constant.EventType(ccEvent.Entity.Type) event.ActorGUID = ccEvent.Entity.ActorGUID event.ActorType = ccEvent.Entity.ActorType event.ActorName = ccEvent.Entity.ActorName event.ActeeGUID = ccEvent.Entity.ActeeGUID event.ActeeType = ccEvent.Entity.ActeeType event.ActeeName = ccEvent.Entity.ActeeName if ccEvent.Entity.Timestamp != nil { event.Timestamp = *ccEvent.Entity.Timestamp } event.Metadata = ccEvent.Entity.Metadata return nil }
go
func (event *Event) UnmarshalJSON(data []byte) error { var ccEvent struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Type string `json:"type,omitempty"` ActorGUID string `json:"actor,omitempty"` ActorType string `json:"actor_type,omitempty"` ActorName string `json:"actor_name,omitempty"` ActeeGUID string `json:"actee,omitempty"` ActeeType string `json:"actee_type,omitempty"` ActeeName string `json:"actee_name,omitempty"` Timestamp *time.Time `json:"timestamp"` Metadata map[string]interface{} `json:"metadata"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccEvent) if err != nil { return err } event.GUID = ccEvent.Metadata.GUID event.Type = constant.EventType(ccEvent.Entity.Type) event.ActorGUID = ccEvent.Entity.ActorGUID event.ActorType = ccEvent.Entity.ActorType event.ActorName = ccEvent.Entity.ActorName event.ActeeGUID = ccEvent.Entity.ActeeGUID event.ActeeType = ccEvent.Entity.ActeeType event.ActeeName = ccEvent.Entity.ActeeName if ccEvent.Entity.Timestamp != nil { event.Timestamp = *ccEvent.Entity.Timestamp } event.Metadata = ccEvent.Entity.Metadata return nil }
[ "func", "(", "event", "*", "Event", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccEvent", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Type", "string", "`json:\"type,omitempty\"`", "\n", "ActorGUID", "string", "`json:\"actor,omitempty\"`", "\n", "ActorType", "string", "`json:\"actor_type,omitempty\"`", "\n", "ActorName", "string", "`json:\"actor_name,omitempty\"`", "\n", "ActeeGUID", "string", "`json:\"actee,omitempty\"`", "\n", "ActeeType", "string", "`json:\"actee_type,omitempty\"`", "\n", "ActeeName", "string", "`json:\"actee_name,omitempty\"`", "\n", "Timestamp", "*", "time", ".", "Time", "`json:\"timestamp\"`", "\n", "Metadata", "map", "[", "string", "]", "interface", "{", "}", "`json:\"metadata\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccEvent", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "event", ".", "GUID", "=", "ccEvent", ".", "Metadata", ".", "GUID", "\n", "event", ".", "Type", "=", "constant", ".", "EventType", "(", "ccEvent", ".", "Entity", ".", "Type", ")", "\n", "event", ".", "ActorGUID", "=", "ccEvent", ".", "Entity", ".", "ActorGUID", "\n", "event", ".", "ActorType", "=", "ccEvent", ".", "Entity", ".", "ActorType", "\n", "event", ".", "ActorName", "=", "ccEvent", ".", "Entity", ".", "ActorName", "\n", "event", ".", "ActeeGUID", "=", "ccEvent", ".", "Entity", ".", "ActeeGUID", "\n", "event", ".", "ActeeType", "=", "ccEvent", ".", "Entity", ".", "ActeeType", "\n", "event", ".", "ActeeName", "=", "ccEvent", ".", "Entity", ".", "ActeeName", "\n", "if", "ccEvent", ".", "Entity", ".", "Timestamp", "!=", "nil", "{", "event", ".", "Timestamp", "=", "*", "ccEvent", ".", "Entity", ".", "Timestamp", "\n", "}", "\n", "event", ".", "Metadata", "=", "ccEvent", ".", "Entity", ".", "Metadata", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Event response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Event", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/event.go#L46-L81
train
cloudfoundry/cli
api/cloudcontroller/ccv2/event.go
GetEvents
func (client *Client) GetEvents(filters ...Filter) ([]Event, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetEventsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullEventsList []Event warnings, err := client.paginate(request, Event{}, func(item interface{}) error { if event, ok := item.(Event); ok { fullEventsList = append(fullEventsList, event) } else { return ccerror.UnknownObjectInListError{ Expected: Event{}, Unexpected: item, } } return nil }) return fullEventsList, warnings, err }
go
func (client *Client) GetEvents(filters ...Filter) ([]Event, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetEventsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullEventsList []Event warnings, err := client.paginate(request, Event{}, func(item interface{}) error { if event, ok := item.(Event); ok { fullEventsList = append(fullEventsList, event) } else { return ccerror.UnknownObjectInListError{ Expected: Event{}, Unexpected: item, } } return nil }) return fullEventsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetEvents", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Event", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetEventsRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullEventsList", "[", "]", "Event", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Event", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "event", ",", "ok", ":=", "item", ".", "(", "Event", ")", ";", "ok", "{", "fullEventsList", "=", "append", "(", "fullEventsList", ",", "event", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Event", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullEventsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetEvents returns back a list of Events based off of the provided queries.
[ "GetEvents", "returns", "back", "a", "list", "of", "Events", "based", "off", "of", "the", "provided", "queries", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/event.go#L84-L107
train
cloudfoundry/cli
api/cloudcontroller/ccv3/v2_formatted_resource.go
UnmarshalJSON
func (r *V2FormattedResource) UnmarshalJSON(data []byte) error { var ccResource struct { Filename string `json:"fn,omitempty"` Mode string `json:"mode,omitempty"` SHA1 string `json:"sha1"` Size int64 `json:"size"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.Filename = ccResource.Filename r.Size = ccResource.Size r.SHA1 = ccResource.SHA1 mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
go
func (r *V2FormattedResource) UnmarshalJSON(data []byte) error { var ccResource struct { Filename string `json:"fn,omitempty"` Mode string `json:"mode,omitempty"` SHA1 string `json:"sha1"` Size int64 `json:"size"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.Filename = ccResource.Filename r.Size = ccResource.Size r.SHA1 = ccResource.SHA1 mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
[ "func", "(", "r", "*", "V2FormattedResource", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccResource", "struct", "{", "Filename", "string", "`json:\"fn,omitempty\"`", "\n", "Mode", "string", "`json:\"mode,omitempty\"`", "\n", "SHA1", "string", "`json:\"sha1\"`", "\n", "Size", "int64", "`json:\"size\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccResource", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r", ".", "Filename", "=", "ccResource", ".", "Filename", "\n", "r", ".", "Size", "=", "ccResource", ".", "Size", "\n", "r", ".", "SHA1", "=", "ccResource", ".", "SHA1", "\n", "mode", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "ccResource", ".", "Mode", ",", "8", ",", "32", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "r", ".", "Mode", "=", "os", ".", "FileMode", "(", "mode", ")", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller V2FormattedResource response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "V2FormattedResource", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/v2_formatted_resource.go#L50-L73
train
cloudfoundry/cli
api/uaa/auth.go
Authenticate
func (client Client) Authenticate(creds map[string]string, origin string, grantType constant.GrantType) (string, string, error) { requestBody := url.Values{ "grant_type": {string(grantType)}, } for k, v := range creds { requestBody.Set(k, v) } type loginHint struct { Origin string `json:"origin"` } originStruct := loginHint{origin} originParam, err := json.Marshal(originStruct) if err != nil { return "", "", err } var query url.Values if origin != "" { query = url.Values{ "login_hint": {string(originParam)}, } } request, err := client.newRequest(requestOptions{ RequestName: internal.PostOAuthTokenRequest, Header: http.Header{ "Content-Type": {"application/x-www-form-urlencoded"}, }, Body: strings.NewReader(requestBody.Encode()), Query: query, }) if err != nil { return "", "", err } if grantType == constant.GrantTypePassword { request.SetBasicAuth(client.config.UAAOAuthClient(), client.config.UAAOAuthClientSecret()) } responseBody := AuthResponse{} response := Response{ Result: &responseBody, } err = client.connection.Make(request, &response) return responseBody.AccessToken, responseBody.RefreshToken, err }
go
func (client Client) Authenticate(creds map[string]string, origin string, grantType constant.GrantType) (string, string, error) { requestBody := url.Values{ "grant_type": {string(grantType)}, } for k, v := range creds { requestBody.Set(k, v) } type loginHint struct { Origin string `json:"origin"` } originStruct := loginHint{origin} originParam, err := json.Marshal(originStruct) if err != nil { return "", "", err } var query url.Values if origin != "" { query = url.Values{ "login_hint": {string(originParam)}, } } request, err := client.newRequest(requestOptions{ RequestName: internal.PostOAuthTokenRequest, Header: http.Header{ "Content-Type": {"application/x-www-form-urlencoded"}, }, Body: strings.NewReader(requestBody.Encode()), Query: query, }) if err != nil { return "", "", err } if grantType == constant.GrantTypePassword { request.SetBasicAuth(client.config.UAAOAuthClient(), client.config.UAAOAuthClientSecret()) } responseBody := AuthResponse{} response := Response{ Result: &responseBody, } err = client.connection.Make(request, &response) return responseBody.AccessToken, responseBody.RefreshToken, err }
[ "func", "(", "client", "Client", ")", "Authenticate", "(", "creds", "map", "[", "string", "]", "string", ",", "origin", "string", ",", "grantType", "constant", ".", "GrantType", ")", "(", "string", ",", "string", ",", "error", ")", "{", "requestBody", ":=", "url", ".", "Values", "{", "\"grant_type\"", ":", "{", "string", "(", "grantType", ")", "}", ",", "}", "\n", "for", "k", ",", "v", ":=", "range", "creds", "{", "requestBody", ".", "Set", "(", "k", ",", "v", ")", "\n", "}", "\n", "type", "loginHint", "struct", "{", "Origin", "string", "`json:\"origin\"`", "\n", "}", "\n", "originStruct", ":=", "loginHint", "{", "origin", "}", "\n", "originParam", ",", "err", ":=", "json", ".", "Marshal", "(", "originStruct", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "\"\"", ",", "err", "\n", "}", "\n", "var", "query", "url", ".", "Values", "\n", "if", "origin", "!=", "\"\"", "{", "query", "=", "url", ".", "Values", "{", "\"login_hint\"", ":", "{", "string", "(", "originParam", ")", "}", ",", "}", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostOAuthTokenRequest", ",", "Header", ":", "http", ".", "Header", "{", "\"Content-Type\"", ":", "{", "\"application/x-www-form-urlencoded\"", "}", ",", "}", ",", "Body", ":", "strings", ".", "NewReader", "(", "requestBody", ".", "Encode", "(", ")", ")", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "\"\"", ",", "err", "\n", "}", "\n", "if", "grantType", "==", "constant", ".", "GrantTypePassword", "{", "request", ".", "SetBasicAuth", "(", "client", ".", "config", ".", "UAAOAuthClient", "(", ")", ",", "client", ".", "config", ".", "UAAOAuthClientSecret", "(", ")", ")", "\n", "}", "\n", "responseBody", ":=", "AuthResponse", "{", "}", "\n", "response", ":=", "Response", "{", "Result", ":", "&", "responseBody", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseBody", ".", "AccessToken", ",", "responseBody", ".", "RefreshToken", ",", "err", "\n", "}" ]
// Authenticate sends a username and password to UAA then returns an access // token and a refresh token.
[ "Authenticate", "sends", "a", "username", "and", "password", "to", "UAA", "then", "returns", "an", "access", "token", "and", "a", "refresh", "token", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/auth.go#L22-L72
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization_quota.go
UnmarshalJSON
func (application *OrganizationQuota) UnmarshalJSON(data []byte) error { var ccOrgQuota struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccOrgQuota) if err != nil { return err } application.GUID = ccOrgQuota.Metadata.GUID application.Name = ccOrgQuota.Entity.Name return nil }
go
func (application *OrganizationQuota) UnmarshalJSON(data []byte) error { var ccOrgQuota struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccOrgQuota) if err != nil { return err } application.GUID = ccOrgQuota.Metadata.GUID application.Name = ccOrgQuota.Entity.Name return nil }
[ "func", "(", "application", "*", "OrganizationQuota", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccOrgQuota", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccOrgQuota", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "application", ".", "GUID", "=", "ccOrgQuota", ".", "Metadata", ".", "GUID", "\n", "application", ".", "Name", "=", "ccOrgQuota", ".", "Entity", ".", "Name", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller organization quota response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "organization", "quota", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization_quota.go#L20-L36
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization_quota.go
GetOrganizationQuota
func (client *Client) GetOrganizationQuota(guid string) (OrganizationQuota, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionRequest, URIParams: Params{"organization_quota_guid": guid}, }) if err != nil { return OrganizationQuota{}, nil, err } var orgQuota OrganizationQuota response := cloudcontroller.Response{ DecodeJSONResponseInto: &orgQuota, } err = client.connection.Make(request, &response) return orgQuota, response.Warnings, err }
go
func (client *Client) GetOrganizationQuota(guid string) (OrganizationQuota, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionRequest, URIParams: Params{"organization_quota_guid": guid}, }) if err != nil { return OrganizationQuota{}, nil, err } var orgQuota OrganizationQuota response := cloudcontroller.Response{ DecodeJSONResponseInto: &orgQuota, } err = client.connection.Make(request, &response) return orgQuota, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganizationQuota", "(", "guid", "string", ")", "(", "OrganizationQuota", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationQuotaDefinitionRequest", ",", "URIParams", ":", "Params", "{", "\"organization_quota_guid\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "OrganizationQuota", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "orgQuota", "OrganizationQuota", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "orgQuota", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "orgQuota", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetOrganizationQuota returns an Organization Quota associated with the // provided GUID.
[ "GetOrganizationQuota", "returns", "an", "Organization", "Quota", "associated", "with", "the", "provided", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization_quota.go#L40-L56
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization_quota.go
GetOrganizationQuotas
func (client *Client) GetOrganizationQuotas(filters ...Filter) ([]OrganizationQuota, Warnings, error) { allQueries := ConvertFilterParameters(filters) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionsRequest, Query: allQueries, }) if err != nil { return []OrganizationQuota{}, nil, err } var fullOrgQuotasList []OrganizationQuota warnings, err := client.paginate(request, OrganizationQuota{}, func(item interface{}) error { if org, ok := item.(OrganizationQuota); ok { fullOrgQuotasList = append(fullOrgQuotasList, org) } else { return ccerror.UnknownObjectInListError{ Expected: OrganizationQuota{}, Unexpected: item, } } return nil }) return fullOrgQuotasList, warnings, err }
go
func (client *Client) GetOrganizationQuotas(filters ...Filter) ([]OrganizationQuota, Warnings, error) { allQueries := ConvertFilterParameters(filters) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionsRequest, Query: allQueries, }) if err != nil { return []OrganizationQuota{}, nil, err } var fullOrgQuotasList []OrganizationQuota warnings, err := client.paginate(request, OrganizationQuota{}, func(item interface{}) error { if org, ok := item.(OrganizationQuota); ok { fullOrgQuotasList = append(fullOrgQuotasList, org) } else { return ccerror.UnknownObjectInListError{ Expected: OrganizationQuota{}, Unexpected: item, } } return nil }) return fullOrgQuotasList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganizationQuotas", "(", "filters", "...", "Filter", ")", "(", "[", "]", "OrganizationQuota", ",", "Warnings", ",", "error", ")", "{", "allQueries", ":=", "ConvertFilterParameters", "(", "filters", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationQuotaDefinitionsRequest", ",", "Query", ":", "allQueries", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "OrganizationQuota", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullOrgQuotasList", "[", "]", "OrganizationQuota", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "OrganizationQuota", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "org", ",", "ok", ":=", "item", ".", "(", "OrganizationQuota", ")", ";", "ok", "{", "fullOrgQuotasList", "=", "append", "(", "fullOrgQuotasList", ",", "org", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "OrganizationQuota", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullOrgQuotasList", ",", "warnings", ",", "err", "\n", "}" ]
// GetOrganizationQuotas returns an Organization Quota list associated with the // provided filters.
[ "GetOrganizationQuotas", "returns", "an", "Organization", "Quota", "list", "associated", "with", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization_quota.go#L60-L86
train
cloudfoundry/cli
actor/v7action/process.go
GetProcessByTypeAndApplication
func (actor Actor) GetProcessByTypeAndApplication(processType string, appGUID string) (Process, Warnings, error) { process, warnings, err := actor.CloudControllerClient.GetApplicationProcessByType(appGUID, processType) if _, ok := err.(ccerror.ProcessNotFoundError); ok { return Process{}, Warnings(warnings), actionerror.ProcessNotFoundError{ProcessType: processType} } return Process(process), Warnings(warnings), err }
go
func (actor Actor) GetProcessByTypeAndApplication(processType string, appGUID string) (Process, Warnings, error) { process, warnings, err := actor.CloudControllerClient.GetApplicationProcessByType(appGUID, processType) if _, ok := err.(ccerror.ProcessNotFoundError); ok { return Process{}, Warnings(warnings), actionerror.ProcessNotFoundError{ProcessType: processType} } return Process(process), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetProcessByTypeAndApplication", "(", "processType", "string", ",", "appGUID", "string", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "process", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationProcessByType", "(", "appGUID", ",", "processType", ")", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ProcessNotFoundError", ")", ";", "ok", "{", "return", "Process", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ProcessNotFoundError", "{", "ProcessType", ":", "processType", "}", "\n", "}", "\n", "return", "Process", "(", "process", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetProcessByTypeAndApplication returns a process for the given application // and type.
[ "GetProcessByTypeAndApplication", "returns", "a", "process", "for", "the", "given", "application", "and", "type", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/process.go#L15-L21
train
cloudfoundry/cli
types/filtered_string.go
ParseValue
func (n *FilteredString) ParseValue(val string) { if val == "" { n.IsSet = false n.Value = "" return } n.IsSet = true switch val { case "null", "default": n.Value = "" default: n.Value = val } }
go
func (n *FilteredString) ParseValue(val string) { if val == "" { n.IsSet = false n.Value = "" return } n.IsSet = true switch val { case "null", "default": n.Value = "" default: n.Value = val } }
[ "func", "(", "n", "*", "FilteredString", ")", "ParseValue", "(", "val", "string", ")", "{", "if", "val", "==", "\"\"", "{", "n", ".", "IsSet", "=", "false", "\n", "n", ".", "Value", "=", "\"\"", "\n", "return", "\n", "}", "\n", "n", ".", "IsSet", "=", "true", "\n", "switch", "val", "{", "case", "\"null\"", ",", "\"default\"", ":", "n", ".", "Value", "=", "\"\"", "\n", "default", ":", "n", ".", "Value", "=", "val", "\n", "}", "\n", "}" ]
// ParseValue is used to parse a user provided flag argument.
[ "ParseValue", "is", "used", "to", "parse", "a", "user", "provided", "flag", "argument", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/types/filtered_string.go#L27-L42
train
cloudfoundry/cli
types/filtered_string.go
MarshalJSON
func (n FilteredString) MarshalJSON() ([]byte, error) { if n.Value != "" { return json.Marshal(n.Value) } return json.Marshal(new(json.RawMessage)) }
go
func (n FilteredString) MarshalJSON() ([]byte, error) { if n.Value != "" { return json.Marshal(n.Value) } return json.Marshal(new(json.RawMessage)) }
[ "func", "(", "n", "FilteredString", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "n", ".", "Value", "!=", "\"\"", "{", "return", "json", ".", "Marshal", "(", "n", ".", "Value", ")", "\n", "}", "\n", "return", "json", ".", "Marshal", "(", "new", "(", "json", ".", "RawMessage", ")", ")", "\n", "}" ]
// MarshalJSON marshals the value field if it's not empty, otherwise returns an // null.
[ "MarshalJSON", "marshals", "the", "value", "field", "if", "it", "s", "not", "empty", "otherwise", "returns", "an", "null", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/types/filtered_string.go#L68-L74
train
cloudfoundry/cli
api/cloudcontroller/decode_json.go
DecodeJSON
func DecodeJSON(raw []byte, v interface{}) error { decoder := json.NewDecoder(bytes.NewBuffer(raw)) decoder.UseNumber() return decoder.Decode(v) }
go
func DecodeJSON(raw []byte, v interface{}) error { decoder := json.NewDecoder(bytes.NewBuffer(raw)) decoder.UseNumber() return decoder.Decode(v) }
[ "func", "DecodeJSON", "(", "raw", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "error", "{", "decoder", ":=", "json", ".", "NewDecoder", "(", "bytes", ".", "NewBuffer", "(", "raw", ")", ")", "\n", "decoder", ".", "UseNumber", "(", ")", "\n", "return", "decoder", ".", "Decode", "(", "v", ")", "\n", "}" ]
// DecodeJSON unmarshals JSON into the given object with the appropriate // settings.
[ "DecodeJSON", "unmarshals", "JSON", "into", "the", "given", "object", "with", "the", "appropriate", "settings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/decode_json.go#L10-L14
train
cloudfoundry/cli
api/cloudcontroller/ccv3/deployment.go
MarshalJSON
func (d Deployment) MarshalJSON() ([]byte, error) { type Droplet struct { GUID string `json:"guid,omitempty"` } var ccDeployment struct { Droplet *Droplet `json:"droplet,omitempty"` Relationships Relationships `json:"relationships,omitempty"` } if d.DropletGUID != "" { ccDeployment.Droplet = &Droplet{d.DropletGUID} } ccDeployment.Relationships = d.Relationships return json.Marshal(ccDeployment) }
go
func (d Deployment) MarshalJSON() ([]byte, error) { type Droplet struct { GUID string `json:"guid,omitempty"` } var ccDeployment struct { Droplet *Droplet `json:"droplet,omitempty"` Relationships Relationships `json:"relationships,omitempty"` } if d.DropletGUID != "" { ccDeployment.Droplet = &Droplet{d.DropletGUID} } ccDeployment.Relationships = d.Relationships return json.Marshal(ccDeployment) }
[ "func", "(", "d", "Deployment", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "type", "Droplet", "struct", "{", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "}", "\n", "var", "ccDeployment", "struct", "{", "Droplet", "*", "Droplet", "`json:\"droplet,omitempty\"`", "\n", "Relationships", "Relationships", "`json:\"relationships,omitempty\"`", "\n", "}", "\n", "if", "d", ".", "DropletGUID", "!=", "\"\"", "{", "ccDeployment", ".", "Droplet", "=", "&", "Droplet", "{", "d", ".", "DropletGUID", "}", "\n", "}", "\n", "ccDeployment", ".", "Relationships", "=", "d", ".", "Relationships", "\n", "return", "json", ".", "Marshal", "(", "ccDeployment", ")", "\n", "}" ]
// MarshalJSON converts a Deployment into a Cloud Controller Deployment.
[ "MarshalJSON", "converts", "a", "Deployment", "into", "a", "Cloud", "Controller", "Deployment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/deployment.go#L23-L40
train
cloudfoundry/cli
api/cloudcontroller/ccv3/deployment.go
UnmarshalJSON
func (d *Deployment) UnmarshalJSON(data []byte) error { var ccDeployment struct { GUID string `json:"guid,omitempty"` CreatedAt string `json:"created_at,omitempty"` Relationships Relationships `json:"relationships,omitempty"` State constant.DeploymentState `json:"state,omitempty"` Droplet Droplet `json:"droplet,omitempty"` } err := cloudcontroller.DecodeJSON(data, &ccDeployment) if err != nil { return err } d.GUID = ccDeployment.GUID d.CreatedAt = ccDeployment.CreatedAt d.Relationships = ccDeployment.Relationships d.State = ccDeployment.State d.DropletGUID = ccDeployment.Droplet.GUID return nil }
go
func (d *Deployment) UnmarshalJSON(data []byte) error { var ccDeployment struct { GUID string `json:"guid,omitempty"` CreatedAt string `json:"created_at,omitempty"` Relationships Relationships `json:"relationships,omitempty"` State constant.DeploymentState `json:"state,omitempty"` Droplet Droplet `json:"droplet,omitempty"` } err := cloudcontroller.DecodeJSON(data, &ccDeployment) if err != nil { return err } d.GUID = ccDeployment.GUID d.CreatedAt = ccDeployment.CreatedAt d.Relationships = ccDeployment.Relationships d.State = ccDeployment.State d.DropletGUID = ccDeployment.Droplet.GUID return nil }
[ "func", "(", "d", "*", "Deployment", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccDeployment", "struct", "{", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "CreatedAt", "string", "`json:\"created_at,omitempty\"`", "\n", "Relationships", "Relationships", "`json:\"relationships,omitempty\"`", "\n", "State", "constant", ".", "DeploymentState", "`json:\"state,omitempty\"`", "\n", "Droplet", "Droplet", "`json:\"droplet,omitempty\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccDeployment", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "d", ".", "GUID", "=", "ccDeployment", ".", "GUID", "\n", "d", ".", "CreatedAt", "=", "ccDeployment", ".", "CreatedAt", "\n", "d", ".", "Relationships", "=", "ccDeployment", ".", "Relationships", "\n", "d", ".", "State", "=", "ccDeployment", ".", "State", "\n", "d", ".", "DropletGUID", "=", "ccDeployment", ".", "Droplet", ".", "GUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Deployment response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Deployment", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/deployment.go#L43-L63
train
cloudfoundry/cli
integration/helpers/environment.go
CheckEnvironmentTargetedCorrectly
func CheckEnvironmentTargetedCorrectly(targetedOrganizationRequired bool, targetedSpaceRequired bool, testOrg string, command ...string) { LoginCF() if targetedOrganizationRequired { By("errors if org is not targeted") session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\.")) Eventually(session).Should(Exit(1)) if targetedSpaceRequired { By("errors if space is not targeted") TargetOrg(testOrg) session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space\\.")) Eventually(session).Should(Exit(1)) } } By("errors if user not logged in") LogoutCF() session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("Not logged in\\. Use 'cf login' to log in\\.")) Eventually(session).Should(Exit(1)) By("errors if cli not targeted") UnsetAPI() session = CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No API endpoint set\\. Use 'cf login' or 'cf api' to target an endpoint\\.")) Eventually(session).Should(Exit(1)) }
go
func CheckEnvironmentTargetedCorrectly(targetedOrganizationRequired bool, targetedSpaceRequired bool, testOrg string, command ...string) { LoginCF() if targetedOrganizationRequired { By("errors if org is not targeted") session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\.")) Eventually(session).Should(Exit(1)) if targetedSpaceRequired { By("errors if space is not targeted") TargetOrg(testOrg) session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space\\.")) Eventually(session).Should(Exit(1)) } } By("errors if user not logged in") LogoutCF() session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("Not logged in\\. Use 'cf login' to log in\\.")) Eventually(session).Should(Exit(1)) By("errors if cli not targeted") UnsetAPI() session = CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No API endpoint set\\. Use 'cf login' or 'cf api' to target an endpoint\\.")) Eventually(session).Should(Exit(1)) }
[ "func", "CheckEnvironmentTargetedCorrectly", "(", "targetedOrganizationRequired", "bool", ",", "targetedSpaceRequired", "bool", ",", "testOrg", "string", ",", "command", "...", "string", ")", "{", "LoginCF", "(", ")", "\n", "if", "targetedOrganizationRequired", "{", "By", "(", "\"errors if org is not targeted\"", ")", "\n", "session", ":=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"FAILED\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"No org targeted, use 'cf target -o ORG' to target an org\\\\.\"", ")", ")", "\n", "\\\\", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n", "}", "\n", "if", "targetedSpaceRequired", "{", "By", "(", "\"errors if space is not targeted\"", ")", "\n", "TargetOrg", "(", "testOrg", ")", "\n", "session", ":=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"FAILED\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"No space targeted, use 'cf target -s SPACE' to target a space\\\\.\"", ")", ")", "\n", "\\\\", "\n", "}", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n", "By", "(", "\"errors if user not logged in\"", ")", "\n", "LogoutCF", "(", ")", "\n", "session", ":=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"FAILED\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"Not logged in\\\\. Use 'cf login' to log in\\\\.\"", ")", ")", "\n", "\\\\", "\n", "\\\\", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n", "By", "(", "\"errors if cli not targeted\"", ")", "\n", "UnsetAPI", "(", ")", "\n", "}" ]
// CheckEnvironmentTargetedCorrectly will confirm if the command requires an // API to be targeted and logged in to run. It can optionally check if the // command requires org and space to be targeted.
[ "CheckEnvironmentTargetedCorrectly", "will", "confirm", "if", "the", "command", "requires", "an", "API", "to", "be", "targeted", "and", "logged", "in", "to", "run", ".", "It", "can", "optionally", "check", "if", "the", "command", "requires", "org", "and", "space", "to", "be", "targeted", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/environment.go#L32-L65
train
cloudfoundry/cli
util/manifest/manifest.go
ReadAndInterpolateManifest
func ReadAndInterpolateManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]Application, error) { rawManifest, err := ReadAndInterpolateRawManifest(pathToManifest, pathsToVarsFiles, vars) if err != nil { return nil, err } var manifest Manifest err = yaml.Unmarshal(rawManifest, &manifest) if err != nil { return nil, err } for i, app := range manifest.Applications { if app.Path != "" && !filepath.IsAbs(app.Path) { manifest.Applications[i].Path = filepath.Join(filepath.Dir(pathToManifest), app.Path) } } return manifest.Applications, err }
go
func ReadAndInterpolateManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]Application, error) { rawManifest, err := ReadAndInterpolateRawManifest(pathToManifest, pathsToVarsFiles, vars) if err != nil { return nil, err } var manifest Manifest err = yaml.Unmarshal(rawManifest, &manifest) if err != nil { return nil, err } for i, app := range manifest.Applications { if app.Path != "" && !filepath.IsAbs(app.Path) { manifest.Applications[i].Path = filepath.Join(filepath.Dir(pathToManifest), app.Path) } } return manifest.Applications, err }
[ "func", "ReadAndInterpolateManifest", "(", "pathToManifest", "string", ",", "pathsToVarsFiles", "[", "]", "string", ",", "vars", "[", "]", "template", ".", "VarKV", ")", "(", "[", "]", "Application", ",", "error", ")", "{", "rawManifest", ",", "err", ":=", "ReadAndInterpolateRawManifest", "(", "pathToManifest", ",", "pathsToVarsFiles", ",", "vars", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "var", "manifest", "Manifest", "\n", "err", "=", "yaml", ".", "Unmarshal", "(", "rawManifest", ",", "&", "manifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "i", ",", "app", ":=", "range", "manifest", ".", "Applications", "{", "if", "app", ".", "Path", "!=", "\"\"", "&&", "!", "filepath", ".", "IsAbs", "(", "app", ".", "Path", ")", "{", "manifest", ".", "Applications", "[", "i", "]", ".", "Path", "=", "filepath", ".", "Join", "(", "filepath", ".", "Dir", "(", "pathToManifest", ")", ",", "app", ".", "Path", ")", "\n", "}", "\n", "}", "\n", "return", "manifest", ".", "Applications", ",", "err", "\n", "}" ]
// ReadAndInterpolateManifest reads the manifest at the provided paths, // interpolates variables if a vars file is provided, and returns a fully // merged set of applications.
[ "ReadAndInterpolateManifest", "reads", "the", "manifest", "at", "the", "provided", "paths", "interpolates", "variables", "if", "a", "vars", "file", "is", "provided", "and", "returns", "a", "fully", "merged", "set", "of", "applications", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/manifest/manifest.go#L37-L56
train
cloudfoundry/cli
util/manifest/manifest.go
ReadAndInterpolateRawManifest
func ReadAndInterpolateRawManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]byte, error) { rawManifest, err := ioutil.ReadFile(pathToManifest) if err != nil { return nil, err } tpl := template.NewTemplate(rawManifest) fileVars := template.StaticVariables{} for _, path := range pathsToVarsFiles { rawVarsFile, ioerr := ioutil.ReadFile(path) if ioerr != nil { return nil, ioerr } var sv template.StaticVariables err = yaml.Unmarshal(rawVarsFile, &sv) if err != nil { return nil, InvalidYAMLError{Err: err} } for k, v := range sv { fileVars[k] = v } } for _, kv := range vars { fileVars[kv.Name] = kv.Value } rawManifest, err = tpl.Evaluate(fileVars, nil, template.EvaluateOpts{ExpectAllKeys: true}) if err != nil { return nil, InterpolationError{Err: err} } return rawManifest, nil }
go
func ReadAndInterpolateRawManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]byte, error) { rawManifest, err := ioutil.ReadFile(pathToManifest) if err != nil { return nil, err } tpl := template.NewTemplate(rawManifest) fileVars := template.StaticVariables{} for _, path := range pathsToVarsFiles { rawVarsFile, ioerr := ioutil.ReadFile(path) if ioerr != nil { return nil, ioerr } var sv template.StaticVariables err = yaml.Unmarshal(rawVarsFile, &sv) if err != nil { return nil, InvalidYAMLError{Err: err} } for k, v := range sv { fileVars[k] = v } } for _, kv := range vars { fileVars[kv.Name] = kv.Value } rawManifest, err = tpl.Evaluate(fileVars, nil, template.EvaluateOpts{ExpectAllKeys: true}) if err != nil { return nil, InterpolationError{Err: err} } return rawManifest, nil }
[ "func", "ReadAndInterpolateRawManifest", "(", "pathToManifest", "string", ",", "pathsToVarsFiles", "[", "]", "string", ",", "vars", "[", "]", "template", ".", "VarKV", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "rawManifest", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "pathToManifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "tpl", ":=", "template", ".", "NewTemplate", "(", "rawManifest", ")", "\n", "fileVars", ":=", "template", ".", "StaticVariables", "{", "}", "\n", "for", "_", ",", "path", ":=", "range", "pathsToVarsFiles", "{", "rawVarsFile", ",", "ioerr", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "ioerr", "!=", "nil", "{", "return", "nil", ",", "ioerr", "\n", "}", "\n", "var", "sv", "template", ".", "StaticVariables", "\n", "err", "=", "yaml", ".", "Unmarshal", "(", "rawVarsFile", ",", "&", "sv", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "InvalidYAMLError", "{", "Err", ":", "err", "}", "\n", "}", "\n", "for", "k", ",", "v", ":=", "range", "sv", "{", "fileVars", "[", "k", "]", "=", "v", "\n", "}", "\n", "}", "\n", "for", "_", ",", "kv", ":=", "range", "vars", "{", "fileVars", "[", "kv", ".", "Name", "]", "=", "kv", ".", "Value", "\n", "}", "\n", "rawManifest", ",", "err", "=", "tpl", ".", "Evaluate", "(", "fileVars", ",", "nil", ",", "template", ".", "EvaluateOpts", "{", "ExpectAllKeys", ":", "true", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "InterpolationError", "{", "Err", ":", "err", "}", "\n", "}", "\n", "return", "rawManifest", ",", "nil", "\n", "}" ]
// ReadAndInterpolateRawManifest reads the manifest at the provided paths, // interpolates variables if a vars file is provided, and returns the // Unmarshalled result.
[ "ReadAndInterpolateRawManifest", "reads", "the", "manifest", "at", "the", "provided", "paths", "interpolates", "variables", "if", "a", "vars", "file", "is", "provided", "and", "returns", "the", "Unmarshalled", "result", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/manifest/manifest.go#L61-L97
train
cloudfoundry/cli
util/manifest/manifest.go
WriteApplicationManifest
func WriteApplicationManifest(application Application, filePath string) error { manifest := Manifest{Applications: []Application{application}} manifestBytes, err := yaml.Marshal(manifest) if err != nil { return ManifestCreationError{Err: err} } err = ioutil.WriteFile(filePath, manifestBytes, 0644) if err != nil { return ManifestCreationError{Err: err} } return nil }
go
func WriteApplicationManifest(application Application, filePath string) error { manifest := Manifest{Applications: []Application{application}} manifestBytes, err := yaml.Marshal(manifest) if err != nil { return ManifestCreationError{Err: err} } err = ioutil.WriteFile(filePath, manifestBytes, 0644) if err != nil { return ManifestCreationError{Err: err} } return nil }
[ "func", "WriteApplicationManifest", "(", "application", "Application", ",", "filePath", "string", ")", "error", "{", "manifest", ":=", "Manifest", "{", "Applications", ":", "[", "]", "Application", "{", "application", "}", "}", "\n", "manifestBytes", ",", "err", ":=", "yaml", ".", "Marshal", "(", "manifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ManifestCreationError", "{", "Err", ":", "err", "}", "\n", "}", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filePath", ",", "manifestBytes", ",", "0644", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ManifestCreationError", "{", "Err", ":", "err", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// WriteApplicationManifest writes the provided application to the given // filepath. If the filepath does not exist, it will create it.
[ "WriteApplicationManifest", "writes", "the", "provided", "application", "to", "the", "given", "filepath", ".", "If", "the", "filepath", "does", "not", "exist", "it", "will", "create", "it", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/manifest/manifest.go#L101-L114
train
cloudfoundry/cli
api/cloudcontroller/ccv3/isolation_segment.go
GetIsolationSegment
func (client *Client) GetIsolationSegment(guid string) (IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentRequest, URIParams: map[string]string{"isolation_segment_guid": guid}, }) if err != nil { return IsolationSegment{}, nil, err } var isolationSegment IsolationSegment response := cloudcontroller.Response{ DecodeJSONResponseInto: &isolationSegment, } err = client.connection.Make(request, &response) if err != nil { return IsolationSegment{}, response.Warnings, err } return isolationSegment, response.Warnings, nil }
go
func (client *Client) GetIsolationSegment(guid string) (IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentRequest, URIParams: map[string]string{"isolation_segment_guid": guid}, }) if err != nil { return IsolationSegment{}, nil, err } var isolationSegment IsolationSegment response := cloudcontroller.Response{ DecodeJSONResponseInto: &isolationSegment, } err = client.connection.Make(request, &response) if err != nil { return IsolationSegment{}, response.Warnings, err } return isolationSegment, response.Warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "GetIsolationSegment", "(", "guid", "string", ")", "(", "IsolationSegment", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetIsolationSegmentRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"isolation_segment_guid\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "IsolationSegment", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "isolationSegment", "IsolationSegment", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "isolationSegment", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "IsolationSegment", "{", "}", ",", "response", ".", "Warnings", ",", "err", "\n", "}", "\n", "return", "isolationSegment", ",", "response", ".", "Warnings", ",", "nil", "\n", "}" ]
// GetIsolationSegment returns back the requested isolation segment that // matches the GUID.
[ "GetIsolationSegment", "returns", "back", "the", "requested", "isolation", "segment", "that", "matches", "the", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/isolation_segment.go#L65-L84
train
cloudfoundry/cli
api/cloudcontroller/ccv3/isolation_segment.go
GetIsolationSegments
func (client *Client) GetIsolationSegments(query ...Query) ([]IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullIsolationSegmentsList []IsolationSegment warnings, err := client.paginate(request, IsolationSegment{}, func(item interface{}) error { if isolationSegment, ok := item.(IsolationSegment); ok { fullIsolationSegmentsList = append(fullIsolationSegmentsList, isolationSegment) } else { return ccerror.UnknownObjectInListError{ Expected: IsolationSegment{}, Unexpected: item, } } return nil }) return fullIsolationSegmentsList, warnings, err }
go
func (client *Client) GetIsolationSegments(query ...Query) ([]IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullIsolationSegmentsList []IsolationSegment warnings, err := client.paginate(request, IsolationSegment{}, func(item interface{}) error { if isolationSegment, ok := item.(IsolationSegment); ok { fullIsolationSegmentsList = append(fullIsolationSegmentsList, isolationSegment) } else { return ccerror.UnknownObjectInListError{ Expected: IsolationSegment{}, Unexpected: item, } } return nil }) return fullIsolationSegmentsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetIsolationSegments", "(", "query", "...", "Query", ")", "(", "[", "]", "IsolationSegment", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetIsolationSegmentsRequest", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullIsolationSegmentsList", "[", "]", "IsolationSegment", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "IsolationSegment", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "isolationSegment", ",", "ok", ":=", "item", ".", "(", "IsolationSegment", ")", ";", "ok", "{", "fullIsolationSegmentsList", "=", "append", "(", "fullIsolationSegmentsList", ",", "isolationSegment", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "IsolationSegment", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullIsolationSegmentsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetIsolationSegments lists isolation segments with optional filters.
[ "GetIsolationSegments", "lists", "isolation", "segments", "with", "optional", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/isolation_segment.go#L87-L110
train
cloudfoundry/cli
api/cloudcontroller/buildpacks/upload.go
CalculateRequestSize
func CalculateRequestSize(buildpackSize int64, bpPath string, fieldName string) (int64, error) { body := &bytes.Buffer{} form := multipart.NewWriter(body) bpFileName := filepath.Base(bpPath) _, err := form.CreateFormFile(fieldName, bpFileName) if err != nil { return 0, err } err = form.Close() if err != nil { return 0, err } return int64(body.Len()) + buildpackSize, nil }
go
func CalculateRequestSize(buildpackSize int64, bpPath string, fieldName string) (int64, error) { body := &bytes.Buffer{} form := multipart.NewWriter(body) bpFileName := filepath.Base(bpPath) _, err := form.CreateFormFile(fieldName, bpFileName) if err != nil { return 0, err } err = form.Close() if err != nil { return 0, err } return int64(body.Len()) + buildpackSize, nil }
[ "func", "CalculateRequestSize", "(", "buildpackSize", "int64", ",", "bpPath", "string", ",", "fieldName", "string", ")", "(", "int64", ",", "error", ")", "{", "body", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "form", ":=", "multipart", ".", "NewWriter", "(", "body", ")", "\n", "bpFileName", ":=", "filepath", ".", "Base", "(", "bpPath", ")", "\n", "_", ",", "err", ":=", "form", ".", "CreateFormFile", "(", "fieldName", ",", "bpFileName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "err", "=", "form", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n", "return", "int64", "(", "body", ".", "Len", "(", ")", ")", "+", "buildpackSize", ",", "nil", "\n", "}" ]
// tested via the ccv2.buildpack_test.go file at this point
[ "tested", "via", "the", "ccv2", ".", "buildpack_test", ".", "go", "file", "at", "this", "point" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/buildpacks/upload.go#L14-L31
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
UnmarshalJSON
func (securityGroup *SecurityGroup) UnmarshalJSON(data []byte) error { var ccSecurityGroup struct { Metadata internal.Metadata `json:"metadata"` Entity struct { GUID string `json:"guid"` Name string `json:"name"` Rules []struct { Description string `json:"description"` Destination string `json:"destination"` Ports string `json:"ports"` Protocol string `json:"protocol"` } `json:"rules"` RunningDefault bool `json:"running_default"` StagingDefault bool `json:"staging_default"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSecurityGroup) if err != nil { return err } securityGroup.GUID = ccSecurityGroup.Metadata.GUID securityGroup.Name = ccSecurityGroup.Entity.Name securityGroup.Rules = make([]SecurityGroupRule, len(ccSecurityGroup.Entity.Rules)) for i, ccRule := range ccSecurityGroup.Entity.Rules { securityGroup.Rules[i].Description = ccRule.Description securityGroup.Rules[i].Destination = ccRule.Destination securityGroup.Rules[i].Ports = ccRule.Ports securityGroup.Rules[i].Protocol = ccRule.Protocol } securityGroup.RunningDefault = ccSecurityGroup.Entity.RunningDefault securityGroup.StagingDefault = ccSecurityGroup.Entity.StagingDefault return nil }
go
func (securityGroup *SecurityGroup) UnmarshalJSON(data []byte) error { var ccSecurityGroup struct { Metadata internal.Metadata `json:"metadata"` Entity struct { GUID string `json:"guid"` Name string `json:"name"` Rules []struct { Description string `json:"description"` Destination string `json:"destination"` Ports string `json:"ports"` Protocol string `json:"protocol"` } `json:"rules"` RunningDefault bool `json:"running_default"` StagingDefault bool `json:"staging_default"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSecurityGroup) if err != nil { return err } securityGroup.GUID = ccSecurityGroup.Metadata.GUID securityGroup.Name = ccSecurityGroup.Entity.Name securityGroup.Rules = make([]SecurityGroupRule, len(ccSecurityGroup.Entity.Rules)) for i, ccRule := range ccSecurityGroup.Entity.Rules { securityGroup.Rules[i].Description = ccRule.Description securityGroup.Rules[i].Destination = ccRule.Destination securityGroup.Rules[i].Ports = ccRule.Ports securityGroup.Rules[i].Protocol = ccRule.Protocol } securityGroup.RunningDefault = ccSecurityGroup.Entity.RunningDefault securityGroup.StagingDefault = ccSecurityGroup.Entity.StagingDefault return nil }
[ "func", "(", "securityGroup", "*", "SecurityGroup", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccSecurityGroup", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "Name", "string", "`json:\"name\"`", "\n", "Rules", "[", "]", "struct", "{", "Description", "string", "`json:\"description\"`", "\n", "Destination", "string", "`json:\"destination\"`", "\n", "Ports", "string", "`json:\"ports\"`", "\n", "Protocol", "string", "`json:\"protocol\"`", "\n", "}", "`json:\"rules\"`", "\n", "RunningDefault", "bool", "`json:\"running_default\"`", "\n", "StagingDefault", "bool", "`json:\"staging_default\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccSecurityGroup", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "securityGroup", ".", "GUID", "=", "ccSecurityGroup", ".", "Metadata", ".", "GUID", "\n", "securityGroup", ".", "Name", "=", "ccSecurityGroup", ".", "Entity", ".", "Name", "\n", "securityGroup", ".", "Rules", "=", "make", "(", "[", "]", "SecurityGroupRule", ",", "len", "(", "ccSecurityGroup", ".", "Entity", ".", "Rules", ")", ")", "\n", "for", "i", ",", "ccRule", ":=", "range", "ccSecurityGroup", ".", "Entity", ".", "Rules", "{", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Description", "=", "ccRule", ".", "Description", "\n", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Destination", "=", "ccRule", ".", "Destination", "\n", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Ports", "=", "ccRule", ".", "Ports", "\n", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Protocol", "=", "ccRule", ".", "Protocol", "\n", "}", "\n", "securityGroup", ".", "RunningDefault", "=", "ccSecurityGroup", ".", "Entity", ".", "RunningDefault", "\n", "securityGroup", ".", "StagingDefault", "=", "ccSecurityGroup", ".", "Entity", ".", "StagingDefault", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Security Group response
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Security", "Group", "response" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L26-L59
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
DeleteSecurityGroupSpace
func (client *Client) DeleteSecurityGroupSpace(securityGroupGUID string, spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSecurityGroupSpaceRequest, URIParams: Params{ "security_group_guid": securityGroupGUID, "space_guid": spaceGUID, }, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteSecurityGroupSpace(securityGroupGUID string, spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSecurityGroupSpaceRequest, URIParams: Params{ "security_group_guid": securityGroupGUID, "space_guid": spaceGUID, }, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteSecurityGroupSpace", "(", "securityGroupGUID", "string", ",", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteSecurityGroupSpaceRequest", ",", "URIParams", ":", "Params", "{", "\"security_group_guid\"", ":", "securityGroupGUID", ",", "\"space_guid\"", ":", "spaceGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteSecurityGroupSpace disassociates a security group in the running phase // for the lifecycle, specified by its GUID, from a space, which is also // specified by its GUID.
[ "DeleteSecurityGroupSpace", "disassociates", "a", "security", "group", "in", "the", "running", "phase", "for", "the", "lifecycle", "specified", "by", "its", "GUID", "from", "a", "space", "which", "is", "also", "specified", "by", "its", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L64-L81
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
GetSecurityGroups
func (client *Client) GetSecurityGroups(filters ...Filter) ([]SecurityGroup, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var securityGroupsList []SecurityGroup warnings, err := client.paginate(request, SecurityGroup{}, func(item interface{}) error { if securityGroup, ok := item.(SecurityGroup); ok { securityGroupsList = append(securityGroupsList, securityGroup) } else { return ccerror.UnknownObjectInListError{ Expected: SecurityGroup{}, Unexpected: item, } } return nil }) return securityGroupsList, warnings, err }
go
func (client *Client) GetSecurityGroups(filters ...Filter) ([]SecurityGroup, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var securityGroupsList []SecurityGroup warnings, err := client.paginate(request, SecurityGroup{}, func(item interface{}) error { if securityGroup, ok := item.(SecurityGroup); ok { securityGroupsList = append(securityGroupsList, securityGroup) } else { return ccerror.UnknownObjectInListError{ Expected: SecurityGroup{}, Unexpected: item, } } return nil }) return securityGroupsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSecurityGroups", "(", "filters", "...", "Filter", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSecurityGroupsRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "securityGroupsList", "[", "]", "SecurityGroup", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "SecurityGroup", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "securityGroup", ",", "ok", ":=", "item", ".", "(", "SecurityGroup", ")", ";", "ok", "{", "securityGroupsList", "=", "append", "(", "securityGroupsList", ",", "securityGroup", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "SecurityGroup", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "securityGroupsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSecurityGroups returns a list of Security Groups based off the provided // filters.
[ "GetSecurityGroups", "returns", "a", "list", "of", "Security", "Groups", "based", "off", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L107-L131
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
GetSpaceSecurityGroups
func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceSecurityGroupsRequest, filters) }
go
func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceSecurityGroupsRequest, filters) }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceSecurityGroups", "(", "spaceGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "return", "client", ".", "getSpaceSecurityGroupsBySpaceAndLifecycle", "(", "spaceGUID", ",", "internal", ".", "GetSpaceSecurityGroupsRequest", ",", "filters", ")", "\n", "}" ]
// GetSpaceSecurityGroups returns the running Security Groups associated with // the provided Space GUID.
[ "GetSpaceSecurityGroups", "returns", "the", "running", "Security", "Groups", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L135-L137
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
GetSpaceStagingSecurityGroups
func (client *Client) GetSpaceStagingSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceStagingSecurityGroupsRequest, filters) }
go
func (client *Client) GetSpaceStagingSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceStagingSecurityGroupsRequest, filters) }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceStagingSecurityGroups", "(", "spaceGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "return", "client", ".", "getSpaceSecurityGroupsBySpaceAndLifecycle", "(", "spaceGUID", ",", "internal", ".", "GetSpaceStagingSecurityGroupsRequest", ",", "filters", ")", "\n", "}" ]
// GetSpaceStagingSecurityGroups returns the staging Security Groups // associated with the provided Space GUID.
[ "GetSpaceStagingSecurityGroups", "returns", "the", "staging", "Security", "Groups", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L141-L143
train
cloudfoundry/cli
api/cloudcontroller/ccv3/job.go
Errors
func (job Job) Errors() []error { var errs []error for _, errDetails := range job.RawErrors { switch errDetails.Code { case constant.JobErrorCodeBuildpackAlreadyExistsForStack: errs = append(errs, ccerror.BuildpackAlreadyExistsForStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackAlreadyExistsWithoutStack: errs = append(errs, ccerror.BuildpackAlreadyExistsWithoutStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStacksDontMatch: errs = append(errs, ccerror.BuildpackStacksDontMatchError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStackDoesNotExist: errs = append(errs, ccerror.BuildpackStackDoesNotExistError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackZipInvalid: errs = append(errs, ccerror.BuildpackZipInvalidError{Message: errDetails.Detail}) default: errs = append(errs, ccerror.V3JobFailedError{ JobGUID: job.GUID, Code: errDetails.Code, Detail: errDetails.Detail, Title: errDetails.Title, }) } } return errs }
go
func (job Job) Errors() []error { var errs []error for _, errDetails := range job.RawErrors { switch errDetails.Code { case constant.JobErrorCodeBuildpackAlreadyExistsForStack: errs = append(errs, ccerror.BuildpackAlreadyExistsForStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackAlreadyExistsWithoutStack: errs = append(errs, ccerror.BuildpackAlreadyExistsWithoutStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStacksDontMatch: errs = append(errs, ccerror.BuildpackStacksDontMatchError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStackDoesNotExist: errs = append(errs, ccerror.BuildpackStackDoesNotExistError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackZipInvalid: errs = append(errs, ccerror.BuildpackZipInvalidError{Message: errDetails.Detail}) default: errs = append(errs, ccerror.V3JobFailedError{ JobGUID: job.GUID, Code: errDetails.Code, Detail: errDetails.Detail, Title: errDetails.Title, }) } } return errs }
[ "func", "(", "job", "Job", ")", "Errors", "(", ")", "[", "]", "error", "{", "var", "errs", "[", "]", "error", "\n", "for", "_", ",", "errDetails", ":=", "range", "job", ".", "RawErrors", "{", "switch", "errDetails", ".", "Code", "{", "case", "constant", ".", "JobErrorCodeBuildpackAlreadyExistsForStack", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackAlreadyExistsForStackError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackAlreadyExistsWithoutStack", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackAlreadyExistsWithoutStackError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackStacksDontMatch", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackStacksDontMatchError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackStackDoesNotExist", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackStackDoesNotExistError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackZipInvalid", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackZipInvalidError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "default", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "V3JobFailedError", "{", "JobGUID", ":", "job", ".", "GUID", ",", "Code", ":", "errDetails", ".", "Code", ",", "Detail", ":", "errDetails", ".", "Detail", ",", "Title", ":", "errDetails", ".", "Title", ",", "}", ")", "\n", "}", "\n", "}", "\n", "return", "errs", "\n", "}" ]
// Errors returns back a list of
[ "Errors", "returns", "back", "a", "list", "of" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job.go#L22-L46
train
cloudfoundry/cli
actor/v7action/application.go
CreateApplicationInSpace
func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) { createdApp, warnings, err := actor.CloudControllerClient.CreateApplication( ccv3.Application{ LifecycleType: app.LifecycleType, LifecycleBuildpacks: app.LifecycleBuildpacks, StackName: app.StackName, Name: app.Name, Relationships: ccv3.Relationships{ constant.RelationshipTypeSpace: ccv3.Relationship{GUID: spaceGUID}, }, }) if err != nil { if _, ok := err.(ccerror.NameNotUniqueInSpaceError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationAlreadyExistsError{Name: app.Name} } return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(createdApp), Warnings(warnings), nil }
go
func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) { createdApp, warnings, err := actor.CloudControllerClient.CreateApplication( ccv3.Application{ LifecycleType: app.LifecycleType, LifecycleBuildpacks: app.LifecycleBuildpacks, StackName: app.StackName, Name: app.Name, Relationships: ccv3.Relationships{ constant.RelationshipTypeSpace: ccv3.Relationship{GUID: spaceGUID}, }, }) if err != nil { if _, ok := err.(ccerror.NameNotUniqueInSpaceError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationAlreadyExistsError{Name: app.Name} } return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(createdApp), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "CreateApplicationInSpace", "(", "app", "Application", ",", "spaceGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "createdApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateApplication", "(", "ccv3", ".", "Application", "{", "LifecycleType", ":", "app", ".", "LifecycleType", ",", "LifecycleBuildpacks", ":", "app", ".", "LifecycleBuildpacks", ",", "StackName", ":", "app", ".", "StackName", ",", "Name", ":", "app", ".", "Name", ",", "Relationships", ":", "ccv3", ".", "Relationships", "{", "constant", ".", "RelationshipTypeSpace", ":", "ccv3", ".", "Relationship", "{", "GUID", ":", "spaceGUID", "}", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "NameNotUniqueInSpaceError", ")", ";", "ok", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ApplicationAlreadyExistsError", "{", "Name", ":", "app", ".", "Name", "}", "\n", "}", "\n", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "return", "actor", ".", "convertCCToActorApplication", "(", "createdApp", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// CreateApplicationInSpace creates and returns the application with the given // name in the given space.
[ "CreateApplicationInSpace", "creates", "and", "returns", "the", "application", "with", "the", "given", "name", "in", "the", "given", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L106-L126
train
cloudfoundry/cli
actor/v7action/application.go
SetApplicationProcessHealthCheckTypeByNameAndSpace
func (actor Actor) SetApplicationProcessHealthCheckTypeByNameAndSpace( appName string, spaceGUID string, healthCheckType constant.HealthCheckType, httpEndpoint string, processType string, invocationTimeout int64, ) (Application, Warnings, error) { app, getWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return Application{}, getWarnings, err } setWarnings, err := actor.UpdateProcessByTypeAndApplication( processType, app.GUID, Process{ HealthCheckType: healthCheckType, HealthCheckEndpoint: httpEndpoint, HealthCheckInvocationTimeout: invocationTimeout, }) return app, append(getWarnings, setWarnings...), err }
go
func (actor Actor) SetApplicationProcessHealthCheckTypeByNameAndSpace( appName string, spaceGUID string, healthCheckType constant.HealthCheckType, httpEndpoint string, processType string, invocationTimeout int64, ) (Application, Warnings, error) { app, getWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return Application{}, getWarnings, err } setWarnings, err := actor.UpdateProcessByTypeAndApplication( processType, app.GUID, Process{ HealthCheckType: healthCheckType, HealthCheckEndpoint: httpEndpoint, HealthCheckInvocationTimeout: invocationTimeout, }) return app, append(getWarnings, setWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "SetApplicationProcessHealthCheckTypeByNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "healthCheckType", "constant", ".", "HealthCheckType", ",", "httpEndpoint", "string", ",", "processType", "string", ",", "invocationTimeout", "int64", ",", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "getWarnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "getWarnings", ",", "err", "\n", "}", "\n", "setWarnings", ",", "err", ":=", "actor", ".", "UpdateProcessByTypeAndApplication", "(", "processType", ",", "app", ".", "GUID", ",", "Process", "{", "HealthCheckType", ":", "healthCheckType", ",", "HealthCheckEndpoint", ":", "httpEndpoint", ",", "HealthCheckInvocationTimeout", ":", "invocationTimeout", ",", "}", ")", "\n", "return", "app", ",", "append", "(", "getWarnings", ",", "setWarnings", "...", ")", ",", "err", "\n", "}" ]
// SetApplicationProcessHealthCheckTypeByNameAndSpace sets the health check // information of the provided processType for an application with the given // name and space GUID.
[ "SetApplicationProcessHealthCheckTypeByNameAndSpace", "sets", "the", "health", "check", "information", "of", "the", "provided", "processType", "for", "an", "application", "with", "the", "given", "name", "and", "space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L131-L154
train
cloudfoundry/cli
actor/v7action/application.go
StopApplication
func (actor Actor) StopApplication(appGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.UpdateApplicationStop(appGUID) return Warnings(warnings), err }
go
func (actor Actor) StopApplication(appGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.UpdateApplicationStop(appGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "StopApplication", "(", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationStop", "(", "appGUID", ")", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// StopApplication stops an application.
[ "StopApplication", "stops", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L157-L161
train
cloudfoundry/cli
actor/v7action/application.go
StartApplication
func (actor Actor) StartApplication(appGUID string) (Application, Warnings, error) { updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationStart(appGUID) if err != nil { return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil }
go
func (actor Actor) StartApplication(appGUID string) (Application, Warnings, error) { updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationStart(appGUID) if err != nil { return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "StartApplication", "(", "appGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "updatedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationStart", "(", "appGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "return", "actor", ".", "convertCCToActorApplication", "(", "updatedApp", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// StartApplication starts an application.
[ "StartApplication", "starts", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L164-L171
train
cloudfoundry/cli
actor/v7action/application.go
RestartApplication
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) { var allWarnings Warnings _, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } pollingWarnings, err := actor.PollStart(appGUID) allWarnings = append(allWarnings, pollingWarnings...) return allWarnings, err }
go
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) { var allWarnings Warnings _, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } pollingWarnings, err := actor.PollStart(appGUID) allWarnings = append(allWarnings, pollingWarnings...) return allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "RestartApplication", "(", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationRestart", "(", "appGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n", "pollingWarnings", ",", "err", ":=", "actor", ".", "PollStart", "(", "appGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "pollingWarnings", "...", ")", "\n", "return", "allWarnings", ",", "err", "\n", "}" ]
// RestartApplication restarts an application and waits for it to start.
[ "RestartApplication", "restarts", "an", "application", "and", "waits", "for", "it", "to", "start", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L174-L185
train
cloudfoundry/cli
actor/actionerror/domain_not_found_error.go
Error
func (e DomainNotFoundError) Error() string { switch { case e.Name != "": return fmt.Sprintf("Domain %s not found", e.Name) case e.GUID != "": return fmt.Sprintf("Domain with GUID %s not found", e.GUID) default: return "Domain not found" } }
go
func (e DomainNotFoundError) Error() string { switch { case e.Name != "": return fmt.Sprintf("Domain %s not found", e.Name) case e.GUID != "": return fmt.Sprintf("Domain with GUID %s not found", e.GUID) default: return "Domain not found" } }
[ "func", "(", "e", "DomainNotFoundError", ")", "Error", "(", ")", "string", "{", "switch", "{", "case", "e", ".", "Name", "!=", "\"\"", ":", "return", "fmt", ".", "Sprintf", "(", "\"Domain %s not found\"", ",", "e", ".", "Name", ")", "\n", "case", "e", ".", "GUID", "!=", "\"\"", ":", "return", "fmt", ".", "Sprintf", "(", "\"Domain with GUID %s not found\"", ",", "e", ".", "GUID", ")", "\n", "default", ":", "return", "\"Domain not found\"", "\n", "}", "\n", "}" ]
// Error method to display the error message.
[ "Error", "method", "to", "display", "the", "error", "message", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/actionerror/domain_not_found_error.go#L13-L22
train
cloudfoundry/cli
integration/helpers/app.go
WithProcfileApp
func WithProcfileApp(f func(dir string)) { dir, err := ioutil.TempDir("", "simple-ruby-app") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(dir) err = ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- web: ruby -run -e httpd . -p $PORT console: bundle exec irb`, ), 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` GEM specs: PLATFORMS ruby DEPENDENCIES BUNDLED WITH 1.15.0 `), 0666) Expect(err).ToNot(HaveOccurred()) f(dir) }
go
func WithProcfileApp(f func(dir string)) { dir, err := ioutil.TempDir("", "simple-ruby-app") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(dir) err = ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- web: ruby -run -e httpd . -p $PORT console: bundle exec irb`, ), 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` GEM specs: PLATFORMS ruby DEPENDENCIES BUNDLED WITH 1.15.0 `), 0666) Expect(err).ToNot(HaveOccurred()) f(dir) }
[ "func", "WithProcfileApp", "(", "f", "func", "(", "dir", "string", ")", ")", "{", "dir", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "\"\"", ",", "\"simple-ruby-app\"", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "defer", "os", ".", "RemoveAll", "(", "dir", ")", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "\"Procfile\"", ")", ",", "[", "]", "byte", "(", "`---web: ruby -run -e httpd . -p $PORTconsole: bundle exec irb`", ",", ")", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "\"Gemfile\"", ")", ",", "nil", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "\"Gemfile.lock\"", ")", ",", "[", "]", "byte", "(", "`GEM specs:PLATFORMS rubyDEPENDENCIESBUNDLED WITH 1.15.0\t`", ")", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "f", "(", "dir", ")", "\n", "}" ]
// WithProcfileApp creates an application to use with your CLI command // that contains Procfile defining web and worker processes.
[ "WithProcfileApp", "creates", "an", "application", "to", "use", "with", "your", "CLI", "command", "that", "contains", "Procfile", "defining", "web", "and", "worker", "processes", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L88-L117
train
cloudfoundry/cli
integration/helpers/app.go
AppGUID
func AppGUID(appName string) string { session := CF("app", appName, "--guid") Eventually(session).Should(Exit(0)) return strings.TrimSpace(string(session.Out.Contents())) }
go
func AppGUID(appName string) string { session := CF("app", appName, "--guid") Eventually(session).Should(Exit(0)) return strings.TrimSpace(string(session.Out.Contents())) }
[ "func", "AppGUID", "(", "appName", "string", ")", "string", "{", "session", ":=", "CF", "(", "\"app\"", ",", "appName", ",", "\"--guid\"", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "0", ")", ")", "\n", "return", "strings", ".", "TrimSpace", "(", "string", "(", "session", ".", "Out", ".", "Contents", "(", ")", ")", ")", "\n", "}" ]
// AppGUID returns the GUID for an app in the currently targeted space.
[ "AppGUID", "returns", "the", "GUID", "for", "an", "app", "in", "the", "currently", "targeted", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L171-L175
train
cloudfoundry/cli
integration/helpers/app.go
WriteManifest
func WriteManifest(path string, manifest map[string]interface{}) { body, err := yaml.Marshal(manifest) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(path, body, 0666) Expect(err).ToNot(HaveOccurred()) }
go
func WriteManifest(path string, manifest map[string]interface{}) { body, err := yaml.Marshal(manifest) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(path, body, 0666) Expect(err).ToNot(HaveOccurred()) }
[ "func", "WriteManifest", "(", "path", "string", ",", "manifest", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "body", ",", "err", ":=", "yaml", ".", "Marshal", "(", "manifest", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "path", ",", "body", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "}" ]
// WriteManifest will write out a YAML manifest file at the specified path.
[ "WriteManifest", "will", "write", "out", "a", "YAML", "manifest", "file", "at", "the", "specified", "path", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L185-L190
train
cloudfoundry/cli
integration/helpers/app.go
Zipit
func Zipit(source, target, prefix string) error { // Thanks to Svett Ralchev // http://blog.ralch.com/tutorial/golang-working-with-zip/ zipfile, err := os.Create(target) if err != nil { return err } defer zipfile.Close() if prefix != "" { _, err = io.WriteString(zipfile, prefix) if err != nil { return err } } archive := zip.NewWriter(zipfile) defer archive.Close() err = filepath.Walk(source, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if path == source { return nil } header, err := zip.FileInfoHeader(info) if err != nil { return err } header.Name, err = filepath.Rel(source, path) if err != nil { return err } header.Name = filepath.ToSlash(header.Name) if info.IsDir() { header.Name += "/" header.SetMode(0755) } else { header.Method = zip.Deflate header.SetMode(0744) } writer, err := archive.CreateHeader(header) if err != nil { return err } if info.IsDir() { return nil } file, err := os.Open(path) if err != nil { return err } defer file.Close() _, err = io.Copy(writer, file) return err }) return err }
go
func Zipit(source, target, prefix string) error { // Thanks to Svett Ralchev // http://blog.ralch.com/tutorial/golang-working-with-zip/ zipfile, err := os.Create(target) if err != nil { return err } defer zipfile.Close() if prefix != "" { _, err = io.WriteString(zipfile, prefix) if err != nil { return err } } archive := zip.NewWriter(zipfile) defer archive.Close() err = filepath.Walk(source, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if path == source { return nil } header, err := zip.FileInfoHeader(info) if err != nil { return err } header.Name, err = filepath.Rel(source, path) if err != nil { return err } header.Name = filepath.ToSlash(header.Name) if info.IsDir() { header.Name += "/" header.SetMode(0755) } else { header.Method = zip.Deflate header.SetMode(0744) } writer, err := archive.CreateHeader(header) if err != nil { return err } if info.IsDir() { return nil } file, err := os.Open(path) if err != nil { return err } defer file.Close() _, err = io.Copy(writer, file) return err }) return err }
[ "func", "Zipit", "(", "source", ",", "target", ",", "prefix", "string", ")", "error", "{", "zipfile", ",", "err", ":=", "os", ".", "Create", "(", "target", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "zipfile", ".", "Close", "(", ")", "\n", "if", "prefix", "!=", "\"\"", "{", "_", ",", "err", "=", "io", ".", "WriteString", "(", "zipfile", ",", "prefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "archive", ":=", "zip", ".", "NewWriter", "(", "zipfile", ")", "\n", "defer", "archive", ".", "Close", "(", ")", "\n", "err", "=", "filepath", ".", "Walk", "(", "source", ",", "func", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "path", "==", "source", "{", "return", "nil", "\n", "}", "\n", "header", ",", "err", ":=", "zip", ".", "FileInfoHeader", "(", "info", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "header", ".", "Name", ",", "err", "=", "filepath", ".", "Rel", "(", "source", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "header", ".", "Name", "=", "filepath", ".", "ToSlash", "(", "header", ".", "Name", ")", "\n", "if", "info", ".", "IsDir", "(", ")", "{", "header", ".", "Name", "+=", "\"/\"", "\n", "header", ".", "SetMode", "(", "0755", ")", "\n", "}", "else", "{", "header", ".", "Method", "=", "zip", ".", "Deflate", "\n", "header", ".", "SetMode", "(", "0744", ")", "\n", "}", "\n", "writer", ",", "err", ":=", "archive", ".", "CreateHeader", "(", "header", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "info", ".", "IsDir", "(", ")", "{", "return", "nil", "\n", "}", "\n", "file", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "writer", ",", "file", ")", "\n", "return", "err", "\n", "}", ")", "\n", "return", "err", "\n", "}" ]
// Zipit zips the source into a .zip file in the target dir
[ "Zipit", "zips", "the", "source", "into", "a", ".", "zip", "file", "in", "the", "target", "dir" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L193-L261
train
cloudfoundry/cli
api/cloudcontroller/ccv2/filter.go
ConvertFilterParameters
func ConvertFilterParameters(filters []Filter) url.Values { params := url.Values{"q": []string{}} for _, filter := range filters { params["q"] = append(params["q"], filter.format()) } return params }
go
func ConvertFilterParameters(filters []Filter) url.Values { params := url.Values{"q": []string{}} for _, filter := range filters { params["q"] = append(params["q"], filter.format()) } return params }
[ "func", "ConvertFilterParameters", "(", "filters", "[", "]", "Filter", ")", "url", ".", "Values", "{", "params", ":=", "url", ".", "Values", "{", "\"q\"", ":", "[", "]", "string", "{", "}", "}", "\n", "for", "_", ",", "filter", ":=", "range", "filters", "{", "params", "[", "\"q\"", "]", "=", "append", "(", "params", "[", "\"q\"", "]", ",", "filter", ".", "format", "(", ")", ")", "\n", "}", "\n", "return", "params", "\n", "}" ]
// ConvertFilterParameters converts a Filter object into a collection that // cloudcontroller.Request can accept.
[ "ConvertFilterParameters", "converts", "a", "Filter", "object", "into", "a", "collection", "that", "cloudcontroller", ".", "Request", "can", "accept", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/filter.go#L30-L37
train
cloudfoundry/cli
actor/pluginaction/plugin_info.go
GetPluginInfoFromRepositoriesForPlatform
func (actor Actor) GetPluginInfoFromRepositoriesForPlatform(pluginName string, pluginRepos []configv3.PluginRepository, platform string) (PluginInfo, []string, error) { var reposWithPlugin []string var newestPluginInfo PluginInfo var pluginFoundWithIncompatibleBinary bool for _, repo := range pluginRepos { pluginInfo, err := actor.getPluginInfoFromRepositoryForPlatform(pluginName, repo, platform) switch err.(type) { case actionerror.PluginNotFoundInRepositoryError: continue case actionerror.NoCompatibleBinaryError: pluginFoundWithIncompatibleBinary = true continue case nil: if len(reposWithPlugin) == 0 || lessThan(newestPluginInfo.Version, pluginInfo.Version) { newestPluginInfo = pluginInfo reposWithPlugin = []string{repo.Name} } else if pluginInfo.Version == newestPluginInfo.Version { reposWithPlugin = append(reposWithPlugin, repo.Name) } default: return PluginInfo{}, nil, actionerror.FetchingPluginInfoFromRepositoryError{ RepositoryName: repo.Name, Err: err, } } } if len(reposWithPlugin) == 0 { if pluginFoundWithIncompatibleBinary { return PluginInfo{}, nil, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, nil, actionerror.PluginNotFoundInAnyRepositoryError{PluginName: pluginName} } return newestPluginInfo, reposWithPlugin, nil }
go
func (actor Actor) GetPluginInfoFromRepositoriesForPlatform(pluginName string, pluginRepos []configv3.PluginRepository, platform string) (PluginInfo, []string, error) { var reposWithPlugin []string var newestPluginInfo PluginInfo var pluginFoundWithIncompatibleBinary bool for _, repo := range pluginRepos { pluginInfo, err := actor.getPluginInfoFromRepositoryForPlatform(pluginName, repo, platform) switch err.(type) { case actionerror.PluginNotFoundInRepositoryError: continue case actionerror.NoCompatibleBinaryError: pluginFoundWithIncompatibleBinary = true continue case nil: if len(reposWithPlugin) == 0 || lessThan(newestPluginInfo.Version, pluginInfo.Version) { newestPluginInfo = pluginInfo reposWithPlugin = []string{repo.Name} } else if pluginInfo.Version == newestPluginInfo.Version { reposWithPlugin = append(reposWithPlugin, repo.Name) } default: return PluginInfo{}, nil, actionerror.FetchingPluginInfoFromRepositoryError{ RepositoryName: repo.Name, Err: err, } } } if len(reposWithPlugin) == 0 { if pluginFoundWithIncompatibleBinary { return PluginInfo{}, nil, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, nil, actionerror.PluginNotFoundInAnyRepositoryError{PluginName: pluginName} } return newestPluginInfo, reposWithPlugin, nil }
[ "func", "(", "actor", "Actor", ")", "GetPluginInfoFromRepositoriesForPlatform", "(", "pluginName", "string", ",", "pluginRepos", "[", "]", "configv3", ".", "PluginRepository", ",", "platform", "string", ")", "(", "PluginInfo", ",", "[", "]", "string", ",", "error", ")", "{", "var", "reposWithPlugin", "[", "]", "string", "\n", "var", "newestPluginInfo", "PluginInfo", "\n", "var", "pluginFoundWithIncompatibleBinary", "bool", "\n", "for", "_", ",", "repo", ":=", "range", "pluginRepos", "{", "pluginInfo", ",", "err", ":=", "actor", ".", "getPluginInfoFromRepositoryForPlatform", "(", "pluginName", ",", "repo", ",", "platform", ")", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "actionerror", ".", "PluginNotFoundInRepositoryError", ":", "continue", "\n", "case", "actionerror", ".", "NoCompatibleBinaryError", ":", "pluginFoundWithIncompatibleBinary", "=", "true", "\n", "continue", "\n", "case", "nil", ":", "if", "len", "(", "reposWithPlugin", ")", "==", "0", "||", "lessThan", "(", "newestPluginInfo", ".", "Version", ",", "pluginInfo", ".", "Version", ")", "{", "newestPluginInfo", "=", "pluginInfo", "\n", "reposWithPlugin", "=", "[", "]", "string", "{", "repo", ".", "Name", "}", "\n", "}", "else", "if", "pluginInfo", ".", "Version", "==", "newestPluginInfo", ".", "Version", "{", "reposWithPlugin", "=", "append", "(", "reposWithPlugin", ",", "repo", ".", "Name", ")", "\n", "}", "\n", "default", ":", "return", "PluginInfo", "{", "}", ",", "nil", ",", "actionerror", ".", "FetchingPluginInfoFromRepositoryError", "{", "RepositoryName", ":", "repo", ".", "Name", ",", "Err", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n", "if", "len", "(", "reposWithPlugin", ")", "==", "0", "{", "if", "pluginFoundWithIncompatibleBinary", "{", "return", "PluginInfo", "{", "}", ",", "nil", ",", "actionerror", ".", "NoCompatibleBinaryError", "{", "}", "\n", "}", "\n", "return", "PluginInfo", "{", "}", ",", "nil", ",", "actionerror", ".", "PluginNotFoundInAnyRepositoryError", "{", "PluginName", ":", "pluginName", "}", "\n", "}", "\n", "return", "newestPluginInfo", ",", "reposWithPlugin", ",", "nil", "\n", "}" ]
// GetPluginInfoFromRepositoriesForPlatform returns the newest version of the specified plugin // and all the repositories that contain that version.
[ "GetPluginInfoFromRepositoriesForPlatform", "returns", "the", "newest", "version", "of", "the", "specified", "plugin", "and", "all", "the", "repositories", "that", "contain", "that", "version", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L20-L55
train
cloudfoundry/cli
actor/pluginaction/plugin_info.go
GetPlatformString
func (actor Actor) GetPlatformString(runtimeGOOS string, runtimeGOARCH string) string { return generic.GeneratePlatform(runtime.GOOS, runtime.GOARCH) }
go
func (actor Actor) GetPlatformString(runtimeGOOS string, runtimeGOARCH string) string { return generic.GeneratePlatform(runtime.GOOS, runtime.GOARCH) }
[ "func", "(", "actor", "Actor", ")", "GetPlatformString", "(", "runtimeGOOS", "string", ",", "runtimeGOARCH", "string", ")", "string", "{", "return", "generic", ".", "GeneratePlatform", "(", "runtime", ".", "GOOS", ",", "runtime", ".", "GOARCH", ")", "\n", "}" ]
// GetPlatformString exists solely for the purposes of mocking it out for command-layers tests.
[ "GetPlatformString", "exists", "solely", "for", "the", "purposes", "of", "mocking", "it", "out", "for", "command", "-", "layers", "tests", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L58-L60
train
cloudfoundry/cli
actor/pluginaction/plugin_info.go
getPluginInfoFromRepositoryForPlatform
func (actor Actor) getPluginInfoFromRepositoryForPlatform(pluginName string, pluginRepo configv3.PluginRepository, platform string) (PluginInfo, error) { pluginRepository, err := actor.client.GetPluginRepository(pluginRepo.URL) if err != nil { return PluginInfo{}, err } var pluginFoundWithIncompatibleBinary bool for _, plugin := range pluginRepository.Plugins { if plugin.Name == pluginName { for _, pluginBinary := range plugin.Binaries { if pluginBinary.Platform == platform { return PluginInfo{ Name: plugin.Name, Version: plugin.Version, URL: pluginBinary.URL, Checksum: pluginBinary.Checksum, }, nil } } pluginFoundWithIncompatibleBinary = true } } if pluginFoundWithIncompatibleBinary { return PluginInfo{}, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, actionerror.PluginNotFoundInRepositoryError{ PluginName: pluginName, RepositoryName: pluginRepo.Name, } }
go
func (actor Actor) getPluginInfoFromRepositoryForPlatform(pluginName string, pluginRepo configv3.PluginRepository, platform string) (PluginInfo, error) { pluginRepository, err := actor.client.GetPluginRepository(pluginRepo.URL) if err != nil { return PluginInfo{}, err } var pluginFoundWithIncompatibleBinary bool for _, plugin := range pluginRepository.Plugins { if plugin.Name == pluginName { for _, pluginBinary := range plugin.Binaries { if pluginBinary.Platform == platform { return PluginInfo{ Name: plugin.Name, Version: plugin.Version, URL: pluginBinary.URL, Checksum: pluginBinary.Checksum, }, nil } } pluginFoundWithIncompatibleBinary = true } } if pluginFoundWithIncompatibleBinary { return PluginInfo{}, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, actionerror.PluginNotFoundInRepositoryError{ PluginName: pluginName, RepositoryName: pluginRepo.Name, } }
[ "func", "(", "actor", "Actor", ")", "getPluginInfoFromRepositoryForPlatform", "(", "pluginName", "string", ",", "pluginRepo", "configv3", ".", "PluginRepository", ",", "platform", "string", ")", "(", "PluginInfo", ",", "error", ")", "{", "pluginRepository", ",", "err", ":=", "actor", ".", "client", ".", "GetPluginRepository", "(", "pluginRepo", ".", "URL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "PluginInfo", "{", "}", ",", "err", "\n", "}", "\n", "var", "pluginFoundWithIncompatibleBinary", "bool", "\n", "for", "_", ",", "plugin", ":=", "range", "pluginRepository", ".", "Plugins", "{", "if", "plugin", ".", "Name", "==", "pluginName", "{", "for", "_", ",", "pluginBinary", ":=", "range", "plugin", ".", "Binaries", "{", "if", "pluginBinary", ".", "Platform", "==", "platform", "{", "return", "PluginInfo", "{", "Name", ":", "plugin", ".", "Name", ",", "Version", ":", "plugin", ".", "Version", ",", "URL", ":", "pluginBinary", ".", "URL", ",", "Checksum", ":", "pluginBinary", ".", "Checksum", ",", "}", ",", "nil", "\n", "}", "\n", "}", "\n", "pluginFoundWithIncompatibleBinary", "=", "true", "\n", "}", "\n", "}", "\n", "if", "pluginFoundWithIncompatibleBinary", "{", "return", "PluginInfo", "{", "}", ",", "actionerror", ".", "NoCompatibleBinaryError", "{", "}", "\n", "}", "\n", "return", "PluginInfo", "{", "}", ",", "actionerror", ".", "PluginNotFoundInRepositoryError", "{", "PluginName", ":", "pluginName", ",", "RepositoryName", ":", "pluginRepo", ".", "Name", ",", "}", "\n", "}" ]
// getPluginInfoFromRepositoryForPlatform returns the plugin info, if found, from // the specified repository for the specified platform.
[ "getPluginInfoFromRepositoryForPlatform", "returns", "the", "plugin", "info", "if", "found", "from", "the", "specified", "repository", "for", "the", "specified", "platform", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L64-L96
train
cloudfoundry/cli
util/generic/executable_filename_windows.go
ExecutableFilename
func ExecutableFilename(name string) string { if strings.HasSuffix(name, ".exe") { return name } return fmt.Sprintf("%s.exe", name) }
go
func ExecutableFilename(name string) string { if strings.HasSuffix(name, ".exe") { return name } return fmt.Sprintf("%s.exe", name) }
[ "func", "ExecutableFilename", "(", "name", "string", ")", "string", "{", "if", "strings", ".", "HasSuffix", "(", "name", ",", "\".exe\"", ")", "{", "return", "name", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"%s.exe\"", ",", "name", ")", "\n", "}" ]
// ExecutableFilename appends '.exe' to a filename when necessary in order to // make it executable on Windows
[ "ExecutableFilename", "appends", ".", "exe", "to", "a", "filename", "when", "necessary", "in", "order", "to", "make", "it", "executable", "on", "Windows" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/generic/executable_filename_windows.go#L12-L17
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship_list.go
EntitleIsolationSegmentToOrganizations
func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: organizationGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostIsolationSegmentRelationshipOrganizationsRequest, URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
go
func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: organizationGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostIsolationSegmentRelationshipOrganizationsRequest, URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "EntitleIsolationSegmentToOrganizations", "(", "isolationSegmentGUID", "string", ",", "organizationGUIDs", "[", "]", "string", ")", "(", "RelationshipList", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "RelationshipList", "{", "GUIDs", ":", "organizationGUIDs", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostIsolationSegmentRelationshipOrganizationsRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"isolation_segment_guid\"", ":", "isolationSegmentGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "relationships", "RelationshipList", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationships", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationships", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// EntitleIsolationSegmentToOrganizations will create a link between the // isolation segment and the list of organizations provided.
[ "EntitleIsolationSegmentToOrganizations", "will", "create", "a", "link", "between", "the", "isolation", "segment", "and", "the", "list", "of", "organizations", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship_list.go#L50-L72
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship_list.go
ShareServiceInstanceToSpaces
func (client *Client) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: spaceGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceInstanceRelationshipsSharedSpacesRequest, URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
go
func (client *Client) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: spaceGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceInstanceRelationshipsSharedSpacesRequest, URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "ShareServiceInstanceToSpaces", "(", "serviceInstanceGUID", "string", ",", "spaceGUIDs", "[", "]", "string", ")", "(", "RelationshipList", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "RelationshipList", "{", "GUIDs", ":", "spaceGUIDs", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostServiceInstanceRelationshipsSharedSpacesRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"service_instance_guid\"", ":", "serviceInstanceGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "relationships", "RelationshipList", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationships", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationships", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// ShareServiceInstanceToSpaces will create a sharing relationship between // the service instance and the shared-to space for each space provided.
[ "ShareServiceInstanceToSpaces", "will", "create", "a", "sharing", "relationship", "between", "the", "service", "instance", "and", "the", "shared", "-", "to", "space", "for", "each", "space", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship_list.go#L76-L99
train
cloudfoundry/cli
util/panichandler/handler.go
HandlePanic
func HandlePanic() { stackTraceBytes := make([]byte, maxStackSizeLimit) runtime.Stack(stackTraceBytes, true) stackTrace := "\t" + strings.Replace(string(stackTraceBytes), "\n", "\n\t", -1) if err := recover(); err != nil { formattedString := ` Something unexpected happened. This is a bug in {{.Binary}}. Please re-run the command that caused this exception with the environment variable CF_TRACE set to true. Also, please update to the latest cli and try the command again: https://code.cloudfoundry.org/cli/releases Please create an issue at: https://code.cloudfoundry.org/cli/issues Include the below information when creating the issue: Command {{.Command}} CLI Version {{.Version}} Error {{.Error}} Stack Trace {{.StackTrace}} Your Platform Details e.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit Shell e.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator ` formattedTemplate := template.Must(template.New("Panic Template").Parse(formattedString)) templateErr := formattedTemplate.Execute(os.Stderr, map[string]interface{}{ "Binary": os.Args[0], "Command": strings.Join(os.Args, " "), "Version": version.VersionString(), "StackTrace": stackTrace, "Error": err, }) if templateErr != nil { fmt.Fprintf(os.Stderr, "Unable to format panic response: %s\n", templateErr.Error(), ) fmt.Fprintf(os.Stderr, "Version:%s\nCommand:%s\nOriginal Stack Trace:%s\nOriginal Error:%s\n", version.VersionString(), strings.Join(os.Args, " "), stackTrace, err, ) } os.Exit(1) } }
go
func HandlePanic() { stackTraceBytes := make([]byte, maxStackSizeLimit) runtime.Stack(stackTraceBytes, true) stackTrace := "\t" + strings.Replace(string(stackTraceBytes), "\n", "\n\t", -1) if err := recover(); err != nil { formattedString := ` Something unexpected happened. This is a bug in {{.Binary}}. Please re-run the command that caused this exception with the environment variable CF_TRACE set to true. Also, please update to the latest cli and try the command again: https://code.cloudfoundry.org/cli/releases Please create an issue at: https://code.cloudfoundry.org/cli/issues Include the below information when creating the issue: Command {{.Command}} CLI Version {{.Version}} Error {{.Error}} Stack Trace {{.StackTrace}} Your Platform Details e.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit Shell e.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator ` formattedTemplate := template.Must(template.New("Panic Template").Parse(formattedString)) templateErr := formattedTemplate.Execute(os.Stderr, map[string]interface{}{ "Binary": os.Args[0], "Command": strings.Join(os.Args, " "), "Version": version.VersionString(), "StackTrace": stackTrace, "Error": err, }) if templateErr != nil { fmt.Fprintf(os.Stderr, "Unable to format panic response: %s\n", templateErr.Error(), ) fmt.Fprintf(os.Stderr, "Version:%s\nCommand:%s\nOriginal Stack Trace:%s\nOriginal Error:%s\n", version.VersionString(), strings.Join(os.Args, " "), stackTrace, err, ) } os.Exit(1) } }
[ "func", "HandlePanic", "(", ")", "{", "stackTraceBytes", ":=", "make", "(", "[", "]", "byte", ",", "maxStackSizeLimit", ")", "\n", "runtime", ".", "Stack", "(", "stackTraceBytes", ",", "true", ")", "\n", "stackTrace", ":=", "\"\\t\"", "+", "\\t", "\n", "strings", ".", "Replace", "(", "string", "(", "stackTraceBytes", ")", ",", "\"\\n\"", ",", "\\n", ",", "\"\\n\\t\"", ")", "\n", "}" ]
// HandlePanic will recover from any panics and display a friendly error // message with additional information used for debugging the panic.
[ "HandlePanic", "will", "recover", "from", "any", "panics", "and", "display", "a", "friendly", "error", "message", "with", "additional", "information", "used", "for", "debugging", "the", "panic", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/panichandler/handler.go#L17-L77
train
cloudfoundry/cli
api/cloudcontroller/ccv2/domain.go
UnmarshalJSON
func (domain *Domain) UnmarshalJSON(data []byte) error { var ccDomain struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` RouterGroupGUID string `json:"router_group_guid"` RouterGroupType string `json:"router_group_type"` Internal bool `json:"internal"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccDomain) if err != nil { return err } domain.GUID = ccDomain.Metadata.GUID domain.Name = ccDomain.Entity.Name domain.RouterGroupGUID = ccDomain.Entity.RouterGroupGUID domain.RouterGroupType = constant.RouterGroupType(ccDomain.Entity.RouterGroupType) domain.Internal = ccDomain.Entity.Internal return nil }
go
func (domain *Domain) UnmarshalJSON(data []byte) error { var ccDomain struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` RouterGroupGUID string `json:"router_group_guid"` RouterGroupType string `json:"router_group_type"` Internal bool `json:"internal"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccDomain) if err != nil { return err } domain.GUID = ccDomain.Metadata.GUID domain.Name = ccDomain.Entity.Name domain.RouterGroupGUID = ccDomain.Entity.RouterGroupGUID domain.RouterGroupType = constant.RouterGroupType(ccDomain.Entity.RouterGroupType) domain.Internal = ccDomain.Entity.Internal return nil }
[ "func", "(", "domain", "*", "Domain", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccDomain", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "RouterGroupGUID", "string", "`json:\"router_group_guid\"`", "\n", "RouterGroupType", "string", "`json:\"router_group_type\"`", "\n", "Internal", "bool", "`json:\"internal\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccDomain", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "domain", ".", "GUID", "=", "ccDomain", ".", "Metadata", ".", "GUID", "\n", "domain", ".", "Name", "=", "ccDomain", ".", "Entity", ".", "Name", "\n", "domain", ".", "RouterGroupGUID", "=", "ccDomain", ".", "Entity", ".", "RouterGroupGUID", "\n", "domain", ".", "RouterGroupType", "=", "constant", ".", "RouterGroupType", "(", "ccDomain", ".", "Entity", ".", "RouterGroupType", ")", "\n", "domain", ".", "Internal", "=", "ccDomain", ".", "Entity", ".", "Internal", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Domain response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Domain", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L38-L59
train