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
beego/bee
logger/logger.go
Warnf
func (l *BeeLogger) Warnf(message string, vars ...interface{}) { l.mustLog(levelWarn, message, vars...) }
go
func (l *BeeLogger) Warnf(message string, vars ...interface{}) { l.mustLog(levelWarn, message, vars...) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Warnf", "(", "message", "string", ",", "vars", "...", "interface", "{", "}", ")", "{", "l", ".", "mustLog", "(", "levelWarn", ",", "message", ",", "vars", "...", ")", "\n", "}" ]
// Warnf outputs a formatted warning log message
[ "Warnf", "outputs", "a", "formatted", "warning", "log", "message" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L240-L242
train
beego/bee
logger/logger.go
Errorf
func (l *BeeLogger) Errorf(message string, vars ...interface{}) { l.mustLog(levelError, message, vars...) }
go
func (l *BeeLogger) Errorf(message string, vars ...interface{}) { l.mustLog(levelError, message, vars...) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Errorf", "(", "message", "string", ",", "vars", "...", "interface", "{", "}", ")", "{", "l", ".", "mustLog", "(", "levelError", ",", "message", ",", "vars", "...", ")", "\n", "}" ]
// Errorf outputs a formatted error log message
[ "Errorf", "outputs", "a", "formatted", "error", "log", "message" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L250-L252
train
beego/bee
logger/logger.go
Fatal
func (l *BeeLogger) Fatal(message string) { l.mustLog(levelFatal, message) os.Exit(255) }
go
func (l *BeeLogger) Fatal(message string) { l.mustLog(levelFatal, message) os.Exit(255) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Fatal", "(", "message", "string", ")", "{", "l", ".", "mustLog", "(", "levelFatal", ",", "message", ")", "\n", "os", ".", "Exit", "(", "255", ")", "\n", "}" ]
// Fatal outputs a fatal log message and exists
[ "Fatal", "outputs", "a", "fatal", "log", "message", "and", "exists" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L255-L258
train
beego/bee
logger/logger.go
Fatalf
func (l *BeeLogger) Fatalf(message string, vars ...interface{}) { l.mustLog(levelFatal, message, vars...) os.Exit(255) }
go
func (l *BeeLogger) Fatalf(message string, vars ...interface{}) { l.mustLog(levelFatal, message, vars...) os.Exit(255) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Fatalf", "(", "message", "string", ",", "vars", "...", "interface", "{", "}", ")", "{", "l", ".", "mustLog", "(", "levelFatal", ",", "message", ",", "vars", "...", ")", "\n", "os", ".", "Exit", "(", "255", ")", "\n", "}" ]
// Fatalf outputs a formatted log message and exists
[ "Fatalf", "outputs", "a", "formatted", "log", "message", "and", "exists" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L261-L264
train
beego/bee
logger/logger.go
Successf
func (l *BeeLogger) Successf(message string, vars ...interface{}) { l.mustLog(levelSuccess, message, vars...) }
go
func (l *BeeLogger) Successf(message string, vars ...interface{}) { l.mustLog(levelSuccess, message, vars...) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Successf", "(", "message", "string", ",", "vars", "...", "interface", "{", "}", ")", "{", "l", ".", "mustLog", "(", "levelSuccess", ",", "message", ",", "vars", "...", ")", "\n", "}" ]
// Successf outputs a formatted success log message
[ "Successf", "outputs", "a", "formatted", "success", "log", "message" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L272-L274
train
beego/bee
logger/logger.go
Hintf
func (l *BeeLogger) Hintf(message string, vars ...interface{}) { l.mustLog(levelHint, message, vars...) }
go
func (l *BeeLogger) Hintf(message string, vars ...interface{}) { l.mustLog(levelHint, message, vars...) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Hintf", "(", "message", "string", ",", "vars", "...", "interface", "{", "}", ")", "{", "l", ".", "mustLog", "(", "levelHint", ",", "message", ",", "vars", "...", ")", "\n", "}" ]
// Hintf outputs a formatted hint log message
[ "Hintf", "outputs", "a", "formatted", "hint", "log", "message" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L282-L284
train
beego/bee
logger/logger.go
Criticalf
func (l *BeeLogger) Criticalf(message string, vars ...interface{}) { l.mustLog(levelCritical, message, vars...) }
go
func (l *BeeLogger) Criticalf(message string, vars ...interface{}) { l.mustLog(levelCritical, message, vars...) }
[ "func", "(", "l", "*", "BeeLogger", ")", "Criticalf", "(", "message", "string", ",", "vars", "...", "interface", "{", "}", ")", "{", "l", ".", "mustLog", "(", "levelCritical", ",", "message", ",", "vars", "...", ")", "\n", "}" ]
// Criticalf outputs a formatted critical log message
[ "Criticalf", "outputs", "a", "formatted", "critical", "log", "message" ]
6a86284cec9a17f9aae6fe82ecf3c436aafed68d
https://github.com/beego/bee/blob/6a86284cec9a17f9aae6fe82ecf3c436aafed68d/logger/logger.go#L292-L294
train
cloudfoundry/cli
actor/v3action/organization.go
GetOrganizationByName
func (actor Actor) GetOrganizationByName(name string) (Organization, Warnings, error) { orgs, warnings, err := actor.CloudControllerClient.GetOrganizations( ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, ) if err != nil { return Organization{}, Warnings(warnings), err } if len(orgs) == 0 { return Organization{}, Warnings(warnings), actionerror.OrganizationNotFoundError{Name: name} } return Organization(orgs[0]), Warnings(warnings), nil }
go
func (actor Actor) GetOrganizationByName(name string) (Organization, Warnings, error) { orgs, warnings, err := actor.CloudControllerClient.GetOrganizations( ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}}, ) if err != nil { return Organization{}, Warnings(warnings), err } if len(orgs) == 0 { return Organization{}, Warnings(warnings), actionerror.OrganizationNotFoundError{Name: name} } return Organization(orgs[0]), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetOrganizationByName", "(", "name", "string", ")", "(", "Organization", ",", "Warnings", ",", "error", ")", "{", "orgs", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetOrganizations", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "NameFilter", ",", "Values", ":", "[", "]", "string", "{", "name", "}", "}", ",", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Organization", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "if", "len", "(", "orgs", ")", "==", "0", "{", "return", "Organization", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "OrganizationNotFoundError", "{", "Name", ":", "name", "}", "\n", "}", "\n", "return", "Organization", "(", "orgs", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetOrganizationByName returns the organization with the given name.
[ "GetOrganizationByName", "returns", "the", "organization", "with", "the", "given", "name", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/organization.go#L14-L27
train
cloudfoundry/cli
util/configv3/json_config.go
SetOrganizationInformation
func (config *Config) SetOrganizationInformation(guid string, name string) { config.ConfigFile.TargetedOrganization.GUID = guid config.ConfigFile.TargetedOrganization.Name = name config.ConfigFile.TargetedOrganization.QuotaDefinition = QuotaDefinition{} }
go
func (config *Config) SetOrganizationInformation(guid string, name string) { config.ConfigFile.TargetedOrganization.GUID = guid config.ConfigFile.TargetedOrganization.Name = name config.ConfigFile.TargetedOrganization.QuotaDefinition = QuotaDefinition{} }
[ "func", "(", "config", "*", "Config", ")", "SetOrganizationInformation", "(", "guid", "string", ",", "name", "string", ")", "{", "config", ".", "ConfigFile", ".", "TargetedOrganization", ".", "GUID", "=", "guid", "\n", "config", ".", "ConfigFile", ".", "TargetedOrganization", ".", "Name", "=", "name", "\n", "config", ".", "ConfigFile", ".", "TargetedOrganization", ".", "QuotaDefinition", "=", "QuotaDefinition", "{", "}", "\n", "}" ]
// SetOrganizationInformation sets the currently targeted organization.
[ "SetOrganizationInformation", "sets", "the", "currently", "targeted", "organization", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L140-L144
train
cloudfoundry/cli
util/configv3/json_config.go
SetSpaceInformation
func (config *Config) SetSpaceInformation(guid string, name string, allowSSH bool) { config.V7SetSpaceInformation(guid, name) config.ConfigFile.TargetedSpace.AllowSSH = allowSSH }
go
func (config *Config) SetSpaceInformation(guid string, name string, allowSSH bool) { config.V7SetSpaceInformation(guid, name) config.ConfigFile.TargetedSpace.AllowSSH = allowSSH }
[ "func", "(", "config", "*", "Config", ")", "SetSpaceInformation", "(", "guid", "string", ",", "name", "string", ",", "allowSSH", "bool", ")", "{", "config", ".", "V7SetSpaceInformation", "(", "guid", ",", "name", ")", "\n", "config", ".", "ConfigFile", ".", "TargetedSpace", ".", "AllowSSH", "=", "allowSSH", "\n", "}" ]
// SetSpaceInformation sets the currently targeted space.
[ "SetSpaceInformation", "sets", "the", "currently", "targeted", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L152-L155
train
cloudfoundry/cli
util/configv3/json_config.go
SetTargetInformation
func (config *Config) SetTargetInformation(api string, apiVersion string, auth string, minCLIVersion string, doppler string, routing string, skipSSLValidation bool) { config.ConfigFile.Target = api config.ConfigFile.APIVersion = apiVersion config.ConfigFile.AuthorizationEndpoint = auth config.SetMinCLIVersion(minCLIVersion) config.ConfigFile.DopplerEndpoint = doppler config.ConfigFile.RoutingEndpoint = routing config.ConfigFile.SkipSSLValidation = skipSSLValidation config.UnsetOrganizationAndSpaceInformation() }
go
func (config *Config) SetTargetInformation(api string, apiVersion string, auth string, minCLIVersion string, doppler string, routing string, skipSSLValidation bool) { config.ConfigFile.Target = api config.ConfigFile.APIVersion = apiVersion config.ConfigFile.AuthorizationEndpoint = auth config.SetMinCLIVersion(minCLIVersion) config.ConfigFile.DopplerEndpoint = doppler config.ConfigFile.RoutingEndpoint = routing config.ConfigFile.SkipSSLValidation = skipSSLValidation config.UnsetOrganizationAndSpaceInformation() }
[ "func", "(", "config", "*", "Config", ")", "SetTargetInformation", "(", "api", "string", ",", "apiVersion", "string", ",", "auth", "string", ",", "minCLIVersion", "string", ",", "doppler", "string", ",", "routing", "string", ",", "skipSSLValidation", "bool", ")", "{", "config", ".", "ConfigFile", ".", "Target", "=", "api", "\n", "config", ".", "ConfigFile", ".", "APIVersion", "=", "apiVersion", "\n", "config", ".", "ConfigFile", ".", "AuthorizationEndpoint", "=", "auth", "\n", "config", ".", "SetMinCLIVersion", "(", "minCLIVersion", ")", "\n", "config", ".", "ConfigFile", ".", "DopplerEndpoint", "=", "doppler", "\n", "config", ".", "ConfigFile", ".", "RoutingEndpoint", "=", "routing", "\n", "config", ".", "ConfigFile", ".", "SkipSSLValidation", "=", "skipSSLValidation", "\n", "config", ".", "UnsetOrganizationAndSpaceInformation", "(", ")", "\n", "}" ]
// SetTargetInformation sets the currently targeted CC API and related other // related API URLs.
[ "SetTargetInformation", "sets", "the", "currently", "targeted", "CC", "API", "and", "related", "other", "related", "API", "URLs", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L159-L169
train
cloudfoundry/cli
util/configv3/json_config.go
SetUAAClientCredentials
func (config *Config) SetUAAClientCredentials(client string, clientSecret string) { config.ConfigFile.UAAOAuthClient = client config.ConfigFile.UAAOAuthClientSecret = clientSecret }
go
func (config *Config) SetUAAClientCredentials(client string, clientSecret string) { config.ConfigFile.UAAOAuthClient = client config.ConfigFile.UAAOAuthClientSecret = clientSecret }
[ "func", "(", "config", "*", "Config", ")", "SetUAAClientCredentials", "(", "client", "string", ",", "clientSecret", "string", ")", "{", "config", ".", "ConfigFile", ".", "UAAOAuthClient", "=", "client", "\n", "config", ".", "ConfigFile", ".", "UAAOAuthClientSecret", "=", "clientSecret", "\n", "}" ]
// SetUAAClientCredentials sets the client credentials.
[ "SetUAAClientCredentials", "sets", "the", "client", "credentials", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L179-L182
train
cloudfoundry/cli
util/configv3/json_config.go
V7SetSpaceInformation
func (config *Config) V7SetSpaceInformation(guid string, name string) { config.ConfigFile.TargetedSpace.GUID = guid config.ConfigFile.TargetedSpace.Name = name }
go
func (config *Config) V7SetSpaceInformation(guid string, name string) { config.ConfigFile.TargetedSpace.GUID = guid config.ConfigFile.TargetedSpace.Name = name }
[ "func", "(", "config", "*", "Config", ")", "V7SetSpaceInformation", "(", "guid", "string", ",", "name", "string", ")", "{", "config", ".", "ConfigFile", ".", "TargetedSpace", ".", "GUID", "=", "guid", "\n", "config", ".", "ConfigFile", ".", "TargetedSpace", ".", "Name", "=", "name", "\n", "}" ]
// V7SetSpaceInformation sets the currently targeted space.
[ "V7SetSpaceInformation", "sets", "the", "currently", "targeted", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/json_config.go#L268-L271
train
cloudfoundry/cli
actor/v3action/actor.go
NewActor
func NewActor(client CloudControllerClient, config Config, sharedActor SharedActor, uaaClient UAAClient) *Actor { return &Actor{ CloudControllerClient: client, Config: config, SharedActor: sharedActor, UAAClient: uaaClient, } }
go
func NewActor(client CloudControllerClient, config Config, sharedActor SharedActor, uaaClient UAAClient) *Actor { return &Actor{ CloudControllerClient: client, Config: config, SharedActor: sharedActor, UAAClient: uaaClient, } }
[ "func", "NewActor", "(", "client", "CloudControllerClient", ",", "config", "Config", ",", "sharedActor", "SharedActor", ",", "uaaClient", "UAAClient", ")", "*", "Actor", "{", "return", "&", "Actor", "{", "CloudControllerClient", ":", "client", ",", "Config", ":", "config", ",", "SharedActor", ":", "sharedActor", ",", "UAAClient", ":", "uaaClient", ",", "}", "\n", "}" ]
// NewActor returns a new V3 actor.
[ "NewActor", "returns", "a", "new", "V3", "actor", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/actor.go#L24-L31
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_binding.go
UnmarshalJSON
func (serviceBinding *ServiceBinding) UnmarshalJSON(data []byte) error { var ccServiceBinding struct { Metadata internal.Metadata Entity struct { AppGUID string `json:"app_guid"` ServiceInstanceGUID string `json:"service_instance_guid"` Name string `json:"name"` LastOperation LastOperation `json:"last_operation"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccServiceBinding) if err != nil { return err } serviceBinding.AppGUID = ccServiceBinding.Entity.AppGUID serviceBinding.GUID = ccServiceBinding.Metadata.GUID serviceBinding.ServiceInstanceGUID = ccServiceBinding.Entity.ServiceInstanceGUID serviceBinding.Name = ccServiceBinding.Entity.Name serviceBinding.LastOperation = ccServiceBinding.Entity.LastOperation return nil }
go
func (serviceBinding *ServiceBinding) UnmarshalJSON(data []byte) error { var ccServiceBinding struct { Metadata internal.Metadata Entity struct { AppGUID string `json:"app_guid"` ServiceInstanceGUID string `json:"service_instance_guid"` Name string `json:"name"` LastOperation LastOperation `json:"last_operation"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccServiceBinding) if err != nil { return err } serviceBinding.AppGUID = ccServiceBinding.Entity.AppGUID serviceBinding.GUID = ccServiceBinding.Metadata.GUID serviceBinding.ServiceInstanceGUID = ccServiceBinding.Entity.ServiceInstanceGUID serviceBinding.Name = ccServiceBinding.Entity.Name serviceBinding.LastOperation = ccServiceBinding.Entity.LastOperation return nil }
[ "func", "(", "serviceBinding", "*", "ServiceBinding", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccServiceBinding", "struct", "{", "Metadata", "internal", ".", "Metadata", "\n", "Entity", "struct", "{", "AppGUID", "string", "`json:\"app_guid\"`", "\n", "ServiceInstanceGUID", "string", "`json:\"service_instance_guid\"`", "\n", "Name", "string", "`json:\"name\"`", "\n", "LastOperation", "LastOperation", "`json:\"last_operation\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccServiceBinding", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "serviceBinding", ".", "AppGUID", "=", "ccServiceBinding", ".", "Entity", ".", "AppGUID", "\n", "serviceBinding", ".", "GUID", "=", "ccServiceBinding", ".", "Metadata", ".", "GUID", "\n", "serviceBinding", ".", "ServiceInstanceGUID", "=", "ccServiceBinding", ".", "Entity", ".", "ServiceInstanceGUID", "\n", "serviceBinding", ".", "Name", "=", "ccServiceBinding", ".", "Entity", ".", "Name", "\n", "serviceBinding", ".", "LastOperation", "=", "ccServiceBinding", ".", "Entity", ".", "LastOperation", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Service Binding response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Service", "Binding", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L29-L50
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_binding.go
DeleteServiceBinding
func (client *Client) DeleteServiceBinding(serviceBindingGUID string, acceptsIncomplete bool) (ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceBindingRequest, URIParams: map[string]string{"service_binding_guid": serviceBindingGUID}, Query: url.Values{"accepts_incomplete": {fmt.Sprint(acceptsIncomplete)}}, }) if err != nil { return ServiceBinding{}, nil, err } var response cloudcontroller.Response var serviceBinding ServiceBinding if acceptsIncomplete { response = cloudcontroller.Response{ DecodeJSONResponseInto: &serviceBinding, } } err = client.connection.Make(request, &response) return serviceBinding, response.Warnings, err }
go
func (client *Client) DeleteServiceBinding(serviceBindingGUID string, acceptsIncomplete bool) (ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceBindingRequest, URIParams: map[string]string{"service_binding_guid": serviceBindingGUID}, Query: url.Values{"accepts_incomplete": {fmt.Sprint(acceptsIncomplete)}}, }) if err != nil { return ServiceBinding{}, nil, err } var response cloudcontroller.Response var serviceBinding ServiceBinding if acceptsIncomplete { response = cloudcontroller.Response{ DecodeJSONResponseInto: &serviceBinding, } } err = client.connection.Make(request, &response) return serviceBinding, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteServiceBinding", "(", "serviceBindingGUID", "string", ",", "acceptsIncomplete", "bool", ")", "(", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteServiceBindingRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"service_binding_guid\"", ":", "serviceBindingGUID", "}", ",", "Query", ":", "url", ".", "Values", "{", "\"accepts_incomplete\"", ":", "{", "fmt", ".", "Sprint", "(", "acceptsIncomplete", ")", "}", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "var", "serviceBinding", "ServiceBinding", "\n", "if", "acceptsIncomplete", "{", "response", "=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceBinding", ",", "}", "\n", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "serviceBinding", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteServiceBinding deletes the specified Service Binding. An updated // service binding is returned only if acceptsIncomplete is true.
[ "DeleteServiceBinding", "deletes", "the", "specified", "Service", "Binding", ".", "An", "updated", "service", "binding", "is", "returned", "only", "if", "acceptsIncomplete", "is", "true", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L98-L118
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_binding.go
GetServiceBinding
func (client *Client) GetServiceBinding(guid string) (ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceBindingRequest, URIParams: Params{"service_binding_guid": guid}, }) if err != nil { return ServiceBinding{}, nil, err } var serviceBinding ServiceBinding response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceBinding, } err = client.connection.Make(request, &response) return serviceBinding, response.Warnings, err }
go
func (client *Client) GetServiceBinding(guid string) (ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceBindingRequest, URIParams: Params{"service_binding_guid": guid}, }) if err != nil { return ServiceBinding{}, nil, err } var serviceBinding ServiceBinding response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceBinding, } err = client.connection.Make(request, &response) return serviceBinding, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceBinding", "(", "guid", "string", ")", "(", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceBindingRequest", ",", "URIParams", ":", "Params", "{", "\"service_binding_guid\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceBinding", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "serviceBinding", "ServiceBinding", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceBinding", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "serviceBinding", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetServiceBinding returns back a service binding with the provided GUID.
[ "GetServiceBinding", "returns", "back", "a", "service", "binding", "with", "the", "provided", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L121-L137
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_binding.go
GetServiceBindings
func (client *Client) GetServiceBindings(filters ...Filter) ([]ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceBindingsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullBindingsList []ServiceBinding warnings, err := client.paginate(request, ServiceBinding{}, func(item interface{}) error { if binding, ok := item.(ServiceBinding); ok { fullBindingsList = append(fullBindingsList, binding) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceBinding{}, Unexpected: item, } } return nil }) return fullBindingsList, warnings, err }
go
func (client *Client) GetServiceBindings(filters ...Filter) ([]ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceBindingsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullBindingsList []ServiceBinding warnings, err := client.paginate(request, ServiceBinding{}, func(item interface{}) error { if binding, ok := item.(ServiceBinding); ok { fullBindingsList = append(fullBindingsList, binding) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceBinding{}, Unexpected: item, } } return nil }) return fullBindingsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceBindings", "(", "filters", "...", "Filter", ")", "(", "[", "]", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceBindingsRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullBindingsList", "[", "]", "ServiceBinding", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ServiceBinding", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "binding", ",", "ok", ":=", "item", ".", "(", "ServiceBinding", ")", ";", "ok", "{", "fullBindingsList", "=", "append", "(", "fullBindingsList", ",", "binding", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ServiceBinding", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullBindingsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetServiceBindings returns back a list of Service Bindings based off of the // provided filters.
[ "GetServiceBindings", "returns", "back", "a", "list", "of", "Service", "Bindings", "based", "off", "of", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L141-L164
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_binding.go
GetServiceInstanceServiceBindings
func (client *Client) GetServiceInstanceServiceBindings(serviceInstanceGUID string) ([]ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceServiceBindingsRequest, URIParams: map[string]string{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return nil, nil, err } var fullBindingsList []ServiceBinding warnings, err := client.paginate(request, ServiceBinding{}, func(item interface{}) error { if binding, ok := item.(ServiceBinding); ok { fullBindingsList = append(fullBindingsList, binding) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceBinding{}, Unexpected: item, } } return nil }) return fullBindingsList, warnings, err }
go
func (client *Client) GetServiceInstanceServiceBindings(serviceInstanceGUID string) ([]ServiceBinding, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceServiceBindingsRequest, URIParams: map[string]string{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return nil, nil, err } var fullBindingsList []ServiceBinding warnings, err := client.paginate(request, ServiceBinding{}, func(item interface{}) error { if binding, ok := item.(ServiceBinding); ok { fullBindingsList = append(fullBindingsList, binding) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceBinding{}, Unexpected: item, } } return nil }) return fullBindingsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceInstanceServiceBindings", "(", "serviceInstanceGUID", "string", ")", "(", "[", "]", "ServiceBinding", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceInstanceServiceBindingsRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"service_instance_guid\"", ":", "serviceInstanceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullBindingsList", "[", "]", "ServiceBinding", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ServiceBinding", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "binding", ",", "ok", ":=", "item", ".", "(", "ServiceBinding", ")", ";", "ok", "{", "fullBindingsList", "=", "append", "(", "fullBindingsList", ",", "binding", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ServiceBinding", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullBindingsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetServiceInstanceServiceBindings returns back a list of Service Bindings for the provided service instance GUID.
[ "GetServiceInstanceServiceBindings", "returns", "back", "a", "list", "of", "Service", "Bindings", "for", "the", "provided", "service", "instance", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_binding.go#L167-L190
train
cloudfoundry/cli
api/cloudcontroller/ccv2/feature_flag.go
GetConfigFeatureFlags
func (client Client) GetConfigFeatureFlags() ([]FeatureFlag, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetConfigFeatureFlagsRequest, }) if err != nil { return nil, nil, err } var featureFlags []FeatureFlag response := cloudcontroller.Response{ DecodeJSONResponseInto: &featureFlags, } err = client.connection.Make(request, &response) return featureFlags, response.Warnings, err }
go
func (client Client) GetConfigFeatureFlags() ([]FeatureFlag, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetConfigFeatureFlagsRequest, }) if err != nil { return nil, nil, err } var featureFlags []FeatureFlag response := cloudcontroller.Response{ DecodeJSONResponseInto: &featureFlags, } err = client.connection.Make(request, &response) return featureFlags, response.Warnings, err }
[ "func", "(", "client", "Client", ")", "GetConfigFeatureFlags", "(", ")", "(", "[", "]", "FeatureFlag", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetConfigFeatureFlagsRequest", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "featureFlags", "[", "]", "FeatureFlag", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "featureFlags", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "featureFlags", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetConfigFeatureFlags retrieves a list of FeatureFlag from the Cloud // Controller.
[ "GetConfigFeatureFlags", "retrieves", "a", "list", "of", "FeatureFlag", "from", "the", "Cloud", "Controller", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/feature_flag.go#L21-L36
train
cloudfoundry/cli
api/router/connection_wrapper.go
WrapConnection
func (client *Client) WrapConnection(wrapper ConnectionWrapper) { client.connection = wrapper.Wrap(client.connection) }
go
func (client *Client) WrapConnection(wrapper ConnectionWrapper) { client.connection = wrapper.Wrap(client.connection) }
[ "func", "(", "client", "*", "Client", ")", "WrapConnection", "(", "wrapper", "ConnectionWrapper", ")", "{", "client", ".", "connection", "=", "wrapper", ".", "Wrap", "(", "client", ".", "connection", ")", "\n", "}" ]
// WrapConnection wraps the current Client connection in the wrapper.
[ "WrapConnection", "wraps", "the", "current", "Client", "connection", "in", "the", "wrapper", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/connection_wrapper.go#L13-L15
train
cloudfoundry/cli
actor/v3action/target.go
ClearTarget
func (actor Actor) ClearTarget() { actor.Config.SetTargetInformation("", "", "", "", "", "", false) actor.Config.SetTokenInformation("", "", "") }
go
func (actor Actor) ClearTarget() { actor.Config.SetTargetInformation("", "", "", "", "", "", false) actor.Config.SetTokenInformation("", "", "") }
[ "func", "(", "actor", "Actor", ")", "ClearTarget", "(", ")", "{", "actor", ".", "Config", ".", "SetTargetInformation", "(", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "\"\"", ",", "false", ")", "\n", "actor", ".", "Config", ".", "SetTokenInformation", "(", "\"\"", ",", "\"\"", ",", "\"\"", ")", "\n", "}" ]
// ClearTarget clears target information from the actor.
[ "ClearTarget", "clears", "target", "information", "from", "the", "actor", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/target.go#L43-L46
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
UnmarshalJSON
func (space *Space) UnmarshalJSON(data []byte) error { var ccSpace struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` AllowSSH bool `json:"allow_ssh"` SpaceQuotaDefinitionGUID string `json:"space_quota_definition_guid"` OrganizationGUID string `json:"organization_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSpace) if err != nil { return err } space.GUID = ccSpace.Metadata.GUID space.Name = ccSpace.Entity.Name space.AllowSSH = ccSpace.Entity.AllowSSH space.SpaceQuotaDefinitionGUID = ccSpace.Entity.SpaceQuotaDefinitionGUID space.OrganizationGUID = ccSpace.Entity.OrganizationGUID return nil }
go
func (space *Space) UnmarshalJSON(data []byte) error { var ccSpace struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` AllowSSH bool `json:"allow_ssh"` SpaceQuotaDefinitionGUID string `json:"space_quota_definition_guid"` OrganizationGUID string `json:"organization_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSpace) if err != nil { return err } space.GUID = ccSpace.Metadata.GUID space.Name = ccSpace.Entity.Name space.AllowSSH = ccSpace.Entity.AllowSSH space.SpaceQuotaDefinitionGUID = ccSpace.Entity.SpaceQuotaDefinitionGUID space.OrganizationGUID = ccSpace.Entity.OrganizationGUID return nil }
[ "func", "(", "space", "*", "Space", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccSpace", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "AllowSSH", "bool", "`json:\"allow_ssh\"`", "\n", "SpaceQuotaDefinitionGUID", "string", "`json:\"space_quota_definition_guid\"`", "\n", "OrganizationGUID", "string", "`json:\"organization_guid\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccSpace", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "space", ".", "GUID", "=", "ccSpace", ".", "Metadata", ".", "GUID", "\n", "space", ".", "Name", "=", "ccSpace", ".", "Entity", ".", "Name", "\n", "space", ".", "AllowSSH", "=", "ccSpace", ".", "Entity", ".", "AllowSSH", "\n", "space", ".", "SpaceQuotaDefinitionGUID", "=", "ccSpace", ".", "Entity", ".", "SpaceQuotaDefinitionGUID", "\n", "space", ".", "OrganizationGUID", "=", "ccSpace", ".", "Entity", ".", "OrganizationGUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Space response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Space", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L34-L55
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
CreateSpace
func (client *Client) CreateSpace(spaceName string, orgGUID string) (Space, Warnings, error) { requestBody := createSpaceRequestBody{ Name: spaceName, OrganizationGUID: orgGUID, } bodyBytes, _ := json.Marshal(requestBody) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostSpaceRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Space{}, nil, err } var space Space response := cloudcontroller.Response{ DecodeJSONResponseInto: &space, } err = client.connection.Make(request, &response) return space, response.Warnings, err }
go
func (client *Client) CreateSpace(spaceName string, orgGUID string) (Space, Warnings, error) { requestBody := createSpaceRequestBody{ Name: spaceName, OrganizationGUID: orgGUID, } bodyBytes, _ := json.Marshal(requestBody) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostSpaceRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Space{}, nil, err } var space Space response := cloudcontroller.Response{ DecodeJSONResponseInto: &space, } err = client.connection.Make(request, &response) return space, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateSpace", "(", "spaceName", "string", ",", "orgGUID", "string", ")", "(", "Space", ",", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "createSpaceRequestBody", "{", "Name", ":", "spaceName", ",", "OrganizationGUID", ":", "orgGUID", ",", "}", "\n", "bodyBytes", ",", "_", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostSpaceRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Space", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "space", "Space", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "space", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "space", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateSpace creates a new space with the provided spaceName in the org with // the provided orgGUID.
[ "CreateSpace", "creates", "a", "new", "space", "with", "the", "provided", "spaceName", "in", "the", "org", "with", "the", "provided", "orgGUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L64-L89
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
DeleteSpace
func (client *Client) DeleteSpace(guid string) (Job, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceRequest, URIParams: Params{"space_guid": guid}, Query: url.Values{ "recursive": {"true"}, "async": {"true"}, }, }) if err != nil { return Job{}, nil, err } var job Job response := cloudcontroller.Response{ DecodeJSONResponseInto: &job, } err = client.connection.Make(request, &response) return job, response.Warnings, err }
go
func (client *Client) DeleteSpace(guid string) (Job, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceRequest, URIParams: Params{"space_guid": guid}, Query: url.Values{ "recursive": {"true"}, "async": {"true"}, }, }) if err != nil { return Job{}, nil, err } var job Job response := cloudcontroller.Response{ DecodeJSONResponseInto: &job, } err = client.connection.Make(request, &response) return job, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteSpace", "(", "guid", "string", ")", "(", "Job", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteSpaceRequest", ",", "URIParams", ":", "Params", "{", "\"space_guid\"", ":", "guid", "}", ",", "Query", ":", "url", ".", "Values", "{", "\"recursive\"", ":", "{", "\"true\"", "}", ",", "\"async\"", ":", "{", "\"true\"", "}", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Job", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "job", "Job", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "job", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "job", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteSpace deletes the Space associated with the provided // GUID. It will return the Cloud Controller job that is assigned to the // Space deletion.
[ "DeleteSpace", "deletes", "the", "Space", "associated", "with", "the", "provided", "GUID", ".", "It", "will", "return", "the", "Cloud", "Controller", "job", "that", "is", "assigned", "to", "the", "Space", "deletion", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L94-L114
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
GetSecurityGroupSpaces
func (client *Client) GetSecurityGroupSpaces(securityGroupGUID string) ([]Space, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupSpacesRequest, URIParams: map[string]string{"security_group_guid": securityGroupGUID}, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
go
func (client *Client) GetSecurityGroupSpaces(securityGroupGUID string) ([]Space, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupSpacesRequest, URIParams: map[string]string{"security_group_guid": securityGroupGUID}, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSecurityGroupSpaces", "(", "securityGroupGUID", "string", ")", "(", "[", "]", "Space", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSecurityGroupSpacesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"security_group_guid\"", ":", "securityGroupGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullSpacesList", "[", "]", "Space", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Space", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "space", ",", "ok", ":=", "item", ".", "(", "Space", ")", ";", "ok", "{", "fullSpacesList", "=", "append", "(", "fullSpacesList", ",", "space", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Space", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullSpacesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSecurityGroupSpaces returns a list of Spaces based on the provided // SecurityGroup GUID.
[ "GetSecurityGroupSpaces", "returns", "a", "list", "of", "Spaces", "based", "on", "the", "provided", "SecurityGroup", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L118-L141
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
GetSpaces
func (client *Client) GetSpaces(filters ...Filter) ([]Space, Warnings, error) { params := ConvertFilterParameters(filters) params.Add("order-by", "name") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpacesRequest, Query: params, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
go
func (client *Client) GetSpaces(filters ...Filter) ([]Space, Warnings, error) { params := ConvertFilterParameters(filters) params.Add("order-by", "name") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpacesRequest, Query: params, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaces", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Space", ",", "Warnings", ",", "error", ")", "{", "params", ":=", "ConvertFilterParameters", "(", "filters", ")", "\n", "params", ".", "Add", "(", "\"order-by\"", ",", "\"name\"", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpacesRequest", ",", "Query", ":", "params", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullSpacesList", "[", "]", "Space", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Space", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "space", ",", "ok", ":=", "item", ".", "(", "Space", ")", ";", "ok", "{", "fullSpacesList", "=", "append", "(", "fullSpacesList", ",", "space", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Space", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullSpacesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSpaces returns a list of Spaces based off of the provided filters.
[ "GetSpaces", "returns", "a", "list", "of", "Spaces", "based", "off", "of", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L171-L196
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
UpdateSpaceDeveloper
func (client *Client) UpdateSpaceDeveloper(spaceGUID string, uaaID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceDeveloperRequest, URIParams: map[string]string{ "space_guid": spaceGUID, "developer_guid": uaaID, }, }) if err != nil { return Warnings{}, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) UpdateSpaceDeveloper(spaceGUID string, uaaID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceDeveloperRequest, URIParams: map[string]string{ "space_guid": spaceGUID, "developer_guid": uaaID, }, }) if err != nil { return Warnings{}, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateSpaceDeveloper", "(", "spaceGUID", "string", ",", "uaaID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutSpaceDeveloperRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"space_guid\"", ":", "spaceGUID", ",", "\"developer_guid\"", ":", "uaaID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Warnings", "{", "}", ",", "err", "\n", "}", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateSpaceDeveloper grants the space developer role to the user or client // associated with the given UAA ID.
[ "UpdateSpaceDeveloper", "grants", "the", "space", "developer", "role", "to", "the", "user", "or", "client", "associated", "with", "the", "given", "UAA", "ID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L200-L215
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
UpdateSpaceManagerByUsername
func (client *Client) UpdateSpaceManagerByUsername(spaceGUID string, username string) (Warnings, error) { requestBody := updateRoleRequestBody{ Username: username, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return Warnings{}, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceManagerByUsernameRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Body: bytes.NewReader(bodyBytes), }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) UpdateSpaceManagerByUsername(spaceGUID string, username string) (Warnings, error) { requestBody := updateRoleRequestBody{ Username: username, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return Warnings{}, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceManagerByUsernameRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Body: bytes.NewReader(bodyBytes), }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateSpaceManagerByUsername", "(", "spaceGUID", "string", ",", "username", "string", ")", "(", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "updateRoleRequestBody", "{", "Username", ":", "username", ",", "}", "\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Warnings", "{", "}", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutSpaceManagerByUsernameRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"space_guid\"", ":", "spaceGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\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", "}" ]
// UpdateSpaceManagerByUsername grants the given username the space manager role.
[ "UpdateSpaceManagerByUsername", "grants", "the", "given", "username", "the", "space", "manager", "role", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L267-L291
train
cloudfoundry/cli
api/uaa/info.go
NewInfo
func NewInfo(link string) Info { var info Info info.Links.Login = link info.Links.UAA = link return info }
go
func NewInfo(link string) Info { var info Info info.Links.Login = link info.Links.UAA = link return info }
[ "func", "NewInfo", "(", "link", "string", ")", "Info", "{", "var", "info", "Info", "\n", "info", ".", "Links", ".", "Login", "=", "link", "\n", "info", ".", "Links", ".", "UAA", "=", "link", "\n", "return", "info", "\n", "}" ]
// NewInfo returns back a new
[ "NewInfo", "returns", "back", "a", "new" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/info.go#L35-L40
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_key.go
CreateServiceKey
func (client *Client) CreateServiceKey(serviceInstanceGUID string, keyName string, parameters map[string]interface{}) (ServiceKey, Warnings, error) { requestBody := serviceKeyRequestBody{ ServiceInstanceGUID: serviceInstanceGUID, Name: keyName, Parameters: parameters, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceKey{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceKeyRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return ServiceKey{}, nil, err } var serviceKey ServiceKey response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceKey, } err = client.connection.Make(request, &response) return serviceKey, response.Warnings, err }
go
func (client *Client) CreateServiceKey(serviceInstanceGUID string, keyName string, parameters map[string]interface{}) (ServiceKey, Warnings, error) { requestBody := serviceKeyRequestBody{ ServiceInstanceGUID: serviceInstanceGUID, Name: keyName, Parameters: parameters, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceKey{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceKeyRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return ServiceKey{}, nil, err } var serviceKey ServiceKey response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceKey, } err = client.connection.Make(request, &response) return serviceKey, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateServiceKey", "(", "serviceInstanceGUID", "string", ",", "keyName", "string", ",", "parameters", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "ServiceKey", ",", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "serviceKeyRequestBody", "{", "ServiceInstanceGUID", ":", "serviceInstanceGUID", ",", "Name", ":", "keyName", ",", "Parameters", ":", "parameters", ",", "}", "\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceKey", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostServiceKeyRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceKey", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "serviceKey", "ServiceKey", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceKey", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "serviceKey", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateServiceKey creates a new service key using the provided name and // parameters for the requested service instance.
[ "CreateServiceKey", "creates", "a", "new", "service", "key", "using", "the", "provided", "name", "and", "parameters", "for", "the", "requested", "service", "instance", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_key.go#L56-L83
train
cloudfoundry/cli
actor/pluginaction/install.go
DownloadExecutableBinaryFromURL
func (actor Actor) DownloadExecutableBinaryFromURL(pluginURL string, tempPluginDir string, proxyReader plugin.ProxyReader) (string, error) { tempFile, err := makeTempFile(tempPluginDir) if err != nil { return "", err } err = actor.client.DownloadPlugin(pluginURL, tempFile.Name(), proxyReader) if err != nil { return "", err } return tempFile.Name(), nil }
go
func (actor Actor) DownloadExecutableBinaryFromURL(pluginURL string, tempPluginDir string, proxyReader plugin.ProxyReader) (string, error) { tempFile, err := makeTempFile(tempPluginDir) if err != nil { return "", err } err = actor.client.DownloadPlugin(pluginURL, tempFile.Name(), proxyReader) if err != nil { return "", err } return tempFile.Name(), nil }
[ "func", "(", "actor", "Actor", ")", "DownloadExecutableBinaryFromURL", "(", "pluginURL", "string", ",", "tempPluginDir", "string", ",", "proxyReader", "plugin", ".", "ProxyReader", ")", "(", "string", ",", "error", ")", "{", "tempFile", ",", "err", ":=", "makeTempFile", "(", "tempPluginDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "err", "=", "actor", ".", "client", ".", "DownloadPlugin", "(", "pluginURL", ",", "tempFile", ".", "Name", "(", ")", ",", "proxyReader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "return", "tempFile", ".", "Name", "(", ")", ",", "nil", "\n", "}" ]
// DownloadExecutableBinaryFromURL fetches a plugin binary from the specified // URL, if it exists.
[ "DownloadExecutableBinaryFromURL", "fetches", "a", "plugin", "binary", "from", "the", "specified", "URL", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/install.go#L63-L75
train
cloudfoundry/cli
actor/pluginaction/install.go
FileExists
func (actor Actor) FileExists(path string) bool { _, err := os.Stat(path) return err == nil }
go
func (actor Actor) FileExists(path string) bool { _, err := os.Stat(path) return err == nil }
[ "func", "(", "actor", "Actor", ")", "FileExists", "(", "path", "string", ")", "bool", "{", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// FileExists returns true if the file exists. It returns false if the file // doesn't exist or there is an error checking.
[ "FileExists", "returns", "true", "if", "the", "file", "exists", ".", "It", "returns", "false", "if", "the", "file", "doesn", "t", "exist", "or", "there", "is", "an", "error", "checking", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/install.go#L79-L82
train
cloudfoundry/cli
util/configv3/plugins_config.go
PluginCommands
func (p Plugin) PluginCommands() []PluginCommand { sort.Slice(p.Commands, func(i, j int) bool { return strings.ToLower(p.Commands[i].Name) < strings.ToLower(p.Commands[j].Name) }) return p.Commands }
go
func (p Plugin) PluginCommands() []PluginCommand { sort.Slice(p.Commands, func(i, j int) bool { return strings.ToLower(p.Commands[i].Name) < strings.ToLower(p.Commands[j].Name) }) return p.Commands }
[ "func", "(", "p", "Plugin", ")", "PluginCommands", "(", ")", "[", "]", "PluginCommand", "{", "sort", ".", "Slice", "(", "p", ".", "Commands", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "strings", ".", "ToLower", "(", "p", ".", "Commands", "[", "i", "]", ".", "Name", ")", "<", "strings", ".", "ToLower", "(", "p", ".", "Commands", "[", "j", "]", ".", "Name", ")", "\n", "}", ")", "\n", "return", "p", ".", "Commands", "\n", "}" ]
// PluginCommands returns the plugin's commands sorted by command name.
[ "PluginCommands", "returns", "the", "plugin", "s", "commands", "sorted", "by", "command", "name", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L43-L48
train
cloudfoundry/cli
util/configv3/plugins_config.go
String
func (v PluginVersion) String() string { if v.Major == 0 && v.Minor == 0 && v.Build == 0 { return notApplicable } return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Build) }
go
func (v PluginVersion) String() string { if v.Major == 0 && v.Minor == 0 && v.Build == 0 { return notApplicable } return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Build) }
[ "func", "(", "v", "PluginVersion", ")", "String", "(", ")", "string", "{", "if", "v", ".", "Major", "==", "0", "&&", "v", ".", "Minor", "==", "0", "&&", "v", ".", "Build", "==", "0", "{", "return", "notApplicable", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"%d.%d.%d\"", ",", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Build", ")", "\n", "}" ]
// String returns the plugin's version in the format x.y.z.
[ "String", "returns", "the", "plugin", "s", "version", "in", "the", "format", "x", ".", "y", ".", "z", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L58-L63
train
cloudfoundry/cli
util/configv3/plugins_config.go
CommandName
func (c PluginCommand) CommandName() string { if c.Name != "" && c.Alias != "" { return fmt.Sprintf("%s, %s", c.Name, c.Alias) } return c.Name }
go
func (c PluginCommand) CommandName() string { if c.Name != "" && c.Alias != "" { return fmt.Sprintf("%s, %s", c.Name, c.Alias) } return c.Name }
[ "func", "(", "c", "PluginCommand", ")", "CommandName", "(", ")", "string", "{", "if", "c", ".", "Name", "!=", "\"\"", "&&", "c", ".", "Alias", "!=", "\"\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"%s, %s\"", ",", "c", ".", "Name", ",", "c", ".", "Alias", ")", "\n", "}", "\n", "return", "c", ".", "Name", "\n", "}" ]
// CommandName returns the name of the plugin. The name is concatenated with // alias if alias is specified.
[ "CommandName", "returns", "the", "name", "of", "the", "plugin", ".", "The", "name", "is", "concatenated", "with", "alias", "if", "alias", "is", "specified", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L75-L80
train
cloudfoundry/cli
util/configv3/plugins_config.go
AddPlugin
func (config *Config) AddPlugin(plugin Plugin) { config.pluginsConfig.Plugins[plugin.Name] = plugin }
go
func (config *Config) AddPlugin(plugin Plugin) { config.pluginsConfig.Plugins[plugin.Name] = plugin }
[ "func", "(", "config", "*", "Config", ")", "AddPlugin", "(", "plugin", "Plugin", ")", "{", "config", ".", "pluginsConfig", ".", "Plugins", "[", "plugin", ".", "Name", "]", "=", "plugin", "\n", "}" ]
// AddPlugin adds the specified plugin to PluginsConfig
[ "AddPlugin", "adds", "the", "specified", "plugin", "to", "PluginsConfig" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L89-L91
train
cloudfoundry/cli
util/configv3/plugins_config.go
GetPlugin
func (config *Config) GetPlugin(pluginName string) (Plugin, bool) { plugin, exists := config.pluginsConfig.Plugins[pluginName] return plugin, exists }
go
func (config *Config) GetPlugin(pluginName string) (Plugin, bool) { plugin, exists := config.pluginsConfig.Plugins[pluginName] return plugin, exists }
[ "func", "(", "config", "*", "Config", ")", "GetPlugin", "(", "pluginName", "string", ")", "(", "Plugin", ",", "bool", ")", "{", "plugin", ",", "exists", ":=", "config", ".", "pluginsConfig", ".", "Plugins", "[", "pluginName", "]", "\n", "return", "plugin", ",", "exists", "\n", "}" ]
// GetPlugin returns the requested plugin and true if it exists.
[ "GetPlugin", "returns", "the", "requested", "plugin", "and", "true", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L98-L101
train
cloudfoundry/cli
util/configv3/plugins_config.go
GetPluginCaseInsensitive
func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) { for name, plugin := range config.pluginsConfig.Plugins { if strings.EqualFold(name, pluginName) { return plugin, true } } return Plugin{}, false }
go
func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) { for name, plugin := range config.pluginsConfig.Plugins { if strings.EqualFold(name, pluginName) { return plugin, true } } return Plugin{}, false }
[ "func", "(", "config", "*", "Config", ")", "GetPluginCaseInsensitive", "(", "pluginName", "string", ")", "(", "Plugin", ",", "bool", ")", "{", "for", "name", ",", "plugin", ":=", "range", "config", ".", "pluginsConfig", ".", "Plugins", "{", "if", "strings", ".", "EqualFold", "(", "name", ",", "pluginName", ")", "{", "return", "plugin", ",", "true", "\n", "}", "\n", "}", "\n", "return", "Plugin", "{", "}", ",", "false", "\n", "}" ]
// GetPluginCaseInsensitive finds the first matching plugin name case // insensitive and returns true if it exists.
[ "GetPluginCaseInsensitive", "finds", "the", "first", "matching", "plugin", "name", "case", "insensitive", "and", "returns", "true", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L105-L113
train
cloudfoundry/cli
util/configv3/plugins_config.go
RemovePlugin
func (config *Config) RemovePlugin(pluginName string) { delete(config.pluginsConfig.Plugins, pluginName) }
go
func (config *Config) RemovePlugin(pluginName string) { delete(config.pluginsConfig.Plugins, pluginName) }
[ "func", "(", "config", "*", "Config", ")", "RemovePlugin", "(", "pluginName", "string", ")", "{", "delete", "(", "config", ".", "pluginsConfig", ".", "Plugins", ",", "pluginName", ")", "\n", "}" ]
// RemovePlugin removes the specified plugin from PluginsConfig idempotently
[ "RemovePlugin", "removes", "the", "specified", "plugin", "from", "PluginsConfig", "idempotently" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L139-L141
train
cloudfoundry/cli
util/configv3/plugins_config.go
WritePluginConfig
func (config *Config) WritePluginConfig() error { // Marshal JSON rawConfig, err := json.MarshalIndent(config.pluginsConfig, "", " ") if err != nil { return err } pluginFileDir := filepath.Join(config.PluginHome()) err = os.MkdirAll(pluginFileDir, 0700) if err != nil { return err } // Write to file return ioutil.WriteFile(filepath.Join(pluginFileDir, "config.json"), rawConfig, 0600) }
go
func (config *Config) WritePluginConfig() error { // Marshal JSON rawConfig, err := json.MarshalIndent(config.pluginsConfig, "", " ") if err != nil { return err } pluginFileDir := filepath.Join(config.PluginHome()) err = os.MkdirAll(pluginFileDir, 0700) if err != nil { return err } // Write to file return ioutil.WriteFile(filepath.Join(pluginFileDir, "config.json"), rawConfig, 0600) }
[ "func", "(", "config", "*", "Config", ")", "WritePluginConfig", "(", ")", "error", "{", "rawConfig", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "config", ".", "pluginsConfig", ",", "\"\"", ",", "\" \"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "pluginFileDir", ":=", "filepath", ".", "Join", "(", "config", ".", "PluginHome", "(", ")", ")", "\n", "err", "=", "os", ".", "MkdirAll", "(", "pluginFileDir", ",", "0700", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "return", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "pluginFileDir", ",", "\"config.json\"", ")", ",", "rawConfig", ",", "0600", ")", "\n", "}" ]
// WritePluginConfig writes the plugin config to config.json in the plugin home // directory.
[ "WritePluginConfig", "writes", "the", "plugin", "config", "to", "config", ".", "json", "in", "the", "plugin", "home", "directory", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L145-L160
train
cloudfoundry/cli
actor/pluginaction/actor.go
NewActor
func NewActor(config Config, client PluginClient) *Actor { return &Actor{config: config, client: client} }
go
func NewActor(config Config, client PluginClient) *Actor { return &Actor{config: config, client: client} }
[ "func", "NewActor", "(", "config", "Config", ",", "client", "PluginClient", ")", "*", "Actor", "{", "return", "&", "Actor", "{", "config", ":", "config", ",", "client", ":", "client", "}", "\n", "}" ]
// NewActor returns a pluginaction Actor
[ "NewActor", "returns", "a", "pluginaction", "Actor" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/actor.go#L11-L13
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
DeleteService
func (client *Client) DeleteService(serviceGUID string, purge bool) (Warnings, error) { queryParams := url.Values{} queryParams.Set("purge", strconv.FormatBool(purge)) queryParams.Set("async", "true") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceRequest, Query: queryParams, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteService(serviceGUID string, purge bool) (Warnings, error) { queryParams := url.Values{} queryParams.Set("purge", strconv.FormatBool(purge)) queryParams.Set("async", "true") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceRequest, Query: queryParams, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteService", "(", "serviceGUID", "string", ",", "purge", "bool", ")", "(", "Warnings", ",", "error", ")", "{", "queryParams", ":=", "url", ".", "Values", "{", "}", "\n", "queryParams", ".", "Set", "(", "\"purge\"", ",", "strconv", ".", "FormatBool", "(", "purge", ")", ")", "\n", "queryParams", ".", "Set", "(", "\"async\"", ",", "\"true\"", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteServiceRequest", ",", "Query", ":", "queryParams", ",", "URIParams", ":", "Params", "{", "\"service_guid\"", ":", "serviceGUID", "}", ",", "}", ")", "\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", "}" ]
// DeleteService deletes the service with the given GUID, and returns any errors and warnings.
[ "DeleteService", "deletes", "the", "service", "with", "the", "given", "GUID", "and", "returns", "any", "errors", "and", "warnings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L31-L49
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
UnmarshalJSON
func (service *Service) UnmarshalJSON(data []byte) error { var ccService struct { Metadata internal.Metadata Entity struct { Label string `json:"label"` Description string `json:"description"` DocumentationURL string `json:"documentation_url"` ServiceBrokerName string `json:"service_broker_name"` Extra string `json:"extra"` } } err := cloudcontroller.DecodeJSON(data, &ccService) if err != nil { return err } service.GUID = ccService.Metadata.GUID service.Label = ccService.Entity.Label service.Description = ccService.Entity.Description service.DocumentationURL = ccService.Entity.DocumentationURL service.ServiceBrokerName = ccService.Entity.ServiceBrokerName // We explicitly unmarshal the Extra field to type string because CC returns // a stringified JSON object ONLY for the 'extra' key (see test stub JSON // response). This unmarshal strips escaped quotes, at which time we can then // unmarshal into the ServiceExtra object. // If 'extra' is null or not provided, this means sharing is NOT enabled if len(ccService.Entity.Extra) != 0 { extra := ServiceExtra{} err = json.Unmarshal([]byte(ccService.Entity.Extra), &extra) if err != nil { return err } service.Extra.Shareable = extra.Shareable if service.DocumentationURL == "" { service.DocumentationURL = extra.DocumentationURL } } return nil }
go
func (service *Service) UnmarshalJSON(data []byte) error { var ccService struct { Metadata internal.Metadata Entity struct { Label string `json:"label"` Description string `json:"description"` DocumentationURL string `json:"documentation_url"` ServiceBrokerName string `json:"service_broker_name"` Extra string `json:"extra"` } } err := cloudcontroller.DecodeJSON(data, &ccService) if err != nil { return err } service.GUID = ccService.Metadata.GUID service.Label = ccService.Entity.Label service.Description = ccService.Entity.Description service.DocumentationURL = ccService.Entity.DocumentationURL service.ServiceBrokerName = ccService.Entity.ServiceBrokerName // We explicitly unmarshal the Extra field to type string because CC returns // a stringified JSON object ONLY for the 'extra' key (see test stub JSON // response). This unmarshal strips escaped quotes, at which time we can then // unmarshal into the ServiceExtra object. // If 'extra' is null or not provided, this means sharing is NOT enabled if len(ccService.Entity.Extra) != 0 { extra := ServiceExtra{} err = json.Unmarshal([]byte(ccService.Entity.Extra), &extra) if err != nil { return err } service.Extra.Shareable = extra.Shareable if service.DocumentationURL == "" { service.DocumentationURL = extra.DocumentationURL } } return nil }
[ "func", "(", "service", "*", "Service", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccService", "struct", "{", "Metadata", "internal", ".", "Metadata", "\n", "Entity", "struct", "{", "Label", "string", "`json:\"label\"`", "\n", "Description", "string", "`json:\"description\"`", "\n", "DocumentationURL", "string", "`json:\"documentation_url\"`", "\n", "ServiceBrokerName", "string", "`json:\"service_broker_name\"`", "\n", "Extra", "string", "`json:\"extra\"`", "\n", "}", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccService", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "service", ".", "GUID", "=", "ccService", ".", "Metadata", ".", "GUID", "\n", "service", ".", "Label", "=", "ccService", ".", "Entity", ".", "Label", "\n", "service", ".", "Description", "=", "ccService", ".", "Entity", ".", "Description", "\n", "service", ".", "DocumentationURL", "=", "ccService", ".", "Entity", ".", "DocumentationURL", "\n", "service", ".", "ServiceBrokerName", "=", "ccService", ".", "Entity", ".", "ServiceBrokerName", "\n", "if", "len", "(", "ccService", ".", "Entity", ".", "Extra", ")", "!=", "0", "{", "extra", ":=", "ServiceExtra", "{", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "ccService", ".", "Entity", ".", "Extra", ")", ",", "&", "extra", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "service", ".", "Extra", ".", "Shareable", "=", "extra", ".", "Shareable", "\n", "if", "service", ".", "DocumentationURL", "==", "\"\"", "{", "service", ".", "DocumentationURL", "=", "extra", ".", "DocumentationURL", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Service response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Service", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L52-L93
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
GetService
func (client *Client) GetService(serviceGUID string) (Service, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceRequest, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return Service{}, nil, err } var service Service response := cloudcontroller.Response{ DecodeJSONResponseInto: &service, } err = client.connection.Make(request, &response) return service, response.Warnings, err }
go
func (client *Client) GetService(serviceGUID string) (Service, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceRequest, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return Service{}, nil, err } var service Service response := cloudcontroller.Response{ DecodeJSONResponseInto: &service, } err = client.connection.Make(request, &response) return service, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetService", "(", "serviceGUID", "string", ")", "(", "Service", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceRequest", ",", "URIParams", ":", "Params", "{", "\"service_guid\"", ":", "serviceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Service", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "service", "Service", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "service", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "service", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetService returns the service with the given GUID.
[ "GetService", "returns", "the", "service", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L96-L112
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
GetServices
func (client *Client) GetServices(filters ...Filter) ([]Service, Warnings, error) { opts := requestOptions{ RequestName: internal.GetServicesRequest, Query: ConvertFilterParameters(filters), } return client.makeServicesRequest(opts) }
go
func (client *Client) GetServices(filters ...Filter) ([]Service, Warnings, error) { opts := requestOptions{ RequestName: internal.GetServicesRequest, Query: ConvertFilterParameters(filters), } return client.makeServicesRequest(opts) }
[ "func", "(", "client", "*", "Client", ")", "GetServices", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Service", ",", "Warnings", ",", "error", ")", "{", "opts", ":=", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServicesRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", "\n", "return", "client", ".", "makeServicesRequest", "(", "opts", ")", "\n", "}" ]
// GetServices returns a list of Services given the provided filters.
[ "GetServices", "returns", "a", "list", "of", "Services", "given", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L115-L122
train
cloudfoundry/cli
actor/v2action/service_plan_visibility.go
GetServicePlanVisibilities
func (actor *Actor) GetServicePlanVisibilities(planGUID string) ([]ServicePlanVisibility, Warnings, error) { visibilities, warnings, err := actor.CloudControllerClient.GetServicePlanVisibilities(ccv2.Filter{ Type: constant.ServicePlanGUIDFilter, Operator: constant.EqualOperator, Values: []string{planGUID}, }) if err != nil { return nil, Warnings(warnings), err } var visibilitesToReturn []ServicePlanVisibility for _, v := range visibilities { visibilitesToReturn = append(visibilitesToReturn, ServicePlanVisibility(v)) } return visibilitesToReturn, Warnings(warnings), nil }
go
func (actor *Actor) GetServicePlanVisibilities(planGUID string) ([]ServicePlanVisibility, Warnings, error) { visibilities, warnings, err := actor.CloudControllerClient.GetServicePlanVisibilities(ccv2.Filter{ Type: constant.ServicePlanGUIDFilter, Operator: constant.EqualOperator, Values: []string{planGUID}, }) if err != nil { return nil, Warnings(warnings), err } var visibilitesToReturn []ServicePlanVisibility for _, v := range visibilities { visibilitesToReturn = append(visibilitesToReturn, ServicePlanVisibility(v)) } return visibilitesToReturn, Warnings(warnings), nil }
[ "func", "(", "actor", "*", "Actor", ")", "GetServicePlanVisibilities", "(", "planGUID", "string", ")", "(", "[", "]", "ServicePlanVisibility", ",", "Warnings", ",", "error", ")", "{", "visibilities", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetServicePlanVisibilities", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "ServicePlanGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "planGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "var", "visibilitesToReturn", "[", "]", "ServicePlanVisibility", "\n", "for", "_", ",", "v", ":=", "range", "visibilities", "{", "visibilitesToReturn", "=", "append", "(", "visibilitesToReturn", ",", "ServicePlanVisibility", "(", "v", ")", ")", "\n", "}", "\n", "return", "visibilitesToReturn", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetServicePlanVisibilities fetches service plan visibilities for a plan by GUID.
[ "GetServicePlanVisibilities", "fetches", "service", "plan", "visibilities", "for", "a", "plan", "by", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_plan_visibility.go#L11-L27
train
cloudfoundry/cli
api/cloudcontroller/ccv3/internal/routing.go
CreatePath
func (r Route) CreatePath(params Params) (string, error) { components := strings.Split(r.Path, "/") for i, c := range components { if len(c) == 0 { continue } if c[0] == ':' { val, ok := params[c[1:]] if !ok { return "", fmt.Errorf("missing param %s", c) } components[i] = val } } u, err := url.Parse(strings.Join(components, "/")) if err != nil { return "", err } return u.String(), nil }
go
func (r Route) CreatePath(params Params) (string, error) { components := strings.Split(r.Path, "/") for i, c := range components { if len(c) == 0 { continue } if c[0] == ':' { val, ok := params[c[1:]] if !ok { return "", fmt.Errorf("missing param %s", c) } components[i] = val } } u, err := url.Parse(strings.Join(components, "/")) if err != nil { return "", err } return u.String(), nil }
[ "func", "(", "r", "Route", ")", "CreatePath", "(", "params", "Params", ")", "(", "string", ",", "error", ")", "{", "components", ":=", "strings", ".", "Split", "(", "r", ".", "Path", ",", "\"/\"", ")", "\n", "for", "i", ",", "c", ":=", "range", "components", "{", "if", "len", "(", "c", ")", "==", "0", "{", "continue", "\n", "}", "\n", "if", "c", "[", "0", "]", "==", "':'", "{", "val", ",", "ok", ":=", "params", "[", "c", "[", "1", ":", "]", "]", "\n", "if", "!", "ok", "{", "return", "\"\"", ",", "fmt", ".", "Errorf", "(", "\"missing param %s\"", ",", "c", ")", "\n", "}", "\n", "components", "[", "i", "]", "=", "val", "\n", "}", "\n", "}", "\n", "u", ",", "err", ":=", "url", ".", "Parse", "(", "strings", ".", "Join", "(", "components", ",", "\"/\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"\"", ",", "err", "\n", "}", "\n", "return", "u", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
// CreatePath combines the route's path pattern with a Params map // to produce a valid path.
[ "CreatePath", "combines", "the", "route", "s", "path", "pattern", "with", "a", "Params", "map", "to", "produce", "a", "valid", "path", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/internal/routing.go#L73-L93
train
cloudfoundry/cli
api/cloudcontroller/ccv3/internal/routing.go
NewRouter
func NewRouter(routes []Route, resources map[string]string) *Router { mappedRoutes := map[string]Route{} for _, route := range routes { mappedRoutes[route.Name] = route } return &Router{ routes: mappedRoutes, resources: resources, } }
go
func NewRouter(routes []Route, resources map[string]string) *Router { mappedRoutes := map[string]Route{} for _, route := range routes { mappedRoutes[route.Name] = route } return &Router{ routes: mappedRoutes, resources: resources, } }
[ "func", "NewRouter", "(", "routes", "[", "]", "Route", ",", "resources", "map", "[", "string", "]", "string", ")", "*", "Router", "{", "mappedRoutes", ":=", "map", "[", "string", "]", "Route", "{", "}", "\n", "for", "_", ",", "route", ":=", "range", "routes", "{", "mappedRoutes", "[", "route", ".", "Name", "]", "=", "route", "\n", "}", "\n", "return", "&", "Router", "{", "routes", ":", "mappedRoutes", ",", "resources", ":", "resources", ",", "}", "\n", "}" ]
// NewRouter returns a pointer to a new Router.
[ "NewRouter", "returns", "a", "pointer", "to", "a", "new", "Router", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/internal/routing.go#L103-L112
train
cloudfoundry/cli
api/cloudcontroller/ccv3/internal/routing.go
CreateRequest
func (router Router) CreateRequest(name string, params Params, body io.Reader) (*http.Request, error) { route, ok := router.routes[name] if !ok { return &http.Request{}, fmt.Errorf("no route exists with the name %s", name) } uri, err := route.CreatePath(params) if err != nil { return &http.Request{}, err } resource, ok := router.resources[route.Resource] if !ok { return &http.Request{}, fmt.Errorf("no resource exists with the name %s", route.Resource) } url, err := router.urlFrom(resource, uri) if err != nil { return &http.Request{}, err } return http.NewRequest(route.Method, url, body) }
go
func (router Router) CreateRequest(name string, params Params, body io.Reader) (*http.Request, error) { route, ok := router.routes[name] if !ok { return &http.Request{}, fmt.Errorf("no route exists with the name %s", name) } uri, err := route.CreatePath(params) if err != nil { return &http.Request{}, err } resource, ok := router.resources[route.Resource] if !ok { return &http.Request{}, fmt.Errorf("no resource exists with the name %s", route.Resource) } url, err := router.urlFrom(resource, uri) if err != nil { return &http.Request{}, err } return http.NewRequest(route.Method, url, body) }
[ "func", "(", "router", "Router", ")", "CreateRequest", "(", "name", "string", ",", "params", "Params", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "route", ",", "ok", ":=", "router", ".", "routes", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"no route exists with the name %s\"", ",", "name", ")", "\n", "}", "\n", "uri", ",", "err", ":=", "route", ".", "CreatePath", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "err", "\n", "}", "\n", "resource", ",", "ok", ":=", "router", ".", "resources", "[", "route", ".", "Resource", "]", "\n", "if", "!", "ok", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"no resource exists with the name %s\"", ",", "route", ".", "Resource", ")", "\n", "}", "\n", "url", ",", "err", ":=", "router", ".", "urlFrom", "(", "resource", ",", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "err", "\n", "}", "\n", "return", "http", ".", "NewRequest", "(", "route", ".", "Method", ",", "url", ",", "body", ")", "\n", "}" ]
// CreateRequest returns a request key'd off of the name given. The params are // merged into the URL and body is set as the request body.
[ "CreateRequest", "returns", "a", "request", "key", "d", "off", "of", "the", "name", "given", ".", "The", "params", "are", "merged", "into", "the", "URL", "and", "body", "is", "set", "as", "the", "request", "body", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/internal/routing.go#L116-L138
train
cloudfoundry/cli
api/uaa/client.go
NewClient
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.BinaryName(), config.BinaryVersion(), runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ config: config, connection: NewConnection(config.SkipSSLValidation(), config.UAADisableKeepAlives(), config.DialTimeout()), userAgent: userAgent, } client.WrapConnection(NewErrorWrapper()) return &client }
go
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.BinaryName(), config.BinaryVersion(), runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ config: config, connection: NewConnection(config.SkipSSLValidation(), config.UAADisableKeepAlives(), config.DialTimeout()), userAgent: userAgent, } client.WrapConnection(NewErrorWrapper()) return &client }
[ "func", "NewClient", "(", "config", "Config", ")", "*", "Client", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"%s/%s (%s; %s %s)\"", ",", "config", ".", "BinaryName", "(", ")", ",", "config", ".", "BinaryVersion", "(", ")", ",", "runtime", ".", "Version", "(", ")", ",", "runtime", ".", "GOARCH", ",", "runtime", ".", "GOOS", ",", ")", "\n", "client", ":=", "Client", "{", "config", ":", "config", ",", "connection", ":", "NewConnection", "(", "config", ".", "SkipSSLValidation", "(", ")", ",", "config", ".", "UAADisableKeepAlives", "(", ")", ",", "config", ".", "DialTimeout", "(", ")", ")", ",", "userAgent", ":", "userAgent", ",", "}", "\n", "client", ".", "WrapConnection", "(", "NewErrorWrapper", "(", ")", ")", "\n", "return", "&", "client", "\n", "}" ]
// NewClient returns a new UAA Client with the provided configuration
[ "NewClient", "returns", "a", "new", "UAA", "Client", "with", "the", "provided", "configuration" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/client.go#L27-L45
train
cloudfoundry/cli
util/ui/ui.go
NewUI
func NewUI(config Config) (*UI, error) { translateFunc, err := GetTranslationFunc(config) if err != nil { return nil, err } location := time.Now().Location() return &UI{ In: os.Stdin, Out: color.Output, OutForInteration: os.Stdout, Err: os.Stderr, colorEnabled: config.ColorEnabled(), translate: translateFunc, terminalLock: &sync.Mutex{}, Exiter: realExiter, fileLock: &sync.Mutex{}, Interactor: realInteract, IsTTY: config.IsTTY(), TerminalWidth: config.TerminalWidth(), TimezoneLocation: location, }, nil }
go
func NewUI(config Config) (*UI, error) { translateFunc, err := GetTranslationFunc(config) if err != nil { return nil, err } location := time.Now().Location() return &UI{ In: os.Stdin, Out: color.Output, OutForInteration: os.Stdout, Err: os.Stderr, colorEnabled: config.ColorEnabled(), translate: translateFunc, terminalLock: &sync.Mutex{}, Exiter: realExiter, fileLock: &sync.Mutex{}, Interactor: realInteract, IsTTY: config.IsTTY(), TerminalWidth: config.TerminalWidth(), TimezoneLocation: location, }, nil }
[ "func", "NewUI", "(", "config", "Config", ")", "(", "*", "UI", ",", "error", ")", "{", "translateFunc", ",", "err", ":=", "GetTranslationFunc", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "location", ":=", "time", ".", "Now", "(", ")", ".", "Location", "(", ")", "\n", "return", "&", "UI", "{", "In", ":", "os", ".", "Stdin", ",", "Out", ":", "color", ".", "Output", ",", "OutForInteration", ":", "os", ".", "Stdout", ",", "Err", ":", "os", ".", "Stderr", ",", "colorEnabled", ":", "config", ".", "ColorEnabled", "(", ")", ",", "translate", ":", "translateFunc", ",", "terminalLock", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "Exiter", ":", "realExiter", ",", "fileLock", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "Interactor", ":", "realInteract", ",", "IsTTY", ":", "config", ".", "IsTTY", "(", ")", ",", "TerminalWidth", ":", "config", ".", "TerminalWidth", "(", ")", ",", "TimezoneLocation", ":", "location", ",", "}", ",", "nil", "\n", "}" ]
// NewUI will return a UI object where Out is set to STDOUT, In is set to // STDIN, and Err is set to STDERR
[ "NewUI", "will", "return", "a", "UI", "object", "where", "Out", "is", "set", "to", "STDOUT", "In", "is", "set", "to", "STDIN", "and", "Err", "is", "set", "to", "STDERR" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L99-L122
train
cloudfoundry/cli
util/ui/ui.go
DisplayError
func (ui *UI) DisplayError(err error) { var errMsg string if translatableError, ok := err.(translatableerror.TranslatableError); ok { errMsg = translatableError.Translate(ui.translate) } else { errMsg = err.Error() } fmt.Fprintf(ui.Err, "%s\n", errMsg) ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText("FAILED"), color.New(color.FgRed, color.Bold))) }
go
func (ui *UI) DisplayError(err error) { var errMsg string if translatableError, ok := err.(translatableerror.TranslatableError); ok { errMsg = translatableError.Translate(ui.translate) } else { errMsg = err.Error() } fmt.Fprintf(ui.Err, "%s\n", errMsg) ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText("FAILED"), color.New(color.FgRed, color.Bold))) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayError", "(", "err", "error", ")", "{", "var", "errMsg", "string", "\n", "if", "translatableError", ",", "ok", ":=", "err", ".", "(", "translatableerror", ".", "TranslatableError", ")", ";", "ok", "{", "errMsg", "=", "translatableError", ".", "Translate", "(", "ui", ".", "translate", ")", "\n", "}", "else", "{", "errMsg", "=", "err", ".", "Error", "(", ")", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Err", ",", "\"%s\\n\"", ",", "\\n", ")", "\n", "errMsg", "\n", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "}" ]
// DisplayError outputs the translated error message to ui.Err if the error // satisfies TranslatableError, otherwise it outputs the original error message // to ui.Err. It also outputs "FAILED" in bold red to ui.Out.
[ "DisplayError", "outputs", "the", "translated", "error", "message", "to", "ui", ".", "Err", "if", "the", "error", "satisfies", "TranslatableError", "otherwise", "it", "outputs", "the", "original", "error", "message", "to", "ui", ".", "Err", ".", "It", "also", "outputs", "FAILED", "in", "bold", "red", "to", "ui", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L157-L170
train
cloudfoundry/cli
util/ui/ui.go
DisplayHeader
func (ui *UI) DisplayHeader(text string) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText(text), color.New(color.Bold))) }
go
func (ui *UI) DisplayHeader(text string) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText(text), color.New(color.Bold))) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayHeader", "(", "text", "string", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"%s\\n\"", ",", "\\n", ")", "\n", "}" ]
// DisplayHeader translates the header, bolds and adds the default color to the // header, and outputs the result to ui.Out.
[ "DisplayHeader", "translates", "the", "header", "bolds", "and", "adds", "the", "default", "color", "to", "the", "header", "and", "outputs", "the", "result", "to", "ui", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L181-L186
train
cloudfoundry/cli
util/ui/ui.go
DisplayNewline
func (ui *UI) DisplayNewline() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "\n") }
go
func (ui *UI) DisplayNewline() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "\n") }
[ "func", "(", "ui", "*", "UI", ")", "DisplayNewline", "(", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"\\n\"", ")", "\n", "}" ]
// DisplayNewline outputs a newline to UI.Out.
[ "DisplayNewline", "outputs", "a", "newline", "to", "UI", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L189-L194
train
cloudfoundry/cli
util/ui/ui.go
DisplayOK
func (ui *UI) DisplayOK() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n\n", ui.modifyColor(ui.TranslateText("OK"), color.New(color.FgGreen, color.Bold))) }
go
func (ui *UI) DisplayOK() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n\n", ui.modifyColor(ui.TranslateText("OK"), color.New(color.FgGreen, color.Bold))) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayOK", "(", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"%s\\n\\n\"", ",", "\\n", ")", "\n", "}" ]
// DisplayOK outputs a bold green translated "OK" to UI.Out.
[ "DisplayOK", "outputs", "a", "bold", "green", "translated", "OK", "to", "UI", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L197-L202
train
cloudfoundry/cli
util/ui/ui.go
DisplayText
func (ui *UI) DisplayText(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, templateValues...)) }
go
func (ui *UI) DisplayText(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, templateValues...)) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayText", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"%s\\n\"", ",", "\\n", ")", "\n", "}" ]
// DisplayText translates the template, substitutes in templateValues, and // outputs the result to ui.Out. Only the first map in templateValues is used.
[ "DisplayText", "translates", "the", "template", "substitutes", "in", "templateValues", "and", "outputs", "the", "result", "to", "ui", ".", "Out", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L206-L211
train
cloudfoundry/cli
util/ui/ui.go
DisplayTextWithFlavor
func (ui *UI) DisplayTextWithFlavor(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() firstTemplateValues := getFirstSet(templateValues) for key, value := range firstTemplateValues { firstTemplateValues[key] = ui.modifyColor(fmt.Sprint(value), color.New(color.FgCyan, color.Bold)) } fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, firstTemplateValues)) }
go
func (ui *UI) DisplayTextWithFlavor(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() firstTemplateValues := getFirstSet(templateValues) for key, value := range firstTemplateValues { firstTemplateValues[key] = ui.modifyColor(fmt.Sprint(value), color.New(color.FgCyan, color.Bold)) } fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, firstTemplateValues)) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayTextWithFlavor", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n", "firstTemplateValues", ":=", "getFirstSet", "(", "templateValues", ")", "\n", "for", "key", ",", "value", ":=", "range", "firstTemplateValues", "{", "firstTemplateValues", "[", "key", "]", "=", "ui", ".", "modifyColor", "(", "fmt", ".", "Sprint", "(", "value", ")", ",", "color", ".", "New", "(", "color", ".", "FgCyan", ",", "color", ".", "Bold", ")", ")", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"%s\\n\"", ",", "\\n", ")", "\n", "}" ]
// DisplayTextWithFlavor translates the template, bolds and adds cyan color to // templateValues, substitutes templateValues into the template, and outputs // the result to ui.Out. Only the first map in templateValues is used.
[ "DisplayTextWithFlavor", "translates", "the", "template", "bolds", "and", "adds", "cyan", "color", "to", "templateValues", "substitutes", "templateValues", "into", "the", "template", "and", "outputs", "the", "result", "to", "ui", ".", "Out", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L230-L239
train
cloudfoundry/cli
util/ui/ui.go
DisplayWarning
func (ui *UI) DisplayWarning(template string, templateValues ...map[string]interface{}) { fmt.Fprintf(ui.Err, "%s\n\n", ui.TranslateText(template, templateValues...)) }
go
func (ui *UI) DisplayWarning(template string, templateValues ...map[string]interface{}) { fmt.Fprintf(ui.Err, "%s\n\n", ui.TranslateText(template, templateValues...)) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayWarning", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "ui", ".", "Err", ",", "\"%s\\n\\n\"", ",", "\\n", ")", "\n", "}" ]
// DisplayWarning translates the warning, substitutes in templateValues, and // outputs to ui.Err. Only the first map in templateValues is used.
[ "DisplayWarning", "translates", "the", "warning", "substitutes", "in", "templateValues", "and", "outputs", "to", "ui", ".", "Err", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L243-L245
train
cloudfoundry/cli
util/ui/ui.go
DisplayWarnings
func (ui *UI) DisplayWarnings(warnings []string) { for _, warning := range warnings { fmt.Fprintf(ui.Err, "%s\n", ui.TranslateText(warning)) } if len(warnings) > 0 { fmt.Fprintln(ui.Err) } }
go
func (ui *UI) DisplayWarnings(warnings []string) { for _, warning := range warnings { fmt.Fprintf(ui.Err, "%s\n", ui.TranslateText(warning)) } if len(warnings) > 0 { fmt.Fprintln(ui.Err) } }
[ "func", "(", "ui", "*", "UI", ")", "DisplayWarnings", "(", "warnings", "[", "]", "string", ")", "{", "for", "_", ",", "warning", ":=", "range", "warnings", "{", "fmt", ".", "Fprintf", "(", "ui", ".", "Err", ",", "\"%s\\n\"", ",", "\\n", ")", "\n", "}", "\n", "ui", ".", "TranslateText", "(", "warning", ")", "\n", "}" ]
// DisplayWarnings translates the warnings and outputs to ui.Err.
[ "DisplayWarnings", "translates", "the", "warnings", "and", "outputs", "to", "ui", ".", "Err", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L248-L255
train
cloudfoundry/cli
util/ui/ui.go
TranslateText
func (ui *UI) TranslateText(template string, templateValues ...map[string]interface{}) string { return ui.translate(template, getFirstSet(templateValues)) }
go
func (ui *UI) TranslateText(template string, templateValues ...map[string]interface{}) string { return ui.translate(template, getFirstSet(templateValues)) }
[ "func", "(", "ui", "*", "UI", ")", "TranslateText", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "string", "{", "return", "ui", ".", "translate", "(", "template", ",", "getFirstSet", "(", "templateValues", ")", ")", "\n", "}" ]
// TranslateText passes the template through an internationalization function // to translate it to a pre-configured language, and returns the template with // templateValues substituted in. Only the first map in templateValues is used.
[ "TranslateText", "passes", "the", "template", "through", "an", "internationalization", "function", "to", "translate", "it", "to", "a", "pre", "-", "configured", "language", "and", "returns", "the", "template", "with", "templateValues", "substituted", "in", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L275-L277
train
cloudfoundry/cli
util/ui/ui.go
UserFriendlyDate
func (ui *UI) UserFriendlyDate(input time.Time) string { return input.Local().Format("Mon 02 Jan 15:04:05 MST 2006") }
go
func (ui *UI) UserFriendlyDate(input time.Time) string { return input.Local().Format("Mon 02 Jan 15:04:05 MST 2006") }
[ "func", "(", "ui", "*", "UI", ")", "UserFriendlyDate", "(", "input", "time", ".", "Time", ")", "string", "{", "return", "input", ".", "Local", "(", ")", ".", "Format", "(", "\"Mon 02 Jan 15:04:05 MST 2006\"", ")", "\n", "}" ]
// UserFriendlyDate converts the time to UTC and then formats it to ISO8601.
[ "UserFriendlyDate", "converts", "the", "time", "to", "UTC", "and", "then", "formats", "it", "to", "ISO8601", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L280-L282
train
cloudfoundry/cli
util/configv3/plugin_repository.go
AddPluginRepository
func (config *Config) AddPluginRepository(name string, url string) { config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories, PluginRepository{Name: name, URL: url}) }
go
func (config *Config) AddPluginRepository(name string, url string) { config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories, PluginRepository{Name: name, URL: url}) }
[ "func", "(", "config", "*", "Config", ")", "AddPluginRepository", "(", "name", "string", ",", "url", "string", ")", "{", "config", ".", "ConfigFile", ".", "PluginRepositories", "=", "append", "(", "config", ".", "ConfigFile", ".", "PluginRepositories", ",", "PluginRepository", "{", "Name", ":", "name", ",", "URL", ":", "url", "}", ")", "\n", "}" ]
// AddPluginRepository adds an new repository to the plugin config. It does not // add duplicates to the config.
[ "AddPluginRepository", "adds", "an", "new", "repository", "to", "the", "plugin", "config", ".", "It", "does", "not", "add", "duplicates", "to", "the", "config", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugin_repository.go#L24-L27
train
cloudfoundry/cli
util/ui/ui_for_push.go
DisplayChangesForPush
func (ui *UI) DisplayChangesForPush(changeSet []Change) error { if len(changeSet) == 0 { return nil } var columnWidth int for _, change := range changeSet { if width := wordSize(ui.TranslateText(change.Header)); width > columnWidth { columnWidth = width } } for _, change := range changeSet { padding := columnWidth - wordSize(ui.TranslateText(change.Header)) + 3 err := ui.DisplayChangeForPush(change.Header, padding, change.HiddenValue, change.CurrentValue, change.NewValue) if err != nil { return err } } return nil }
go
func (ui *UI) DisplayChangesForPush(changeSet []Change) error { if len(changeSet) == 0 { return nil } var columnWidth int for _, change := range changeSet { if width := wordSize(ui.TranslateText(change.Header)); width > columnWidth { columnWidth = width } } for _, change := range changeSet { padding := columnWidth - wordSize(ui.TranslateText(change.Header)) + 3 err := ui.DisplayChangeForPush(change.Header, padding, change.HiddenValue, change.CurrentValue, change.NewValue) if err != nil { return err } } return nil }
[ "func", "(", "ui", "*", "UI", ")", "DisplayChangesForPush", "(", "changeSet", "[", "]", "Change", ")", "error", "{", "if", "len", "(", "changeSet", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n", "var", "columnWidth", "int", "\n", "for", "_", ",", "change", ":=", "range", "changeSet", "{", "if", "width", ":=", "wordSize", "(", "ui", ".", "TranslateText", "(", "change", ".", "Header", ")", ")", ";", "width", ">", "columnWidth", "{", "columnWidth", "=", "width", "\n", "}", "\n", "}", "\n", "for", "_", ",", "change", ":=", "range", "changeSet", "{", "padding", ":=", "columnWidth", "-", "wordSize", "(", "ui", ".", "TranslateText", "(", "change", ".", "Header", ")", ")", "+", "3", "\n", "err", ":=", "ui", ".", "DisplayChangeForPush", "(", "change", ".", "Header", ",", "padding", ",", "change", ".", "HiddenValue", ",", "change", ".", "CurrentValue", ",", "change", ".", "NewValue", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// DisplayChangesForPush will display the set of changes via // DisplayChangeForPush in the order given.
[ "DisplayChangesForPush", "will", "display", "the", "set", "of", "changes", "via", "DisplayChangeForPush", "in", "the", "order", "given", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui_for_push.go#L73-L94
train
cloudfoundry/cli
actor/v2action/service_instance.go
CreateServiceInstance
func (actor Actor) CreateServiceInstance(spaceGUID, serviceName, servicePlanName, serviceInstanceName, brokerName string, params map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) { var allWarnings Warnings plan, allWarnings, err := actor.getServicePlanForServiceInSpace(servicePlanName, serviceName, spaceGUID, brokerName) if err != nil { return ServiceInstance{}, allWarnings, err } instance, warnings, err := actor.CloudControllerClient.CreateServiceInstance(spaceGUID, plan.GUID, serviceInstanceName, params, tags) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceInstance{}, allWarnings, err } return ServiceInstance(instance), allWarnings, nil }
go
func (actor Actor) CreateServiceInstance(spaceGUID, serviceName, servicePlanName, serviceInstanceName, brokerName string, params map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) { var allWarnings Warnings plan, allWarnings, err := actor.getServicePlanForServiceInSpace(servicePlanName, serviceName, spaceGUID, brokerName) if err != nil { return ServiceInstance{}, allWarnings, err } instance, warnings, err := actor.CloudControllerClient.CreateServiceInstance(spaceGUID, plan.GUID, serviceInstanceName, params, tags) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceInstance{}, allWarnings, err } return ServiceInstance(instance), allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "CreateServiceInstance", "(", "spaceGUID", ",", "serviceName", ",", "servicePlanName", ",", "serviceInstanceName", ",", "brokerName", "string", ",", "params", "map", "[", "string", "]", "interface", "{", "}", ",", "tags", "[", "]", "string", ")", "(", "ServiceInstance", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "plan", ",", "allWarnings", ",", "err", ":=", "actor", ".", "getServicePlanForServiceInSpace", "(", "servicePlanName", ",", "serviceName", ",", "spaceGUID", ",", "brokerName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "instance", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateServiceInstance", "(", "spaceGUID", ",", "plan", ".", "GUID", ",", "serviceInstanceName", ",", "params", ",", "tags", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "return", "ServiceInstance", "(", "instance", ")", ",", "allWarnings", ",", "nil", "\n", "}" ]
// CreateServiceInstance creates a new service instance with the provided attributes.
[ "CreateServiceInstance", "creates", "a", "new", "service", "instance", "with", "the", "provided", "attributes", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_instance.go#L14-L29
train
cloudfoundry/cli
actor/v2action/route.go
Summary
func (rs Routes) Summary() string { formattedRoutes := []string{} for _, route := range rs { formattedRoutes = append(formattedRoutes, route.String()) } return strings.Join(formattedRoutes, ", ") }
go
func (rs Routes) Summary() string { formattedRoutes := []string{} for _, route := range rs { formattedRoutes = append(formattedRoutes, route.String()) } return strings.Join(formattedRoutes, ", ") }
[ "func", "(", "rs", "Routes", ")", "Summary", "(", ")", "string", "{", "formattedRoutes", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "route", ":=", "range", "rs", "{", "formattedRoutes", "=", "append", "(", "formattedRoutes", ",", "route", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "formattedRoutes", ",", "\", \"", ")", "\n", "}" ]
// Summary converts routes into a comma separated string.
[ "Summary", "converts", "routes", "into", "a", "comma", "separated", "string", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L19-L25
train
cloudfoundry/cli
actor/v2action/route.go
Validate
func (r Route) Validate() error { if r.Domain.IsHTTP() { if r.Port.IsSet { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsShared() && r.Host == "" { return actionerror.NoHostnameAndSharedDomainError{} } } else { // Is TCP Domain if r.Host != "" || r.Path != "" { return actionerror.InvalidTCPRouteSettings{Domain: r.Domain.Name} } } return nil }
go
func (r Route) Validate() error { if r.Domain.IsHTTP() { if r.Port.IsSet { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsShared() && r.Host == "" { return actionerror.NoHostnameAndSharedDomainError{} } } else { // Is TCP Domain if r.Host != "" || r.Path != "" { return actionerror.InvalidTCPRouteSettings{Domain: r.Domain.Name} } } return nil }
[ "func", "(", "r", "Route", ")", "Validate", "(", ")", "error", "{", "if", "r", ".", "Domain", ".", "IsHTTP", "(", ")", "{", "if", "r", ".", "Port", ".", "IsSet", "{", "return", "actionerror", ".", "InvalidHTTPRouteSettings", "{", "Domain", ":", "r", ".", "Domain", ".", "Name", "}", "\n", "}", "\n", "if", "r", ".", "Domain", ".", "IsShared", "(", ")", "&&", "r", ".", "Host", "==", "\"\"", "{", "return", "actionerror", ".", "NoHostnameAndSharedDomainError", "{", "}", "\n", "}", "\n", "}", "else", "{", "if", "r", ".", "Host", "!=", "\"\"", "||", "r", ".", "Path", "!=", "\"\"", "{", "return", "actionerror", ".", "InvalidTCPRouteSettings", "{", "Domain", ":", "r", ".", "Domain", ".", "Name", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate will return an error if there are invalid HTTP or TCP settings for // it's given domain.
[ "Validate", "will", "return", "an", "error", "if", "there", "are", "invalid", "HTTP", "or", "TCP", "settings", "for", "it", "s", "given", "domain", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L43-L57
train
cloudfoundry/cli
actor/v2action/route.go
ValidateWithRandomPort
func (r Route) ValidateWithRandomPort(randomPort bool) error { if r.Domain.IsHTTP() && randomPort { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsTCP() && !r.Port.IsSet && !randomPort { return actionerror.TCPRouteOptionsNotProvidedError{} } return r.Validate() }
go
func (r Route) ValidateWithRandomPort(randomPort bool) error { if r.Domain.IsHTTP() && randomPort { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsTCP() && !r.Port.IsSet && !randomPort { return actionerror.TCPRouteOptionsNotProvidedError{} } return r.Validate() }
[ "func", "(", "r", "Route", ")", "ValidateWithRandomPort", "(", "randomPort", "bool", ")", "error", "{", "if", "r", ".", "Domain", ".", "IsHTTP", "(", ")", "&&", "randomPort", "{", "return", "actionerror", ".", "InvalidHTTPRouteSettings", "{", "Domain", ":", "r", ".", "Domain", ".", "Name", "}", "\n", "}", "\n", "if", "r", ".", "Domain", ".", "IsTCP", "(", ")", "&&", "!", "r", ".", "Port", ".", "IsSet", "&&", "!", "randomPort", "{", "return", "actionerror", ".", "TCPRouteOptionsNotProvidedError", "{", "}", "\n", "}", "\n", "return", "r", ".", "Validate", "(", ")", "\n", "}" ]
// ValidateWithRandomPort will return an error if a random port is requested // for an HTTP route, or if the route is TCP, a random port wasn't requested, // and the route has no port set.
[ "ValidateWithRandomPort", "will", "return", "an", "error", "if", "a", "random", "port", "is", "requested", "for", "an", "HTTP", "route", "or", "if", "the", "route", "is", "TCP", "a", "random", "port", "wasn", "t", "requested", "and", "the", "route", "has", "no", "port", "set", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L62-L71
train
cloudfoundry/cli
actor/v2action/route.go
String
func (r Route) String() string { routeString := r.Domain.Name if r.Port.IsSet { routeString = fmt.Sprintf("%s:%d", routeString, r.Port.Value) } else if r.RandomTCPPort() { routeString = fmt.Sprintf("%s:????", routeString) } if r.Host != "" { routeString = fmt.Sprintf("%s.%s", r.Host, routeString) } if r.Path != "" { routeString = path.Join(routeString, r.Path) } return routeString }
go
func (r Route) String() string { routeString := r.Domain.Name if r.Port.IsSet { routeString = fmt.Sprintf("%s:%d", routeString, r.Port.Value) } else if r.RandomTCPPort() { routeString = fmt.Sprintf("%s:????", routeString) } if r.Host != "" { routeString = fmt.Sprintf("%s.%s", r.Host, routeString) } if r.Path != "" { routeString = path.Join(routeString, r.Path) } return routeString }
[ "func", "(", "r", "Route", ")", "String", "(", ")", "string", "{", "routeString", ":=", "r", ".", "Domain", ".", "Name", "\n", "if", "r", ".", "Port", ".", "IsSet", "{", "routeString", "=", "fmt", ".", "Sprintf", "(", "\"%s:%d\"", ",", "routeString", ",", "r", ".", "Port", ".", "Value", ")", "\n", "}", "else", "if", "r", ".", "RandomTCPPort", "(", ")", "{", "routeString", "=", "fmt", ".", "Sprintf", "(", "\"%s:????\"", ",", "routeString", ")", "\n", "}", "\n", "if", "r", ".", "Host", "!=", "\"\"", "{", "routeString", "=", "fmt", ".", "Sprintf", "(", "\"%s.%s\"", ",", "r", ".", "Host", ",", "routeString", ")", "\n", "}", "\n", "if", "r", ".", "Path", "!=", "\"\"", "{", "routeString", "=", "path", ".", "Join", "(", "routeString", ",", "r", ".", "Path", ")", "\n", "}", "\n", "return", "routeString", "\n", "}" ]
// String formats the route in a human readable format.
[ "String", "formats", "the", "route", "in", "a", "human", "readable", "format", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L74-L92
train
cloudfoundry/cli
actor/v2action/route.go
GetOrphanedRoutesBySpace
func (actor Actor) GetOrphanedRoutesBySpace(spaceGUID string) ([]Route, Warnings, error) { var ( orphanedRoutes []Route allWarnings Warnings ) routes, warnings, err := actor.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, route := range routes { apps, warnings, err := actor.GetRouteApplications(route.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } if len(apps) == 0 { orphanedRoutes = append(orphanedRoutes, route) } } if len(orphanedRoutes) == 0 { return nil, allWarnings, actionerror.OrphanedRoutesNotFoundError{} } return orphanedRoutes, allWarnings, nil }
go
func (actor Actor) GetOrphanedRoutesBySpace(spaceGUID string) ([]Route, Warnings, error) { var ( orphanedRoutes []Route allWarnings Warnings ) routes, warnings, err := actor.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, route := range routes { apps, warnings, err := actor.GetRouteApplications(route.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } if len(apps) == 0 { orphanedRoutes = append(orphanedRoutes, route) } } if len(orphanedRoutes) == 0 { return nil, allWarnings, actionerror.OrphanedRoutesNotFoundError{} } return orphanedRoutes, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetOrphanedRoutesBySpace", "(", "spaceGUID", "string", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "var", "(", "orphanedRoutes", "[", "]", "Route", "\n", "allWarnings", "Warnings", "\n", ")", "\n", "routes", ",", "warnings", ",", "err", ":=", "actor", ".", "GetSpaceRoutes", "(", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "route", ":=", "range", "routes", "{", "apps", ",", "warnings", ",", "err", ":=", "actor", ".", "GetRouteApplications", "(", "route", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n", "if", "len", "(", "apps", ")", "==", "0", "{", "orphanedRoutes", "=", "append", "(", "orphanedRoutes", ",", "route", ")", "\n", "}", "\n", "}", "\n", "if", "len", "(", "orphanedRoutes", ")", "==", "0", "{", "return", "nil", ",", "allWarnings", ",", "actionerror", ".", "OrphanedRoutesNotFoundError", "{", "}", "\n", "}", "\n", "return", "orphanedRoutes", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetOrphanedRoutesBySpace returns a list of orphaned routes associated with // the provided Space GUID.
[ "GetOrphanedRoutesBySpace", "returns", "a", "list", "of", "orphaned", "routes", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L165-L194
train
cloudfoundry/cli
actor/v2action/route.go
GetApplicationRoutes
func (actor Actor) GetApplicationRoutes(applicationGUID string) (Routes, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetApplicationRoutes(applicationGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
go
func (actor Actor) GetApplicationRoutes(applicationGUID string) (Routes, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetApplicationRoutes(applicationGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "GetApplicationRoutes", "(", "applicationGUID", "string", ")", "(", "Routes", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "ccv2Routes", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationRoutes", "(", "applicationGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n", "routes", ",", "domainWarnings", ",", "err", ":=", "actor", ".", "applyDomain", "(", "ccv2Routes", ")", "\n", "return", "routes", ",", "append", "(", "allWarnings", ",", "domainWarnings", "...", ")", ",", "err", "\n", "}" ]
// GetApplicationRoutes returns a list of routes associated with the provided // Application GUID.
[ "GetApplicationRoutes", "returns", "a", "list", "of", "routes", "associated", "with", "the", "provided", "Application", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L198-L209
train
cloudfoundry/cli
actor/v2action/route.go
GetSpaceRoutes
func (actor Actor) GetSpaceRoutes(spaceGUID string) ([]Route, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
go
func (actor Actor) GetSpaceRoutes(spaceGUID string) ([]Route, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "GetSpaceRoutes", "(", "spaceGUID", "string", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "ccv2Routes", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaceRoutes", "(", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n", "routes", ",", "domainWarnings", ",", "err", ":=", "actor", ".", "applyDomain", "(", "ccv2Routes", ")", "\n", "return", "routes", ",", "append", "(", "allWarnings", ",", "domainWarnings", "...", ")", ",", "err", "\n", "}" ]
// GetSpaceRoutes returns a list of routes associated with the provided Space // GUID.
[ "GetSpaceRoutes", "returns", "a", "list", "of", "routes", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L213-L224
train
cloudfoundry/cli
actor/v2action/route.go
DeleteUnmappedRoutes
func (actor Actor) DeleteUnmappedRoutes(spaceGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.DeleteSpaceUnmappedRoutes(spaceGUID) return Warnings(warnings), err }
go
func (actor Actor) DeleteUnmappedRoutes(spaceGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.DeleteSpaceUnmappedRoutes(spaceGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "DeleteUnmappedRoutes", "(", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "DeleteSpaceUnmappedRoutes", "(", "spaceGUID", ")", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// DeleteUnmappedRoutes deletes the unmapped routes associated with the provided Space GUID.
[ "DeleteUnmappedRoutes", "deletes", "the", "unmapped", "routes", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L227-L230
train
cloudfoundry/cli
actor/v2action/route.go
FindRouteBoundToSpaceWithSettings
func (actor Actor) FindRouteBoundToSpaceWithSettings(route Route) (Route, Warnings, error) { existingRoute, warnings, err := actor.GetRouteByComponents(route) if routeNotFoundErr, ok := err.(actionerror.RouteNotFoundError); ok { // This check only works for API versions 2.55 or higher. It will return // false for anything below that. log.Infof("checking route existence for: %s\n", route) exists, checkRouteWarnings, chkErr := actor.CheckRoute(route) if chkErr != nil { log.Errorln("check route:", err) return Route{}, append(Warnings(warnings), checkRouteWarnings...), chkErr } // This will happen if the route exists in a space to which the user does // not have access. if exists { log.Errorf("unable to find route %s in current space", route.String()) return Route{}, append(Warnings(warnings), checkRouteWarnings...), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Warnf("negative existence check for route %s - returning partial route", route.String()) log.Debugf("partialRoute: %#v", route) return Route{}, append(Warnings(warnings), checkRouteWarnings...), routeNotFoundErr } else if err != nil { log.Errorln("finding route:", err) return Route{}, Warnings(warnings), err } if existingRoute.SpaceGUID != route.SpaceGUID { log.WithFields(log.Fields{ "targeted_space_guid": route.SpaceGUID, "existing_space_guid": existingRoute.SpaceGUID, }).Errorf("route exists in different space the user has access to") return Route{}, Warnings(warnings), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Debugf("found route: %#v", existingRoute) return existingRoute, Warnings(warnings), err }
go
func (actor Actor) FindRouteBoundToSpaceWithSettings(route Route) (Route, Warnings, error) { existingRoute, warnings, err := actor.GetRouteByComponents(route) if routeNotFoundErr, ok := err.(actionerror.RouteNotFoundError); ok { // This check only works for API versions 2.55 or higher. It will return // false for anything below that. log.Infof("checking route existence for: %s\n", route) exists, checkRouteWarnings, chkErr := actor.CheckRoute(route) if chkErr != nil { log.Errorln("check route:", err) return Route{}, append(Warnings(warnings), checkRouteWarnings...), chkErr } // This will happen if the route exists in a space to which the user does // not have access. if exists { log.Errorf("unable to find route %s in current space", route.String()) return Route{}, append(Warnings(warnings), checkRouteWarnings...), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Warnf("negative existence check for route %s - returning partial route", route.String()) log.Debugf("partialRoute: %#v", route) return Route{}, append(Warnings(warnings), checkRouteWarnings...), routeNotFoundErr } else if err != nil { log.Errorln("finding route:", err) return Route{}, Warnings(warnings), err } if existingRoute.SpaceGUID != route.SpaceGUID { log.WithFields(log.Fields{ "targeted_space_guid": route.SpaceGUID, "existing_space_guid": existingRoute.SpaceGUID, }).Errorf("route exists in different space the user has access to") return Route{}, Warnings(warnings), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Debugf("found route: %#v", existingRoute) return existingRoute, Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "FindRouteBoundToSpaceWithSettings", "(", "route", "Route", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "existingRoute", ",", "warnings", ",", "err", ":=", "actor", ".", "GetRouteByComponents", "(", "route", ")", "\n", "if", "routeNotFoundErr", ",", "ok", ":=", "err", ".", "(", "actionerror", ".", "RouteNotFoundError", ")", ";", "ok", "{", "log", ".", "Infof", "(", "\"checking route existence for: %s\\n\"", ",", "\\n", ")", "\n", "route", "\n", "exists", ",", "checkRouteWarnings", ",", "chkErr", ":=", "actor", ".", "CheckRoute", "(", "route", ")", "\n", "if", "chkErr", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"check route:\"", ",", "err", ")", "\n", "return", "Route", "{", "}", ",", "append", "(", "Warnings", "(", "warnings", ")", ",", "checkRouteWarnings", "...", ")", ",", "chkErr", "\n", "}", "\n", "if", "exists", "{", "log", ".", "Errorf", "(", "\"unable to find route %s in current space\"", ",", "route", ".", "String", "(", ")", ")", "\n", "return", "Route", "{", "}", ",", "append", "(", "Warnings", "(", "warnings", ")", ",", "checkRouteWarnings", "...", ")", ",", "actionerror", ".", "RouteInDifferentSpaceError", "{", "Route", ":", "route", ".", "String", "(", ")", "}", "\n", "}", "\n", "log", ".", "Warnf", "(", "\"negative existence check for route %s - returning partial route\"", ",", "route", ".", "String", "(", ")", ")", "\n", "log", ".", "Debugf", "(", "\"partialRoute: %#v\"", ",", "route", ")", "\n", "}", "else", "return", "Route", "{", "}", ",", "append", "(", "Warnings", "(", "warnings", ")", ",", "checkRouteWarnings", "...", ")", ",", "routeNotFoundErr", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"finding route:\"", ",", "err", ")", "\n", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "if", "existingRoute", ".", "SpaceGUID", "!=", "route", ".", "SpaceGUID", "{", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"targeted_space_guid\"", ":", "route", ".", "SpaceGUID", ",", "\"existing_space_guid\"", ":", "existingRoute", ".", "SpaceGUID", ",", "}", ")", ".", "Errorf", "(", "\"route exists in different space the user has access to\"", ")", "\n", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "RouteInDifferentSpaceError", "{", "Route", ":", "route", ".", "String", "(", ")", "}", "\n", "}", "\n", "log", ".", "Debugf", "(", "\"found route: %#v\"", ",", "existingRoute", ")", "\n", "}" ]
// FindRouteBoundToSpaceWithSettings finds the route with the given host, // domain and space. If it is unable to find the route, it will check if it // exists anywhere in the system. When the route exists in another space, // RouteInDifferentSpaceError is returned. Use this when you know the space // GUID.
[ "FindRouteBoundToSpaceWithSettings", "finds", "the", "route", "with", "the", "given", "host", "domain", "and", "space", ".", "If", "it", "is", "unable", "to", "find", "the", "route", "it", "will", "check", "if", "it", "exists", "anywhere", "in", "the", "system", ".", "When", "the", "route", "exists", "in", "another", "space", "RouteInDifferentSpaceError", "is", "returned", ".", "Use", "this", "when", "you", "know", "the", "space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L248-L285
train
cloudfoundry/cli
actor/v2action/route.go
GetRouteByComponents
func (actor Actor) GetRouteByComponents(route Route) (Route, Warnings, error) { // TODO: validation should probably be done separately (?) if route.Domain.IsTCP() && !route.Port.IsSet { return Route{}, nil, actionerror.PortNotProvidedForQueryError{} } if route.Domain.IsShared() && route.Domain.IsHTTP() && route.Host == "" { return Route{}, nil, actionerror.NoHostnameAndSharedDomainError{} } queries := []ccv2.Filter{ { Type: constant.DomainGUIDFilter, Operator: constant.EqualOperator, Values: []string{route.Domain.GUID}, }, { Type: constant.HostFilter, Operator: constant.EqualOperator, Values: []string{route.Host}, }, { Type: constant.PathFilter, Operator: constant.EqualOperator, Values: []string{route.Path}, }, } if route.Port.IsSet { queries = append(queries, ccv2.Filter{ Type: constant.PortFilter, Operator: constant.EqualOperator, Values: []string{fmt.Sprint(route.Port.Value)}, }) } ccv2Routes, warnings, err := actor.CloudControllerClient.GetRoutes(queries...) if err != nil { return Route{}, Warnings(warnings), err } if len(ccv2Routes) == 0 { return Route{}, Warnings(warnings), actionerror.RouteNotFoundError{ Host: route.Host, DomainGUID: route.Domain.GUID, Path: route.Path, Port: route.Port.Value, } } return CCToActorRoute(ccv2Routes[0], route.Domain), Warnings(warnings), err }
go
func (actor Actor) GetRouteByComponents(route Route) (Route, Warnings, error) { // TODO: validation should probably be done separately (?) if route.Domain.IsTCP() && !route.Port.IsSet { return Route{}, nil, actionerror.PortNotProvidedForQueryError{} } if route.Domain.IsShared() && route.Domain.IsHTTP() && route.Host == "" { return Route{}, nil, actionerror.NoHostnameAndSharedDomainError{} } queries := []ccv2.Filter{ { Type: constant.DomainGUIDFilter, Operator: constant.EqualOperator, Values: []string{route.Domain.GUID}, }, { Type: constant.HostFilter, Operator: constant.EqualOperator, Values: []string{route.Host}, }, { Type: constant.PathFilter, Operator: constant.EqualOperator, Values: []string{route.Path}, }, } if route.Port.IsSet { queries = append(queries, ccv2.Filter{ Type: constant.PortFilter, Operator: constant.EqualOperator, Values: []string{fmt.Sprint(route.Port.Value)}, }) } ccv2Routes, warnings, err := actor.CloudControllerClient.GetRoutes(queries...) if err != nil { return Route{}, Warnings(warnings), err } if len(ccv2Routes) == 0 { return Route{}, Warnings(warnings), actionerror.RouteNotFoundError{ Host: route.Host, DomainGUID: route.Domain.GUID, Path: route.Path, Port: route.Port.Value, } } return CCToActorRoute(ccv2Routes[0], route.Domain), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetRouteByComponents", "(", "route", "Route", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "if", "route", ".", "Domain", ".", "IsTCP", "(", ")", "&&", "!", "route", ".", "Port", ".", "IsSet", "{", "return", "Route", "{", "}", ",", "nil", ",", "actionerror", ".", "PortNotProvidedForQueryError", "{", "}", "\n", "}", "\n", "if", "route", ".", "Domain", ".", "IsShared", "(", ")", "&&", "route", ".", "Domain", ".", "IsHTTP", "(", ")", "&&", "route", ".", "Host", "==", "\"\"", "{", "return", "Route", "{", "}", ",", "nil", ",", "actionerror", ".", "NoHostnameAndSharedDomainError", "{", "}", "\n", "}", "\n", "queries", ":=", "[", "]", "ccv2", ".", "Filter", "{", "{", "Type", ":", "constant", ".", "DomainGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "route", ".", "Domain", ".", "GUID", "}", ",", "}", ",", "{", "Type", ":", "constant", ".", "HostFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "route", ".", "Host", "}", ",", "}", ",", "{", "Type", ":", "constant", ".", "PathFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "route", ".", "Path", "}", ",", "}", ",", "}", "\n", "if", "route", ".", "Port", ".", "IsSet", "{", "queries", "=", "append", "(", "queries", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "PortFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "fmt", ".", "Sprint", "(", "route", ".", "Port", ".", "Value", ")", "}", ",", "}", ")", "\n", "}", "\n", "ccv2Routes", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetRoutes", "(", "queries", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "if", "len", "(", "ccv2Routes", ")", "==", "0", "{", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "RouteNotFoundError", "{", "Host", ":", "route", ".", "Host", ",", "DomainGUID", ":", "route", ".", "Domain", ".", "GUID", ",", "Path", ":", "route", ".", "Path", ",", "Port", ":", "route", ".", "Port", ".", "Value", ",", "}", "\n", "}", "\n", "return", "CCToActorRoute", "(", "ccv2Routes", "[", "0", "]", ",", "route", ".", "Domain", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetRouteByComponents returns the route with the matching host, domain, path, // and port. Use this when you don't know the space GUID. // TCP routes require a port to be uniquely identified // HTTP routes using shared domains require a hostname or path to be uniquely identified
[ "GetRouteByComponents", "returns", "the", "route", "with", "the", "matching", "host", "domain", "path", "and", "port", ".", "Use", "this", "when", "you", "don", "t", "know", "the", "space", "GUID", ".", "TCP", "routes", "require", "a", "port", "to", "be", "uniquely", "identified", "HTTP", "routes", "using", "shared", "domains", "require", "a", "hostname", "or", "path", "to", "be", "uniquely", "identified" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L291-L340
train
cloudfoundry/cli
actor/sharedaction/resource.go
ToV3Resource
func (r Resource) ToV3Resource() V3Resource { return V3Resource{ FilePath: r.Filename, Mode: r.Mode, Checksum: ccv3.Checksum{Value: r.SHA1}, SizeInBytes: r.Size, } }
go
func (r Resource) ToV3Resource() V3Resource { return V3Resource{ FilePath: r.Filename, Mode: r.Mode, Checksum: ccv3.Checksum{Value: r.SHA1}, SizeInBytes: r.Size, } }
[ "func", "(", "r", "Resource", ")", "ToV3Resource", "(", ")", "V3Resource", "{", "return", "V3Resource", "{", "FilePath", ":", "r", ".", "Filename", ",", "Mode", ":", "r", ".", "Mode", ",", "Checksum", ":", "ccv3", ".", "Checksum", "{", "Value", ":", "r", ".", "SHA1", "}", ",", "SizeInBytes", ":", "r", ".", "Size", ",", "}", "\n", "}" ]
// ToV3Resource converts a sharedaction Resource to V3 Resource format
[ "ToV3Resource", "converts", "a", "sharedaction", "Resource", "to", "V3", "Resource", "format" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L49-L56
train
cloudfoundry/cli
actor/sharedaction/resource.go
ToV2Resource
func (r V3Resource) ToV2Resource() Resource { return Resource{ Filename: r.FilePath, Mode: r.Mode, SHA1: r.Checksum.Value, Size: r.SizeInBytes, } }
go
func (r V3Resource) ToV2Resource() Resource { return Resource{ Filename: r.FilePath, Mode: r.Mode, SHA1: r.Checksum.Value, Size: r.SizeInBytes, } }
[ "func", "(", "r", "V3Resource", ")", "ToV2Resource", "(", ")", "Resource", "{", "return", "Resource", "{", "Filename", ":", "r", ".", "FilePath", ",", "Mode", ":", "r", ".", "Mode", ",", "SHA1", ":", "r", ".", "Checksum", ".", "Value", ",", "Size", ":", "r", ".", "SizeInBytes", ",", "}", "\n", "}" ]
// ToV2Resource converts a V3 Resource to V2 Resource format
[ "ToV2Resource", "converts", "a", "V3", "Resource", "to", "V2", "Resource", "format" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L59-L66
train
cloudfoundry/cli
actor/sharedaction/resource.go
GatherArchiveResources
func (actor Actor) GatherArchiveResources(archivePath string) ([]Resource, error) { var resources []Resource archive, err := os.Open(archivePath) if err != nil { return nil, err } defer archive.Close() reader, err := actor.newArchiveReader(archive) if err != nil { return nil, err } gitIgnore, err := actor.generateArchiveCFIgnoreMatcher(reader.File) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } for _, archivedFile := range reader.File { filename := filepath.ToSlash(archivedFile.Name) if gitIgnore.MatchesPath(filename) { continue } resource := Resource{Filename: filename} info := archivedFile.FileInfo() switch { case info.IsDir(): resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: resource.Mode = info.Mode() default: fileReader, err := archivedFile.Open() if err != nil { return nil, err } defer fileReader.Close() hash := sha1.New() _, err = io.Copy(hash, fileReader) if err != nil { return nil, err } resource.Mode = DefaultArchiveFilePermissions resource.SHA1 = fmt.Sprintf("%x", hash.Sum(nil)) resource.Size = archivedFile.FileInfo().Size() } resources = append(resources, resource) } if len(resources) <= 1 { return nil, actionerror.EmptyArchiveError{Path: archivePath} } return resources, nil }
go
func (actor Actor) GatherArchiveResources(archivePath string) ([]Resource, error) { var resources []Resource archive, err := os.Open(archivePath) if err != nil { return nil, err } defer archive.Close() reader, err := actor.newArchiveReader(archive) if err != nil { return nil, err } gitIgnore, err := actor.generateArchiveCFIgnoreMatcher(reader.File) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } for _, archivedFile := range reader.File { filename := filepath.ToSlash(archivedFile.Name) if gitIgnore.MatchesPath(filename) { continue } resource := Resource{Filename: filename} info := archivedFile.FileInfo() switch { case info.IsDir(): resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: resource.Mode = info.Mode() default: fileReader, err := archivedFile.Open() if err != nil { return nil, err } defer fileReader.Close() hash := sha1.New() _, err = io.Copy(hash, fileReader) if err != nil { return nil, err } resource.Mode = DefaultArchiveFilePermissions resource.SHA1 = fmt.Sprintf("%x", hash.Sum(nil)) resource.Size = archivedFile.FileInfo().Size() } resources = append(resources, resource) } if len(resources) <= 1 { return nil, actionerror.EmptyArchiveError{Path: archivePath} } return resources, nil }
[ "func", "(", "actor", "Actor", ")", "GatherArchiveResources", "(", "archivePath", "string", ")", "(", "[", "]", "Resource", ",", "error", ")", "{", "var", "resources", "[", "]", "Resource", "\n", "archive", ",", "err", ":=", "os", ".", "Open", "(", "archivePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "archive", ".", "Close", "(", ")", "\n", "reader", ",", "err", ":=", "actor", ".", "newArchiveReader", "(", "archive", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "gitIgnore", ",", "err", ":=", "actor", ".", "generateArchiveCFIgnoreMatcher", "(", "reader", ".", "File", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"reading .cfignore file:\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "archivedFile", ":=", "range", "reader", ".", "File", "{", "filename", ":=", "filepath", ".", "ToSlash", "(", "archivedFile", ".", "Name", ")", "\n", "if", "gitIgnore", ".", "MatchesPath", "(", "filename", ")", "{", "continue", "\n", "}", "\n", "resource", ":=", "Resource", "{", "Filename", ":", "filename", "}", "\n", "info", ":=", "archivedFile", ".", "FileInfo", "(", ")", "\n", "switch", "{", "case", "info", ".", "IsDir", "(", ")", ":", "resource", ".", "Mode", "=", "DefaultFolderPermissions", "\n", "case", "info", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "os", ".", "ModeSymlink", ":", "resource", ".", "Mode", "=", "info", ".", "Mode", "(", ")", "\n", "default", ":", "fileReader", ",", "err", ":=", "archivedFile", ".", "Open", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "fileReader", ".", "Close", "(", ")", "\n", "hash", ":=", "sha1", ".", "New", "(", ")", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "hash", ",", "fileReader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "resource", ".", "Mode", "=", "DefaultArchiveFilePermissions", "\n", "resource", ".", "SHA1", "=", "fmt", ".", "Sprintf", "(", "\"%x\"", ",", "hash", ".", "Sum", "(", "nil", ")", ")", "\n", "resource", ".", "Size", "=", "archivedFile", ".", "FileInfo", "(", ")", ".", "Size", "(", ")", "\n", "}", "\n", "resources", "=", "append", "(", "resources", ",", "resource", ")", "\n", "}", "\n", "if", "len", "(", "resources", ")", "<=", "1", "{", "return", "nil", ",", "actionerror", ".", "EmptyArchiveError", "{", "Path", ":", "archivePath", "}", "\n", "}", "\n", "return", "resources", ",", "nil", "\n", "}" ]
// GatherArchiveResources returns a list of resources for an archive.
[ "GatherArchiveResources", "returns", "a", "list", "of", "resources", "for", "an", "archive", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L69-L128
train
cloudfoundry/cli
actor/sharedaction/resource.go
GatherDirectoryResources
func (actor Actor) GatherDirectoryResources(sourceDir string) ([]Resource, error) { var ( resources []Resource gitIgnore *ignore.GitIgnore ) gitIgnore, err := actor.generateDirectoryCFIgnoreMatcher(sourceDir) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } evalDir, err := filepath.EvalSymlinks(sourceDir) if err != nil { log.Errorln("evaluating symlink:", err) return nil, err } walkErr := filepath.Walk(evalDir, func(fullPath string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(evalDir, fullPath) if err != nil { return err } // if file ignored continue to the next file if gitIgnore.MatchesPath(relPath) { return nil } if relPath == "." { return nil } resource := Resource{ Filename: filepath.ToSlash(relPath), } switch { case info.IsDir(): // If the file is a directory resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: // If the file is a Symlink we just set the mode of the file // We won't be using any sha information since we don't do // any resource matching on symlinks. resource.Mode = fixMode(info.Mode()) default: // If the file is regular we want to open // and calculate the sha of the file file, err := os.Open(fullPath) if err != nil { return err } defer file.Close() sum := sha1.New() _, err = io.Copy(sum, file) if err != nil { return err } resource.Mode = fixMode(info.Mode()) resource.SHA1 = fmt.Sprintf("%x", sum.Sum(nil)) resource.Size = info.Size() } resources = append(resources, resource) return nil }) if len(resources) == 0 { return nil, actionerror.EmptyDirectoryError{Path: sourceDir} } return resources, walkErr }
go
func (actor Actor) GatherDirectoryResources(sourceDir string) ([]Resource, error) { var ( resources []Resource gitIgnore *ignore.GitIgnore ) gitIgnore, err := actor.generateDirectoryCFIgnoreMatcher(sourceDir) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } evalDir, err := filepath.EvalSymlinks(sourceDir) if err != nil { log.Errorln("evaluating symlink:", err) return nil, err } walkErr := filepath.Walk(evalDir, func(fullPath string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(evalDir, fullPath) if err != nil { return err } // if file ignored continue to the next file if gitIgnore.MatchesPath(relPath) { return nil } if relPath == "." { return nil } resource := Resource{ Filename: filepath.ToSlash(relPath), } switch { case info.IsDir(): // If the file is a directory resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: // If the file is a Symlink we just set the mode of the file // We won't be using any sha information since we don't do // any resource matching on symlinks. resource.Mode = fixMode(info.Mode()) default: // If the file is regular we want to open // and calculate the sha of the file file, err := os.Open(fullPath) if err != nil { return err } defer file.Close() sum := sha1.New() _, err = io.Copy(sum, file) if err != nil { return err } resource.Mode = fixMode(info.Mode()) resource.SHA1 = fmt.Sprintf("%x", sum.Sum(nil)) resource.Size = info.Size() } resources = append(resources, resource) return nil }) if len(resources) == 0 { return nil, actionerror.EmptyDirectoryError{Path: sourceDir} } return resources, walkErr }
[ "func", "(", "actor", "Actor", ")", "GatherDirectoryResources", "(", "sourceDir", "string", ")", "(", "[", "]", "Resource", ",", "error", ")", "{", "var", "(", "resources", "[", "]", "Resource", "\n", "gitIgnore", "*", "ignore", ".", "GitIgnore", "\n", ")", "\n", "gitIgnore", ",", "err", ":=", "actor", ".", "generateDirectoryCFIgnoreMatcher", "(", "sourceDir", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"reading .cfignore file:\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "evalDir", ",", "err", ":=", "filepath", ".", "EvalSymlinks", "(", "sourceDir", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"evaluating symlink:\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n", "walkErr", ":=", "filepath", ".", "Walk", "(", "evalDir", ",", "func", "(", "fullPath", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "relPath", ",", "err", ":=", "filepath", ".", "Rel", "(", "evalDir", ",", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "if", "gitIgnore", ".", "MatchesPath", "(", "relPath", ")", "{", "return", "nil", "\n", "}", "\n", "if", "relPath", "==", "\".\"", "{", "return", "nil", "\n", "}", "\n", "resource", ":=", "Resource", "{", "Filename", ":", "filepath", ".", "ToSlash", "(", "relPath", ")", ",", "}", "\n", "switch", "{", "case", "info", ".", "IsDir", "(", ")", ":", "resource", ".", "Mode", "=", "DefaultFolderPermissions", "\n", "case", "info", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "os", ".", "ModeSymlink", ":", "resource", ".", "Mode", "=", "fixMode", "(", "info", ".", "Mode", "(", ")", ")", "\n", "default", ":", "file", ",", "err", ":=", "os", ".", "Open", "(", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n", "sum", ":=", "sha1", ".", "New", "(", ")", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "sum", ",", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "resource", ".", "Mode", "=", "fixMode", "(", "info", ".", "Mode", "(", ")", ")", "\n", "resource", ".", "SHA1", "=", "fmt", ".", "Sprintf", "(", "\"%x\"", ",", "sum", ".", "Sum", "(", "nil", ")", ")", "\n", "resource", ".", "Size", "=", "info", ".", "Size", "(", ")", "\n", "}", "\n", "resources", "=", "append", "(", "resources", ",", "resource", ")", "\n", "return", "nil", "\n", "}", ")", "\n", "if", "len", "(", "resources", ")", "==", "0", "{", "return", "nil", ",", "actionerror", ".", "EmptyDirectoryError", "{", "Path", ":", "sourceDir", "}", "\n", "}", "\n", "return", "resources", ",", "walkErr", "\n", "}" ]
// GatherDirectoryResources returns a list of resources for a directory.
[ "GatherDirectoryResources", "returns", "a", "list", "of", "resources", "for", "a", "directory", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L131-L210
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
MarshalJSON
func (application Application) MarshalJSON() ([]byte, error) { ccApp := struct { Buildpack *string `json:"buildpack,omitempty"` Command *string `json:"command,omitempty"` DiskQuota *uint64 `json:"disk_quota,omitempty"` DockerCredentials *DockerCredentials `json:"docker_credentials,omitempty"` DockerImage string `json:"docker_image,omitempty"` EnvironmentVariables map[string]string `json:"environment_json,omitempty"` HealthCheckHTTPEndpoint *string `json:"health_check_http_endpoint,omitempty"` HealthCheckTimeout uint64 `json:"health_check_timeout,omitempty"` HealthCheckType constant.ApplicationHealthCheckType `json:"health_check_type,omitempty"` Instances *int `json:"instances,omitempty"` Memory *uint64 `json:"memory,omitempty"` Name string `json:"name,omitempty"` SpaceGUID string `json:"space_guid,omitempty"` StackGUID string `json:"stack_guid,omitempty"` State constant.ApplicationState `json:"state,omitempty"` }{ DockerImage: application.DockerImage, EnvironmentVariables: application.EnvironmentVariables, HealthCheckTimeout: application.HealthCheckTimeout, HealthCheckType: application.HealthCheckType, Name: application.Name, SpaceGUID: application.SpaceGUID, StackGUID: application.StackGUID, State: application.State, } if application.Buildpack.IsSet { ccApp.Buildpack = &application.Buildpack.Value } if application.Command.IsSet { ccApp.Command = &application.Command.Value } if application.DiskQuota.IsSet { ccApp.DiskQuota = &application.DiskQuota.Value } if application.DockerCredentials.Username != "" || application.DockerCredentials.Password != "" { ccApp.DockerCredentials = &DockerCredentials{ Username: application.DockerCredentials.Username, Password: application.DockerCredentials.Password, } } if application.Instances.IsSet { ccApp.Instances = &application.Instances.Value } if application.HealthCheckType != "" { ccApp.HealthCheckHTTPEndpoint = &application.HealthCheckHTTPEndpoint } if application.Memory.IsSet { ccApp.Memory = &application.Memory.Value } return json.Marshal(ccApp) }
go
func (application Application) MarshalJSON() ([]byte, error) { ccApp := struct { Buildpack *string `json:"buildpack,omitempty"` Command *string `json:"command,omitempty"` DiskQuota *uint64 `json:"disk_quota,omitempty"` DockerCredentials *DockerCredentials `json:"docker_credentials,omitempty"` DockerImage string `json:"docker_image,omitempty"` EnvironmentVariables map[string]string `json:"environment_json,omitempty"` HealthCheckHTTPEndpoint *string `json:"health_check_http_endpoint,omitempty"` HealthCheckTimeout uint64 `json:"health_check_timeout,omitempty"` HealthCheckType constant.ApplicationHealthCheckType `json:"health_check_type,omitempty"` Instances *int `json:"instances,omitempty"` Memory *uint64 `json:"memory,omitempty"` Name string `json:"name,omitempty"` SpaceGUID string `json:"space_guid,omitempty"` StackGUID string `json:"stack_guid,omitempty"` State constant.ApplicationState `json:"state,omitempty"` }{ DockerImage: application.DockerImage, EnvironmentVariables: application.EnvironmentVariables, HealthCheckTimeout: application.HealthCheckTimeout, HealthCheckType: application.HealthCheckType, Name: application.Name, SpaceGUID: application.SpaceGUID, StackGUID: application.StackGUID, State: application.State, } if application.Buildpack.IsSet { ccApp.Buildpack = &application.Buildpack.Value } if application.Command.IsSet { ccApp.Command = &application.Command.Value } if application.DiskQuota.IsSet { ccApp.DiskQuota = &application.DiskQuota.Value } if application.DockerCredentials.Username != "" || application.DockerCredentials.Password != "" { ccApp.DockerCredentials = &DockerCredentials{ Username: application.DockerCredentials.Username, Password: application.DockerCredentials.Password, } } if application.Instances.IsSet { ccApp.Instances = &application.Instances.Value } if application.HealthCheckType != "" { ccApp.HealthCheckHTTPEndpoint = &application.HealthCheckHTTPEndpoint } if application.Memory.IsSet { ccApp.Memory = &application.Memory.Value } return json.Marshal(ccApp) }
[ "func", "(", "application", "Application", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ccApp", ":=", "struct", "{", "Buildpack", "*", "string", "`json:\"buildpack,omitempty\"`", "\n", "Command", "*", "string", "`json:\"command,omitempty\"`", "\n", "DiskQuota", "*", "uint64", "`json:\"disk_quota,omitempty\"`", "\n", "DockerCredentials", "*", "DockerCredentials", "`json:\"docker_credentials,omitempty\"`", "\n", "DockerImage", "string", "`json:\"docker_image,omitempty\"`", "\n", "EnvironmentVariables", "map", "[", "string", "]", "string", "`json:\"environment_json,omitempty\"`", "\n", "HealthCheckHTTPEndpoint", "*", "string", "`json:\"health_check_http_endpoint,omitempty\"`", "\n", "HealthCheckTimeout", "uint64", "`json:\"health_check_timeout,omitempty\"`", "\n", "HealthCheckType", "constant", ".", "ApplicationHealthCheckType", "`json:\"health_check_type,omitempty\"`", "\n", "Instances", "*", "int", "`json:\"instances,omitempty\"`", "\n", "Memory", "*", "uint64", "`json:\"memory,omitempty\"`", "\n", "Name", "string", "`json:\"name,omitempty\"`", "\n", "SpaceGUID", "string", "`json:\"space_guid,omitempty\"`", "\n", "StackGUID", "string", "`json:\"stack_guid,omitempty\"`", "\n", "State", "constant", ".", "ApplicationState", "`json:\"state,omitempty\"`", "\n", "}", "{", "DockerImage", ":", "application", ".", "DockerImage", ",", "EnvironmentVariables", ":", "application", ".", "EnvironmentVariables", ",", "HealthCheckTimeout", ":", "application", ".", "HealthCheckTimeout", ",", "HealthCheckType", ":", "application", ".", "HealthCheckType", ",", "Name", ":", "application", ".", "Name", ",", "SpaceGUID", ":", "application", ".", "SpaceGUID", ",", "StackGUID", ":", "application", ".", "StackGUID", ",", "State", ":", "application", ".", "State", ",", "}", "\n", "if", "application", ".", "Buildpack", ".", "IsSet", "{", "ccApp", ".", "Buildpack", "=", "&", "application", ".", "Buildpack", ".", "Value", "\n", "}", "\n", "if", "application", ".", "Command", ".", "IsSet", "{", "ccApp", ".", "Command", "=", "&", "application", ".", "Command", ".", "Value", "\n", "}", "\n", "if", "application", ".", "DiskQuota", ".", "IsSet", "{", "ccApp", ".", "DiskQuota", "=", "&", "application", ".", "DiskQuota", ".", "Value", "\n", "}", "\n", "if", "application", ".", "DockerCredentials", ".", "Username", "!=", "\"\"", "||", "application", ".", "DockerCredentials", ".", "Password", "!=", "\"\"", "{", "ccApp", ".", "DockerCredentials", "=", "&", "DockerCredentials", "{", "Username", ":", "application", ".", "DockerCredentials", ".", "Username", ",", "Password", ":", "application", ".", "DockerCredentials", ".", "Password", ",", "}", "\n", "}", "\n", "if", "application", ".", "Instances", ".", "IsSet", "{", "ccApp", ".", "Instances", "=", "&", "application", ".", "Instances", ".", "Value", "\n", "}", "\n", "if", "application", ".", "HealthCheckType", "!=", "\"\"", "{", "ccApp", ".", "HealthCheckHTTPEndpoint", "=", "&", "application", ".", "HealthCheckHTTPEndpoint", "\n", "}", "\n", "if", "application", ".", "Memory", ".", "IsSet", "{", "ccApp", ".", "Memory", "=", "&", "application", ".", "Memory", ".", "Value", "\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/ccv2/application.go#L89-L149
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
CreateApplication
func (client *Client) CreateApplication(app Application) (Application, Warnings, error) { body, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRequest, Body: bytes.NewReader(body), }) if err != nil { return Application{}, nil, err } var updatedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &updatedApp, } err = client.connection.Make(request, &response) return updatedApp, response.Warnings, err }
go
func (client *Client) CreateApplication(app Application) (Application, Warnings, error) { body, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRequest, Body: bytes.NewReader(body), }) if err != nil { return Application{}, nil, err } var updatedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &updatedApp, } err = client.connection.Make(request, &response) return updatedApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "app", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostAppRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "updatedApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "updatedApp", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "updatedApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateApplication creates a cloud controller application in with the given // settings. SpaceGUID and Name are the only required fields.
[ "CreateApplication", "creates", "a", "cloud", "controller", "application", "in", "with", "the", "given", "settings", ".", "SpaceGUID", "and", "Name", "are", "the", "only", "required", "fields", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L227-L248
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
GetApplication
func (client *Client) GetApplication(guid string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetAppRequest, URIParams: Params{"app_guid": guid}, }) if err != nil { return Application{}, nil, err } var app Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &app, } err = client.connection.Make(request, &response) return app, response.Warnings, err }
go
func (client *Client) GetApplication(guid string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetAppRequest, URIParams: Params{"app_guid": guid}, }) if err != nil { return Application{}, nil, err } var app Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &app, } err = client.connection.Make(request, &response) return app, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplication", "(", "guid", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetAppRequest", ",", "URIParams", ":", "Params", "{", "\"app_guid\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "app", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "app", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "app", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetApplication returns back an Application.
[ "GetApplication", "returns", "back", "an", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L251-L267
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
GetRouteApplications
func (client *Client) GetRouteApplications(routeGUID string, filters ...Filter) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteAppsRequest, URIParams: map[string]string{"route_guid": routeGUID}, Query: ConvertFilterParameters(filters), }) 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) GetRouteApplications(routeGUID string, filters ...Filter) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteAppsRequest, URIParams: map[string]string{"route_guid": routeGUID}, Query: ConvertFilterParameters(filters), }) 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", ")", "GetRouteApplications", "(", "routeGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouteAppsRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"route_guid\"", ":", "routeGUID", "}", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\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", "}" ]
// GetRouteApplications returns a list of Applications based off a route // GUID and the provided filters.
[ "GetRouteApplications", "returns", "a", "list", "of", "Applications", "based", "off", "a", "route", "GUID", "and", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L298-L322
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
RestageApplication
func (client *Client) RestageApplication(app Application) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRestageRequest, URIParams: Params{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var restagedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &restagedApp, } err = client.connection.Make(request, &response) return restagedApp, response.Warnings, err }
go
func (client *Client) RestageApplication(app Application) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRestageRequest, URIParams: Params{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var restagedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &restagedApp, } err = client.connection.Make(request, &response) return restagedApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "RestageApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostAppRestageRequest", ",", "URIParams", ":", "Params", "{", "\"app_guid\"", ":", "app", ".", "GUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "restagedApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "restagedApp", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "restagedApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// RestageApplication restages the application with the given GUID.
[ "RestageApplication", "restages", "the", "application", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L325-L341
train
cloudfoundry/cli
actor/pushaction/application.go
CalculatedBuildpacks
func (app Application) CalculatedBuildpacks() []string { buildpack := app.CalculatedBuildpack() switch { case app.Buildpacks != nil: return app.Buildpacks case len(buildpack) > 0: return []string{buildpack} default: return nil } }
go
func (app Application) CalculatedBuildpacks() []string { buildpack := app.CalculatedBuildpack() switch { case app.Buildpacks != nil: return app.Buildpacks case len(buildpack) > 0: return []string{buildpack} default: return nil } }
[ "func", "(", "app", "Application", ")", "CalculatedBuildpacks", "(", ")", "[", "]", "string", "{", "buildpack", ":=", "app", ".", "CalculatedBuildpack", "(", ")", "\n", "switch", "{", "case", "app", ".", "Buildpacks", "!=", "nil", ":", "return", "app", ".", "Buildpacks", "\n", "case", "len", "(", "buildpack", ")", ">", "0", ":", "return", "[", "]", "string", "{", "buildpack", "}", "\n", "default", ":", "return", "nil", "\n", "}", "\n", "}" ]
// CalculatedBuildpacks will return back the buildpacks for the application.
[ "CalculatedBuildpacks", "will", "return", "back", "the", "buildpacks", "for", "the", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/application.go#L22-L32
train
cloudfoundry/cli
actor/pushaction/application.go
ignoreSameStackGUID
func (actor Actor) ignoreSameStackGUID(config ApplicationConfig, v2App v2action.Application) v2action.Application { if config.CurrentApplication.StackGUID == config.DesiredApplication.StackGUID { v2App.StackGUID = "" } return v2App }
go
func (actor Actor) ignoreSameStackGUID(config ApplicationConfig, v2App v2action.Application) v2action.Application { if config.CurrentApplication.StackGUID == config.DesiredApplication.StackGUID { v2App.StackGUID = "" } return v2App }
[ "func", "(", "actor", "Actor", ")", "ignoreSameStackGUID", "(", "config", "ApplicationConfig", ",", "v2App", "v2action", ".", "Application", ")", "v2action", ".", "Application", "{", "if", "config", ".", "CurrentApplication", ".", "StackGUID", "==", "config", ".", "DesiredApplication", ".", "StackGUID", "{", "v2App", ".", "StackGUID", "=", "\"\"", "\n", "}", "\n", "return", "v2App", "\n", "}" ]
// Apps updates with both docker image and stack guids fail. So do not send // StackGUID unless it is necessary.
[ "Apps", "updates", "with", "both", "docker", "image", "and", "stack", "guids", "fail", ".", "So", "do", "not", "send", "StackGUID", "unless", "it", "is", "necessary", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/application.go#L155-L161
train
cloudfoundry/cli
api/plugin/client.go
NewClient
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, connection: NewConnection(config.SkipSSLValidation, config.DialTimeout), } return &client }
go
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, connection: NewConnection(config.SkipSSLValidation, config.DialTimeout), } return &client }
[ "func", "NewClient", "(", "config", "Config", ")", "*", "Client", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"%s/%s (%s; %s %s)\"", ",", "config", ".", "AppName", ",", "config", ".", "AppVersion", ",", "runtime", ".", "Version", "(", ")", ",", "runtime", ".", "GOARCH", ",", "runtime", ".", "GOOS", ",", ")", "\n", "client", ":=", "Client", "{", "userAgent", ":", "userAgent", ",", "connection", ":", "NewConnection", "(", "config", ".", "SkipSSLValidation", ",", "config", ".", "DialTimeout", ")", ",", "}", "\n", "return", "&", "client", "\n", "}" ]
// NewClient returns a new plugin Client.
[ "NewClient", "returns", "a", "new", "plugin", "Client", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/plugin/client.go#L39-L53
train
cloudfoundry/cli
actor/v7pushaction/update_application_settings.go
UpdateApplicationSettings
func (actor Actor) UpdateApplicationSettings(pushPlans []PushPlan) ([]PushPlan, Warnings, error) { appNames := actor.getAppNames(pushPlans) applications, getWarnings, err := actor.V7Actor.GetApplicationsByNamesAndSpace(appNames, pushPlans[0].SpaceGUID) warnings := Warnings(getWarnings) if err != nil { log.Errorln("Looking up applications:", err) return nil, warnings, err } nameToApp := actor.generateAppNameToApplicationMapping(applications) var updatedPushPlans []PushPlan for _, pushPlan := range pushPlans { app := nameToApp[pushPlan.Application.Name] pushPlan.Application.GUID = app.GUID pushPlan.Application.State = app.State updatedPushPlans = append(updatedPushPlans, pushPlan) } return updatedPushPlans, warnings, err }
go
func (actor Actor) UpdateApplicationSettings(pushPlans []PushPlan) ([]PushPlan, Warnings, error) { appNames := actor.getAppNames(pushPlans) applications, getWarnings, err := actor.V7Actor.GetApplicationsByNamesAndSpace(appNames, pushPlans[0].SpaceGUID) warnings := Warnings(getWarnings) if err != nil { log.Errorln("Looking up applications:", err) return nil, warnings, err } nameToApp := actor.generateAppNameToApplicationMapping(applications) var updatedPushPlans []PushPlan for _, pushPlan := range pushPlans { app := nameToApp[pushPlan.Application.Name] pushPlan.Application.GUID = app.GUID pushPlan.Application.State = app.State updatedPushPlans = append(updatedPushPlans, pushPlan) } return updatedPushPlans, warnings, err }
[ "func", "(", "actor", "Actor", ")", "UpdateApplicationSettings", "(", "pushPlans", "[", "]", "PushPlan", ")", "(", "[", "]", "PushPlan", ",", "Warnings", ",", "error", ")", "{", "appNames", ":=", "actor", ".", "getAppNames", "(", "pushPlans", ")", "\n", "applications", ",", "getWarnings", ",", "err", ":=", "actor", ".", "V7Actor", ".", "GetApplicationsByNamesAndSpace", "(", "appNames", ",", "pushPlans", "[", "0", "]", ".", "SpaceGUID", ")", "\n", "warnings", ":=", "Warnings", "(", "getWarnings", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"Looking up applications:\"", ",", "err", ")", "\n", "return", "nil", ",", "warnings", ",", "err", "\n", "}", "\n", "nameToApp", ":=", "actor", ".", "generateAppNameToApplicationMapping", "(", "applications", ")", "\n", "var", "updatedPushPlans", "[", "]", "PushPlan", "\n", "for", "_", ",", "pushPlan", ":=", "range", "pushPlans", "{", "app", ":=", "nameToApp", "[", "pushPlan", ".", "Application", ".", "Name", "]", "\n", "pushPlan", ".", "Application", ".", "GUID", "=", "app", ".", "GUID", "\n", "pushPlan", ".", "Application", ".", "State", "=", "app", ".", "State", "\n", "updatedPushPlans", "=", "append", "(", "updatedPushPlans", ",", "pushPlan", ")", "\n", "}", "\n", "return", "updatedPushPlans", ",", "warnings", ",", "err", "\n", "}" ]
// UpdateApplicationSettings syncs the Application state and GUID with the API.
[ "UpdateApplicationSettings", "syncs", "the", "Application", "state", "and", "GUID", "with", "the", "API", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/update_application_settings.go#L10-L31
train
cloudfoundry/cli
cf/api/logs/noaa_message_queue.go
Less
func (pq *NoaaMessageQueue) Less(i, j int) bool { return *pq.messages[i].Timestamp < *pq.messages[j].Timestamp }
go
func (pq *NoaaMessageQueue) Less(i, j int) bool { return *pq.messages[i].Timestamp < *pq.messages[j].Timestamp }
[ "func", "(", "pq", "*", "NoaaMessageQueue", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "*", "pq", ".", "messages", "[", "i", "]", ".", "Timestamp", "<", "*", "pq", ".", "messages", "[", "j", "]", ".", "Timestamp", "\n", "}" ]
// implement sort interface so we can sort messages as we receive them in PushMessage
[ "implement", "sort", "interface", "so", "we", "can", "sort", "messages", "as", "we", "receive", "them", "in", "PushMessage" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/api/logs/noaa_message_queue.go#L27-L29
train
cloudfoundry/cli
actor/v7pushaction/create_push_plans.go
CreatePushPlans
func (actor Actor) CreatePushPlans(appNameArg string, spaceGUID string, orgGUID string, parser ManifestParser, overrides FlagOverrides) ([]PushPlan, error) { var pushPlans []PushPlan eligibleApps, err := actor.getEligibleApplications(parser, appNameArg) if err != nil { return nil, err } for _, manifestApplication := range eligibleApps { plan := PushPlan{ OrgGUID: orgGUID, SpaceGUID: spaceGUID, } // List of PushPlanFuncs is defined in NewActor for _, updatePlan := range actor.PushPlanFuncs { var err error plan, err = updatePlan(plan, overrides, manifestApplication) if err != nil { return nil, err } } pushPlans = append(pushPlans, plan) } return pushPlans, nil }
go
func (actor Actor) CreatePushPlans(appNameArg string, spaceGUID string, orgGUID string, parser ManifestParser, overrides FlagOverrides) ([]PushPlan, error) { var pushPlans []PushPlan eligibleApps, err := actor.getEligibleApplications(parser, appNameArg) if err != nil { return nil, err } for _, manifestApplication := range eligibleApps { plan := PushPlan{ OrgGUID: orgGUID, SpaceGUID: spaceGUID, } // List of PushPlanFuncs is defined in NewActor for _, updatePlan := range actor.PushPlanFuncs { var err error plan, err = updatePlan(plan, overrides, manifestApplication) if err != nil { return nil, err } } pushPlans = append(pushPlans, plan) } return pushPlans, nil }
[ "func", "(", "actor", "Actor", ")", "CreatePushPlans", "(", "appNameArg", "string", ",", "spaceGUID", "string", ",", "orgGUID", "string", ",", "parser", "ManifestParser", ",", "overrides", "FlagOverrides", ")", "(", "[", "]", "PushPlan", ",", "error", ")", "{", "var", "pushPlans", "[", "]", "PushPlan", "\n", "eligibleApps", ",", "err", ":=", "actor", ".", "getEligibleApplications", "(", "parser", ",", "appNameArg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "for", "_", ",", "manifestApplication", ":=", "range", "eligibleApps", "{", "plan", ":=", "PushPlan", "{", "OrgGUID", ":", "orgGUID", ",", "SpaceGUID", ":", "spaceGUID", ",", "}", "\n", "for", "_", ",", "updatePlan", ":=", "range", "actor", ".", "PushPlanFuncs", "{", "var", "err", "error", "\n", "plan", ",", "err", "=", "updatePlan", "(", "plan", ",", "overrides", ",", "manifestApplication", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n", "pushPlans", "=", "append", "(", "pushPlans", ",", "plan", ")", "\n", "}", "\n", "return", "pushPlans", ",", "nil", "\n", "}" ]
// CreatePushPlans returns a set of PushPlan objects based off the inputs // provided. It's assumed that all flag and argument and manifest combinations // have been validated prior to calling this function.
[ "CreatePushPlans", "returns", "a", "set", "of", "PushPlan", "objects", "based", "off", "the", "inputs", "provided", ".", "It", "s", "assumed", "that", "all", "flag", "and", "argument", "and", "manifest", "combinations", "have", "been", "validated", "prior", "to", "calling", "this", "function", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/create_push_plans.go#L10-L37
train
cloudfoundry/cli
api/cloudcontroller/ccv3/buildpack.go
DeleteBuildpack
func (client Client) DeleteBuildpack(buildpackGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteBuildpackRequest, URIParams: map[string]string{ "buildpack_guid": buildpackGUID, }, }) 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) DeleteBuildpack(buildpackGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteBuildpackRequest, URIParams: map[string]string{ "buildpack_guid": buildpackGUID, }, }) 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", ")", "DeleteBuildpack", "(", "buildpackGUID", "string", ")", "(", "JobURL", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteBuildpackRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"buildpack_guid\"", ":", "buildpackGUID", ",", "}", ",", "}", ")", "\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", "}" ]
// DeleteBuildpack deletes the buildpack with the provided guid.
[ "DeleteBuildpack", "deletes", "the", "buildpack", "with", "the", "provided", "guid", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/buildpack.go#L122-L137
train
cloudfoundry/cli
actor/v7pushaction/resource_match.go
MatchResources
func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) { matches, warnings, err := actor.V7Actor.ResourceMatch(resources) mapChecksumToResource := map[string]sharedaction.V3Resource{} for _, resource := range matches { mapChecksumToResource[resource.Checksum.Value] = resource } var unmatches []sharedaction.V3Resource for _, resource := range resources { if _, ok := mapChecksumToResource[resource.Checksum.Value]; !ok { unmatches = append(unmatches, resource) } } return matches, unmatches, Warnings(warnings), err }
go
func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) { matches, warnings, err := actor.V7Actor.ResourceMatch(resources) mapChecksumToResource := map[string]sharedaction.V3Resource{} for _, resource := range matches { mapChecksumToResource[resource.Checksum.Value] = resource } var unmatches []sharedaction.V3Resource for _, resource := range resources { if _, ok := mapChecksumToResource[resource.Checksum.Value]; !ok { unmatches = append(unmatches, resource) } } return matches, unmatches, Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "MatchResources", "(", "resources", "[", "]", "sharedaction", ".", "V3Resource", ")", "(", "[", "]", "sharedaction", ".", "V3Resource", ",", "[", "]", "sharedaction", ".", "V3Resource", ",", "Warnings", ",", "error", ")", "{", "matches", ",", "warnings", ",", "err", ":=", "actor", ".", "V7Actor", ".", "ResourceMatch", "(", "resources", ")", "\n", "mapChecksumToResource", ":=", "map", "[", "string", "]", "sharedaction", ".", "V3Resource", "{", "}", "\n", "for", "_", ",", "resource", ":=", "range", "matches", "{", "mapChecksumToResource", "[", "resource", ".", "Checksum", ".", "Value", "]", "=", "resource", "\n", "}", "\n", "var", "unmatches", "[", "]", "sharedaction", ".", "V3Resource", "\n", "for", "_", ",", "resource", ":=", "range", "resources", "{", "if", "_", ",", "ok", ":=", "mapChecksumToResource", "[", "resource", ".", "Checksum", ".", "Value", "]", ";", "!", "ok", "{", "unmatches", "=", "append", "(", "unmatches", ",", "resource", ")", "\n", "}", "\n", "}", "\n", "return", "matches", ",", "unmatches", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// MatchResources returns back a list of matched and unmatched resources for the provided resources.
[ "MatchResources", "returns", "back", "a", "list", "of", "matched", "and", "unmatched", "resources", "for", "the", "provided", "resources", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/resource_match.go#L6-L22
train
cloudfoundry/cli
api/cloudcontroller/ccv2/user.go
UnmarshalJSON
func (user *User) UnmarshalJSON(data []byte) error { var ccUser struct { Metadata internal.Metadata `json:"metadata"` } err := cloudcontroller.DecodeJSON(data, &ccUser) if err != nil { return err } user.GUID = ccUser.Metadata.GUID return nil }
go
func (user *User) UnmarshalJSON(data []byte) error { var ccUser struct { Metadata internal.Metadata `json:"metadata"` } err := cloudcontroller.DecodeJSON(data, &ccUser) if err != nil { return err } user.GUID = ccUser.Metadata.GUID return nil }
[ "func", "(", "user", "*", "User", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccUser", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccUser", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "user", ".", "GUID", "=", "ccUser", ".", "Metadata", ".", "GUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller User response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "User", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/user.go#L18-L29
train
cloudfoundry/cli
api/cloudcontroller/ccv2/user.go
CreateUser
func (client *Client) CreateUser(uaaUserID string) (User, Warnings, error) { type userRequestBody struct { GUID string `json:"guid"` } bodyBytes, err := json.Marshal(userRequestBody{ GUID: uaaUserID, }) if err != nil { return User{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostUserRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return User{}, nil, err } var user User response := cloudcontroller.Response{ DecodeJSONResponseInto: &user, } err = client.connection.Make(request, &response) if err != nil { return User{}, response.Warnings, err } return user, response.Warnings, nil }
go
func (client *Client) CreateUser(uaaUserID string) (User, Warnings, error) { type userRequestBody struct { GUID string `json:"guid"` } bodyBytes, err := json.Marshal(userRequestBody{ GUID: uaaUserID, }) if err != nil { return User{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostUserRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return User{}, nil, err } var user User response := cloudcontroller.Response{ DecodeJSONResponseInto: &user, } err = client.connection.Make(request, &response) if err != nil { return User{}, response.Warnings, err } return user, response.Warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "CreateUser", "(", "uaaUserID", "string", ")", "(", "User", ",", "Warnings", ",", "error", ")", "{", "type", "userRequestBody", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "userRequestBody", "{", "GUID", ":", "uaaUserID", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostUserRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "user", "User", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "user", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "response", ".", "Warnings", ",", "err", "\n", "}", "\n", "return", "user", ",", "response", ".", "Warnings", ",", "nil", "\n", "}" ]
// CreateUser creates a new Cloud Controller User from the provided UAA user // ID.
[ "CreateUser", "creates", "a", "new", "Cloud", "Controller", "User", "from", "the", "provided", "UAA", "user", "ID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/user.go#L33-L64
train
cloudfoundry/cli
api/router/client.go
NewClient
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, router: rata.NewRequestGenerator(config.RoutingEndpoint, internal.APIRoutes), connection: NewConnection(config.ConnectionConfig), } for _, wrapper := range config.Wrappers { client.connection = wrapper.Wrap(client.connection) } return &client }
go
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, router: rata.NewRequestGenerator(config.RoutingEndpoint, internal.APIRoutes), connection: NewConnection(config.ConnectionConfig), } for _, wrapper := range config.Wrappers { client.connection = wrapper.Wrap(client.connection) } return &client }
[ "func", "NewClient", "(", "config", "Config", ")", "*", "Client", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"%s/%s (%s; %s %s)\"", ",", "config", ".", "AppName", ",", "config", ".", "AppVersion", ",", "runtime", ".", "Version", "(", ")", ",", "runtime", ".", "GOARCH", ",", "runtime", ".", "GOOS", ",", ")", "\n", "client", ":=", "Client", "{", "userAgent", ":", "userAgent", ",", "router", ":", "rata", ".", "NewRequestGenerator", "(", "config", ".", "RoutingEndpoint", ",", "internal", ".", "APIRoutes", ")", ",", "connection", ":", "NewConnection", "(", "config", ".", "ConnectionConfig", ")", ",", "}", "\n", "for", "_", ",", "wrapper", ":=", "range", "config", ".", "Wrappers", "{", "client", ".", "connection", "=", "wrapper", ".", "Wrap", "(", "client", ".", "connection", ")", "\n", "}", "\n", "return", "&", "client", "\n", "}" ]
// NewClient returns a new Router Client.
[ "NewClient", "returns", "a", "new", "Router", "Client", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/client.go#L42-L62
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance_shared_from.go
GetServiceInstanceSharedFrom
func (client *Client) GetServiceInstanceSharedFrom(serviceInstanceGUID string) (ServiceInstanceSharedFrom, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedFromRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return ServiceInstanceSharedFrom{}, nil, err } var serviceInstanceSharedFrom ServiceInstanceSharedFrom response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceInstanceSharedFrom, } err = client.connection.Make(request, &response) return serviceInstanceSharedFrom, response.Warnings, err }
go
func (client *Client) GetServiceInstanceSharedFrom(serviceInstanceGUID string) (ServiceInstanceSharedFrom, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedFromRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return ServiceInstanceSharedFrom{}, nil, err } var serviceInstanceSharedFrom ServiceInstanceSharedFrom response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceInstanceSharedFrom, } err = client.connection.Make(request, &response) return serviceInstanceSharedFrom, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceInstanceSharedFrom", "(", "serviceInstanceGUID", "string", ")", "(", "ServiceInstanceSharedFrom", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceInstanceSharedFromRequest", ",", "URIParams", ":", "Params", "{", "\"service_instance_guid\"", ":", "serviceInstanceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstanceSharedFrom", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "serviceInstanceSharedFrom", "ServiceInstanceSharedFrom", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceInstanceSharedFrom", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "serviceInstanceSharedFrom", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetServiceInstanceSharedFrom returns back a ServiceInstanceSharedFrom // object.
[ "GetServiceInstanceSharedFrom", "returns", "back", "a", "ServiceInstanceSharedFrom", "object", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance_shared_from.go#L26-L42
train
cloudfoundry/cli
api/cloudcontroller/ccv3/feature_flag.go
GetFeatureFlags
func (client *Client) GetFeatureFlags() ([]FeatureFlag, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetFeatureFlagsRequest, }) if err != nil { return nil, nil, err } var fullFeatureFlagList []FeatureFlag warnings, err := client.paginate(request, FeatureFlag{}, func(item interface{}) error { if featureFlag, ok := item.(FeatureFlag); ok { fullFeatureFlagList = append(fullFeatureFlagList, featureFlag) } else { return ccerror.UnknownObjectInListError{ Expected: FeatureFlag{}, Unexpected: item, } } return nil }) return fullFeatureFlagList, warnings, err }
go
func (client *Client) GetFeatureFlags() ([]FeatureFlag, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetFeatureFlagsRequest, }) if err != nil { return nil, nil, err } var fullFeatureFlagList []FeatureFlag warnings, err := client.paginate(request, FeatureFlag{}, func(item interface{}) error { if featureFlag, ok := item.(FeatureFlag); ok { fullFeatureFlagList = append(fullFeatureFlagList, featureFlag) } else { return ccerror.UnknownObjectInListError{ Expected: FeatureFlag{}, Unexpected: item, } } return nil }) return fullFeatureFlagList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetFeatureFlags", "(", ")", "(", "[", "]", "FeatureFlag", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetFeatureFlagsRequest", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n", "var", "fullFeatureFlagList", "[", "]", "FeatureFlag", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "FeatureFlag", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "featureFlag", ",", "ok", ":=", "item", ".", "(", "FeatureFlag", ")", ";", "ok", "{", "fullFeatureFlagList", "=", "append", "(", "fullFeatureFlagList", ",", "featureFlag", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "FeatureFlag", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n", "return", "fullFeatureFlagList", ",", "warnings", ",", "err", "\n", "}" ]
// GetFeatureFlags lists feature flags.
[ "GetFeatureFlags", "lists", "feature", "flags", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/feature_flag.go#L51-L75
train
cloudfoundry/cli
command/v7/ssh_command.go
EvaluateTTYOption
func (cmd SSHCommand) EvaluateTTYOption() (sharedaction.TTYOption, error) { var count int option := sharedaction.RequestTTYAuto if cmd.DisablePseudoTTY { option = sharedaction.RequestTTYNo count++ } if cmd.ForcePseudoTTY { option = sharedaction.RequestTTYForce count++ } if cmd.RequestPseudoTTY { option = sharedaction.RequestTTYYes count++ } if count > 1 { return option, translatableerror.ArgumentCombinationError{Args: []string{ "--disable-pseudo-tty", "-T", "--force-pseudo-tty", "--request-pseudo-tty", "-t", }} } return option, nil }
go
func (cmd SSHCommand) EvaluateTTYOption() (sharedaction.TTYOption, error) { var count int option := sharedaction.RequestTTYAuto if cmd.DisablePseudoTTY { option = sharedaction.RequestTTYNo count++ } if cmd.ForcePseudoTTY { option = sharedaction.RequestTTYForce count++ } if cmd.RequestPseudoTTY { option = sharedaction.RequestTTYYes count++ } if count > 1 { return option, translatableerror.ArgumentCombinationError{Args: []string{ "--disable-pseudo-tty", "-T", "--force-pseudo-tty", "--request-pseudo-tty", "-t", }} } return option, nil }
[ "func", "(", "cmd", "SSHCommand", ")", "EvaluateTTYOption", "(", ")", "(", "sharedaction", ".", "TTYOption", ",", "error", ")", "{", "var", "count", "int", "\n", "option", ":=", "sharedaction", ".", "RequestTTYAuto", "\n", "if", "cmd", ".", "DisablePseudoTTY", "{", "option", "=", "sharedaction", ".", "RequestTTYNo", "\n", "count", "++", "\n", "}", "\n", "if", "cmd", ".", "ForcePseudoTTY", "{", "option", "=", "sharedaction", ".", "RequestTTYForce", "\n", "count", "++", "\n", "}", "\n", "if", "cmd", ".", "RequestPseudoTTY", "{", "option", "=", "sharedaction", ".", "RequestTTYYes", "\n", "count", "++", "\n", "}", "\n", "if", "count", ">", "1", "{", "return", "option", ",", "translatableerror", ".", "ArgumentCombinationError", "{", "Args", ":", "[", "]", "string", "{", "\"--disable-pseudo-tty\"", ",", "\"-T\"", ",", "\"--force-pseudo-tty\"", ",", "\"--request-pseudo-tty\"", ",", "\"-t\"", ",", "}", "}", "\n", "}", "\n", "return", "option", ",", "nil", "\n", "}" ]
// EvaluateTTYOption determines which TTY options are mutually exclusive and // returns an error accordingly.
[ "EvaluateTTYOption", "determines", "which", "TTY", "options", "are", "mutually", "exclusive", "and", "returns", "an", "error", "accordingly", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v7/ssh_command.go#L118-L142
train
cloudfoundry/cli
actor/v2action/space_quota.go
GetSpaceQuotaByName
func (actor Actor) GetSpaceQuotaByName(quotaName, orgGUID string) (SpaceQuota, Warnings, error) { quotas, warnings, err := actor.CloudControllerClient.GetSpaceQuotas(orgGUID) if err != nil { return SpaceQuota{}, Warnings(warnings), err } for _, quota := range quotas { if quota.Name == quotaName { return SpaceQuota(quota), Warnings(warnings), nil } } return SpaceQuota{}, Warnings(warnings), actionerror.SpaceQuotaNotFoundByNameError{Name: quotaName} }
go
func (actor Actor) GetSpaceQuotaByName(quotaName, orgGUID string) (SpaceQuota, Warnings, error) { quotas, warnings, err := actor.CloudControllerClient.GetSpaceQuotas(orgGUID) if err != nil { return SpaceQuota{}, Warnings(warnings), err } for _, quota := range quotas { if quota.Name == quotaName { return SpaceQuota(quota), Warnings(warnings), nil } } return SpaceQuota{}, Warnings(warnings), actionerror.SpaceQuotaNotFoundByNameError{Name: quotaName} }
[ "func", "(", "actor", "Actor", ")", "GetSpaceQuotaByName", "(", "quotaName", ",", "orgGUID", "string", ")", "(", "SpaceQuota", ",", "Warnings", ",", "error", ")", "{", "quotas", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaceQuotas", "(", "orgGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "SpaceQuota", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "for", "_", ",", "quota", ":=", "range", "quotas", "{", "if", "quota", ".", "Name", "==", "quotaName", "{", "return", "SpaceQuota", "(", "quota", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}", "\n", "}", "\n", "return", "SpaceQuota", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "SpaceQuotaNotFoundByNameError", "{", "Name", ":", "quotaName", "}", "\n", "}" ]
// GetSpaceQuotaByName finds the quota by name and returns an error if not found
[ "GetSpaceQuotaByName", "finds", "the", "quota", "by", "name", "and", "returns", "an", "error", "if", "not", "found" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space_quota.go#L22-L36
train
cloudfoundry/cli
actor/v2action/space_quota.go
SetSpaceQuota
func (actor Actor) SetSpaceQuota(spaceGUID, quotaGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.SetSpaceQuota(spaceGUID, quotaGUID) return Warnings(warnings), err }
go
func (actor Actor) SetSpaceQuota(spaceGUID, quotaGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.SetSpaceQuota(spaceGUID, quotaGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "SetSpaceQuota", "(", "spaceGUID", ",", "quotaGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "SetSpaceQuota", "(", "spaceGUID", ",", "quotaGUID", ")", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// SetSpaceQuota sets the space quota for the corresponding space
[ "SetSpaceQuota", "sets", "the", "space", "quota", "for", "the", "corresponding", "space" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space_quota.go#L39-L42
train