repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
sequence
docstring
stringlengths
6
2.61k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
cloudfoundry/cli
actor/v2action/application.go
CreateApplication
func (actor Actor) CreateApplication(application Application) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.CreateApplication(ccv2.Application(application)) return Application(app), Warnings(warnings), err }
go
func (actor Actor) CreateApplication(application Application) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.CreateApplication(ccv2.Application(application)) return Application(app), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "CreateApplication", "(", "application", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateApplication", "(", "ccv2", ".", "Application", "(", "application", ")", ")", "\n", "return", "Application", "(", "app", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// CreateApplication creates an application.
[ "CreateApplication", "creates", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L115-L118
train
cloudfoundry/cli
actor/v2action/application.go
GetApplication
func (actor Actor) GetApplication(guid string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplication(guid) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{GUID: guid} } return Application(app), Warnings(warnings), err }
go
func (actor Actor) GetApplication(guid string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplication(guid) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{GUID: guid} } return Application(app), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetApplication", "(", "guid", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplication", "(", "guid", ")", "\n\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "ok", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ApplicationNotFoundError", "{", "GUID", ":", "guid", "}", "\n", "}", "\n\n", "return", "Application", "(", "app", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetApplication returns the application.
[ "GetApplication", "returns", "the", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L121-L129
train
cloudfoundry/cli
actor/v2action/application.go
GetApplicationByNameAndSpace
func (actor Actor) GetApplicationByNameAndSpace(name string, spaceGUID string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplications( ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{name}, }, ccv2.Filter{ Type: constant.SpaceGUIDFilter, Operator: constant.EqualOperator, Values: []string{spaceGUID}, }, ) if err != nil { return Application{}, Warnings(warnings), err } if len(app) == 0 { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{ Name: name, } } return Application(app[0]), Warnings(warnings), nil }
go
func (actor Actor) GetApplicationByNameAndSpace(name string, spaceGUID string) (Application, Warnings, error) { app, warnings, err := actor.CloudControllerClient.GetApplications( ccv2.Filter{ Type: constant.NameFilter, Operator: constant.EqualOperator, Values: []string{name}, }, ccv2.Filter{ Type: constant.SpaceGUIDFilter, Operator: constant.EqualOperator, Values: []string{spaceGUID}, }, ) if err != nil { return Application{}, Warnings(warnings), err } if len(app) == 0 { return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{ Name: name, } } return Application(app[0]), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetApplicationByNameAndSpace", "(", "name", "string", ",", "spaceGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplications", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "name", "}", ",", "}", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "SpaceGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "spaceGUID", "}", ",", "}", ",", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "app", ")", "==", "0", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ApplicationNotFoundError", "{", "Name", ":", "name", ",", "}", "\n", "}", "\n\n", "return", "Application", "(", "app", "[", "0", "]", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetApplicationByNameAndSpace returns an application with matching name in // the space.
[ "GetApplicationByNameAndSpace", "returns", "an", "application", "with", "matching", "name", "in", "the", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L133-L158
train
cloudfoundry/cli
actor/v2action/application.go
GetRouteApplications
func (actor Actor) GetRouteApplications(routeGUID string) ([]Application, Warnings, error) { apps, warnings, err := actor.CloudControllerClient.GetRouteApplications(routeGUID) if err != nil { return nil, Warnings(warnings), err } allApplications := []Application{} for _, app := range apps { allApplications = append(allApplications, Application(app)) } return allApplications, Warnings(warnings), nil }
go
func (actor Actor) GetRouteApplications(routeGUID string) ([]Application, Warnings, error) { apps, warnings, err := actor.CloudControllerClient.GetRouteApplications(routeGUID) if err != nil { return nil, Warnings(warnings), err } allApplications := []Application{} for _, app := range apps { allApplications = append(allApplications, Application(app)) } return allApplications, Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "GetRouteApplications", "(", "routeGUID", "string", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "apps", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetRouteApplications", "(", "routeGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n", "allApplications", ":=", "[", "]", "Application", "{", "}", "\n", "for", "_", ",", "app", ":=", "range", "apps", "{", "allApplications", "=", "append", "(", "allApplications", ",", "Application", "(", "app", ")", ")", "\n", "}", "\n", "return", "allApplications", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetRouteApplications returns a list of apps associated with the provided // Route GUID.
[ "GetRouteApplications", "returns", "a", "list", "of", "apps", "associated", "with", "the", "provided", "Route", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L184-L194
train
cloudfoundry/cli
actor/v2action/application.go
SetApplicationHealthCheckTypeByNameAndSpace
func (actor Actor) SetApplicationHealthCheckTypeByNameAndSpace(name string, spaceGUID string, healthCheckType constant.ApplicationHealthCheckType, httpEndpoint string) (Application, Warnings, error) { if httpEndpoint != "/" && healthCheckType != constant.ApplicationHealthCheckHTTP { return Application{}, nil, actionerror.HTTPHealthCheckInvalidError{} } var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(name, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return Application{}, allWarnings, err } if app.HealthCheckType != healthCheckType || healthCheckType == constant.ApplicationHealthCheckHTTP && app.HealthCheckHTTPEndpoint != httpEndpoint { var healthCheckEndpoint string if healthCheckType == constant.ApplicationHealthCheckHTTP { healthCheckEndpoint = httpEndpoint } updatedApp, apiWarnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, HealthCheckType: healthCheckType, HealthCheckHTTPEndpoint: healthCheckEndpoint, }) allWarnings = append(allWarnings, Warnings(apiWarnings)...) return Application(updatedApp), allWarnings, err } return app, allWarnings, nil }
go
func (actor Actor) SetApplicationHealthCheckTypeByNameAndSpace(name string, spaceGUID string, healthCheckType constant.ApplicationHealthCheckType, httpEndpoint string) (Application, Warnings, error) { if httpEndpoint != "/" && healthCheckType != constant.ApplicationHealthCheckHTTP { return Application{}, nil, actionerror.HTTPHealthCheckInvalidError{} } var allWarnings Warnings app, warnings, err := actor.GetApplicationByNameAndSpace(name, spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return Application{}, allWarnings, err } if app.HealthCheckType != healthCheckType || healthCheckType == constant.ApplicationHealthCheckHTTP && app.HealthCheckHTTPEndpoint != httpEndpoint { var healthCheckEndpoint string if healthCheckType == constant.ApplicationHealthCheckHTTP { healthCheckEndpoint = httpEndpoint } updatedApp, apiWarnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, HealthCheckType: healthCheckType, HealthCheckHTTPEndpoint: healthCheckEndpoint, }) allWarnings = append(allWarnings, Warnings(apiWarnings)...) return Application(updatedApp), allWarnings, err } return app, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "SetApplicationHealthCheckTypeByNameAndSpace", "(", "name", "string", ",", "spaceGUID", "string", ",", "healthCheckType", "constant", ".", "ApplicationHealthCheckType", ",", "httpEndpoint", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "if", "httpEndpoint", "!=", "\"", "\"", "&&", "healthCheckType", "!=", "constant", ".", "ApplicationHealthCheckHTTP", "{", "return", "Application", "{", "}", ",", "nil", ",", "actionerror", ".", "HTTPHealthCheckInvalidError", "{", "}", "\n", "}", "\n\n", "var", "allWarnings", "Warnings", "\n\n", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "name", ",", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "if", "app", ".", "HealthCheckType", "!=", "healthCheckType", "||", "healthCheckType", "==", "constant", ".", "ApplicationHealthCheckHTTP", "&&", "app", ".", "HealthCheckHTTPEndpoint", "!=", "httpEndpoint", "{", "var", "healthCheckEndpoint", "string", "\n", "if", "healthCheckType", "==", "constant", ".", "ApplicationHealthCheckHTTP", "{", "healthCheckEndpoint", "=", "httpEndpoint", "\n", "}", "\n\n", "updatedApp", ",", "apiWarnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplication", "(", "ccv2", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "HealthCheckType", ":", "healthCheckType", ",", "HealthCheckHTTPEndpoint", ":", "healthCheckEndpoint", ",", "}", ")", "\n\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "Warnings", "(", "apiWarnings", ")", "...", ")", "\n", "return", "Application", "(", "updatedApp", ")", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "return", "app", ",", "allWarnings", ",", "nil", "\n", "}" ]
// SetApplicationHealthCheckTypeByNameAndSpace updates an application's health // check type if it is not already the desired type.
[ "SetApplicationHealthCheckTypeByNameAndSpace", "updates", "an", "application", "s", "health", "check", "type", "if", "it", "is", "not", "already", "the", "desired", "type", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L198-L230
train
cloudfoundry/cli
actor/v2action/application.go
StartApplication
func (actor Actor) StartApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients if app.PackageState != constant.ApplicationPackageStaged { appState <- ApplicationStateStaging } updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, State: constant.ApplicationStarted, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(updatedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
go
func (actor Actor) StartApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients if app.PackageState != constant.ApplicationPackageStaged { appState <- ApplicationStateStaging } updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccv2.Application{ GUID: app.GUID, State: constant.ApplicationStarted, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(updatedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
[ "func", "(", "actor", "Actor", ")", "StartApplication", "(", "app", "Application", ",", "client", "NOAAClient", ")", "(", "<-", "chan", "*", "LogMessage", ",", "<-", "chan", "error", ",", "<-", "chan", "ApplicationStateChange", ",", "<-", "chan", "string", ",", "<-", "chan", "error", ")", "{", "messages", ",", "logErrs", ":=", "actor", ".", "GetStreamingLogs", "(", "app", ".", "GUID", ",", "client", ")", "\n\n", "appState", ":=", "make", "(", "chan", "ApplicationStateChange", ")", "\n", "allWarnings", ":=", "make", "(", "chan", "string", ")", "\n", "errs", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "defer", "close", "(", "appState", ")", "\n", "defer", "close", "(", "allWarnings", ")", "\n", "defer", "close", "(", "errs", ")", "\n", "defer", "client", ".", "Close", "(", ")", "// automatic close to prevent stale clients", "\n\n", "if", "app", ".", "PackageState", "!=", "constant", ".", "ApplicationPackageStaged", "{", "appState", "<-", "ApplicationStateStaging", "\n", "}", "\n\n", "updatedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplication", "(", "ccv2", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "State", ":", "constant", ".", "ApplicationStarted", ",", "}", ")", "\n\n", "for", "_", ",", "warning", ":=", "range", "warnings", "{", "allWarnings", "<-", "warning", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "errs", "<-", "err", "\n", "return", "\n", "}", "\n\n", "actor", ".", "waitForApplicationStageAndStart", "(", "Application", "(", "updatedApp", ")", ",", "client", ",", "appState", ",", "allWarnings", ",", "errs", ")", "\n", "}", "(", ")", "\n\n", "return", "messages", ",", "logErrs", ",", "appState", ",", "allWarnings", ",", "errs", "\n", "}" ]
// StartApplication restarts a given application. If already stopped, no stop // call will be sent.
[ "StartApplication", "restarts", "a", "given", "application", ".", "If", "already", "stopped", "no", "stop", "call", "will", "be", "sent", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L234-L267
train
cloudfoundry/cli
actor/v2action/application.go
RestageApplication
func (actor Actor) RestageApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients appState <- ApplicationStateStaging restagedApp, warnings, err := actor.CloudControllerClient.RestageApplication(ccv2.Application{ GUID: app.GUID, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(restagedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
go
func (actor Actor) RestageApplication(app Application, client NOAAClient) (<-chan *LogMessage, <-chan error, <-chan ApplicationStateChange, <-chan string, <-chan error) { messages, logErrs := actor.GetStreamingLogs(app.GUID, client) appState := make(chan ApplicationStateChange) allWarnings := make(chan string) errs := make(chan error) go func() { defer close(appState) defer close(allWarnings) defer close(errs) defer client.Close() // automatic close to prevent stale clients appState <- ApplicationStateStaging restagedApp, warnings, err := actor.CloudControllerClient.RestageApplication(ccv2.Application{ GUID: app.GUID, }) for _, warning := range warnings { allWarnings <- warning } if err != nil { errs <- err return } actor.waitForApplicationStageAndStart(Application(restagedApp), client, appState, allWarnings, errs) }() return messages, logErrs, appState, allWarnings, errs }
[ "func", "(", "actor", "Actor", ")", "RestageApplication", "(", "app", "Application", ",", "client", "NOAAClient", ")", "(", "<-", "chan", "*", "LogMessage", ",", "<-", "chan", "error", ",", "<-", "chan", "ApplicationStateChange", ",", "<-", "chan", "string", ",", "<-", "chan", "error", ")", "{", "messages", ",", "logErrs", ":=", "actor", ".", "GetStreamingLogs", "(", "app", ".", "GUID", ",", "client", ")", "\n\n", "appState", ":=", "make", "(", "chan", "ApplicationStateChange", ")", "\n", "allWarnings", ":=", "make", "(", "chan", "string", ")", "\n", "errs", ":=", "make", "(", "chan", "error", ")", "\n", "go", "func", "(", ")", "{", "defer", "close", "(", "appState", ")", "\n", "defer", "close", "(", "allWarnings", ")", "\n", "defer", "close", "(", "errs", ")", "\n", "defer", "client", ".", "Close", "(", ")", "// automatic close to prevent stale clients", "\n\n", "appState", "<-", "ApplicationStateStaging", "\n", "restagedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "RestageApplication", "(", "ccv2", ".", "Application", "{", "GUID", ":", "app", ".", "GUID", ",", "}", ")", "\n\n", "for", "_", ",", "warning", ":=", "range", "warnings", "{", "allWarnings", "<-", "warning", "\n", "}", "\n", "if", "err", "!=", "nil", "{", "errs", "<-", "err", "\n", "return", "\n", "}", "\n\n", "actor", ".", "waitForApplicationStageAndStart", "(", "Application", "(", "restagedApp", ")", ",", "client", ",", "appState", ",", "allWarnings", ",", "errs", ")", "\n", "}", "(", ")", "\n\n", "return", "messages", ",", "logErrs", ",", "appState", ",", "allWarnings", ",", "errs", "\n", "}" ]
// RestageApplication restarts a given application. If already stopped, no stop // call will be sent.
[ "RestageApplication", "restarts", "a", "given", "application", ".", "If", "already", "stopped", "no", "stop", "call", "will", "be", "sent", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L323-L352
train
cloudfoundry/cli
api/router/router_group.go
GetRouterGroupByName
func (client *Client) GetRouterGroupByName(name string) (RouterGroup, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouterGroups, Query: url.Values{"name": []string{name}}, }) if err != nil { return RouterGroup{}, err } var routerGroups []RouterGroup var response = Response{ Result: &routerGroups, } err = client.connection.Make(request, &response) if err != nil { return RouterGroup{}, err } for _, routerGroup := range routerGroups { if routerGroup.Name == name { return routerGroup, nil } } return RouterGroup{}, routererror.ResourceNotFoundError{} }
go
func (client *Client) GetRouterGroupByName(name string) (RouterGroup, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouterGroups, Query: url.Values{"name": []string{name}}, }) if err != nil { return RouterGroup{}, err } var routerGroups []RouterGroup var response = Response{ Result: &routerGroups, } err = client.connection.Make(request, &response) if err != nil { return RouterGroup{}, err } for _, routerGroup := range routerGroups { if routerGroup.Name == name { return routerGroup, nil } } return RouterGroup{}, routererror.ResourceNotFoundError{} }
[ "func", "(", "client", "*", "Client", ")", "GetRouterGroupByName", "(", "name", "string", ")", "(", "RouterGroup", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouterGroups", ",", "Query", ":", "url", ".", "Values", "{", "\"", "\"", ":", "[", "]", "string", "{", "name", "}", "}", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "RouterGroup", "{", "}", ",", "err", "\n", "}", "\n", "var", "routerGroups", "[", "]", "RouterGroup", "\n\n", "var", "response", "=", "Response", "{", "Result", ":", "&", "routerGroups", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RouterGroup", "{", "}", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "routerGroup", ":=", "range", "routerGroups", "{", "if", "routerGroup", ".", "Name", "==", "name", "{", "return", "routerGroup", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "RouterGroup", "{", "}", ",", "routererror", ".", "ResourceNotFoundError", "{", "}", "\n", "}" ]
// GetRouterGroupByName returns a list of RouterGroups.
[ "GetRouterGroupByName", "returns", "a", "list", "of", "RouterGroups", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/router_group.go#L19-L46
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
MarshalJSON
func (b Build) MarshalJSON() ([]byte, error) { var ccBuild struct { Package struct { GUID string `json:"guid"` } `json:"package"` } ccBuild.Package.GUID = b.PackageGUID return json.Marshal(ccBuild) }
go
func (b Build) MarshalJSON() ([]byte, error) { var ccBuild struct { Package struct { GUID string `json:"guid"` } `json:"package"` } ccBuild.Package.GUID = b.PackageGUID return json.Marshal(ccBuild) }
[ "func", "(", "b", "Build", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "ccBuild", "struct", "{", "Package", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "`json:\"package\"`", "\n", "}", "\n\n", "ccBuild", ".", "Package", ".", "GUID", "=", "b", ".", "PackageGUID", "\n\n", "return", "json", ".", "Marshal", "(", "ccBuild", ")", "\n", "}" ]
// MarshalJSON converts a Build into a Cloud Controller Application.
[ "MarshalJSON", "converts", "a", "Build", "into", "a", "Cloud", "Controller", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L31-L41
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
UnmarshalJSON
func (b *Build) UnmarshalJSON(data []byte) error { var ccBuild struct { CreatedAt string `json:"created_at,omitempty"` GUID string `json:"guid,omitempty"` Error string `json:"error"` Package struct { GUID string `json:"guid"` } `json:"package"` State constant.BuildState `json:"state,omitempty"` Droplet struct { GUID string `json:"guid"` } `json:"droplet"` } err := cloudcontroller.DecodeJSON(data, &ccBuild) if err != nil { return err } b.GUID = ccBuild.GUID b.CreatedAt = ccBuild.CreatedAt b.Error = ccBuild.Error b.PackageGUID = ccBuild.Package.GUID b.State = ccBuild.State b.DropletGUID = ccBuild.Droplet.GUID return nil }
go
func (b *Build) UnmarshalJSON(data []byte) error { var ccBuild struct { CreatedAt string `json:"created_at,omitempty"` GUID string `json:"guid,omitempty"` Error string `json:"error"` Package struct { GUID string `json:"guid"` } `json:"package"` State constant.BuildState `json:"state,omitempty"` Droplet struct { GUID string `json:"guid"` } `json:"droplet"` } err := cloudcontroller.DecodeJSON(data, &ccBuild) if err != nil { return err } b.GUID = ccBuild.GUID b.CreatedAt = ccBuild.CreatedAt b.Error = ccBuild.Error b.PackageGUID = ccBuild.Package.GUID b.State = ccBuild.State b.DropletGUID = ccBuild.Droplet.GUID return nil }
[ "func", "(", "b", "*", "Build", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccBuild", "struct", "{", "CreatedAt", "string", "`json:\"created_at,omitempty\"`", "\n", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "Error", "string", "`json:\"error\"`", "\n", "Package", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "`json:\"package\"`", "\n", "State", "constant", ".", "BuildState", "`json:\"state,omitempty\"`", "\n", "Droplet", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "`json:\"droplet\"`", "\n", "}", "\n\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccBuild", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "b", ".", "GUID", "=", "ccBuild", ".", "GUID", "\n", "b", ".", "CreatedAt", "=", "ccBuild", ".", "CreatedAt", "\n", "b", ".", "Error", "=", "ccBuild", ".", "Error", "\n", "b", ".", "PackageGUID", "=", "ccBuild", ".", "Package", ".", "GUID", "\n", "b", ".", "State", "=", "ccBuild", ".", "State", "\n", "b", ".", "DropletGUID", "=", "ccBuild", ".", "Droplet", ".", "GUID", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Build response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Build", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L44-L71
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
CreateBuild
func (client *Client) CreateBuild(build Build) (Build, Warnings, error) { bodyBytes, err := json.Marshal(build) if err != nil { return Build{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostBuildRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
go
func (client *Client) CreateBuild(build Build) (Build, Warnings, error) { bodyBytes, err := json.Marshal(build) if err != nil { return Build{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostBuildRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateBuild", "(", "build", "Build", ")", "(", "Build", ",", "Warnings", ",", "error", ")", "{", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "build", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Build", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostBuildRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Build", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseBuild", "Build", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseBuild", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responseBuild", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateBuild creates the given build, requires Package GUID to be set on the // build.
[ "CreateBuild", "creates", "the", "given", "build", "requires", "Package", "GUID", "to", "be", "set", "on", "the", "build", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L75-L96
train
cloudfoundry/cli
api/cloudcontroller/ccv3/build.go
GetBuild
func (client *Client) GetBuild(guid string) (Build, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetBuildRequest, URIParams: internal.Params{"build_guid": guid}, }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
go
func (client *Client) GetBuild(guid string) (Build, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetBuildRequest, URIParams: internal.Params{"build_guid": guid}, }) if err != nil { return Build{}, nil, err } var responseBuild Build response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseBuild, } err = client.connection.Make(request, &response) return responseBuild, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetBuild", "(", "guid", "string", ")", "(", "Build", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetBuildRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Build", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseBuild", "Build", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseBuild", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responseBuild", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetBuild gets the build with the given GUID.
[ "GetBuild", "gets", "the", "build", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/build.go#L99-L115
train
cloudfoundry/cli
actor/v3action/environment_variable.go
GetEnvironmentVariablesByApplicationNameAndSpace
func (actor *Actor) GetEnvironmentVariablesByApplicationNameAndSpace(appName string, spaceGUID string) (EnvironmentVariableGroups, Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return EnvironmentVariableGroups{}, warnings, appErr } ccEnvGroups, v3Warnings, apiErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, v3Warnings...) return EnvironmentVariableGroups(ccEnvGroups), warnings, apiErr }
go
func (actor *Actor) GetEnvironmentVariablesByApplicationNameAndSpace(appName string, spaceGUID string) (EnvironmentVariableGroups, Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return EnvironmentVariableGroups{}, warnings, appErr } ccEnvGroups, v3Warnings, apiErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, v3Warnings...) return EnvironmentVariableGroups(ccEnvGroups), warnings, apiErr }
[ "func", "(", "actor", "*", "Actor", ")", "GetEnvironmentVariablesByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ")", "(", "EnvironmentVariableGroups", ",", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "appErr", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "appErr", "!=", "nil", "{", "return", "EnvironmentVariableGroups", "{", "}", ",", "warnings", ",", "appErr", "\n", "}", "\n\n", "ccEnvGroups", ",", "v3Warnings", ",", "apiErr", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationEnvironment", "(", "app", ".", "GUID", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "v3Warnings", "...", ")", "\n", "return", "EnvironmentVariableGroups", "(", "ccEnvGroups", ")", ",", "warnings", ",", "apiErr", "\n", "}" ]
// GetEnvironmentVariablesByApplicationNameAndSpace returns the environment // variables for an application.
[ "GetEnvironmentVariablesByApplicationNameAndSpace", "returns", "the", "environment", "variables", "for", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/environment_variable.go#L20-L29
train
cloudfoundry/cli
actor/v3action/environment_variable.go
SetEnvironmentVariableByApplicationNameAndSpace
func (actor *Actor) SetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, envPair EnvironmentVariablePair) (Warnings, error) { app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return warnings, err } _, v3Warnings, apiErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ envPair.Key: {Value: envPair.Value, IsSet: true}, }) warnings = append(warnings, v3Warnings...) return warnings, apiErr }
go
func (actor *Actor) SetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, envPair EnvironmentVariablePair) (Warnings, error) { app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return warnings, err } _, v3Warnings, apiErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ envPair.Key: {Value: envPair.Value, IsSet: true}, }) warnings = append(warnings, v3Warnings...) return warnings, apiErr }
[ "func", "(", "actor", "*", "Actor", ")", "SetEnvironmentVariableByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "envPair", "EnvironmentVariablePair", ")", "(", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "warnings", ",", "err", "\n", "}", "\n\n", "_", ",", "v3Warnings", ",", "apiErr", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationEnvironmentVariables", "(", "app", ".", "GUID", ",", "ccv3", ".", "EnvironmentVariables", "{", "envPair", ".", "Key", ":", "{", "Value", ":", "envPair", ".", "Value", ",", "IsSet", ":", "true", "}", ",", "}", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "v3Warnings", "...", ")", "\n", "return", "warnings", ",", "apiErr", "\n", "}" ]
// SetEnvironmentVariableByApplicationNameAndSpace adds an // EnvironmentVariablePair to an application. It must be restarted for changes // to take effect.
[ "SetEnvironmentVariableByApplicationNameAndSpace", "adds", "an", "EnvironmentVariablePair", "to", "an", "application", ".", "It", "must", "be", "restarted", "for", "changes", "to", "take", "effect", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/environment_variable.go#L34-L47
train
cloudfoundry/cli
actor/v3action/environment_variable.go
UnsetEnvironmentVariableByApplicationNameAndSpace
func (actor *Actor) UnsetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, environmentVariableName string) (Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return warnings, appErr } envGroups, getWarnings, getErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, getWarnings...) if getErr != nil { return warnings, getErr } if _, ok := envGroups.EnvironmentVariables[environmentVariableName]; !ok { return warnings, actionerror.EnvironmentVariableNotSetError{EnvironmentVariableName: environmentVariableName} } _, patchWarnings, patchErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ environmentVariableName: {Value: "", IsSet: false}, }) warnings = append(warnings, patchWarnings...) return warnings, patchErr }
go
func (actor *Actor) UnsetEnvironmentVariableByApplicationNameAndSpace(appName string, spaceGUID string, environmentVariableName string) (Warnings, error) { app, warnings, appErr := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if appErr != nil { return warnings, appErr } envGroups, getWarnings, getErr := actor.CloudControllerClient.GetApplicationEnvironment(app.GUID) warnings = append(warnings, getWarnings...) if getErr != nil { return warnings, getErr } if _, ok := envGroups.EnvironmentVariables[environmentVariableName]; !ok { return warnings, actionerror.EnvironmentVariableNotSetError{EnvironmentVariableName: environmentVariableName} } _, patchWarnings, patchErr := actor.CloudControllerClient.UpdateApplicationEnvironmentVariables( app.GUID, ccv3.EnvironmentVariables{ environmentVariableName: {Value: "", IsSet: false}, }) warnings = append(warnings, patchWarnings...) return warnings, patchErr }
[ "func", "(", "actor", "*", "Actor", ")", "UnsetEnvironmentVariableByApplicationNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "environmentVariableName", "string", ")", "(", "Warnings", ",", "error", ")", "{", "app", ",", "warnings", ",", "appErr", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "appErr", "!=", "nil", "{", "return", "warnings", ",", "appErr", "\n", "}", "\n", "envGroups", ",", "getWarnings", ",", "getErr", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationEnvironment", "(", "app", ".", "GUID", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "getWarnings", "...", ")", "\n", "if", "getErr", "!=", "nil", "{", "return", "warnings", ",", "getErr", "\n", "}", "\n\n", "if", "_", ",", "ok", ":=", "envGroups", ".", "EnvironmentVariables", "[", "environmentVariableName", "]", ";", "!", "ok", "{", "return", "warnings", ",", "actionerror", ".", "EnvironmentVariableNotSetError", "{", "EnvironmentVariableName", ":", "environmentVariableName", "}", "\n", "}", "\n\n", "_", ",", "patchWarnings", ",", "patchErr", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationEnvironmentVariables", "(", "app", ".", "GUID", ",", "ccv3", ".", "EnvironmentVariables", "{", "environmentVariableName", ":", "{", "Value", ":", "\"", "\"", ",", "IsSet", ":", "false", "}", ",", "}", ")", "\n", "warnings", "=", "append", "(", "warnings", ",", "patchWarnings", "...", ")", "\n", "return", "warnings", ",", "patchErr", "\n", "}" ]
// UnsetEnvironmentVariableByApplicationNameAndSpace removes an enviornment // variable from an application. It must be restarted for changes to take // effect.
[ "UnsetEnvironmentVariableByApplicationNameAndSpace", "removes", "an", "enviornment", "variable", "from", "an", "application", ".", "It", "must", "be", "restarted", "for", "changes", "to", "take", "effect", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/environment_variable.go#L52-L74
train
cloudfoundry/cli
util/ui/prompt.go
DisplayBoolPrompt
func (ui *UI) DisplayBoolPrompt(defaultResponse bool, template string, templateValues ...map[string]interface{}) (bool, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() response := defaultResponse interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(&response) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return response, err }
go
func (ui *UI) DisplayBoolPrompt(defaultResponse bool, template string, templateValues ...map[string]interface{}) (bool, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() response := defaultResponse interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(&response) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return response, err }
[ "func", "(", "ui", "*", "UI", ")", "DisplayBoolPrompt", "(", "defaultResponse", "bool", ",", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "bool", ",", "error", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "response", ":=", "defaultResponse", "\n", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "&", "response", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "return", "response", ",", "err", "\n", "}" ]
// DisplayBoolPrompt outputs the prompt and waits for user input. It only // allows for a boolean response. A default boolean response can be set with // defaultResponse.
[ "DisplayBoolPrompt", "outputs", "the", "prompt", "and", "waits", "for", "user", "input", ".", "It", "only", "allows", "for", "a", "boolean", "response", ".", "A", "default", "boolean", "response", "can", "be", "set", "with", "defaultResponse", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L36-L49
train
cloudfoundry/cli
util/ui/prompt.go
DisplayPasswordPrompt
func (ui *UI) DisplayPasswordPrompt(template string, templateValues ...map[string]interface{}) (string, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() var password interact.Password interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&password)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return string(password), err }
go
func (ui *UI) DisplayPasswordPrompt(template string, templateValues ...map[string]interface{}) (string, error) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() var password interact.Password interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&password)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return string(password), err }
[ "func", "(", "ui", "*", "UI", ")", "DisplayPasswordPrompt", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "var", "password", "interact", ".", "Password", "\n", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "interact", ".", "Required", "(", "&", "password", ")", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "return", "string", "(", "password", ")", ",", "err", "\n", "}" ]
// DisplayPasswordPrompt outputs the prompt and waits for user input. Hides // user's response from the screen.
[ "DisplayPasswordPrompt", "outputs", "the", "prompt", "and", "waits", "for", "user", "input", ".", "Hides", "user", "s", "response", "from", "the", "screen", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L66-L79
train
cloudfoundry/cli
util/ui/prompt.go
DisplayTextMenu
func (ui *UI) DisplayTextMenu(choices []string, promptTemplate string, templateValues ...map[string]interface{}) (string, error) { for i, c := range choices { t := fmt.Sprintf("%d. %s", i+1, c) ui.DisplayText(t) } translatedPrompt := ui.TranslateText(promptTemplate, templateValues...) interactivePrompt := ui.Interactor.NewInteraction(translatedPrompt) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) var value string = "enter to skip" err := interactivePrompt.Resolve(&value) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } if err != nil { return "", err } if value == "enter to skip" { return "", nil } i, err := strconv.Atoi(value) if err != nil { if contains(choices, value) { return value, nil } return "", InvalidChoiceError{Choice: value} } if i > len(choices) || i <= 0 { return "", ErrInvalidIndex } return choices[i-1], nil }
go
func (ui *UI) DisplayTextMenu(choices []string, promptTemplate string, templateValues ...map[string]interface{}) (string, error) { for i, c := range choices { t := fmt.Sprintf("%d. %s", i+1, c) ui.DisplayText(t) } translatedPrompt := ui.TranslateText(promptTemplate, templateValues...) interactivePrompt := ui.Interactor.NewInteraction(translatedPrompt) interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) var value string = "enter to skip" err := interactivePrompt.Resolve(&value) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } if err != nil { return "", err } if value == "enter to skip" { return "", nil } i, err := strconv.Atoi(value) if err != nil { if contains(choices, value) { return value, nil } return "", InvalidChoiceError{Choice: value} } if i > len(choices) || i <= 0 { return "", ErrInvalidIndex } return choices[i-1], nil }
[ "func", "(", "ui", "*", "UI", ")", "DisplayTextMenu", "(", "choices", "[", "]", "string", ",", "promptTemplate", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "for", "i", ",", "c", ":=", "range", "choices", "{", "t", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "i", "+", "1", ",", "c", ")", "\n", "ui", ".", "DisplayText", "(", "t", ")", "\n", "}", "\n\n", "translatedPrompt", ":=", "ui", ".", "TranslateText", "(", "promptTemplate", ",", "templateValues", "...", ")", "\n\n", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "translatedPrompt", ")", "\n\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n\n", "var", "value", "string", "=", "\"", "\"", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "&", "value", ")", "\n\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "value", "==", "\"", "\"", "{", "return", "\"", "\"", ",", "nil", "\n", "}", "\n\n", "i", ",", "err", ":=", "strconv", ".", "Atoi", "(", "value", ")", "\n", "if", "err", "!=", "nil", "{", "if", "contains", "(", "choices", ",", "value", ")", "{", "return", "value", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "InvalidChoiceError", "{", "Choice", ":", "value", "}", "\n", "}", "\n\n", "if", "i", ">", "len", "(", "choices", ")", "||", "i", "<=", "0", "{", "return", "\"", "\"", ",", "ErrInvalidIndex", "\n", "}", "\n", "return", "choices", "[", "i", "-", "1", "]", ",", "nil", "\n", "}" ]
// DisplayTextMenu lets the user choose from a list of options, either by name // or by number.
[ "DisplayTextMenu", "lets", "the", "user", "choose", "from", "a", "list", "of", "options", "either", "by", "name", "or", "by", "number", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L83-L123
train
cloudfoundry/cli
util/ui/prompt.go
DisplayTextPrompt
func (ui *UI) DisplayTextPrompt(template string, templateValues ...map[string]interface{}) (string, error) { interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) var value string interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&value)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return value, err }
go
func (ui *UI) DisplayTextPrompt(template string, templateValues ...map[string]interface{}) (string, error) { interactivePrompt := ui.Interactor.NewInteraction(ui.TranslateText(template, templateValues...)) var value string interactivePrompt.SetIn(ui.In) interactivePrompt.SetOut(ui.OutForInteration) err := interactivePrompt.Resolve(interact.Required(&value)) if isInterrupt(err) { ui.Exiter.Exit(sigIntExitCode) } return value, err }
[ "func", "(", "ui", "*", "UI", ")", "DisplayTextPrompt", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "string", ",", "error", ")", "{", "interactivePrompt", ":=", "ui", ".", "Interactor", ".", "NewInteraction", "(", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "var", "value", "string", "\n", "interactivePrompt", ".", "SetIn", "(", "ui", ".", "In", ")", "\n", "interactivePrompt", ".", "SetOut", "(", "ui", ".", "OutForInteration", ")", "\n", "err", ":=", "interactivePrompt", ".", "Resolve", "(", "interact", ".", "Required", "(", "&", "value", ")", ")", "\n", "if", "isInterrupt", "(", "err", ")", "{", "ui", ".", "Exiter", ".", "Exit", "(", "sigIntExitCode", ")", "\n", "}", "\n", "return", "value", ",", "err", "\n", "}" ]
// DisplayTextPrompt outputs the prompt and waits for user input.
[ "DisplayTextPrompt", "outputs", "the", "prompt", "and", "waits", "for", "user", "input", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/prompt.go#L126-L136
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
UnmarshalJSON
func (route *Route) UnmarshalJSON(data []byte) error { var ccRoute struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Host string `json:"host"` Path string `json:"path"` Port types.NullInt `json:"port"` DomainGUID string `json:"domain_guid"` SpaceGUID string `json:"space_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccRoute) if err != nil { return err } route.GUID = ccRoute.Metadata.GUID route.Host = ccRoute.Entity.Host route.Path = ccRoute.Entity.Path route.Port = ccRoute.Entity.Port route.DomainGUID = ccRoute.Entity.DomainGUID route.SpaceGUID = ccRoute.Entity.SpaceGUID return nil }
go
func (route *Route) UnmarshalJSON(data []byte) error { var ccRoute struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Host string `json:"host"` Path string `json:"path"` Port types.NullInt `json:"port"` DomainGUID string `json:"domain_guid"` SpaceGUID string `json:"space_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccRoute) if err != nil { return err } route.GUID = ccRoute.Metadata.GUID route.Host = ccRoute.Entity.Host route.Path = ccRoute.Entity.Path route.Port = ccRoute.Entity.Port route.DomainGUID = ccRoute.Entity.DomainGUID route.SpaceGUID = ccRoute.Entity.SpaceGUID return nil }
[ "func", "(", "route", "*", "Route", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccRoute", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Host", "string", "`json:\"host\"`", "\n", "Path", "string", "`json:\"path\"`", "\n", "Port", "types", ".", "NullInt", "`json:\"port\"`", "\n", "DomainGUID", "string", "`json:\"domain_guid\"`", "\n", "SpaceGUID", "string", "`json:\"space_guid\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccRoute", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "route", ".", "GUID", "=", "ccRoute", ".", "Metadata", ".", "GUID", "\n", "route", ".", "Host", "=", "ccRoute", ".", "Entity", ".", "Host", "\n", "route", ".", "Path", "=", "ccRoute", ".", "Entity", ".", "Path", "\n", "route", ".", "Port", "=", "ccRoute", ".", "Entity", ".", "Port", "\n", "route", ".", "DomainGUID", "=", "ccRoute", ".", "Entity", ".", "DomainGUID", "\n", "route", ".", "SpaceGUID", "=", "ccRoute", ".", "Entity", ".", "SpaceGUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Route response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Route", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L39-L62
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
CheckRoute
func (client *Client) CheckRoute(route Route) (bool, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteReservedRequest, URIParams: map[string]string{"domain_guid": route.DomainGUID}, }) if err != nil { return false, nil, err } queryParams := url.Values{} if route.Host != "" { queryParams.Add("host", route.Host) } if route.Path != "" { queryParams.Add("path", route.Path) } if route.Port.IsSet { queryParams.Add("port", fmt.Sprint(route.Port.Value)) } request.URL.RawQuery = queryParams.Encode() var response cloudcontroller.Response err = client.connection.Make(request, &response) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return false, response.Warnings, nil } return response.HTTPResponse.StatusCode == http.StatusNoContent, response.Warnings, err }
go
func (client *Client) CheckRoute(route Route) (bool, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteReservedRequest, URIParams: map[string]string{"domain_guid": route.DomainGUID}, }) if err != nil { return false, nil, err } queryParams := url.Values{} if route.Host != "" { queryParams.Add("host", route.Host) } if route.Path != "" { queryParams.Add("path", route.Path) } if route.Port.IsSet { queryParams.Add("port", fmt.Sprint(route.Port.Value)) } request.URL.RawQuery = queryParams.Encode() var response cloudcontroller.Response err = client.connection.Make(request, &response) if _, ok := err.(ccerror.ResourceNotFoundError); ok { return false, response.Warnings, nil } return response.HTTPResponse.StatusCode == http.StatusNoContent, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CheckRoute", "(", "route", "Route", ")", "(", "bool", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouteReservedRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "route", ".", "DomainGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "nil", ",", "err", "\n", "}", "\n\n", "queryParams", ":=", "url", ".", "Values", "{", "}", "\n", "if", "route", ".", "Host", "!=", "\"", "\"", "{", "queryParams", ".", "Add", "(", "\"", "\"", ",", "route", ".", "Host", ")", "\n", "}", "\n", "if", "route", ".", "Path", "!=", "\"", "\"", "{", "queryParams", ".", "Add", "(", "\"", "\"", ",", "route", ".", "Path", ")", "\n", "}", "\n", "if", "route", ".", "Port", ".", "IsSet", "{", "queryParams", ".", "Add", "(", "\"", "\"", ",", "fmt", ".", "Sprint", "(", "route", ".", "Port", ".", "Value", ")", ")", "\n", "}", "\n", "request", ".", "URL", ".", "RawQuery", "=", "queryParams", ".", "Encode", "(", ")", "\n\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "ok", "{", "return", "false", ",", "response", ".", "Warnings", ",", "nil", "\n", "}", "\n\n", "return", "response", ".", "HTTPResponse", ".", "StatusCode", "==", "http", ".", "StatusNoContent", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CheckRoute returns true if the route exists in the CF instance.
[ "CheckRoute", "returns", "true", "if", "the", "route", "exists", "in", "the", "CF", "instance", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L65-L93
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
DeleteRouteApplication
func (client *Client) DeleteRouteApplication(routeGUID string, appGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteRouteApplication(routeGUID string, appGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteRouteApplication", "(", "routeGUID", "string", ",", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteRouteAppRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "appGUID", ",", "\"", "\"", ":", "routeGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteRouteApplication removes the link between the route and application.
[ "DeleteRouteApplication", "removes", "the", "link", "between", "the", "route", "and", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L146-L161
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
DeleteSpaceUnmappedRoutes
func (client *Client) DeleteSpaceUnmappedRoutes(spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceUnmappedRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteSpaceUnmappedRoutes(spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceUnmappedRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, }) if err != nil { return nil, err } var response cloudcontroller.Response err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteSpaceUnmappedRoutes", "(", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteSpaceUnmappedRoutesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "response", "cloudcontroller", ".", "Response", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteSpaceUnmappedRoutes deletes Routes within a specified Space not mapped // to an Application
[ "DeleteSpaceUnmappedRoutes", "deletes", "Routes", "within", "a", "specified", "Space", "not", "mapped", "to", "an", "Application" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L165-L177
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
GetRoute
func (client *Client) GetRoute(guid string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteRequest, URIParams: Params{"route_guid": guid}, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
go
func (client *Client) GetRoute(guid string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteRequest, URIParams: Params{"route_guid": guid}, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetRoute", "(", "guid", "string", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouteRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Route", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "route", "Route", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "route", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "route", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetRoute returns a route with the provided guid.
[ "GetRoute", "returns", "a", "route", "with", "the", "provided", "guid", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L208-L224
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
GetRoutes
func (client *Client) GetRoutes(filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRoutesRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
go
func (client *Client) GetRoutes(filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRoutesRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetRoutes", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRoutesRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullRoutesList", "[", "]", "Route", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Route", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "route", ",", "ok", ":=", "item", ".", "(", "Route", ")", ";", "ok", "{", "fullRoutesList", "=", "append", "(", "fullRoutesList", ",", "route", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Route", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullRoutesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetRoutes returns a list of Routes based off of the provided filters.
[ "GetRoutes", "returns", "a", "list", "of", "Routes", "based", "off", "of", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L227-L250
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
GetSpaceRoutes
func (client *Client) GetSpaceRoutes(spaceGUID string, filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
go
func (client *Client) GetSpaceRoutes(spaceGUID string, filters ...Filter) ([]Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceRoutesRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullRoutesList []Route warnings, err := client.paginate(request, Route{}, func(item interface{}) error { if route, ok := item.(Route); ok { fullRoutesList = append(fullRoutesList, route) } else { return ccerror.UnknownObjectInListError{ Expected: Route{}, Unexpected: item, } } return nil }) return fullRoutesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceRoutes", "(", "spaceGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpaceRoutesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullRoutesList", "[", "]", "Route", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Route", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "route", ",", "ok", ":=", "item", ".", "(", "Route", ")", ";", "ok", "{", "fullRoutesList", "=", "append", "(", "fullRoutesList", ",", "route", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Route", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullRoutesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSpaceRoutes returns a list of Routes associated with the provided Space // GUID, and filtered by the provided filters.
[ "GetSpaceRoutes", "returns", "a", "list", "of", "Routes", "associated", "with", "the", "provided", "Space", "GUID", "and", "filtered", "by", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L254-L278
train
cloudfoundry/cli
api/cloudcontroller/ccv2/route.go
UpdateRouteApplication
func (client *Client) UpdateRouteApplication(routeGUID string, appGUID string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
go
func (client *Client) UpdateRouteApplication(routeGUID string, appGUID string) (Route, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutRouteAppRequest, URIParams: map[string]string{ "app_guid": appGUID, "route_guid": routeGUID, }, }) if err != nil { return Route{}, nil, err } var route Route response := cloudcontroller.Response{ DecodeJSONResponseInto: &route, } err = client.connection.Make(request, &response) return route, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateRouteApplication", "(", "routeGUID", "string", ",", "appGUID", "string", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutRouteAppRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "appGUID", ",", "\"", "\"", ":", "routeGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Route", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "route", "Route", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "route", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "route", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateRouteApplication creates a link between the route and application.
[ "UpdateRouteApplication", "creates", "a", "link", "between", "the", "route", "and", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/route.go#L281-L300
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process.go
CreateApplicationProcessScale
func (client *Client) CreateApplicationProcessScale(appGUID string, process Process) (Process, Warnings, error) { body, err := json.Marshal(process) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationProcessActionScaleRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"app_guid": appGUID, "type": process.Type}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
go
func (client *Client) CreateApplicationProcessScale(appGUID string, process Process) (Process, Warnings, error) { body, err := json.Marshal(process) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationProcessActionScaleRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"app_guid": appGUID, "type": process.Type}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateApplicationProcessScale", "(", "appGUID", "string", ",", "process", "Process", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "process", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationProcessActionScaleRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "appGUID", ",", "\"", "\"", ":", "process", ".", "Type", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseProcess", "Process", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseProcess", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseProcess", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateApplicationProcessScale updates process instances count, memory or disk
[ "CreateApplicationProcessScale", "updates", "process", "instances", "count", "memory", "or", "disk" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process.go#L81-L102
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process.go
GetApplicationProcessByType
func (client *Client) GetApplicationProcessByType(appGUID string, processType string) (Process, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationProcessRequest, URIParams: map[string]string{ "app_guid": appGUID, "type": processType, }, }) if err != nil { return Process{}, nil, err } var process Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &process, } err = client.connection.Make(request, &response) return process, response.Warnings, err }
go
func (client *Client) GetApplicationProcessByType(appGUID string, processType string) (Process, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationProcessRequest, URIParams: map[string]string{ "app_guid": appGUID, "type": processType, }, }) if err != nil { return Process{}, nil, err } var process Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &process, } err = client.connection.Make(request, &response) return process, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplicationProcessByType", "(", "appGUID", "string", ",", "processType", "string", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetApplicationProcessRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "appGUID", ",", "\"", "\"", ":", "processType", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "process", "Process", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "process", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "process", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetApplicationProcessByType returns application process of specified type
[ "GetApplicationProcessByType", "returns", "application", "process", "of", "specified", "type" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process.go#L105-L123
train
cloudfoundry/cli
api/cloudcontroller/ccv3/process.go
UpdateProcess
func (client *Client) UpdateProcess(process Process) (Process, Warnings, error) { body, err := json.Marshal(Process{ Command: process.Command, HealthCheckType: process.HealthCheckType, HealthCheckEndpoint: process.HealthCheckEndpoint, HealthCheckTimeout: process.HealthCheckTimeout, HealthCheckInvocationTimeout: process.HealthCheckInvocationTimeout, }) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchProcessRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"process_guid": process.GUID}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
go
func (client *Client) UpdateProcess(process Process) (Process, Warnings, error) { body, err := json.Marshal(Process{ Command: process.Command, HealthCheckType: process.HealthCheckType, HealthCheckEndpoint: process.HealthCheckEndpoint, HealthCheckTimeout: process.HealthCheckTimeout, HealthCheckInvocationTimeout: process.HealthCheckInvocationTimeout, }) if err != nil { return Process{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchProcessRequest, Body: bytes.NewReader(body), URIParams: internal.Params{"process_guid": process.GUID}, }) if err != nil { return Process{}, nil, err } var responseProcess Process response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseProcess, } err = client.connection.Make(request, &response) return responseProcess, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateProcess", "(", "process", "Process", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "Process", "{", "Command", ":", "process", ".", "Command", ",", "HealthCheckType", ":", "process", ".", "HealthCheckType", ",", "HealthCheckEndpoint", ":", "process", ".", "HealthCheckEndpoint", ",", "HealthCheckTimeout", ":", "process", ".", "HealthCheckTimeout", ",", "HealthCheckInvocationTimeout", ":", "process", ".", "HealthCheckInvocationTimeout", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchProcessRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "process", ".", "GUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Process", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseProcess", "Process", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseProcess", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseProcess", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateProcess updates the process's command or health check settings. GUID // is always required; HealthCheckType is only required when updating health // check settings.
[ "UpdateProcess", "updates", "the", "process", "s", "command", "or", "health", "check", "settings", ".", "GUID", "is", "always", "required", ";", "HealthCheckType", "is", "only", "required", "when", "updating", "health", "check", "settings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process.go#L155-L182
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance_shared_to.go
GetServiceInstanceSharedTos
func (client *Client) GetServiceInstanceSharedTos(serviceInstanceGUID string) ([]ServiceInstanceSharedTo, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedToRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return nil, nil, err } var fullSharedToList []ServiceInstanceSharedTo warnings, err := client.paginate(request, ServiceInstanceSharedTo{}, func(item interface{}) error { if instance, ok := item.(ServiceInstanceSharedTo); ok { fullSharedToList = append(fullSharedToList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceInstanceSharedTo{}, Unexpected: item, } } return nil }) return fullSharedToList, warnings, err }
go
func (client *Client) GetServiceInstanceSharedTos(serviceInstanceGUID string) ([]ServiceInstanceSharedTo, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedToRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return nil, nil, err } var fullSharedToList []ServiceInstanceSharedTo warnings, err := client.paginate(request, ServiceInstanceSharedTo{}, func(item interface{}) error { if instance, ok := item.(ServiceInstanceSharedTo); ok { fullSharedToList = append(fullSharedToList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceInstanceSharedTo{}, Unexpected: item, } } return nil }) return fullSharedToList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceInstanceSharedTos", "(", "serviceInstanceGUID", "string", ")", "(", "[", "]", "ServiceInstanceSharedTo", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceInstanceSharedToRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "serviceInstanceGUID", "}", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullSharedToList", "[", "]", "ServiceInstanceSharedTo", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ServiceInstanceSharedTo", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "instance", ",", "ok", ":=", "item", ".", "(", "ServiceInstanceSharedTo", ")", ";", "ok", "{", "fullSharedToList", "=", "append", "(", "fullSharedToList", ",", "instance", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ServiceInstanceSharedTo", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullSharedToList", ",", "warnings", ",", "err", "\n", "}" ]
// GetServiceInstanceSharedTos returns a list of ServiceInstanceSharedTo objects.
[ "GetServiceInstanceSharedTos", "returns", "a", "list", "of", "ServiceInstanceSharedTo", "objects", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance_shared_to.go#L29-L53
train
cloudfoundry/cli
api/uaa/uaa_connection.go
NewConnection
func NewConnection(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration) *UAAConnection { tr := &http.Transport{ DialContext: (&net.Dialer{ KeepAlive: 30 * time.Second, Timeout: dialTimeout, }).DialContext, DisableKeepAlives: disableKeepAlives, Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{ InsecureSkipVerify: skipSSLValidation, }, } return &UAAConnection{ HTTPClient: &http.Client{ Transport: tr, CheckRedirect: func(_ *http.Request, _ []*http.Request) error { // This prevents redirects. When making a request to /oauth/authorize, // the client should not follow redirects in order to obtain the ssh // passcode. return http.ErrUseLastResponse }, }, } }
go
func NewConnection(skipSSLValidation bool, disableKeepAlives bool, dialTimeout time.Duration) *UAAConnection { tr := &http.Transport{ DialContext: (&net.Dialer{ KeepAlive: 30 * time.Second, Timeout: dialTimeout, }).DialContext, DisableKeepAlives: disableKeepAlives, Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{ InsecureSkipVerify: skipSSLValidation, }, } return &UAAConnection{ HTTPClient: &http.Client{ Transport: tr, CheckRedirect: func(_ *http.Request, _ []*http.Request) error { // This prevents redirects. When making a request to /oauth/authorize, // the client should not follow redirects in order to obtain the ssh // passcode. return http.ErrUseLastResponse }, }, } }
[ "func", "NewConnection", "(", "skipSSLValidation", "bool", ",", "disableKeepAlives", "bool", ",", "dialTimeout", "time", ".", "Duration", ")", "*", "UAAConnection", "{", "tr", ":=", "&", "http", ".", "Transport", "{", "DialContext", ":", "(", "&", "net", ".", "Dialer", "{", "KeepAlive", ":", "30", "*", "time", ".", "Second", ",", "Timeout", ":", "dialTimeout", ",", "}", ")", ".", "DialContext", ",", "DisableKeepAlives", ":", "disableKeepAlives", ",", "Proxy", ":", "http", ".", "ProxyFromEnvironment", ",", "TLSClientConfig", ":", "&", "tls", ".", "Config", "{", "InsecureSkipVerify", ":", "skipSSLValidation", ",", "}", ",", "}", "\n\n", "return", "&", "UAAConnection", "{", "HTTPClient", ":", "&", "http", ".", "Client", "{", "Transport", ":", "tr", ",", "CheckRedirect", ":", "func", "(", "_", "*", "http", ".", "Request", ",", "_", "[", "]", "*", "http", ".", "Request", ")", "error", "{", "// This prevents redirects. When making a request to /oauth/authorize,", "// the client should not follow redirects in order to obtain the ssh", "// passcode.", "return", "http", ".", "ErrUseLastResponse", "\n", "}", ",", "}", ",", "}", "\n", "}" ]
// NewConnection returns a pointer to a new UAA Connection
[ "NewConnection", "returns", "a", "pointer", "to", "a", "new", "UAA", "Connection" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/uaa_connection.go#L21-L45
train
cloudfoundry/cli
api/uaa/uaa_connection.go
Make
func (connection *UAAConnection) Make(request *http.Request, passedResponse *Response) error { // In case this function is called from a retry, passedResponse may already // be populated with a previous response. We reset in case there's an HTTP // error and we don't repopulate it in populateResponse. passedResponse.reset() response, err := connection.HTTPClient.Do(request) if err != nil { return connection.processRequestErrors(request, err) } return connection.populateResponse(response, passedResponse) }
go
func (connection *UAAConnection) Make(request *http.Request, passedResponse *Response) error { // In case this function is called from a retry, passedResponse may already // be populated with a previous response. We reset in case there's an HTTP // error and we don't repopulate it in populateResponse. passedResponse.reset() response, err := connection.HTTPClient.Do(request) if err != nil { return connection.processRequestErrors(request, err) } return connection.populateResponse(response, passedResponse) }
[ "func", "(", "connection", "*", "UAAConnection", ")", "Make", "(", "request", "*", "http", ".", "Request", ",", "passedResponse", "*", "Response", ")", "error", "{", "// In case this function is called from a retry, passedResponse may already", "// be populated with a previous response. We reset in case there's an HTTP", "// error and we don't repopulate it in populateResponse.", "passedResponse", ".", "reset", "(", ")", "\n\n", "response", ",", "err", ":=", "connection", ".", "HTTPClient", ".", "Do", "(", "request", ")", "\n", "if", "err", "!=", "nil", "{", "return", "connection", ".", "processRequestErrors", "(", "request", ",", "err", ")", "\n", "}", "\n\n", "return", "connection", ".", "populateResponse", "(", "response", ",", "passedResponse", ")", "\n", "}" ]
// Make takes a passedRequest, converts it into an HTTP request and then // executes it. The response is then injected into passedResponse.
[ "Make", "takes", "a", "passedRequest", "converts", "it", "into", "an", "HTTP", "request", "and", "then", "executes", "it", ".", "The", "response", "is", "then", "injected", "into", "passedResponse", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/uaa_connection.go#L49-L61
train
cloudfoundry/cli
api/cloudcontroller/ccv2/event.go
UnmarshalJSON
func (event *Event) UnmarshalJSON(data []byte) error { var ccEvent struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Type string `json:"type,omitempty"` ActorGUID string `json:"actor,omitempty"` ActorType string `json:"actor_type,omitempty"` ActorName string `json:"actor_name,omitempty"` ActeeGUID string `json:"actee,omitempty"` ActeeType string `json:"actee_type,omitempty"` ActeeName string `json:"actee_name,omitempty"` Timestamp *time.Time `json:"timestamp"` Metadata map[string]interface{} `json:"metadata"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccEvent) if err != nil { return err } event.GUID = ccEvent.Metadata.GUID event.Type = constant.EventType(ccEvent.Entity.Type) event.ActorGUID = ccEvent.Entity.ActorGUID event.ActorType = ccEvent.Entity.ActorType event.ActorName = ccEvent.Entity.ActorName event.ActeeGUID = ccEvent.Entity.ActeeGUID event.ActeeType = ccEvent.Entity.ActeeType event.ActeeName = ccEvent.Entity.ActeeName if ccEvent.Entity.Timestamp != nil { event.Timestamp = *ccEvent.Entity.Timestamp } event.Metadata = ccEvent.Entity.Metadata return nil }
go
func (event *Event) UnmarshalJSON(data []byte) error { var ccEvent struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Type string `json:"type,omitempty"` ActorGUID string `json:"actor,omitempty"` ActorType string `json:"actor_type,omitempty"` ActorName string `json:"actor_name,omitempty"` ActeeGUID string `json:"actee,omitempty"` ActeeType string `json:"actee_type,omitempty"` ActeeName string `json:"actee_name,omitempty"` Timestamp *time.Time `json:"timestamp"` Metadata map[string]interface{} `json:"metadata"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccEvent) if err != nil { return err } event.GUID = ccEvent.Metadata.GUID event.Type = constant.EventType(ccEvent.Entity.Type) event.ActorGUID = ccEvent.Entity.ActorGUID event.ActorType = ccEvent.Entity.ActorType event.ActorName = ccEvent.Entity.ActorName event.ActeeGUID = ccEvent.Entity.ActeeGUID event.ActeeType = ccEvent.Entity.ActeeType event.ActeeName = ccEvent.Entity.ActeeName if ccEvent.Entity.Timestamp != nil { event.Timestamp = *ccEvent.Entity.Timestamp } event.Metadata = ccEvent.Entity.Metadata return nil }
[ "func", "(", "event", "*", "Event", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccEvent", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Type", "string", "`json:\"type,omitempty\"`", "\n", "ActorGUID", "string", "`json:\"actor,omitempty\"`", "\n", "ActorType", "string", "`json:\"actor_type,omitempty\"`", "\n", "ActorName", "string", "`json:\"actor_name,omitempty\"`", "\n", "ActeeGUID", "string", "`json:\"actee,omitempty\"`", "\n", "ActeeType", "string", "`json:\"actee_type,omitempty\"`", "\n", "ActeeName", "string", "`json:\"actee_name,omitempty\"`", "\n", "Timestamp", "*", "time", ".", "Time", "`json:\"timestamp\"`", "\n", "Metadata", "map", "[", "string", "]", "interface", "{", "}", "`json:\"metadata\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccEvent", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "event", ".", "GUID", "=", "ccEvent", ".", "Metadata", ".", "GUID", "\n", "event", ".", "Type", "=", "constant", ".", "EventType", "(", "ccEvent", ".", "Entity", ".", "Type", ")", "\n", "event", ".", "ActorGUID", "=", "ccEvent", ".", "Entity", ".", "ActorGUID", "\n", "event", ".", "ActorType", "=", "ccEvent", ".", "Entity", ".", "ActorType", "\n", "event", ".", "ActorName", "=", "ccEvent", ".", "Entity", ".", "ActorName", "\n", "event", ".", "ActeeGUID", "=", "ccEvent", ".", "Entity", ".", "ActeeGUID", "\n", "event", ".", "ActeeType", "=", "ccEvent", ".", "Entity", ".", "ActeeType", "\n", "event", ".", "ActeeName", "=", "ccEvent", ".", "Entity", ".", "ActeeName", "\n", "if", "ccEvent", ".", "Entity", ".", "Timestamp", "!=", "nil", "{", "event", ".", "Timestamp", "=", "*", "ccEvent", ".", "Entity", ".", "Timestamp", "\n", "}", "\n", "event", ".", "Metadata", "=", "ccEvent", ".", "Entity", ".", "Metadata", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Event response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Event", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/event.go#L46-L81
train
cloudfoundry/cli
api/cloudcontroller/ccv2/event.go
GetEvents
func (client *Client) GetEvents(filters ...Filter) ([]Event, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetEventsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullEventsList []Event warnings, err := client.paginate(request, Event{}, func(item interface{}) error { if event, ok := item.(Event); ok { fullEventsList = append(fullEventsList, event) } else { return ccerror.UnknownObjectInListError{ Expected: Event{}, Unexpected: item, } } return nil }) return fullEventsList, warnings, err }
go
func (client *Client) GetEvents(filters ...Filter) ([]Event, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetEventsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullEventsList []Event warnings, err := client.paginate(request, Event{}, func(item interface{}) error { if event, ok := item.(Event); ok { fullEventsList = append(fullEventsList, event) } else { return ccerror.UnknownObjectInListError{ Expected: Event{}, Unexpected: item, } } return nil }) return fullEventsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetEvents", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Event", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetEventsRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullEventsList", "[", "]", "Event", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Event", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "event", ",", "ok", ":=", "item", ".", "(", "Event", ")", ";", "ok", "{", "fullEventsList", "=", "append", "(", "fullEventsList", ",", "event", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Event", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullEventsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetEvents returns back a list of Events based off of the provided queries.
[ "GetEvents", "returns", "back", "a", "list", "of", "Events", "based", "off", "of", "the", "provided", "queries", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/event.go#L84-L107
train
cloudfoundry/cli
api/cloudcontroller/ccv3/v2_formatted_resource.go
UnmarshalJSON
func (r *V2FormattedResource) UnmarshalJSON(data []byte) error { var ccResource struct { Filename string `json:"fn,omitempty"` Mode string `json:"mode,omitempty"` SHA1 string `json:"sha1"` Size int64 `json:"size"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.Filename = ccResource.Filename r.Size = ccResource.Size r.SHA1 = ccResource.SHA1 mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
go
func (r *V2FormattedResource) UnmarshalJSON(data []byte) error { var ccResource struct { Filename string `json:"fn,omitempty"` Mode string `json:"mode,omitempty"` SHA1 string `json:"sha1"` Size int64 `json:"size"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.Filename = ccResource.Filename r.Size = ccResource.Size r.SHA1 = ccResource.SHA1 mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
[ "func", "(", "r", "*", "V2FormattedResource", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccResource", "struct", "{", "Filename", "string", "`json:\"fn,omitempty\"`", "\n", "Mode", "string", "`json:\"mode,omitempty\"`", "\n", "SHA1", "string", "`json:\"sha1\"`", "\n", "Size", "int64", "`json:\"size\"`", "\n", "}", "\n\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccResource", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "r", ".", "Filename", "=", "ccResource", ".", "Filename", "\n", "r", ".", "Size", "=", "ccResource", ".", "Size", "\n", "r", ".", "SHA1", "=", "ccResource", ".", "SHA1", "\n", "mode", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "ccResource", ".", "Mode", ",", "8", ",", "32", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "r", ".", "Mode", "=", "os", ".", "FileMode", "(", "mode", ")", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller V2FormattedResource response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "V2FormattedResource", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/v2_formatted_resource.go#L50-L73
train
cloudfoundry/cli
api/uaa/auth.go
Authenticate
func (client Client) Authenticate(creds map[string]string, origin string, grantType constant.GrantType) (string, string, error) { requestBody := url.Values{ "grant_type": {string(grantType)}, } for k, v := range creds { requestBody.Set(k, v) } type loginHint struct { Origin string `json:"origin"` } originStruct := loginHint{origin} originParam, err := json.Marshal(originStruct) if err != nil { return "", "", err } var query url.Values if origin != "" { query = url.Values{ "login_hint": {string(originParam)}, } } request, err := client.newRequest(requestOptions{ RequestName: internal.PostOAuthTokenRequest, Header: http.Header{ "Content-Type": {"application/x-www-form-urlencoded"}, }, Body: strings.NewReader(requestBody.Encode()), Query: query, }) if err != nil { return "", "", err } if grantType == constant.GrantTypePassword { request.SetBasicAuth(client.config.UAAOAuthClient(), client.config.UAAOAuthClientSecret()) } responseBody := AuthResponse{} response := Response{ Result: &responseBody, } err = client.connection.Make(request, &response) return responseBody.AccessToken, responseBody.RefreshToken, err }
go
func (client Client) Authenticate(creds map[string]string, origin string, grantType constant.GrantType) (string, string, error) { requestBody := url.Values{ "grant_type": {string(grantType)}, } for k, v := range creds { requestBody.Set(k, v) } type loginHint struct { Origin string `json:"origin"` } originStruct := loginHint{origin} originParam, err := json.Marshal(originStruct) if err != nil { return "", "", err } var query url.Values if origin != "" { query = url.Values{ "login_hint": {string(originParam)}, } } request, err := client.newRequest(requestOptions{ RequestName: internal.PostOAuthTokenRequest, Header: http.Header{ "Content-Type": {"application/x-www-form-urlencoded"}, }, Body: strings.NewReader(requestBody.Encode()), Query: query, }) if err != nil { return "", "", err } if grantType == constant.GrantTypePassword { request.SetBasicAuth(client.config.UAAOAuthClient(), client.config.UAAOAuthClientSecret()) } responseBody := AuthResponse{} response := Response{ Result: &responseBody, } err = client.connection.Make(request, &response) return responseBody.AccessToken, responseBody.RefreshToken, err }
[ "func", "(", "client", "Client", ")", "Authenticate", "(", "creds", "map", "[", "string", "]", "string", ",", "origin", "string", ",", "grantType", "constant", ".", "GrantType", ")", "(", "string", ",", "string", ",", "error", ")", "{", "requestBody", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "string", "(", "grantType", ")", "}", ",", "}", "\n\n", "for", "k", ",", "v", ":=", "range", "creds", "{", "requestBody", ".", "Set", "(", "k", ",", "v", ")", "\n", "}", "\n\n", "type", "loginHint", "struct", "{", "Origin", "string", "`json:\"origin\"`", "\n", "}", "\n\n", "originStruct", ":=", "loginHint", "{", "origin", "}", "\n", "originParam", ",", "err", ":=", "json", ".", "Marshal", "(", "originStruct", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "var", "query", "url", ".", "Values", "\n", "if", "origin", "!=", "\"", "\"", "{", "query", "=", "url", ".", "Values", "{", "\"", "\"", ":", "{", "string", "(", "originParam", ")", "}", ",", "}", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostOAuthTokenRequest", ",", "Header", ":", "http", ".", "Header", "{", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "}", ",", "Body", ":", "strings", ".", "NewReader", "(", "requestBody", ".", "Encode", "(", ")", ")", ",", "Query", ":", "query", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "err", "\n", "}", "\n\n", "if", "grantType", "==", "constant", ".", "GrantTypePassword", "{", "request", ".", "SetBasicAuth", "(", "client", ".", "config", ".", "UAAOAuthClient", "(", ")", ",", "client", ".", "config", ".", "UAAOAuthClientSecret", "(", ")", ")", "\n", "}", "\n\n", "responseBody", ":=", "AuthResponse", "{", "}", "\n", "response", ":=", "Response", "{", "Result", ":", "&", "responseBody", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseBody", ".", "AccessToken", ",", "responseBody", ".", "RefreshToken", ",", "err", "\n", "}" ]
// Authenticate sends a username and password to UAA then returns an access // token and a refresh token.
[ "Authenticate", "sends", "a", "username", "and", "password", "to", "UAA", "then", "returns", "an", "access", "token", "and", "a", "refresh", "token", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/auth.go#L22-L72
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization_quota.go
UnmarshalJSON
func (application *OrganizationQuota) UnmarshalJSON(data []byte) error { var ccOrgQuota struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccOrgQuota) if err != nil { return err } application.GUID = ccOrgQuota.Metadata.GUID application.Name = ccOrgQuota.Entity.Name return nil }
go
func (application *OrganizationQuota) UnmarshalJSON(data []byte) error { var ccOrgQuota struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccOrgQuota) if err != nil { return err } application.GUID = ccOrgQuota.Metadata.GUID application.Name = ccOrgQuota.Entity.Name return nil }
[ "func", "(", "application", "*", "OrganizationQuota", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccOrgQuota", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccOrgQuota", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "application", ".", "GUID", "=", "ccOrgQuota", ".", "Metadata", ".", "GUID", "\n", "application", ".", "Name", "=", "ccOrgQuota", ".", "Entity", ".", "Name", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller organization quota response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "organization", "quota", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization_quota.go#L20-L36
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization_quota.go
GetOrganizationQuota
func (client *Client) GetOrganizationQuota(guid string) (OrganizationQuota, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionRequest, URIParams: Params{"organization_quota_guid": guid}, }) if err != nil { return OrganizationQuota{}, nil, err } var orgQuota OrganizationQuota response := cloudcontroller.Response{ DecodeJSONResponseInto: &orgQuota, } err = client.connection.Make(request, &response) return orgQuota, response.Warnings, err }
go
func (client *Client) GetOrganizationQuota(guid string) (OrganizationQuota, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionRequest, URIParams: Params{"organization_quota_guid": guid}, }) if err != nil { return OrganizationQuota{}, nil, err } var orgQuota OrganizationQuota response := cloudcontroller.Response{ DecodeJSONResponseInto: &orgQuota, } err = client.connection.Make(request, &response) return orgQuota, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganizationQuota", "(", "guid", "string", ")", "(", "OrganizationQuota", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationQuotaDefinitionRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "OrganizationQuota", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "orgQuota", "OrganizationQuota", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "orgQuota", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "orgQuota", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetOrganizationQuota returns an Organization Quota associated with the // provided GUID.
[ "GetOrganizationQuota", "returns", "an", "Organization", "Quota", "associated", "with", "the", "provided", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization_quota.go#L40-L56
train
cloudfoundry/cli
api/cloudcontroller/ccv2/organization_quota.go
GetOrganizationQuotas
func (client *Client) GetOrganizationQuotas(filters ...Filter) ([]OrganizationQuota, Warnings, error) { allQueries := ConvertFilterParameters(filters) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionsRequest, Query: allQueries, }) if err != nil { return []OrganizationQuota{}, nil, err } var fullOrgQuotasList []OrganizationQuota warnings, err := client.paginate(request, OrganizationQuota{}, func(item interface{}) error { if org, ok := item.(OrganizationQuota); ok { fullOrgQuotasList = append(fullOrgQuotasList, org) } else { return ccerror.UnknownObjectInListError{ Expected: OrganizationQuota{}, Unexpected: item, } } return nil }) return fullOrgQuotasList, warnings, err }
go
func (client *Client) GetOrganizationQuotas(filters ...Filter) ([]OrganizationQuota, Warnings, error) { allQueries := ConvertFilterParameters(filters) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetOrganizationQuotaDefinitionsRequest, Query: allQueries, }) if err != nil { return []OrganizationQuota{}, nil, err } var fullOrgQuotasList []OrganizationQuota warnings, err := client.paginate(request, OrganizationQuota{}, func(item interface{}) error { if org, ok := item.(OrganizationQuota); ok { fullOrgQuotasList = append(fullOrgQuotasList, org) } else { return ccerror.UnknownObjectInListError{ Expected: OrganizationQuota{}, Unexpected: item, } } return nil }) return fullOrgQuotasList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetOrganizationQuotas", "(", "filters", "...", "Filter", ")", "(", "[", "]", "OrganizationQuota", ",", "Warnings", ",", "error", ")", "{", "allQueries", ":=", "ConvertFilterParameters", "(", "filters", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetOrganizationQuotaDefinitionsRequest", ",", "Query", ":", "allQueries", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "OrganizationQuota", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullOrgQuotasList", "[", "]", "OrganizationQuota", "\n\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "OrganizationQuota", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "org", ",", "ok", ":=", "item", ".", "(", "OrganizationQuota", ")", ";", "ok", "{", "fullOrgQuotasList", "=", "append", "(", "fullOrgQuotasList", ",", "org", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "OrganizationQuota", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullOrgQuotasList", ",", "warnings", ",", "err", "\n", "}" ]
// GetOrganizationQuotas returns an Organization Quota list associated with the // provided filters.
[ "GetOrganizationQuotas", "returns", "an", "Organization", "Quota", "list", "associated", "with", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization_quota.go#L60-L86
train
cloudfoundry/cli
actor/v7action/process.go
GetProcessByTypeAndApplication
func (actor Actor) GetProcessByTypeAndApplication(processType string, appGUID string) (Process, Warnings, error) { process, warnings, err := actor.CloudControllerClient.GetApplicationProcessByType(appGUID, processType) if _, ok := err.(ccerror.ProcessNotFoundError); ok { return Process{}, Warnings(warnings), actionerror.ProcessNotFoundError{ProcessType: processType} } return Process(process), Warnings(warnings), err }
go
func (actor Actor) GetProcessByTypeAndApplication(processType string, appGUID string) (Process, Warnings, error) { process, warnings, err := actor.CloudControllerClient.GetApplicationProcessByType(appGUID, processType) if _, ok := err.(ccerror.ProcessNotFoundError); ok { return Process{}, Warnings(warnings), actionerror.ProcessNotFoundError{ProcessType: processType} } return Process(process), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetProcessByTypeAndApplication", "(", "processType", "string", ",", "appGUID", "string", ")", "(", "Process", ",", "Warnings", ",", "error", ")", "{", "process", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationProcessByType", "(", "appGUID", ",", "processType", ")", "\n", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ProcessNotFoundError", ")", ";", "ok", "{", "return", "Process", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ProcessNotFoundError", "{", "ProcessType", ":", "processType", "}", "\n", "}", "\n", "return", "Process", "(", "process", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetProcessByTypeAndApplication returns a process for the given application // and type.
[ "GetProcessByTypeAndApplication", "returns", "a", "process", "for", "the", "given", "application", "and", "type", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/process.go#L15-L21
train
cloudfoundry/cli
types/filtered_string.go
ParseValue
func (n *FilteredString) ParseValue(val string) { if val == "" { n.IsSet = false n.Value = "" return } n.IsSet = true switch val { case "null", "default": n.Value = "" default: n.Value = val } }
go
func (n *FilteredString) ParseValue(val string) { if val == "" { n.IsSet = false n.Value = "" return } n.IsSet = true switch val { case "null", "default": n.Value = "" default: n.Value = val } }
[ "func", "(", "n", "*", "FilteredString", ")", "ParseValue", "(", "val", "string", ")", "{", "if", "val", "==", "\"", "\"", "{", "n", ".", "IsSet", "=", "false", "\n", "n", ".", "Value", "=", "\"", "\"", "\n", "return", "\n", "}", "\n\n", "n", ".", "IsSet", "=", "true", "\n\n", "switch", "val", "{", "case", "\"", "\"", ",", "\"", "\"", ":", "n", ".", "Value", "=", "\"", "\"", "\n", "default", ":", "n", ".", "Value", "=", "val", "\n", "}", "\n", "}" ]
// ParseValue is used to parse a user provided flag argument.
[ "ParseValue", "is", "used", "to", "parse", "a", "user", "provided", "flag", "argument", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/types/filtered_string.go#L27-L42
train
cloudfoundry/cli
types/filtered_string.go
MarshalJSON
func (n FilteredString) MarshalJSON() ([]byte, error) { if n.Value != "" { return json.Marshal(n.Value) } return json.Marshal(new(json.RawMessage)) }
go
func (n FilteredString) MarshalJSON() ([]byte, error) { if n.Value != "" { return json.Marshal(n.Value) } return json.Marshal(new(json.RawMessage)) }
[ "func", "(", "n", "FilteredString", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "if", "n", ".", "Value", "!=", "\"", "\"", "{", "return", "json", ".", "Marshal", "(", "n", ".", "Value", ")", "\n", "}", "\n\n", "return", "json", ".", "Marshal", "(", "new", "(", "json", ".", "RawMessage", ")", ")", "\n", "}" ]
// MarshalJSON marshals the value field if it's not empty, otherwise returns an // null.
[ "MarshalJSON", "marshals", "the", "value", "field", "if", "it", "s", "not", "empty", "otherwise", "returns", "an", "null", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/types/filtered_string.go#L68-L74
train
cloudfoundry/cli
api/cloudcontroller/decode_json.go
DecodeJSON
func DecodeJSON(raw []byte, v interface{}) error { decoder := json.NewDecoder(bytes.NewBuffer(raw)) decoder.UseNumber() return decoder.Decode(v) }
go
func DecodeJSON(raw []byte, v interface{}) error { decoder := json.NewDecoder(bytes.NewBuffer(raw)) decoder.UseNumber() return decoder.Decode(v) }
[ "func", "DecodeJSON", "(", "raw", "[", "]", "byte", ",", "v", "interface", "{", "}", ")", "error", "{", "decoder", ":=", "json", ".", "NewDecoder", "(", "bytes", ".", "NewBuffer", "(", "raw", ")", ")", "\n", "decoder", ".", "UseNumber", "(", ")", "\n", "return", "decoder", ".", "Decode", "(", "v", ")", "\n", "}" ]
// DecodeJSON unmarshals JSON into the given object with the appropriate // settings.
[ "DecodeJSON", "unmarshals", "JSON", "into", "the", "given", "object", "with", "the", "appropriate", "settings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/decode_json.go#L10-L14
train
cloudfoundry/cli
api/cloudcontroller/ccv3/deployment.go
MarshalJSON
func (d Deployment) MarshalJSON() ([]byte, error) { type Droplet struct { GUID string `json:"guid,omitempty"` } var ccDeployment struct { Droplet *Droplet `json:"droplet,omitempty"` Relationships Relationships `json:"relationships,omitempty"` } if d.DropletGUID != "" { ccDeployment.Droplet = &Droplet{d.DropletGUID} } ccDeployment.Relationships = d.Relationships return json.Marshal(ccDeployment) }
go
func (d Deployment) MarshalJSON() ([]byte, error) { type Droplet struct { GUID string `json:"guid,omitempty"` } var ccDeployment struct { Droplet *Droplet `json:"droplet,omitempty"` Relationships Relationships `json:"relationships,omitempty"` } if d.DropletGUID != "" { ccDeployment.Droplet = &Droplet{d.DropletGUID} } ccDeployment.Relationships = d.Relationships return json.Marshal(ccDeployment) }
[ "func", "(", "d", "Deployment", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "type", "Droplet", "struct", "{", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "}", "\n\n", "var", "ccDeployment", "struct", "{", "Droplet", "*", "Droplet", "`json:\"droplet,omitempty\"`", "\n", "Relationships", "Relationships", "`json:\"relationships,omitempty\"`", "\n", "}", "\n\n", "if", "d", ".", "DropletGUID", "!=", "\"", "\"", "{", "ccDeployment", ".", "Droplet", "=", "&", "Droplet", "{", "d", ".", "DropletGUID", "}", "\n", "}", "\n\n", "ccDeployment", ".", "Relationships", "=", "d", ".", "Relationships", "\n\n", "return", "json", ".", "Marshal", "(", "ccDeployment", ")", "\n", "}" ]
// MarshalJSON converts a Deployment into a Cloud Controller Deployment.
[ "MarshalJSON", "converts", "a", "Deployment", "into", "a", "Cloud", "Controller", "Deployment", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/deployment.go#L23-L40
train
cloudfoundry/cli
api/cloudcontroller/ccv3/deployment.go
UnmarshalJSON
func (d *Deployment) UnmarshalJSON(data []byte) error { var ccDeployment struct { GUID string `json:"guid,omitempty"` CreatedAt string `json:"created_at,omitempty"` Relationships Relationships `json:"relationships,omitempty"` State constant.DeploymentState `json:"state,omitempty"` Droplet Droplet `json:"droplet,omitempty"` } err := cloudcontroller.DecodeJSON(data, &ccDeployment) if err != nil { return err } d.GUID = ccDeployment.GUID d.CreatedAt = ccDeployment.CreatedAt d.Relationships = ccDeployment.Relationships d.State = ccDeployment.State d.DropletGUID = ccDeployment.Droplet.GUID return nil }
go
func (d *Deployment) UnmarshalJSON(data []byte) error { var ccDeployment struct { GUID string `json:"guid,omitempty"` CreatedAt string `json:"created_at,omitempty"` Relationships Relationships `json:"relationships,omitempty"` State constant.DeploymentState `json:"state,omitempty"` Droplet Droplet `json:"droplet,omitempty"` } err := cloudcontroller.DecodeJSON(data, &ccDeployment) if err != nil { return err } d.GUID = ccDeployment.GUID d.CreatedAt = ccDeployment.CreatedAt d.Relationships = ccDeployment.Relationships d.State = ccDeployment.State d.DropletGUID = ccDeployment.Droplet.GUID return nil }
[ "func", "(", "d", "*", "Deployment", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccDeployment", "struct", "{", "GUID", "string", "`json:\"guid,omitempty\"`", "\n", "CreatedAt", "string", "`json:\"created_at,omitempty\"`", "\n", "Relationships", "Relationships", "`json:\"relationships,omitempty\"`", "\n", "State", "constant", ".", "DeploymentState", "`json:\"state,omitempty\"`", "\n", "Droplet", "Droplet", "`json:\"droplet,omitempty\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccDeployment", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "d", ".", "GUID", "=", "ccDeployment", ".", "GUID", "\n", "d", ".", "CreatedAt", "=", "ccDeployment", ".", "CreatedAt", "\n", "d", ".", "Relationships", "=", "ccDeployment", ".", "Relationships", "\n", "d", ".", "State", "=", "ccDeployment", ".", "State", "\n", "d", ".", "DropletGUID", "=", "ccDeployment", ".", "Droplet", ".", "GUID", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Deployment response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Deployment", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/deployment.go#L43-L63
train
cloudfoundry/cli
integration/helpers/environment.go
CheckEnvironmentTargetedCorrectly
func CheckEnvironmentTargetedCorrectly(targetedOrganizationRequired bool, targetedSpaceRequired bool, testOrg string, command ...string) { LoginCF() if targetedOrganizationRequired { By("errors if org is not targeted") session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\.")) Eventually(session).Should(Exit(1)) if targetedSpaceRequired { By("errors if space is not targeted") TargetOrg(testOrg) session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space\\.")) Eventually(session).Should(Exit(1)) } } By("errors if user not logged in") LogoutCF() session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("Not logged in\\. Use 'cf login' to log in\\.")) Eventually(session).Should(Exit(1)) By("errors if cli not targeted") UnsetAPI() session = CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No API endpoint set\\. Use 'cf login' or 'cf api' to target an endpoint\\.")) Eventually(session).Should(Exit(1)) }
go
func CheckEnvironmentTargetedCorrectly(targetedOrganizationRequired bool, targetedSpaceRequired bool, testOrg string, command ...string) { LoginCF() if targetedOrganizationRequired { By("errors if org is not targeted") session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No org targeted, use 'cf target -o ORG' to target an org\\.")) Eventually(session).Should(Exit(1)) if targetedSpaceRequired { By("errors if space is not targeted") TargetOrg(testOrg) session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No space targeted, use 'cf target -s SPACE' to target a space\\.")) Eventually(session).Should(Exit(1)) } } By("errors if user not logged in") LogoutCF() session := CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("Not logged in\\. Use 'cf login' to log in\\.")) Eventually(session).Should(Exit(1)) By("errors if cli not targeted") UnsetAPI() session = CF(command...) Eventually(session).Should(Say("FAILED")) Eventually(session.Err).Should(Say("No API endpoint set\\. Use 'cf login' or 'cf api' to target an endpoint\\.")) Eventually(session).Should(Exit(1)) }
[ "func", "CheckEnvironmentTargetedCorrectly", "(", "targetedOrganizationRequired", "bool", ",", "targetedSpaceRequired", "bool", ",", "testOrg", "string", ",", "command", "...", "string", ")", "{", "LoginCF", "(", ")", "\n\n", "if", "targetedOrganizationRequired", "{", "By", "(", "\"", "\"", ")", "\n", "session", ":=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"", "\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"", "\\\\", "\"", ")", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n\n", "if", "targetedSpaceRequired", "{", "By", "(", "\"", "\"", ")", "\n", "TargetOrg", "(", "testOrg", ")", "\n", "session", ":=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"", "\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"", "\\\\", "\"", ")", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n", "}", "\n", "}", "\n\n", "By", "(", "\"", "\"", ")", "\n", "LogoutCF", "(", ")", "\n", "session", ":=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"", "\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"", "\\\\", "\\\\", "\"", ")", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n\n", "By", "(", "\"", "\"", ")", "\n", "UnsetAPI", "(", ")", "\n", "session", "=", "CF", "(", "command", "...", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Say", "(", "\"", "\"", ")", ")", "\n", "Eventually", "(", "session", ".", "Err", ")", ".", "Should", "(", "Say", "(", "\"", "\\\\", "\\\\", "\"", ")", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "1", ")", ")", "\n", "}" ]
// CheckEnvironmentTargetedCorrectly will confirm if the command requires an // API to be targeted and logged in to run. It can optionally check if the // command requires org and space to be targeted.
[ "CheckEnvironmentTargetedCorrectly", "will", "confirm", "if", "the", "command", "requires", "an", "API", "to", "be", "targeted", "and", "logged", "in", "to", "run", ".", "It", "can", "optionally", "check", "if", "the", "command", "requires", "org", "and", "space", "to", "be", "targeted", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/environment.go#L32-L65
train
cloudfoundry/cli
util/manifest/manifest.go
ReadAndInterpolateManifest
func ReadAndInterpolateManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]Application, error) { rawManifest, err := ReadAndInterpolateRawManifest(pathToManifest, pathsToVarsFiles, vars) if err != nil { return nil, err } var manifest Manifest err = yaml.Unmarshal(rawManifest, &manifest) if err != nil { return nil, err } for i, app := range manifest.Applications { if app.Path != "" && !filepath.IsAbs(app.Path) { manifest.Applications[i].Path = filepath.Join(filepath.Dir(pathToManifest), app.Path) } } return manifest.Applications, err }
go
func ReadAndInterpolateManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]Application, error) { rawManifest, err := ReadAndInterpolateRawManifest(pathToManifest, pathsToVarsFiles, vars) if err != nil { return nil, err } var manifest Manifest err = yaml.Unmarshal(rawManifest, &manifest) if err != nil { return nil, err } for i, app := range manifest.Applications { if app.Path != "" && !filepath.IsAbs(app.Path) { manifest.Applications[i].Path = filepath.Join(filepath.Dir(pathToManifest), app.Path) } } return manifest.Applications, err }
[ "func", "ReadAndInterpolateManifest", "(", "pathToManifest", "string", ",", "pathsToVarsFiles", "[", "]", "string", ",", "vars", "[", "]", "template", ".", "VarKV", ")", "(", "[", "]", "Application", ",", "error", ")", "{", "rawManifest", ",", "err", ":=", "ReadAndInterpolateRawManifest", "(", "pathToManifest", ",", "pathsToVarsFiles", ",", "vars", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "var", "manifest", "Manifest", "\n", "err", "=", "yaml", ".", "Unmarshal", "(", "rawManifest", ",", "&", "manifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "i", ",", "app", ":=", "range", "manifest", ".", "Applications", "{", "if", "app", ".", "Path", "!=", "\"", "\"", "&&", "!", "filepath", ".", "IsAbs", "(", "app", ".", "Path", ")", "{", "manifest", ".", "Applications", "[", "i", "]", ".", "Path", "=", "filepath", ".", "Join", "(", "filepath", ".", "Dir", "(", "pathToManifest", ")", ",", "app", ".", "Path", ")", "\n", "}", "\n", "}", "\n\n", "return", "manifest", ".", "Applications", ",", "err", "\n", "}" ]
// ReadAndInterpolateManifest reads the manifest at the provided paths, // interpolates variables if a vars file is provided, and returns a fully // merged set of applications.
[ "ReadAndInterpolateManifest", "reads", "the", "manifest", "at", "the", "provided", "paths", "interpolates", "variables", "if", "a", "vars", "file", "is", "provided", "and", "returns", "a", "fully", "merged", "set", "of", "applications", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/manifest/manifest.go#L37-L56
train
cloudfoundry/cli
util/manifest/manifest.go
ReadAndInterpolateRawManifest
func ReadAndInterpolateRawManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]byte, error) { rawManifest, err := ioutil.ReadFile(pathToManifest) if err != nil { return nil, err } tpl := template.NewTemplate(rawManifest) fileVars := template.StaticVariables{} for _, path := range pathsToVarsFiles { rawVarsFile, ioerr := ioutil.ReadFile(path) if ioerr != nil { return nil, ioerr } var sv template.StaticVariables err = yaml.Unmarshal(rawVarsFile, &sv) if err != nil { return nil, InvalidYAMLError{Err: err} } for k, v := range sv { fileVars[k] = v } } for _, kv := range vars { fileVars[kv.Name] = kv.Value } rawManifest, err = tpl.Evaluate(fileVars, nil, template.EvaluateOpts{ExpectAllKeys: true}) if err != nil { return nil, InterpolationError{Err: err} } return rawManifest, nil }
go
func ReadAndInterpolateRawManifest(pathToManifest string, pathsToVarsFiles []string, vars []template.VarKV) ([]byte, error) { rawManifest, err := ioutil.ReadFile(pathToManifest) if err != nil { return nil, err } tpl := template.NewTemplate(rawManifest) fileVars := template.StaticVariables{} for _, path := range pathsToVarsFiles { rawVarsFile, ioerr := ioutil.ReadFile(path) if ioerr != nil { return nil, ioerr } var sv template.StaticVariables err = yaml.Unmarshal(rawVarsFile, &sv) if err != nil { return nil, InvalidYAMLError{Err: err} } for k, v := range sv { fileVars[k] = v } } for _, kv := range vars { fileVars[kv.Name] = kv.Value } rawManifest, err = tpl.Evaluate(fileVars, nil, template.EvaluateOpts{ExpectAllKeys: true}) if err != nil { return nil, InterpolationError{Err: err} } return rawManifest, nil }
[ "func", "ReadAndInterpolateRawManifest", "(", "pathToManifest", "string", ",", "pathsToVarsFiles", "[", "]", "string", ",", "vars", "[", "]", "template", ".", "VarKV", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "rawManifest", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "pathToManifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "tpl", ":=", "template", ".", "NewTemplate", "(", "rawManifest", ")", "\n", "fileVars", ":=", "template", ".", "StaticVariables", "{", "}", "\n\n", "for", "_", ",", "path", ":=", "range", "pathsToVarsFiles", "{", "rawVarsFile", ",", "ioerr", ":=", "ioutil", ".", "ReadFile", "(", "path", ")", "\n", "if", "ioerr", "!=", "nil", "{", "return", "nil", ",", "ioerr", "\n", "}", "\n\n", "var", "sv", "template", ".", "StaticVariables", "\n\n", "err", "=", "yaml", ".", "Unmarshal", "(", "rawVarsFile", ",", "&", "sv", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "InvalidYAMLError", "{", "Err", ":", "err", "}", "\n", "}", "\n\n", "for", "k", ",", "v", ":=", "range", "sv", "{", "fileVars", "[", "k", "]", "=", "v", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "kv", ":=", "range", "vars", "{", "fileVars", "[", "kv", ".", "Name", "]", "=", "kv", ".", "Value", "\n", "}", "\n\n", "rawManifest", ",", "err", "=", "tpl", ".", "Evaluate", "(", "fileVars", ",", "nil", ",", "template", ".", "EvaluateOpts", "{", "ExpectAllKeys", ":", "true", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "InterpolationError", "{", "Err", ":", "err", "}", "\n", "}", "\n", "return", "rawManifest", ",", "nil", "\n", "}" ]
// ReadAndInterpolateRawManifest reads the manifest at the provided paths, // interpolates variables if a vars file is provided, and returns the // Unmarshalled result.
[ "ReadAndInterpolateRawManifest", "reads", "the", "manifest", "at", "the", "provided", "paths", "interpolates", "variables", "if", "a", "vars", "file", "is", "provided", "and", "returns", "the", "Unmarshalled", "result", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/manifest/manifest.go#L61-L97
train
cloudfoundry/cli
util/manifest/manifest.go
WriteApplicationManifest
func WriteApplicationManifest(application Application, filePath string) error { manifest := Manifest{Applications: []Application{application}} manifestBytes, err := yaml.Marshal(manifest) if err != nil { return ManifestCreationError{Err: err} } err = ioutil.WriteFile(filePath, manifestBytes, 0644) if err != nil { return ManifestCreationError{Err: err} } return nil }
go
func WriteApplicationManifest(application Application, filePath string) error { manifest := Manifest{Applications: []Application{application}} manifestBytes, err := yaml.Marshal(manifest) if err != nil { return ManifestCreationError{Err: err} } err = ioutil.WriteFile(filePath, manifestBytes, 0644) if err != nil { return ManifestCreationError{Err: err} } return nil }
[ "func", "WriteApplicationManifest", "(", "application", "Application", ",", "filePath", "string", ")", "error", "{", "manifest", ":=", "Manifest", "{", "Applications", ":", "[", "]", "Application", "{", "application", "}", "}", "\n", "manifestBytes", ",", "err", ":=", "yaml", ".", "Marshal", "(", "manifest", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ManifestCreationError", "{", "Err", ":", "err", "}", "\n", "}", "\n\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filePath", ",", "manifestBytes", ",", "0644", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ManifestCreationError", "{", "Err", ":", "err", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// WriteApplicationManifest writes the provided application to the given // filepath. If the filepath does not exist, it will create it.
[ "WriteApplicationManifest", "writes", "the", "provided", "application", "to", "the", "given", "filepath", ".", "If", "the", "filepath", "does", "not", "exist", "it", "will", "create", "it", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/manifest/manifest.go#L101-L114
train
cloudfoundry/cli
api/cloudcontroller/ccv3/isolation_segment.go
GetIsolationSegment
func (client *Client) GetIsolationSegment(guid string) (IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentRequest, URIParams: map[string]string{"isolation_segment_guid": guid}, }) if err != nil { return IsolationSegment{}, nil, err } var isolationSegment IsolationSegment response := cloudcontroller.Response{ DecodeJSONResponseInto: &isolationSegment, } err = client.connection.Make(request, &response) if err != nil { return IsolationSegment{}, response.Warnings, err } return isolationSegment, response.Warnings, nil }
go
func (client *Client) GetIsolationSegment(guid string) (IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentRequest, URIParams: map[string]string{"isolation_segment_guid": guid}, }) if err != nil { return IsolationSegment{}, nil, err } var isolationSegment IsolationSegment response := cloudcontroller.Response{ DecodeJSONResponseInto: &isolationSegment, } err = client.connection.Make(request, &response) if err != nil { return IsolationSegment{}, response.Warnings, err } return isolationSegment, response.Warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "GetIsolationSegment", "(", "guid", "string", ")", "(", "IsolationSegment", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetIsolationSegmentRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "IsolationSegment", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n", "var", "isolationSegment", "IsolationSegment", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "isolationSegment", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "IsolationSegment", "{", "}", ",", "response", ".", "Warnings", ",", "err", "\n", "}", "\n\n", "return", "isolationSegment", ",", "response", ".", "Warnings", ",", "nil", "\n", "}" ]
// GetIsolationSegment returns back the requested isolation segment that // matches the GUID.
[ "GetIsolationSegment", "returns", "back", "the", "requested", "isolation", "segment", "that", "matches", "the", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/isolation_segment.go#L65-L84
train
cloudfoundry/cli
api/cloudcontroller/ccv3/isolation_segment.go
GetIsolationSegments
func (client *Client) GetIsolationSegments(query ...Query) ([]IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullIsolationSegmentsList []IsolationSegment warnings, err := client.paginate(request, IsolationSegment{}, func(item interface{}) error { if isolationSegment, ok := item.(IsolationSegment); ok { fullIsolationSegmentsList = append(fullIsolationSegmentsList, isolationSegment) } else { return ccerror.UnknownObjectInListError{ Expected: IsolationSegment{}, Unexpected: item, } } return nil }) return fullIsolationSegmentsList, warnings, err }
go
func (client *Client) GetIsolationSegments(query ...Query) ([]IsolationSegment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetIsolationSegmentsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullIsolationSegmentsList []IsolationSegment warnings, err := client.paginate(request, IsolationSegment{}, func(item interface{}) error { if isolationSegment, ok := item.(IsolationSegment); ok { fullIsolationSegmentsList = append(fullIsolationSegmentsList, isolationSegment) } else { return ccerror.UnknownObjectInListError{ Expected: IsolationSegment{}, Unexpected: item, } } return nil }) return fullIsolationSegmentsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetIsolationSegments", "(", "query", "...", "Query", ")", "(", "[", "]", "IsolationSegment", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetIsolationSegmentsRequest", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullIsolationSegmentsList", "[", "]", "IsolationSegment", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "IsolationSegment", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "isolationSegment", ",", "ok", ":=", "item", ".", "(", "IsolationSegment", ")", ";", "ok", "{", "fullIsolationSegmentsList", "=", "append", "(", "fullIsolationSegmentsList", ",", "isolationSegment", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "IsolationSegment", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullIsolationSegmentsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetIsolationSegments lists isolation segments with optional filters.
[ "GetIsolationSegments", "lists", "isolation", "segments", "with", "optional", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/isolation_segment.go#L87-L110
train
cloudfoundry/cli
api/cloudcontroller/buildpacks/upload.go
CalculateRequestSize
func CalculateRequestSize(buildpackSize int64, bpPath string, fieldName string) (int64, error) { body := &bytes.Buffer{} form := multipart.NewWriter(body) bpFileName := filepath.Base(bpPath) _, err := form.CreateFormFile(fieldName, bpFileName) if err != nil { return 0, err } err = form.Close() if err != nil { return 0, err } return int64(body.Len()) + buildpackSize, nil }
go
func CalculateRequestSize(buildpackSize int64, bpPath string, fieldName string) (int64, error) { body := &bytes.Buffer{} form := multipart.NewWriter(body) bpFileName := filepath.Base(bpPath) _, err := form.CreateFormFile(fieldName, bpFileName) if err != nil { return 0, err } err = form.Close() if err != nil { return 0, err } return int64(body.Len()) + buildpackSize, nil }
[ "func", "CalculateRequestSize", "(", "buildpackSize", "int64", ",", "bpPath", "string", ",", "fieldName", "string", ")", "(", "int64", ",", "error", ")", "{", "body", ":=", "&", "bytes", ".", "Buffer", "{", "}", "\n", "form", ":=", "multipart", ".", "NewWriter", "(", "body", ")", "\n\n", "bpFileName", ":=", "filepath", ".", "Base", "(", "bpPath", ")", "\n\n", "_", ",", "err", ":=", "form", ".", "CreateFormFile", "(", "fieldName", ",", "bpFileName", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "err", "=", "form", ".", "Close", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "0", ",", "err", "\n", "}", "\n\n", "return", "int64", "(", "body", ".", "Len", "(", ")", ")", "+", "buildpackSize", ",", "nil", "\n", "}" ]
// tested via the ccv2.buildpack_test.go file at this point
[ "tested", "via", "the", "ccv2", ".", "buildpack_test", ".", "go", "file", "at", "this", "point" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/buildpacks/upload.go#L14-L31
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
UnmarshalJSON
func (securityGroup *SecurityGroup) UnmarshalJSON(data []byte) error { var ccSecurityGroup struct { Metadata internal.Metadata `json:"metadata"` Entity struct { GUID string `json:"guid"` Name string `json:"name"` Rules []struct { Description string `json:"description"` Destination string `json:"destination"` Ports string `json:"ports"` Protocol string `json:"protocol"` } `json:"rules"` RunningDefault bool `json:"running_default"` StagingDefault bool `json:"staging_default"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSecurityGroup) if err != nil { return err } securityGroup.GUID = ccSecurityGroup.Metadata.GUID securityGroup.Name = ccSecurityGroup.Entity.Name securityGroup.Rules = make([]SecurityGroupRule, len(ccSecurityGroup.Entity.Rules)) for i, ccRule := range ccSecurityGroup.Entity.Rules { securityGroup.Rules[i].Description = ccRule.Description securityGroup.Rules[i].Destination = ccRule.Destination securityGroup.Rules[i].Ports = ccRule.Ports securityGroup.Rules[i].Protocol = ccRule.Protocol } securityGroup.RunningDefault = ccSecurityGroup.Entity.RunningDefault securityGroup.StagingDefault = ccSecurityGroup.Entity.StagingDefault return nil }
go
func (securityGroup *SecurityGroup) UnmarshalJSON(data []byte) error { var ccSecurityGroup struct { Metadata internal.Metadata `json:"metadata"` Entity struct { GUID string `json:"guid"` Name string `json:"name"` Rules []struct { Description string `json:"description"` Destination string `json:"destination"` Ports string `json:"ports"` Protocol string `json:"protocol"` } `json:"rules"` RunningDefault bool `json:"running_default"` StagingDefault bool `json:"staging_default"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSecurityGroup) if err != nil { return err } securityGroup.GUID = ccSecurityGroup.Metadata.GUID securityGroup.Name = ccSecurityGroup.Entity.Name securityGroup.Rules = make([]SecurityGroupRule, len(ccSecurityGroup.Entity.Rules)) for i, ccRule := range ccSecurityGroup.Entity.Rules { securityGroup.Rules[i].Description = ccRule.Description securityGroup.Rules[i].Destination = ccRule.Destination securityGroup.Rules[i].Ports = ccRule.Ports securityGroup.Rules[i].Protocol = ccRule.Protocol } securityGroup.RunningDefault = ccSecurityGroup.Entity.RunningDefault securityGroup.StagingDefault = ccSecurityGroup.Entity.StagingDefault return nil }
[ "func", "(", "securityGroup", "*", "SecurityGroup", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccSecurityGroup", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "Name", "string", "`json:\"name\"`", "\n", "Rules", "[", "]", "struct", "{", "Description", "string", "`json:\"description\"`", "\n", "Destination", "string", "`json:\"destination\"`", "\n", "Ports", "string", "`json:\"ports\"`", "\n", "Protocol", "string", "`json:\"protocol\"`", "\n", "}", "`json:\"rules\"`", "\n", "RunningDefault", "bool", "`json:\"running_default\"`", "\n", "StagingDefault", "bool", "`json:\"staging_default\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccSecurityGroup", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "securityGroup", ".", "GUID", "=", "ccSecurityGroup", ".", "Metadata", ".", "GUID", "\n", "securityGroup", ".", "Name", "=", "ccSecurityGroup", ".", "Entity", ".", "Name", "\n", "securityGroup", ".", "Rules", "=", "make", "(", "[", "]", "SecurityGroupRule", ",", "len", "(", "ccSecurityGroup", ".", "Entity", ".", "Rules", ")", ")", "\n", "for", "i", ",", "ccRule", ":=", "range", "ccSecurityGroup", ".", "Entity", ".", "Rules", "{", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Description", "=", "ccRule", ".", "Description", "\n", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Destination", "=", "ccRule", ".", "Destination", "\n", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Ports", "=", "ccRule", ".", "Ports", "\n", "securityGroup", ".", "Rules", "[", "i", "]", ".", "Protocol", "=", "ccRule", ".", "Protocol", "\n", "}", "\n", "securityGroup", ".", "RunningDefault", "=", "ccSecurityGroup", ".", "Entity", ".", "RunningDefault", "\n", "securityGroup", ".", "StagingDefault", "=", "ccSecurityGroup", ".", "Entity", ".", "StagingDefault", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Security Group response
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Security", "Group", "response" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L26-L59
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
DeleteSecurityGroupSpace
func (client *Client) DeleteSecurityGroupSpace(securityGroupGUID string, spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSecurityGroupSpaceRequest, URIParams: Params{ "security_group_guid": securityGroupGUID, "space_guid": spaceGUID, }, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteSecurityGroupSpace(securityGroupGUID string, spaceGUID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSecurityGroupSpaceRequest, URIParams: Params{ "security_group_guid": securityGroupGUID, "space_guid": spaceGUID, }, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteSecurityGroupSpace", "(", "securityGroupGUID", "string", ",", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteSecurityGroupSpaceRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "securityGroupGUID", ",", "\"", "\"", ":", "spaceGUID", ",", "}", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteSecurityGroupSpace disassociates a security group in the running phase // for the lifecycle, specified by its GUID, from a space, which is also // specified by its GUID.
[ "DeleteSecurityGroupSpace", "disassociates", "a", "security", "group", "in", "the", "running", "phase", "for", "the", "lifecycle", "specified", "by", "its", "GUID", "from", "a", "space", "which", "is", "also", "specified", "by", "its", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L64-L81
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
GetSecurityGroups
func (client *Client) GetSecurityGroups(filters ...Filter) ([]SecurityGroup, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var securityGroupsList []SecurityGroup warnings, err := client.paginate(request, SecurityGroup{}, func(item interface{}) error { if securityGroup, ok := item.(SecurityGroup); ok { securityGroupsList = append(securityGroupsList, securityGroup) } else { return ccerror.UnknownObjectInListError{ Expected: SecurityGroup{}, Unexpected: item, } } return nil }) return securityGroupsList, warnings, err }
go
func (client *Client) GetSecurityGroups(filters ...Filter) ([]SecurityGroup, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var securityGroupsList []SecurityGroup warnings, err := client.paginate(request, SecurityGroup{}, func(item interface{}) error { if securityGroup, ok := item.(SecurityGroup); ok { securityGroupsList = append(securityGroupsList, securityGroup) } else { return ccerror.UnknownObjectInListError{ Expected: SecurityGroup{}, Unexpected: item, } } return nil }) return securityGroupsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSecurityGroups", "(", "filters", "...", "Filter", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSecurityGroupsRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "securityGroupsList", "[", "]", "SecurityGroup", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "SecurityGroup", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "securityGroup", ",", "ok", ":=", "item", ".", "(", "SecurityGroup", ")", ";", "ok", "{", "securityGroupsList", "=", "append", "(", "securityGroupsList", ",", "securityGroup", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "SecurityGroup", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "securityGroupsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSecurityGroups returns a list of Security Groups based off the provided // filters.
[ "GetSecurityGroups", "returns", "a", "list", "of", "Security", "Groups", "based", "off", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L107-L131
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
GetSpaceSecurityGroups
func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceSecurityGroupsRequest, filters) }
go
func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceSecurityGroupsRequest, filters) }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceSecurityGroups", "(", "spaceGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "return", "client", ".", "getSpaceSecurityGroupsBySpaceAndLifecycle", "(", "spaceGUID", ",", "internal", ".", "GetSpaceSecurityGroupsRequest", ",", "filters", ")", "\n", "}" ]
// GetSpaceSecurityGroups returns the running Security Groups associated with // the provided Space GUID.
[ "GetSpaceSecurityGroups", "returns", "the", "running", "Security", "Groups", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L135-L137
train
cloudfoundry/cli
api/cloudcontroller/ccv2/security_group.go
GetSpaceStagingSecurityGroups
func (client *Client) GetSpaceStagingSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceStagingSecurityGroupsRequest, filters) }
go
func (client *Client) GetSpaceStagingSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) { return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceStagingSecurityGroupsRequest, filters) }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceStagingSecurityGroups", "(", "spaceGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "SecurityGroup", ",", "Warnings", ",", "error", ")", "{", "return", "client", ".", "getSpaceSecurityGroupsBySpaceAndLifecycle", "(", "spaceGUID", ",", "internal", ".", "GetSpaceStagingSecurityGroupsRequest", ",", "filters", ")", "\n", "}" ]
// GetSpaceStagingSecurityGroups returns the staging Security Groups // associated with the provided Space GUID.
[ "GetSpaceStagingSecurityGroups", "returns", "the", "staging", "Security", "Groups", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L141-L143
train
cloudfoundry/cli
api/cloudcontroller/ccv3/job.go
Errors
func (job Job) Errors() []error { var errs []error for _, errDetails := range job.RawErrors { switch errDetails.Code { case constant.JobErrorCodeBuildpackAlreadyExistsForStack: errs = append(errs, ccerror.BuildpackAlreadyExistsForStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackAlreadyExistsWithoutStack: errs = append(errs, ccerror.BuildpackAlreadyExistsWithoutStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStacksDontMatch: errs = append(errs, ccerror.BuildpackStacksDontMatchError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStackDoesNotExist: errs = append(errs, ccerror.BuildpackStackDoesNotExistError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackZipInvalid: errs = append(errs, ccerror.BuildpackZipInvalidError{Message: errDetails.Detail}) default: errs = append(errs, ccerror.V3JobFailedError{ JobGUID: job.GUID, Code: errDetails.Code, Detail: errDetails.Detail, Title: errDetails.Title, }) } } return errs }
go
func (job Job) Errors() []error { var errs []error for _, errDetails := range job.RawErrors { switch errDetails.Code { case constant.JobErrorCodeBuildpackAlreadyExistsForStack: errs = append(errs, ccerror.BuildpackAlreadyExistsForStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackAlreadyExistsWithoutStack: errs = append(errs, ccerror.BuildpackAlreadyExistsWithoutStackError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStacksDontMatch: errs = append(errs, ccerror.BuildpackStacksDontMatchError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackStackDoesNotExist: errs = append(errs, ccerror.BuildpackStackDoesNotExistError{Message: errDetails.Detail}) case constant.JobErrorCodeBuildpackZipInvalid: errs = append(errs, ccerror.BuildpackZipInvalidError{Message: errDetails.Detail}) default: errs = append(errs, ccerror.V3JobFailedError{ JobGUID: job.GUID, Code: errDetails.Code, Detail: errDetails.Detail, Title: errDetails.Title, }) } } return errs }
[ "func", "(", "job", "Job", ")", "Errors", "(", ")", "[", "]", "error", "{", "var", "errs", "[", "]", "error", "\n", "for", "_", ",", "errDetails", ":=", "range", "job", ".", "RawErrors", "{", "switch", "errDetails", ".", "Code", "{", "case", "constant", ".", "JobErrorCodeBuildpackAlreadyExistsForStack", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackAlreadyExistsForStackError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackAlreadyExistsWithoutStack", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackAlreadyExistsWithoutStackError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackStacksDontMatch", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackStacksDontMatchError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackStackDoesNotExist", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackStackDoesNotExistError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "case", "constant", ".", "JobErrorCodeBuildpackZipInvalid", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "BuildpackZipInvalidError", "{", "Message", ":", "errDetails", ".", "Detail", "}", ")", "\n", "default", ":", "errs", "=", "append", "(", "errs", ",", "ccerror", ".", "V3JobFailedError", "{", "JobGUID", ":", "job", ".", "GUID", ",", "Code", ":", "errDetails", ".", "Code", ",", "Detail", ":", "errDetails", ".", "Detail", ",", "Title", ":", "errDetails", ".", "Title", ",", "}", ")", "\n", "}", "\n", "}", "\n", "return", "errs", "\n", "}" ]
// Errors returns back a list of
[ "Errors", "returns", "back", "a", "list", "of" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job.go#L22-L46
train
cloudfoundry/cli
actor/v7action/application.go
CreateApplicationInSpace
func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) { createdApp, warnings, err := actor.CloudControllerClient.CreateApplication( ccv3.Application{ LifecycleType: app.LifecycleType, LifecycleBuildpacks: app.LifecycleBuildpacks, StackName: app.StackName, Name: app.Name, Relationships: ccv3.Relationships{ constant.RelationshipTypeSpace: ccv3.Relationship{GUID: spaceGUID}, }, }) if err != nil { if _, ok := err.(ccerror.NameNotUniqueInSpaceError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationAlreadyExistsError{Name: app.Name} } return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(createdApp), Warnings(warnings), nil }
go
func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) { createdApp, warnings, err := actor.CloudControllerClient.CreateApplication( ccv3.Application{ LifecycleType: app.LifecycleType, LifecycleBuildpacks: app.LifecycleBuildpacks, StackName: app.StackName, Name: app.Name, Relationships: ccv3.Relationships{ constant.RelationshipTypeSpace: ccv3.Relationship{GUID: spaceGUID}, }, }) if err != nil { if _, ok := err.(ccerror.NameNotUniqueInSpaceError); ok { return Application{}, Warnings(warnings), actionerror.ApplicationAlreadyExistsError{Name: app.Name} } return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(createdApp), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "CreateApplicationInSpace", "(", "app", "Application", ",", "spaceGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "createdApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateApplication", "(", "ccv3", ".", "Application", "{", "LifecycleType", ":", "app", ".", "LifecycleType", ",", "LifecycleBuildpacks", ":", "app", ".", "LifecycleBuildpacks", ",", "StackName", ":", "app", ".", "StackName", ",", "Name", ":", "app", ".", "Name", ",", "Relationships", ":", "ccv3", ".", "Relationships", "{", "constant", ".", "RelationshipTypeSpace", ":", "ccv3", ".", "Relationship", "{", "GUID", ":", "spaceGUID", "}", ",", "}", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "NameNotUniqueInSpaceError", ")", ";", "ok", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "ApplicationAlreadyExistsError", "{", "Name", ":", "app", ".", "Name", "}", "\n", "}", "\n", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "return", "actor", ".", "convertCCToActorApplication", "(", "createdApp", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// CreateApplicationInSpace creates and returns the application with the given // name in the given space.
[ "CreateApplicationInSpace", "creates", "and", "returns", "the", "application", "with", "the", "given", "name", "in", "the", "given", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L106-L126
train
cloudfoundry/cli
actor/v7action/application.go
SetApplicationProcessHealthCheckTypeByNameAndSpace
func (actor Actor) SetApplicationProcessHealthCheckTypeByNameAndSpace( appName string, spaceGUID string, healthCheckType constant.HealthCheckType, httpEndpoint string, processType string, invocationTimeout int64, ) (Application, Warnings, error) { app, getWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return Application{}, getWarnings, err } setWarnings, err := actor.UpdateProcessByTypeAndApplication( processType, app.GUID, Process{ HealthCheckType: healthCheckType, HealthCheckEndpoint: httpEndpoint, HealthCheckInvocationTimeout: invocationTimeout, }) return app, append(getWarnings, setWarnings...), err }
go
func (actor Actor) SetApplicationProcessHealthCheckTypeByNameAndSpace( appName string, spaceGUID string, healthCheckType constant.HealthCheckType, httpEndpoint string, processType string, invocationTimeout int64, ) (Application, Warnings, error) { app, getWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return Application{}, getWarnings, err } setWarnings, err := actor.UpdateProcessByTypeAndApplication( processType, app.GUID, Process{ HealthCheckType: healthCheckType, HealthCheckEndpoint: httpEndpoint, HealthCheckInvocationTimeout: invocationTimeout, }) return app, append(getWarnings, setWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "SetApplicationProcessHealthCheckTypeByNameAndSpace", "(", "appName", "string", ",", "spaceGUID", "string", ",", "healthCheckType", "constant", ".", "HealthCheckType", ",", "httpEndpoint", "string", ",", "processType", "string", ",", "invocationTimeout", "int64", ",", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "app", ",", "getWarnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "getWarnings", ",", "err", "\n", "}", "\n\n", "setWarnings", ",", "err", ":=", "actor", ".", "UpdateProcessByTypeAndApplication", "(", "processType", ",", "app", ".", "GUID", ",", "Process", "{", "HealthCheckType", ":", "healthCheckType", ",", "HealthCheckEndpoint", ":", "httpEndpoint", ",", "HealthCheckInvocationTimeout", ":", "invocationTimeout", ",", "}", ")", "\n", "return", "app", ",", "append", "(", "getWarnings", ",", "setWarnings", "...", ")", ",", "err", "\n", "}" ]
// SetApplicationProcessHealthCheckTypeByNameAndSpace sets the health check // information of the provided processType for an application with the given // name and space GUID.
[ "SetApplicationProcessHealthCheckTypeByNameAndSpace", "sets", "the", "health", "check", "information", "of", "the", "provided", "processType", "for", "an", "application", "with", "the", "given", "name", "and", "space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L131-L154
train
cloudfoundry/cli
actor/v7action/application.go
StopApplication
func (actor Actor) StopApplication(appGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.UpdateApplicationStop(appGUID) return Warnings(warnings), err }
go
func (actor Actor) StopApplication(appGUID string) (Warnings, error) { _, warnings, err := actor.CloudControllerClient.UpdateApplicationStop(appGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "StopApplication", "(", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationStop", "(", "appGUID", ")", "\n\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// StopApplication stops an application.
[ "StopApplication", "stops", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L157-L161
train
cloudfoundry/cli
actor/v7action/application.go
StartApplication
func (actor Actor) StartApplication(appGUID string) (Application, Warnings, error) { updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationStart(appGUID) if err != nil { return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil }
go
func (actor Actor) StartApplication(appGUID string) (Application, Warnings, error) { updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationStart(appGUID) if err != nil { return Application{}, Warnings(warnings), err } return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "StartApplication", "(", "appGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "updatedApp", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationStart", "(", "appGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "return", "actor", ".", "convertCCToActorApplication", "(", "updatedApp", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// StartApplication starts an application.
[ "StartApplication", "starts", "an", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L164-L171
train
cloudfoundry/cli
actor/v7action/application.go
RestartApplication
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) { var allWarnings Warnings _, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } pollingWarnings, err := actor.PollStart(appGUID) allWarnings = append(allWarnings, pollingWarnings...) return allWarnings, err }
go
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) { var allWarnings Warnings _, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return allWarnings, err } pollingWarnings, err := actor.PollStart(appGUID) allWarnings = append(allWarnings, pollingWarnings...) return allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "RestartApplication", "(", "appGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "_", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "UpdateApplicationRestart", "(", "appGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n\n", "pollingWarnings", ",", "err", ":=", "actor", ".", "PollStart", "(", "appGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "pollingWarnings", "...", ")", "\n", "return", "allWarnings", ",", "err", "\n", "}" ]
// RestartApplication restarts an application and waits for it to start.
[ "RestartApplication", "restarts", "an", "application", "and", "waits", "for", "it", "to", "start", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L174-L185
train
cloudfoundry/cli
actor/actionerror/domain_not_found_error.go
Error
func (e DomainNotFoundError) Error() string { switch { case e.Name != "": return fmt.Sprintf("Domain %s not found", e.Name) case e.GUID != "": return fmt.Sprintf("Domain with GUID %s not found", e.GUID) default: return "Domain not found" } }
go
func (e DomainNotFoundError) Error() string { switch { case e.Name != "": return fmt.Sprintf("Domain %s not found", e.Name) case e.GUID != "": return fmt.Sprintf("Domain with GUID %s not found", e.GUID) default: return "Domain not found" } }
[ "func", "(", "e", "DomainNotFoundError", ")", "Error", "(", ")", "string", "{", "switch", "{", "case", "e", ".", "Name", "!=", "\"", "\"", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Name", ")", "\n", "case", "e", ".", "GUID", "!=", "\"", "\"", ":", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "GUID", ")", "\n", "default", ":", "return", "\"", "\"", "\n", "}", "\n", "}" ]
// Error method to display the error message.
[ "Error", "method", "to", "display", "the", "error", "message", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/actionerror/domain_not_found_error.go#L13-L22
train
cloudfoundry/cli
integration/helpers/app.go
WithProcfileApp
func WithProcfileApp(f func(dir string)) { dir, err := ioutil.TempDir("", "simple-ruby-app") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(dir) err = ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- web: ruby -run -e httpd . -p $PORT console: bundle exec irb`, ), 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` GEM specs: PLATFORMS ruby DEPENDENCIES BUNDLED WITH 1.15.0 `), 0666) Expect(err).ToNot(HaveOccurred()) f(dir) }
go
func WithProcfileApp(f func(dir string)) { dir, err := ioutil.TempDir("", "simple-ruby-app") Expect(err).ToNot(HaveOccurred()) defer os.RemoveAll(dir) err = ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`--- web: ruby -run -e httpd . -p $PORT console: bundle exec irb`, ), 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(` GEM specs: PLATFORMS ruby DEPENDENCIES BUNDLED WITH 1.15.0 `), 0666) Expect(err).ToNot(HaveOccurred()) f(dir) }
[ "func", "WithProcfileApp", "(", "f", "func", "(", "dir", "string", ")", ")", "{", "dir", ",", "err", ":=", "ioutil", ".", "TempDir", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "defer", "os", ".", "RemoveAll", "(", "dir", ")", "\n\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", ",", "[", "]", "byte", "(", "`---\nweb: ruby -run -e httpd . -p $PORT\nconsole: bundle exec irb`", ",", ")", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", ",", "nil", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n\n", "err", "=", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "dir", ",", "\"", "\"", ")", ",", "[", "]", "byte", "(", "`\nGEM\n specs:\n\nPLATFORMS\n ruby\n\nDEPENDENCIES\n\nBUNDLED WITH\n 1.15.0\n\t`", ")", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n\n", "f", "(", "dir", ")", "\n", "}" ]
// WithProcfileApp creates an application to use with your CLI command // that contains Procfile defining web and worker processes.
[ "WithProcfileApp", "creates", "an", "application", "to", "use", "with", "your", "CLI", "command", "that", "contains", "Procfile", "defining", "web", "and", "worker", "processes", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L88-L117
train
cloudfoundry/cli
integration/helpers/app.go
AppGUID
func AppGUID(appName string) string { session := CF("app", appName, "--guid") Eventually(session).Should(Exit(0)) return strings.TrimSpace(string(session.Out.Contents())) }
go
func AppGUID(appName string) string { session := CF("app", appName, "--guid") Eventually(session).Should(Exit(0)) return strings.TrimSpace(string(session.Out.Contents())) }
[ "func", "AppGUID", "(", "appName", "string", ")", "string", "{", "session", ":=", "CF", "(", "\"", "\"", ",", "appName", ",", "\"", "\"", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "0", ")", ")", "\n", "return", "strings", ".", "TrimSpace", "(", "string", "(", "session", ".", "Out", ".", "Contents", "(", ")", ")", ")", "\n", "}" ]
// AppGUID returns the GUID for an app in the currently targeted space.
[ "AppGUID", "returns", "the", "GUID", "for", "an", "app", "in", "the", "currently", "targeted", "space", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L171-L175
train
cloudfoundry/cli
integration/helpers/app.go
WriteManifest
func WriteManifest(path string, manifest map[string]interface{}) { body, err := yaml.Marshal(manifest) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(path, body, 0666) Expect(err).ToNot(HaveOccurred()) }
go
func WriteManifest(path string, manifest map[string]interface{}) { body, err := yaml.Marshal(manifest) Expect(err).ToNot(HaveOccurred()) err = ioutil.WriteFile(path, body, 0666) Expect(err).ToNot(HaveOccurred()) }
[ "func", "WriteManifest", "(", "path", "string", ",", "manifest", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "body", ",", "err", ":=", "yaml", ".", "Marshal", "(", "manifest", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "err", "=", "ioutil", ".", "WriteFile", "(", "path", ",", "body", ",", "0666", ")", "\n", "Expect", "(", "err", ")", ".", "ToNot", "(", "HaveOccurred", "(", ")", ")", "\n", "}" ]
// WriteManifest will write out a YAML manifest file at the specified path.
[ "WriteManifest", "will", "write", "out", "a", "YAML", "manifest", "file", "at", "the", "specified", "path", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L185-L190
train
cloudfoundry/cli
integration/helpers/app.go
Zipit
func Zipit(source, target, prefix string) error { // Thanks to Svett Ralchev // http://blog.ralch.com/tutorial/golang-working-with-zip/ zipfile, err := os.Create(target) if err != nil { return err } defer zipfile.Close() if prefix != "" { _, err = io.WriteString(zipfile, prefix) if err != nil { return err } } archive := zip.NewWriter(zipfile) defer archive.Close() err = filepath.Walk(source, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if path == source { return nil } header, err := zip.FileInfoHeader(info) if err != nil { return err } header.Name, err = filepath.Rel(source, path) if err != nil { return err } header.Name = filepath.ToSlash(header.Name) if info.IsDir() { header.Name += "/" header.SetMode(0755) } else { header.Method = zip.Deflate header.SetMode(0744) } writer, err := archive.CreateHeader(header) if err != nil { return err } if info.IsDir() { return nil } file, err := os.Open(path) if err != nil { return err } defer file.Close() _, err = io.Copy(writer, file) return err }) return err }
go
func Zipit(source, target, prefix string) error { // Thanks to Svett Ralchev // http://blog.ralch.com/tutorial/golang-working-with-zip/ zipfile, err := os.Create(target) if err != nil { return err } defer zipfile.Close() if prefix != "" { _, err = io.WriteString(zipfile, prefix) if err != nil { return err } } archive := zip.NewWriter(zipfile) defer archive.Close() err = filepath.Walk(source, func(path string, info os.FileInfo, err error) error { if err != nil { return err } if path == source { return nil } header, err := zip.FileInfoHeader(info) if err != nil { return err } header.Name, err = filepath.Rel(source, path) if err != nil { return err } header.Name = filepath.ToSlash(header.Name) if info.IsDir() { header.Name += "/" header.SetMode(0755) } else { header.Method = zip.Deflate header.SetMode(0744) } writer, err := archive.CreateHeader(header) if err != nil { return err } if info.IsDir() { return nil } file, err := os.Open(path) if err != nil { return err } defer file.Close() _, err = io.Copy(writer, file) return err }) return err }
[ "func", "Zipit", "(", "source", ",", "target", ",", "prefix", "string", ")", "error", "{", "// Thanks to Svett Ralchev", "// http://blog.ralch.com/tutorial/golang-working-with-zip/", "zipfile", ",", "err", ":=", "os", ".", "Create", "(", "target", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "zipfile", ".", "Close", "(", ")", "\n\n", "if", "prefix", "!=", "\"", "\"", "{", "_", ",", "err", "=", "io", ".", "WriteString", "(", "zipfile", ",", "prefix", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "archive", ":=", "zip", ".", "NewWriter", "(", "zipfile", ")", "\n", "defer", "archive", ".", "Close", "(", ")", "\n\n", "err", "=", "filepath", ".", "Walk", "(", "source", ",", "func", "(", "path", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "path", "==", "source", "{", "return", "nil", "\n", "}", "\n\n", "header", ",", "err", ":=", "zip", ".", "FileInfoHeader", "(", "info", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "header", ".", "Name", ",", "err", "=", "filepath", ".", "Rel", "(", "source", ",", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "header", ".", "Name", "=", "filepath", ".", "ToSlash", "(", "header", ".", "Name", ")", "\n\n", "if", "info", ".", "IsDir", "(", ")", "{", "header", ".", "Name", "+=", "\"", "\"", "\n", "header", ".", "SetMode", "(", "0755", ")", "\n", "}", "else", "{", "header", ".", "Method", "=", "zip", ".", "Deflate", "\n", "header", ".", "SetMode", "(", "0744", ")", "\n", "}", "\n\n", "writer", ",", "err", ":=", "archive", ".", "CreateHeader", "(", "header", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "if", "info", ".", "IsDir", "(", ")", "{", "return", "nil", "\n", "}", "\n\n", "file", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "writer", ",", "file", ")", "\n", "return", "err", "\n", "}", ")", "\n\n", "return", "err", "\n", "}" ]
// Zipit zips the source into a .zip file in the target dir
[ "Zipit", "zips", "the", "source", "into", "a", ".", "zip", "file", "in", "the", "target", "dir" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L193-L261
train
cloudfoundry/cli
api/cloudcontroller/ccv2/filter.go
ConvertFilterParameters
func ConvertFilterParameters(filters []Filter) url.Values { params := url.Values{"q": []string{}} for _, filter := range filters { params["q"] = append(params["q"], filter.format()) } return params }
go
func ConvertFilterParameters(filters []Filter) url.Values { params := url.Values{"q": []string{}} for _, filter := range filters { params["q"] = append(params["q"], filter.format()) } return params }
[ "func", "ConvertFilterParameters", "(", "filters", "[", "]", "Filter", ")", "url", ".", "Values", "{", "params", ":=", "url", ".", "Values", "{", "\"", "\"", ":", "[", "]", "string", "{", "}", "}", "\n", "for", "_", ",", "filter", ":=", "range", "filters", "{", "params", "[", "\"", "\"", "]", "=", "append", "(", "params", "[", "\"", "\"", "]", ",", "filter", ".", "format", "(", ")", ")", "\n", "}", "\n\n", "return", "params", "\n", "}" ]
// ConvertFilterParameters converts a Filter object into a collection that // cloudcontroller.Request can accept.
[ "ConvertFilterParameters", "converts", "a", "Filter", "object", "into", "a", "collection", "that", "cloudcontroller", ".", "Request", "can", "accept", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/filter.go#L30-L37
train
cloudfoundry/cli
actor/pluginaction/plugin_info.go
GetPluginInfoFromRepositoriesForPlatform
func (actor Actor) GetPluginInfoFromRepositoriesForPlatform(pluginName string, pluginRepos []configv3.PluginRepository, platform string) (PluginInfo, []string, error) { var reposWithPlugin []string var newestPluginInfo PluginInfo var pluginFoundWithIncompatibleBinary bool for _, repo := range pluginRepos { pluginInfo, err := actor.getPluginInfoFromRepositoryForPlatform(pluginName, repo, platform) switch err.(type) { case actionerror.PluginNotFoundInRepositoryError: continue case actionerror.NoCompatibleBinaryError: pluginFoundWithIncompatibleBinary = true continue case nil: if len(reposWithPlugin) == 0 || lessThan(newestPluginInfo.Version, pluginInfo.Version) { newestPluginInfo = pluginInfo reposWithPlugin = []string{repo.Name} } else if pluginInfo.Version == newestPluginInfo.Version { reposWithPlugin = append(reposWithPlugin, repo.Name) } default: return PluginInfo{}, nil, actionerror.FetchingPluginInfoFromRepositoryError{ RepositoryName: repo.Name, Err: err, } } } if len(reposWithPlugin) == 0 { if pluginFoundWithIncompatibleBinary { return PluginInfo{}, nil, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, nil, actionerror.PluginNotFoundInAnyRepositoryError{PluginName: pluginName} } return newestPluginInfo, reposWithPlugin, nil }
go
func (actor Actor) GetPluginInfoFromRepositoriesForPlatform(pluginName string, pluginRepos []configv3.PluginRepository, platform string) (PluginInfo, []string, error) { var reposWithPlugin []string var newestPluginInfo PluginInfo var pluginFoundWithIncompatibleBinary bool for _, repo := range pluginRepos { pluginInfo, err := actor.getPluginInfoFromRepositoryForPlatform(pluginName, repo, platform) switch err.(type) { case actionerror.PluginNotFoundInRepositoryError: continue case actionerror.NoCompatibleBinaryError: pluginFoundWithIncompatibleBinary = true continue case nil: if len(reposWithPlugin) == 0 || lessThan(newestPluginInfo.Version, pluginInfo.Version) { newestPluginInfo = pluginInfo reposWithPlugin = []string{repo.Name} } else if pluginInfo.Version == newestPluginInfo.Version { reposWithPlugin = append(reposWithPlugin, repo.Name) } default: return PluginInfo{}, nil, actionerror.FetchingPluginInfoFromRepositoryError{ RepositoryName: repo.Name, Err: err, } } } if len(reposWithPlugin) == 0 { if pluginFoundWithIncompatibleBinary { return PluginInfo{}, nil, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, nil, actionerror.PluginNotFoundInAnyRepositoryError{PluginName: pluginName} } return newestPluginInfo, reposWithPlugin, nil }
[ "func", "(", "actor", "Actor", ")", "GetPluginInfoFromRepositoriesForPlatform", "(", "pluginName", "string", ",", "pluginRepos", "[", "]", "configv3", ".", "PluginRepository", ",", "platform", "string", ")", "(", "PluginInfo", ",", "[", "]", "string", ",", "error", ")", "{", "var", "reposWithPlugin", "[", "]", "string", "\n", "var", "newestPluginInfo", "PluginInfo", "\n", "var", "pluginFoundWithIncompatibleBinary", "bool", "\n\n", "for", "_", ",", "repo", ":=", "range", "pluginRepos", "{", "pluginInfo", ",", "err", ":=", "actor", ".", "getPluginInfoFromRepositoryForPlatform", "(", "pluginName", ",", "repo", ",", "platform", ")", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "actionerror", ".", "PluginNotFoundInRepositoryError", ":", "continue", "\n", "case", "actionerror", ".", "NoCompatibleBinaryError", ":", "pluginFoundWithIncompatibleBinary", "=", "true", "\n", "continue", "\n", "case", "nil", ":", "if", "len", "(", "reposWithPlugin", ")", "==", "0", "||", "lessThan", "(", "newestPluginInfo", ".", "Version", ",", "pluginInfo", ".", "Version", ")", "{", "newestPluginInfo", "=", "pluginInfo", "\n", "reposWithPlugin", "=", "[", "]", "string", "{", "repo", ".", "Name", "}", "\n", "}", "else", "if", "pluginInfo", ".", "Version", "==", "newestPluginInfo", ".", "Version", "{", "reposWithPlugin", "=", "append", "(", "reposWithPlugin", ",", "repo", ".", "Name", ")", "\n", "}", "\n", "default", ":", "return", "PluginInfo", "{", "}", ",", "nil", ",", "actionerror", ".", "FetchingPluginInfoFromRepositoryError", "{", "RepositoryName", ":", "repo", ".", "Name", ",", "Err", ":", "err", ",", "}", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "reposWithPlugin", ")", "==", "0", "{", "if", "pluginFoundWithIncompatibleBinary", "{", "return", "PluginInfo", "{", "}", ",", "nil", ",", "actionerror", ".", "NoCompatibleBinaryError", "{", "}", "\n", "}", "\n", "return", "PluginInfo", "{", "}", ",", "nil", ",", "actionerror", ".", "PluginNotFoundInAnyRepositoryError", "{", "PluginName", ":", "pluginName", "}", "\n", "}", "\n", "return", "newestPluginInfo", ",", "reposWithPlugin", ",", "nil", "\n", "}" ]
// GetPluginInfoFromRepositoriesForPlatform returns the newest version of the specified plugin // and all the repositories that contain that version.
[ "GetPluginInfoFromRepositoriesForPlatform", "returns", "the", "newest", "version", "of", "the", "specified", "plugin", "and", "all", "the", "repositories", "that", "contain", "that", "version", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L20-L55
train
cloudfoundry/cli
actor/pluginaction/plugin_info.go
GetPlatformString
func (actor Actor) GetPlatformString(runtimeGOOS string, runtimeGOARCH string) string { return generic.GeneratePlatform(runtime.GOOS, runtime.GOARCH) }
go
func (actor Actor) GetPlatformString(runtimeGOOS string, runtimeGOARCH string) string { return generic.GeneratePlatform(runtime.GOOS, runtime.GOARCH) }
[ "func", "(", "actor", "Actor", ")", "GetPlatformString", "(", "runtimeGOOS", "string", ",", "runtimeGOARCH", "string", ")", "string", "{", "return", "generic", ".", "GeneratePlatform", "(", "runtime", ".", "GOOS", ",", "runtime", ".", "GOARCH", ")", "\n", "}" ]
// GetPlatformString exists solely for the purposes of mocking it out for command-layers tests.
[ "GetPlatformString", "exists", "solely", "for", "the", "purposes", "of", "mocking", "it", "out", "for", "command", "-", "layers", "tests", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L58-L60
train
cloudfoundry/cli
actor/pluginaction/plugin_info.go
getPluginInfoFromRepositoryForPlatform
func (actor Actor) getPluginInfoFromRepositoryForPlatform(pluginName string, pluginRepo configv3.PluginRepository, platform string) (PluginInfo, error) { pluginRepository, err := actor.client.GetPluginRepository(pluginRepo.URL) if err != nil { return PluginInfo{}, err } var pluginFoundWithIncompatibleBinary bool for _, plugin := range pluginRepository.Plugins { if plugin.Name == pluginName { for _, pluginBinary := range plugin.Binaries { if pluginBinary.Platform == platform { return PluginInfo{ Name: plugin.Name, Version: plugin.Version, URL: pluginBinary.URL, Checksum: pluginBinary.Checksum, }, nil } } pluginFoundWithIncompatibleBinary = true } } if pluginFoundWithIncompatibleBinary { return PluginInfo{}, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, actionerror.PluginNotFoundInRepositoryError{ PluginName: pluginName, RepositoryName: pluginRepo.Name, } }
go
func (actor Actor) getPluginInfoFromRepositoryForPlatform(pluginName string, pluginRepo configv3.PluginRepository, platform string) (PluginInfo, error) { pluginRepository, err := actor.client.GetPluginRepository(pluginRepo.URL) if err != nil { return PluginInfo{}, err } var pluginFoundWithIncompatibleBinary bool for _, plugin := range pluginRepository.Plugins { if plugin.Name == pluginName { for _, pluginBinary := range plugin.Binaries { if pluginBinary.Platform == platform { return PluginInfo{ Name: plugin.Name, Version: plugin.Version, URL: pluginBinary.URL, Checksum: pluginBinary.Checksum, }, nil } } pluginFoundWithIncompatibleBinary = true } } if pluginFoundWithIncompatibleBinary { return PluginInfo{}, actionerror.NoCompatibleBinaryError{} } return PluginInfo{}, actionerror.PluginNotFoundInRepositoryError{ PluginName: pluginName, RepositoryName: pluginRepo.Name, } }
[ "func", "(", "actor", "Actor", ")", "getPluginInfoFromRepositoryForPlatform", "(", "pluginName", "string", ",", "pluginRepo", "configv3", ".", "PluginRepository", ",", "platform", "string", ")", "(", "PluginInfo", ",", "error", ")", "{", "pluginRepository", ",", "err", ":=", "actor", ".", "client", ".", "GetPluginRepository", "(", "pluginRepo", ".", "URL", ")", "\n", "if", "err", "!=", "nil", "{", "return", "PluginInfo", "{", "}", ",", "err", "\n", "}", "\n\n", "var", "pluginFoundWithIncompatibleBinary", "bool", "\n\n", "for", "_", ",", "plugin", ":=", "range", "pluginRepository", ".", "Plugins", "{", "if", "plugin", ".", "Name", "==", "pluginName", "{", "for", "_", ",", "pluginBinary", ":=", "range", "plugin", ".", "Binaries", "{", "if", "pluginBinary", ".", "Platform", "==", "platform", "{", "return", "PluginInfo", "{", "Name", ":", "plugin", ".", "Name", ",", "Version", ":", "plugin", ".", "Version", ",", "URL", ":", "pluginBinary", ".", "URL", ",", "Checksum", ":", "pluginBinary", ".", "Checksum", ",", "}", ",", "nil", "\n", "}", "\n", "}", "\n", "pluginFoundWithIncompatibleBinary", "=", "true", "\n", "}", "\n", "}", "\n\n", "if", "pluginFoundWithIncompatibleBinary", "{", "return", "PluginInfo", "{", "}", ",", "actionerror", ".", "NoCompatibleBinaryError", "{", "}", "\n", "}", "\n\n", "return", "PluginInfo", "{", "}", ",", "actionerror", ".", "PluginNotFoundInRepositoryError", "{", "PluginName", ":", "pluginName", ",", "RepositoryName", ":", "pluginRepo", ".", "Name", ",", "}", "\n", "}" ]
// getPluginInfoFromRepositoryForPlatform returns the plugin info, if found, from // the specified repository for the specified platform.
[ "getPluginInfoFromRepositoryForPlatform", "returns", "the", "plugin", "info", "if", "found", "from", "the", "specified", "repository", "for", "the", "specified", "platform", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L64-L96
train
cloudfoundry/cli
util/generic/executable_filename_windows.go
ExecutableFilename
func ExecutableFilename(name string) string { if strings.HasSuffix(name, ".exe") { return name } return fmt.Sprintf("%s.exe", name) }
go
func ExecutableFilename(name string) string { if strings.HasSuffix(name, ".exe") { return name } return fmt.Sprintf("%s.exe", name) }
[ "func", "ExecutableFilename", "(", "name", "string", ")", "string", "{", "if", "strings", ".", "HasSuffix", "(", "name", ",", "\"", "\"", ")", "{", "return", "name", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "name", ")", "\n", "}" ]
// ExecutableFilename appends '.exe' to a filename when necessary in order to // make it executable on Windows
[ "ExecutableFilename", "appends", ".", "exe", "to", "a", "filename", "when", "necessary", "in", "order", "to", "make", "it", "executable", "on", "Windows" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/generic/executable_filename_windows.go#L12-L17
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship_list.go
EntitleIsolationSegmentToOrganizations
func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: organizationGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostIsolationSegmentRelationshipOrganizationsRequest, URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
go
func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: organizationGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostIsolationSegmentRelationshipOrganizationsRequest, URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "EntitleIsolationSegmentToOrganizations", "(", "isolationSegmentGUID", "string", ",", "organizationGUIDs", "[", "]", "string", ")", "(", "RelationshipList", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "RelationshipList", "{", "GUIDs", ":", "organizationGUIDs", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostIsolationSegmentRelationshipOrganizationsRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "isolationSegmentGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "relationships", "RelationshipList", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationships", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationships", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// EntitleIsolationSegmentToOrganizations will create a link between the // isolation segment and the list of organizations provided.
[ "EntitleIsolationSegmentToOrganizations", "will", "create", "a", "link", "between", "the", "isolation", "segment", "and", "the", "list", "of", "organizations", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship_list.go#L50-L72
train
cloudfoundry/cli
api/cloudcontroller/ccv3/relationship_list.go
ShareServiceInstanceToSpaces
func (client *Client) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: spaceGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceInstanceRelationshipsSharedSpacesRequest, URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
go
func (client *Client) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (RelationshipList, Warnings, error) { body, err := json.Marshal(RelationshipList{GUIDs: spaceGUIDs}) if err != nil { return RelationshipList{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceInstanceRelationshipsSharedSpacesRequest, URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID}, Body: bytes.NewReader(body), }) if err != nil { return RelationshipList{}, nil, err } var relationships RelationshipList response := cloudcontroller.Response{ DecodeJSONResponseInto: &relationships, } err = client.connection.Make(request, &response) return relationships, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "ShareServiceInstanceToSpaces", "(", "serviceInstanceGUID", "string", ",", "spaceGUIDs", "[", "]", "string", ")", "(", "RelationshipList", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "RelationshipList", "{", "GUIDs", ":", "spaceGUIDs", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostServiceInstanceRelationshipsSharedSpacesRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "serviceInstanceGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "RelationshipList", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "relationships", "RelationshipList", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "relationships", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "relationships", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// ShareServiceInstanceToSpaces will create a sharing relationship between // the service instance and the shared-to space for each space provided.
[ "ShareServiceInstanceToSpaces", "will", "create", "a", "sharing", "relationship", "between", "the", "service", "instance", "and", "the", "shared", "-", "to", "space", "for", "each", "space", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship_list.go#L76-L99
train
cloudfoundry/cli
util/panichandler/handler.go
HandlePanic
func HandlePanic() { stackTraceBytes := make([]byte, maxStackSizeLimit) runtime.Stack(stackTraceBytes, true) stackTrace := "\t" + strings.Replace(string(stackTraceBytes), "\n", "\n\t", -1) if err := recover(); err != nil { formattedString := ` Something unexpected happened. This is a bug in {{.Binary}}. Please re-run the command that caused this exception with the environment variable CF_TRACE set to true. Also, please update to the latest cli and try the command again: https://code.cloudfoundry.org/cli/releases Please create an issue at: https://code.cloudfoundry.org/cli/issues Include the below information when creating the issue: Command {{.Command}} CLI Version {{.Version}} Error {{.Error}} Stack Trace {{.StackTrace}} Your Platform Details e.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit Shell e.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator ` formattedTemplate := template.Must(template.New("Panic Template").Parse(formattedString)) templateErr := formattedTemplate.Execute(os.Stderr, map[string]interface{}{ "Binary": os.Args[0], "Command": strings.Join(os.Args, " "), "Version": version.VersionString(), "StackTrace": stackTrace, "Error": err, }) if templateErr != nil { fmt.Fprintf(os.Stderr, "Unable to format panic response: %s\n", templateErr.Error(), ) fmt.Fprintf(os.Stderr, "Version:%s\nCommand:%s\nOriginal Stack Trace:%s\nOriginal Error:%s\n", version.VersionString(), strings.Join(os.Args, " "), stackTrace, err, ) } os.Exit(1) } }
go
func HandlePanic() { stackTraceBytes := make([]byte, maxStackSizeLimit) runtime.Stack(stackTraceBytes, true) stackTrace := "\t" + strings.Replace(string(stackTraceBytes), "\n", "\n\t", -1) if err := recover(); err != nil { formattedString := ` Something unexpected happened. This is a bug in {{.Binary}}. Please re-run the command that caused this exception with the environment variable CF_TRACE set to true. Also, please update to the latest cli and try the command again: https://code.cloudfoundry.org/cli/releases Please create an issue at: https://code.cloudfoundry.org/cli/issues Include the below information when creating the issue: Command {{.Command}} CLI Version {{.Version}} Error {{.Error}} Stack Trace {{.StackTrace}} Your Platform Details e.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit Shell e.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator ` formattedTemplate := template.Must(template.New("Panic Template").Parse(formattedString)) templateErr := formattedTemplate.Execute(os.Stderr, map[string]interface{}{ "Binary": os.Args[0], "Command": strings.Join(os.Args, " "), "Version": version.VersionString(), "StackTrace": stackTrace, "Error": err, }) if templateErr != nil { fmt.Fprintf(os.Stderr, "Unable to format panic response: %s\n", templateErr.Error(), ) fmt.Fprintf(os.Stderr, "Version:%s\nCommand:%s\nOriginal Stack Trace:%s\nOriginal Error:%s\n", version.VersionString(), strings.Join(os.Args, " "), stackTrace, err, ) } os.Exit(1) } }
[ "func", "HandlePanic", "(", ")", "{", "stackTraceBytes", ":=", "make", "(", "[", "]", "byte", ",", "maxStackSizeLimit", ")", "\n", "runtime", ".", "Stack", "(", "stackTraceBytes", ",", "true", ")", "\n", "stackTrace", ":=", "\"", "\\t", "\"", "+", "strings", ".", "Replace", "(", "string", "(", "stackTraceBytes", ")", ",", "\"", "\\n", "\"", ",", "\"", "\\n", "\\t", "\"", ",", "-", "1", ")", "\n", "if", "err", ":=", "recover", "(", ")", ";", "err", "!=", "nil", "{", "formattedString", ":=", "`\n\t\tSomething unexpected happened. This is a bug in {{.Binary}}.\n\n\t\tPlease re-run the command that caused this exception with the environment\n\t\tvariable CF_TRACE set to true.\n\n\t\tAlso, please update to the latest cli and try the command again:\n\t\thttps://code.cloudfoundry.org/cli/releases\n\n\t\tPlease create an issue at: https://code.cloudfoundry.org/cli/issues\n\n\t\tInclude the below information when creating the issue:\n\n\t\tCommand\n\t\t{{.Command}}\n\n\t\tCLI Version\n\t\t{{.Version}}\n\n\t\tError\n\t\t{{.Error}}\n\n\t\tStack Trace\n\t\t{{.StackTrace}}\n\n\t\tYour Platform Details\n\t\te.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit\n\n\t\tShell\n\t\te.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator\n\t\t`", "\n", "formattedTemplate", ":=", "template", ".", "Must", "(", "template", ".", "New", "(", "\"", "\"", ")", ".", "Parse", "(", "formattedString", ")", ")", "\n", "templateErr", ":=", "formattedTemplate", ".", "Execute", "(", "os", ".", "Stderr", ",", "map", "[", "string", "]", "interface", "{", "}", "{", "\"", "\"", ":", "os", ".", "Args", "[", "0", "]", ",", "\"", "\"", ":", "strings", ".", "Join", "(", "os", ".", "Args", ",", "\"", "\"", ")", ",", "\"", "\"", ":", "version", ".", "VersionString", "(", ")", ",", "\"", "\"", ":", "stackTrace", ",", "\"", "\"", ":", "err", ",", "}", ")", "\n", "if", "templateErr", "!=", "nil", "{", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\"", ",", "templateErr", ".", "Error", "(", ")", ",", ")", "\n\n", "fmt", ".", "Fprintf", "(", "os", ".", "Stderr", ",", "\"", "\\n", "\\n", "\\n", "\\n", "\"", ",", "version", ".", "VersionString", "(", ")", ",", "strings", ".", "Join", "(", "os", ".", "Args", ",", "\"", "\"", ")", ",", "stackTrace", ",", "err", ",", ")", "\n", "}", "\n", "os", ".", "Exit", "(", "1", ")", "\n", "}", "\n", "}" ]
// HandlePanic will recover from any panics and display a friendly error // message with additional information used for debugging the panic.
[ "HandlePanic", "will", "recover", "from", "any", "panics", "and", "display", "a", "friendly", "error", "message", "with", "additional", "information", "used", "for", "debugging", "the", "panic", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/panichandler/handler.go#L17-L77
train
cloudfoundry/cli
api/cloudcontroller/ccv2/domain.go
UnmarshalJSON
func (domain *Domain) UnmarshalJSON(data []byte) error { var ccDomain struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` RouterGroupGUID string `json:"router_group_guid"` RouterGroupType string `json:"router_group_type"` Internal bool `json:"internal"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccDomain) if err != nil { return err } domain.GUID = ccDomain.Metadata.GUID domain.Name = ccDomain.Entity.Name domain.RouterGroupGUID = ccDomain.Entity.RouterGroupGUID domain.RouterGroupType = constant.RouterGroupType(ccDomain.Entity.RouterGroupType) domain.Internal = ccDomain.Entity.Internal return nil }
go
func (domain *Domain) UnmarshalJSON(data []byte) error { var ccDomain struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` RouterGroupGUID string `json:"router_group_guid"` RouterGroupType string `json:"router_group_type"` Internal bool `json:"internal"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccDomain) if err != nil { return err } domain.GUID = ccDomain.Metadata.GUID domain.Name = ccDomain.Entity.Name domain.RouterGroupGUID = ccDomain.Entity.RouterGroupGUID domain.RouterGroupType = constant.RouterGroupType(ccDomain.Entity.RouterGroupType) domain.Internal = ccDomain.Entity.Internal return nil }
[ "func", "(", "domain", "*", "Domain", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccDomain", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "RouterGroupGUID", "string", "`json:\"router_group_guid\"`", "\n", "RouterGroupType", "string", "`json:\"router_group_type\"`", "\n", "Internal", "bool", "`json:\"internal\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccDomain", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "domain", ".", "GUID", "=", "ccDomain", ".", "Metadata", ".", "GUID", "\n", "domain", ".", "Name", "=", "ccDomain", ".", "Entity", ".", "Name", "\n", "domain", ".", "RouterGroupGUID", "=", "ccDomain", ".", "Entity", ".", "RouterGroupGUID", "\n", "domain", ".", "RouterGroupType", "=", "constant", ".", "RouterGroupType", "(", "ccDomain", ".", "Entity", ".", "RouterGroupType", ")", "\n", "domain", ".", "Internal", "=", "ccDomain", ".", "Entity", ".", "Internal", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Domain response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Domain", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L38-L59
train
cloudfoundry/cli
api/cloudcontroller/ccv2/domain.go
GetPrivateDomain
func (client *Client) GetPrivateDomain(domainGUID string) (Domain, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPrivateDomainRequest, URIParams: map[string]string{"private_domain_guid": domainGUID}, }) if err != nil { return Domain{}, nil, err } var domain Domain response := cloudcontroller.Response{ DecodeJSONResponseInto: &domain, } err = client.connection.Make(request, &response) if err != nil { return Domain{}, response.Warnings, err } domain.Type = constant.PrivateDomain return domain, response.Warnings, nil }
go
func (client *Client) GetPrivateDomain(domainGUID string) (Domain, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPrivateDomainRequest, URIParams: map[string]string{"private_domain_guid": domainGUID}, }) if err != nil { return Domain{}, nil, err } var domain Domain response := cloudcontroller.Response{ DecodeJSONResponseInto: &domain, } err = client.connection.Make(request, &response) if err != nil { return Domain{}, response.Warnings, err } domain.Type = constant.PrivateDomain return domain, response.Warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "GetPrivateDomain", "(", "domainGUID", "string", ")", "(", "Domain", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetPrivateDomainRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "domainGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Domain", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "domain", "Domain", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "domain", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Domain", "{", "}", ",", "response", ".", "Warnings", ",", "err", "\n", "}", "\n\n", "domain", ".", "Type", "=", "constant", ".", "PrivateDomain", "\n", "return", "domain", ",", "response", ".", "Warnings", ",", "nil", "\n", "}" ]
// GetPrivateDomain returns the Private Domain associated with the provided // Domain GUID.
[ "GetPrivateDomain", "returns", "the", "Private", "Domain", "associated", "with", "the", "provided", "Domain", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L119-L140
train
cloudfoundry/cli
api/cloudcontroller/ccv2/domain.go
GetPrivateDomains
func (client *Client) GetPrivateDomains(filters ...Filter) ([]Domain, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPrivateDomainsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return []Domain{}, nil, err } fullDomainsList := []Domain{} warnings, err := client.paginate(request, Domain{}, func(item interface{}) error { if domain, ok := item.(Domain); ok { domain.Type = constant.PrivateDomain fullDomainsList = append(fullDomainsList, domain) } else { return ccerror.UnknownObjectInListError{ Expected: Domain{}, Unexpected: item, } } return nil }) return fullDomainsList, warnings, err }
go
func (client *Client) GetPrivateDomains(filters ...Filter) ([]Domain, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetPrivateDomainsRequest, Query: ConvertFilterParameters(filters), }) if err != nil { return []Domain{}, nil, err } fullDomainsList := []Domain{} warnings, err := client.paginate(request, Domain{}, func(item interface{}) error { if domain, ok := item.(Domain); ok { domain.Type = constant.PrivateDomain fullDomainsList = append(fullDomainsList, domain) } else { return ccerror.UnknownObjectInListError{ Expected: Domain{}, Unexpected: item, } } return nil }) return fullDomainsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetPrivateDomains", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Domain", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetPrivateDomainsRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Domain", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "fullDomainsList", ":=", "[", "]", "Domain", "{", "}", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Domain", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "domain", ",", "ok", ":=", "item", ".", "(", "Domain", ")", ";", "ok", "{", "domain", ".", "Type", "=", "constant", ".", "PrivateDomain", "\n", "fullDomainsList", "=", "append", "(", "fullDomainsList", ",", "domain", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Domain", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullDomainsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetPrivateDomains returns the private domains this client has access to.
[ "GetPrivateDomains", "returns", "the", "private", "domains", "this", "client", "has", "access", "to", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L143-L167
train
cloudfoundry/cli
command/common/command_list_v6.go
HasCommand
func (c commandList) HasCommand(name string) bool { if name == "" { return false } cType := reflect.TypeOf(c) _, found := cType.FieldByNameFunc( func(fieldName string) bool { field, _ := cType.FieldByName(fieldName) return field.Tag.Get("command") == name }, ) return found }
go
func (c commandList) HasCommand(name string) bool { if name == "" { return false } cType := reflect.TypeOf(c) _, found := cType.FieldByNameFunc( func(fieldName string) bool { field, _ := cType.FieldByName(fieldName) return field.Tag.Get("command") == name }, ) return found }
[ "func", "(", "c", "commandList", ")", "HasCommand", "(", "name", "string", ")", "bool", "{", "if", "name", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n\n", "cType", ":=", "reflect", ".", "TypeOf", "(", "c", ")", "\n", "_", ",", "found", ":=", "cType", ".", "FieldByNameFunc", "(", "func", "(", "fieldName", "string", ")", "bool", "{", "field", ",", "_", ":=", "cType", ".", "FieldByName", "(", "fieldName", ")", "\n", "return", "field", ".", "Tag", ".", "Get", "(", "\"", "\"", ")", "==", "name", "\n", "}", ",", ")", "\n\n", "return", "found", "\n", "}" ]
// HasCommand returns true if the command name is in the command list.
[ "HasCommand", "returns", "true", "if", "the", "command", "name", "is", "in", "the", "command", "list", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/common/command_list_v6.go#L218-L232
train
cloudfoundry/cli
util/ui/log_message.go
DisplayLogMessage
func (ui *UI) DisplayLogMessage(message LogMessage, displayHeader bool) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() var header string if displayHeader { time := message.Timestamp().In(ui.TimezoneLocation).Format(LogTimestampFormat) header = fmt.Sprintf("%s [%s/%s] %s ", time, message.SourceType(), message.SourceInstance(), message.Type(), ) } for _, line := range strings.Split(message.Message(), "\n") { logLine := fmt.Sprintf("%s%s", header, strings.TrimRight(line, "\r\n")) if message.Type() == "ERR" { logLine = ui.modifyColor(logLine, color.New(color.FgRed)) } fmt.Fprintf(ui.Out, " %s\n", logLine) } }
go
func (ui *UI) DisplayLogMessage(message LogMessage, displayHeader bool) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() var header string if displayHeader { time := message.Timestamp().In(ui.TimezoneLocation).Format(LogTimestampFormat) header = fmt.Sprintf("%s [%s/%s] %s ", time, message.SourceType(), message.SourceInstance(), message.Type(), ) } for _, line := range strings.Split(message.Message(), "\n") { logLine := fmt.Sprintf("%s%s", header, strings.TrimRight(line, "\r\n")) if message.Type() == "ERR" { logLine = ui.modifyColor(logLine, color.New(color.FgRed)) } fmt.Fprintf(ui.Out, " %s\n", logLine) } }
[ "func", "(", "ui", "*", "UI", ")", "DisplayLogMessage", "(", "message", "LogMessage", ",", "displayHeader", "bool", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "var", "header", "string", "\n", "if", "displayHeader", "{", "time", ":=", "message", ".", "Timestamp", "(", ")", ".", "In", "(", "ui", ".", "TimezoneLocation", ")", ".", "Format", "(", "LogTimestampFormat", ")", "\n\n", "header", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "time", ",", "message", ".", "SourceType", "(", ")", ",", "message", ".", "SourceInstance", "(", ")", ",", "message", ".", "Type", "(", ")", ",", ")", "\n", "}", "\n\n", "for", "_", ",", "line", ":=", "range", "strings", ".", "Split", "(", "message", ".", "Message", "(", ")", ",", "\"", "\\n", "\"", ")", "{", "logLine", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "header", ",", "strings", ".", "TrimRight", "(", "line", ",", "\"", "\\r", "\\n", "\"", ")", ")", "\n", "if", "message", ".", "Type", "(", ")", "==", "\"", "\"", "{", "logLine", "=", "ui", ".", "modifyColor", "(", "logLine", ",", "color", ".", "New", "(", "color", ".", "FgRed", ")", ")", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\"", ",", "logLine", ")", "\n", "}", "\n", "}" ]
// DisplayLogMessage formats and outputs a given log message.
[ "DisplayLogMessage", "formats", "and", "outputs", "a", "given", "log", "message", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/log_message.go#L27-L50
train
cloudfoundry/cli
command/common/install_plugin_command.go
handleFetchingPluginInfoFromRepositoriesError
func (InstallPluginCommand) handleFetchingPluginInfoFromRepositoriesError(fetchErr actionerror.FetchingPluginInfoFromRepositoryError) error { switch clientErr := fetchErr.Err.(type) { case pluginerror.RawHTTPStatusError: return translatableerror.FetchingPluginInfoFromRepositoriesError{ Message: clientErr.Status, RepositoryName: fetchErr.RepositoryName, } case pluginerror.SSLValidationHostnameError: return translatableerror.FetchingPluginInfoFromRepositoriesError{ Message: clientErr.Error(), RepositoryName: fetchErr.RepositoryName, } case pluginerror.UnverifiedServerError: return translatableerror.FetchingPluginInfoFromRepositoriesError{ Message: clientErr.Error(), RepositoryName: fetchErr.RepositoryName, } default: return clientErr } }
go
func (InstallPluginCommand) handleFetchingPluginInfoFromRepositoriesError(fetchErr actionerror.FetchingPluginInfoFromRepositoryError) error { switch clientErr := fetchErr.Err.(type) { case pluginerror.RawHTTPStatusError: return translatableerror.FetchingPluginInfoFromRepositoriesError{ Message: clientErr.Status, RepositoryName: fetchErr.RepositoryName, } case pluginerror.SSLValidationHostnameError: return translatableerror.FetchingPluginInfoFromRepositoriesError{ Message: clientErr.Error(), RepositoryName: fetchErr.RepositoryName, } case pluginerror.UnverifiedServerError: return translatableerror.FetchingPluginInfoFromRepositoriesError{ Message: clientErr.Error(), RepositoryName: fetchErr.RepositoryName, } default: return clientErr } }
[ "func", "(", "InstallPluginCommand", ")", "handleFetchingPluginInfoFromRepositoriesError", "(", "fetchErr", "actionerror", ".", "FetchingPluginInfoFromRepositoryError", ")", "error", "{", "switch", "clientErr", ":=", "fetchErr", ".", "Err", ".", "(", "type", ")", "{", "case", "pluginerror", ".", "RawHTTPStatusError", ":", "return", "translatableerror", ".", "FetchingPluginInfoFromRepositoriesError", "{", "Message", ":", "clientErr", ".", "Status", ",", "RepositoryName", ":", "fetchErr", ".", "RepositoryName", ",", "}", "\n\n", "case", "pluginerror", ".", "SSLValidationHostnameError", ":", "return", "translatableerror", ".", "FetchingPluginInfoFromRepositoriesError", "{", "Message", ":", "clientErr", ".", "Error", "(", ")", ",", "RepositoryName", ":", "fetchErr", ".", "RepositoryName", ",", "}", "\n\n", "case", "pluginerror", ".", "UnverifiedServerError", ":", "return", "translatableerror", ".", "FetchingPluginInfoFromRepositoriesError", "{", "Message", ":", "clientErr", ".", "Error", "(", ")", ",", "RepositoryName", ":", "fetchErr", ".", "RepositoryName", ",", "}", "\n\n", "default", ":", "return", "clientErr", "\n", "}", "\n", "}" ]
// These are specific errors that we output to the user in the context of // installing from any repository.
[ "These", "are", "specific", "errors", "that", "we", "output", "to", "the", "user", "in", "the", "context", "of", "installing", "from", "any", "repository", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/common/install_plugin_command.go#L246-L269
train
cloudfoundry/cli
api/cloudcontroller/ccv3/environment.go
GetApplicationEnvironment
func (client *Client) GetApplicationEnvironment(appGUID string) (Environment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ URIParams: internal.Params{"app_guid": appGUID}, RequestName: internal.GetApplicationEnvRequest, }) if err != nil { return Environment{}, nil, err } var responseEnvVars Environment response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseEnvVars, } err = client.connection.Make(request, &response) return responseEnvVars, response.Warnings, err }
go
func (client *Client) GetApplicationEnvironment(appGUID string) (Environment, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ URIParams: internal.Params{"app_guid": appGUID}, RequestName: internal.GetApplicationEnvRequest, }) if err != nil { return Environment{}, nil, err } var responseEnvVars Environment response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseEnvVars, } err = client.connection.Make(request, &response) return responseEnvVars, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplicationEnvironment", "(", "appGUID", "string", ")", "(", "Environment", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "appGUID", "}", ",", "RequestName", ":", "internal", ".", "GetApplicationEnvRequest", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Environment", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseEnvVars", "Environment", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseEnvVars", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseEnvVars", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetApplicationEnvironment fetches all the environment variables on // an application by groups.
[ "GetApplicationEnvironment", "fetches", "all", "the", "environment", "variables", "on", "an", "application", "by", "groups", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/environment.go#L30-L45
train
cloudfoundry/cli
command/v6/shared/new_clients.go
NewClients
func NewClients(config command.Config, ui command.UI, targetCF bool) (*ccv2.Client, *uaa.Client, error) { ccWrappers := []ccv2.ConnectionWrapper{} verbose, location := config.Verbose() if verbose { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } authWrapper := ccWrapper.NewUAAAuthentication(nil, config) ccWrappers = append(ccWrappers, authWrapper) ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount())) ccClient := ccv2.NewClient(ccv2.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), JobPollingTimeout: config.OverallPollingTimeout(), JobPollingInterval: config.PollingInterval(), Wrappers: ccWrappers, }) if !targetCF { return ccClient, nil, nil } if config.Target() == "" { return nil, nil, translatableerror.NoAPISetError{ BinaryName: config.BinaryName(), } } _, err := ccClient.TargetCF(ccv2.TargetSettings{ URL: config.Target(), SkipSSLValidation: config.SkipSSLValidation(), DialTimeout: config.DialTimeout(), }) if err != nil { return nil, nil, err } if err = command.WarnIfAPIVersionBelowSupportedMinimum(ccClient.APIVersion(), ui); err != nil { return nil, nil, err } if ccClient.AuthorizationEndpoint() == "" { return nil, nil, translatableerror.AuthorizationEndpointNotFoundError{} } uaaClient := uaa.NewClient(config) if verbose { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(nil, config) uaaClient.WrapConnection(uaaAuthWrapper) uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount())) err = uaaClient.SetupResources(ccClient.AuthorizationEndpoint()) if err != nil { return nil, nil, err } uaaAuthWrapper.SetClient(uaaClient) authWrapper.SetClient(uaaClient) return ccClient, uaaClient, err }
go
func NewClients(config command.Config, ui command.UI, targetCF bool) (*ccv2.Client, *uaa.Client, error) { ccWrappers := []ccv2.ConnectionWrapper{} verbose, location := config.Verbose() if verbose { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } authWrapper := ccWrapper.NewUAAAuthentication(nil, config) ccWrappers = append(ccWrappers, authWrapper) ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount())) ccClient := ccv2.NewClient(ccv2.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), JobPollingTimeout: config.OverallPollingTimeout(), JobPollingInterval: config.PollingInterval(), Wrappers: ccWrappers, }) if !targetCF { return ccClient, nil, nil } if config.Target() == "" { return nil, nil, translatableerror.NoAPISetError{ BinaryName: config.BinaryName(), } } _, err := ccClient.TargetCF(ccv2.TargetSettings{ URL: config.Target(), SkipSSLValidation: config.SkipSSLValidation(), DialTimeout: config.DialTimeout(), }) if err != nil { return nil, nil, err } if err = command.WarnIfAPIVersionBelowSupportedMinimum(ccClient.APIVersion(), ui); err != nil { return nil, nil, err } if ccClient.AuthorizationEndpoint() == "" { return nil, nil, translatableerror.AuthorizationEndpointNotFoundError{} } uaaClient := uaa.NewClient(config) if verbose { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(nil, config) uaaClient.WrapConnection(uaaAuthWrapper) uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount())) err = uaaClient.SetupResources(ccClient.AuthorizationEndpoint()) if err != nil { return nil, nil, err } uaaAuthWrapper.SetClient(uaaClient) authWrapper.SetClient(uaaClient) return ccClient, uaaClient, err }
[ "func", "NewClients", "(", "config", "command", ".", "Config", ",", "ui", "command", ".", "UI", ",", "targetCF", "bool", ")", "(", "*", "ccv2", ".", "Client", ",", "*", "uaa", ".", "Client", ",", "error", ")", "{", "ccWrappers", ":=", "[", "]", "ccv2", ".", "ConnectionWrapper", "{", "}", "\n\n", "verbose", ",", "location", ":=", "config", ".", "Verbose", "(", ")", "\n", "if", "verbose", "{", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "ccWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n\n", "if", "location", "!=", "nil", "{", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "ccWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n\n", "authWrapper", ":=", "ccWrapper", ".", "NewUAAAuthentication", "(", "nil", ",", "config", ")", "\n\n", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "authWrapper", ")", "\n", "ccWrappers", "=", "append", "(", "ccWrappers", ",", "ccWrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n\n", "ccClient", ":=", "ccv2", ".", "NewClient", "(", "ccv2", ".", "Config", "{", "AppName", ":", "config", ".", "BinaryName", "(", ")", ",", "AppVersion", ":", "config", ".", "BinaryVersion", "(", ")", ",", "JobPollingTimeout", ":", "config", ".", "OverallPollingTimeout", "(", ")", ",", "JobPollingInterval", ":", "config", ".", "PollingInterval", "(", ")", ",", "Wrappers", ":", "ccWrappers", ",", "}", ")", "\n\n", "if", "!", "targetCF", "{", "return", "ccClient", ",", "nil", ",", "nil", "\n", "}", "\n\n", "if", "config", ".", "Target", "(", ")", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "translatableerror", ".", "NoAPISetError", "{", "BinaryName", ":", "config", ".", "BinaryName", "(", ")", ",", "}", "\n", "}", "\n\n", "_", ",", "err", ":=", "ccClient", ".", "TargetCF", "(", "ccv2", ".", "TargetSettings", "{", "URL", ":", "config", ".", "Target", "(", ")", ",", "SkipSSLValidation", ":", "config", ".", "SkipSSLValidation", "(", ")", ",", "DialTimeout", ":", "config", ".", "DialTimeout", "(", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "err", "=", "command", ".", "WarnIfAPIVersionBelowSupportedMinimum", "(", "ccClient", ".", "APIVersion", "(", ")", ",", "ui", ")", ";", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "if", "ccClient", ".", "AuthorizationEndpoint", "(", ")", "==", "\"", "\"", "{", "return", "nil", ",", "nil", ",", "translatableerror", ".", "AuthorizationEndpointNotFoundError", "{", "}", "\n", "}", "\n\n", "uaaClient", ":=", "uaa", ".", "NewClient", "(", "config", ")", "\n\n", "if", "verbose", "{", "uaaClient", ".", "WrapConnection", "(", "uaaWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "uaaClient", ".", "WrapConnection", "(", "uaaWrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n\n", "uaaAuthWrapper", ":=", "uaaWrapper", ".", "NewUAAAuthentication", "(", "nil", ",", "config", ")", "\n", "uaaClient", ".", "WrapConnection", "(", "uaaAuthWrapper", ")", "\n", "uaaClient", ".", "WrapConnection", "(", "uaaWrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n\n", "err", "=", "uaaClient", ".", "SetupResources", "(", "ccClient", ".", "AuthorizationEndpoint", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "uaaAuthWrapper", ".", "SetClient", "(", "uaaClient", ")", "\n", "authWrapper", ".", "SetClient", "(", "uaaClient", ")", "\n\n", "return", "ccClient", ",", "uaaClient", ",", "err", "\n", "}" ]
// NewClients creates a new V2 Cloud Controller client and UAA client using the // passed in config.
[ "NewClients", "creates", "a", "new", "V2", "Cloud", "Controller", "client", "and", "UAA", "client", "using", "the", "passed", "in", "config", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/new_clients.go#L16-L90
train
cloudfoundry/cli
actor/sharedaction/check_target.go
CheckTarget
func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error { if !actor.IsLoggedIn() { return actionerror.NotLoggedInError{ BinaryName: actor.Config.BinaryName(), } } if targetedOrganizationRequired { if !actor.IsOrgTargeted() { return actionerror.NoOrganizationTargetedError{ BinaryName: actor.Config.BinaryName(), } } if targetedSpaceRequired { if !actor.IsSpaceTargeted() { return actionerror.NoSpaceTargetedError{ BinaryName: actor.Config.BinaryName(), } } } } return nil }
go
func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error { if !actor.IsLoggedIn() { return actionerror.NotLoggedInError{ BinaryName: actor.Config.BinaryName(), } } if targetedOrganizationRequired { if !actor.IsOrgTargeted() { return actionerror.NoOrganizationTargetedError{ BinaryName: actor.Config.BinaryName(), } } if targetedSpaceRequired { if !actor.IsSpaceTargeted() { return actionerror.NoSpaceTargetedError{ BinaryName: actor.Config.BinaryName(), } } } } return nil }
[ "func", "(", "actor", "Actor", ")", "CheckTarget", "(", "targetedOrganizationRequired", "bool", ",", "targetedSpaceRequired", "bool", ")", "error", "{", "if", "!", "actor", ".", "IsLoggedIn", "(", ")", "{", "return", "actionerror", ".", "NotLoggedInError", "{", "BinaryName", ":", "actor", ".", "Config", ".", "BinaryName", "(", ")", ",", "}", "\n", "}", "\n\n", "if", "targetedOrganizationRequired", "{", "if", "!", "actor", ".", "IsOrgTargeted", "(", ")", "{", "return", "actionerror", ".", "NoOrganizationTargetedError", "{", "BinaryName", ":", "actor", ".", "Config", ".", "BinaryName", "(", ")", ",", "}", "\n", "}", "\n\n", "if", "targetedSpaceRequired", "{", "if", "!", "actor", ".", "IsSpaceTargeted", "(", ")", "{", "return", "actionerror", ".", "NoSpaceTargetedError", "{", "BinaryName", ":", "actor", ".", "Config", ".", "BinaryName", "(", ")", ",", "}", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// CheckTarget confirms that the user is logged in. Optionally it will also // check if an organization and space are targeted.
[ "CheckTarget", "confirms", "that", "the", "user", "is", "logged", "in", ".", "Optionally", "it", "will", "also", "check", "if", "an", "organization", "and", "space", "are", "targeted", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/check_target.go#L7-L31
train
cloudfoundry/cli
api/cloudcontroller/ccv3/task.go
CreateApplicationTask
func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error) { bodyBytes, err := json.Marshal(task) if err != nil { return Task{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationTasksRequest, URIParams: internal.Params{ "app_guid": appGUID, }, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Task{}, nil, err } var responseTask Task response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseTask, } err = client.connection.Make(request, &response) return responseTask, response.Warnings, err }
go
func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error) { bodyBytes, err := json.Marshal(task) if err != nil { return Task{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationTasksRequest, URIParams: internal.Params{ "app_guid": appGUID, }, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Task{}, nil, err } var responseTask Task response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseTask, } err = client.connection.Make(request, &response) return responseTask, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateApplicationTask", "(", "appGUID", "string", ",", "task", "Task", ")", "(", "Task", ",", "Warnings", ",", "error", ")", "{", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "task", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Task", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationTasksRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "appGUID", ",", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Task", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseTask", "Task", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseTask", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "responseTask", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateApplicationTask runs a command in the Application environment // associated with the provided Application GUID.
[ "CreateApplicationTask", "runs", "a", "command", "in", "the", "Application", "environment", "associated", "with", "the", "provided", "Application", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/task.go#L37-L61
train
cloudfoundry/cli
api/cloudcontroller/ccv3/task.go
GetApplicationTasks
func (client *Client) GetApplicationTasks(appGUID string, query ...Query) ([]Task, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationTasksRequest, URIParams: internal.Params{ "app_guid": appGUID, }, Query: query, }) if err != nil { return nil, nil, err } var fullTasksList []Task warnings, err := client.paginate(request, Task{}, func(item interface{}) error { if task, ok := item.(Task); ok { fullTasksList = append(fullTasksList, task) } else { return ccerror.UnknownObjectInListError{ Expected: Task{}, Unexpected: item, } } return nil }) return fullTasksList, warnings, err }
go
func (client *Client) GetApplicationTasks(appGUID string, query ...Query) ([]Task, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationTasksRequest, URIParams: internal.Params{ "app_guid": appGUID, }, Query: query, }) if err != nil { return nil, nil, err } var fullTasksList []Task warnings, err := client.paginate(request, Task{}, func(item interface{}) error { if task, ok := item.(Task); ok { fullTasksList = append(fullTasksList, task) } else { return ccerror.UnknownObjectInListError{ Expected: Task{}, Unexpected: item, } } return nil }) return fullTasksList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplicationTasks", "(", "appGUID", "string", ",", "query", "...", "Query", ")", "(", "[", "]", "Task", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetApplicationTasksRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "appGUID", ",", "}", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullTasksList", "[", "]", "Task", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Task", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "task", ",", "ok", ":=", "item", ".", "(", "Task", ")", ";", "ok", "{", "fullTasksList", "=", "append", "(", "fullTasksList", ",", "task", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Task", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullTasksList", ",", "warnings", ",", "err", "\n", "}" ]
// GetApplicationTasks returns a list of tasks associated with the provided // application GUID. Results can be filtered by providing URL queries.
[ "GetApplicationTasks", "returns", "a", "list", "of", "tasks", "associated", "with", "the", "provided", "application", "GUID", ".", "Results", "can", "be", "filtered", "by", "providing", "URL", "queries", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/task.go#L65-L91
train
cloudfoundry/cli
api/cloudcontroller/ccv3/task.go
UpdateTaskCancel
func (client *Client) UpdateTaskCancel(taskGUID string) (Task, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutTaskCancelRequest, URIParams: internal.Params{ "task_guid": taskGUID, }, }) if err != nil { return Task{}, nil, err } var task Task response := cloudcontroller.Response{ DecodeJSONResponseInto: &task, } err = client.connection.Make(request, &response) if err != nil { return Task{}, response.Warnings, err } return task, response.Warnings, nil }
go
func (client *Client) UpdateTaskCancel(taskGUID string) (Task, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutTaskCancelRequest, URIParams: internal.Params{ "task_guid": taskGUID, }, }) if err != nil { return Task{}, nil, err } var task Task response := cloudcontroller.Response{ DecodeJSONResponseInto: &task, } err = client.connection.Make(request, &response) if err != nil { return Task{}, response.Warnings, err } return task, response.Warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "UpdateTaskCancel", "(", "taskGUID", "string", ")", "(", "Task", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutTaskCancelRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "taskGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Task", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "task", "Task", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "task", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Task", "{", "}", ",", "response", ".", "Warnings", ",", "err", "\n", "}", "\n\n", "return", "task", ",", "response", ".", "Warnings", ",", "nil", "\n", "}" ]
// UpdateTaskCancel cancels a task.
[ "UpdateTaskCancel", "cancels", "a", "task", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/task.go#L94-L116
train
cloudfoundry/cli
actor/v7action/feature_flag.go
GetFeatureFlagByName
func (actor Actor) GetFeatureFlagByName(featureFlagName string) (FeatureFlag, Warnings, error) { var ( ccv3FeatureFlag ccv3.FeatureFlag warnings ccv3.Warnings err error ) ccv3FeatureFlag, warnings, err = actor.CloudControllerClient.GetFeatureFlag(featureFlagName) if err != nil { if _, ok := err.(ccerror.FeatureFlagNotFoundError); ok { return FeatureFlag{}, Warnings(warnings), actionerror.FeatureFlagNotFoundError{FeatureFlagName: featureFlagName} } return FeatureFlag{}, Warnings(warnings), err } return FeatureFlag(ccv3FeatureFlag), Warnings(warnings), err }
go
func (actor Actor) GetFeatureFlagByName(featureFlagName string) (FeatureFlag, Warnings, error) { var ( ccv3FeatureFlag ccv3.FeatureFlag warnings ccv3.Warnings err error ) ccv3FeatureFlag, warnings, err = actor.CloudControllerClient.GetFeatureFlag(featureFlagName) if err != nil { if _, ok := err.(ccerror.FeatureFlagNotFoundError); ok { return FeatureFlag{}, Warnings(warnings), actionerror.FeatureFlagNotFoundError{FeatureFlagName: featureFlagName} } return FeatureFlag{}, Warnings(warnings), err } return FeatureFlag(ccv3FeatureFlag), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetFeatureFlagByName", "(", "featureFlagName", "string", ")", "(", "FeatureFlag", ",", "Warnings", ",", "error", ")", "{", "var", "(", "ccv3FeatureFlag", "ccv3", ".", "FeatureFlag", "\n", "warnings", "ccv3", ".", "Warnings", "\n", "err", "error", "\n", ")", "\n", "ccv3FeatureFlag", ",", "warnings", ",", "err", "=", "actor", ".", "CloudControllerClient", ".", "GetFeatureFlag", "(", "featureFlagName", ")", "\n\n", "if", "err", "!=", "nil", "{", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "FeatureFlagNotFoundError", ")", ";", "ok", "{", "return", "FeatureFlag", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "FeatureFlagNotFoundError", "{", "FeatureFlagName", ":", "featureFlagName", "}", "\n", "}", "\n", "return", "FeatureFlag", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "return", "FeatureFlag", "(", "ccv3FeatureFlag", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetFeatureFlagByName returns a featureFlag with the provided name.
[ "GetFeatureFlagByName", "returns", "a", "featureFlag", "with", "the", "provided", "name", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/feature_flag.go#L12-L28
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance.go
UnmarshalJSON
func (serviceInstance *ServiceInstance) UnmarshalJSON(data []byte) error { var ccServiceInstance struct { Metadata internal.Metadata Entity struct { Name string `json:"name"` SpaceGUID string `json:"space_guid"` ServiceGUID string `json:"service_guid"` ServicePlanGUID string `json:"service_plan_guid"` Type string `json:"type"` Tags []string `json:"tags"` DashboardURL string `json:"dashboard_url"` RouteServiceURL string `json:"route_service_url"` LastOperation LastOperation `json:"last_operation"` } } err := cloudcontroller.DecodeJSON(data, &ccServiceInstance) if err != nil { return err } serviceInstance.GUID = ccServiceInstance.Metadata.GUID serviceInstance.Name = ccServiceInstance.Entity.Name serviceInstance.SpaceGUID = ccServiceInstance.Entity.SpaceGUID serviceInstance.ServiceGUID = ccServiceInstance.Entity.ServiceGUID serviceInstance.ServicePlanGUID = ccServiceInstance.Entity.ServicePlanGUID serviceInstance.Type = constant.ServiceInstanceType(ccServiceInstance.Entity.Type) serviceInstance.Tags = ccServiceInstance.Entity.Tags serviceInstance.DashboardURL = ccServiceInstance.Entity.DashboardURL serviceInstance.RouteServiceURL = ccServiceInstance.Entity.RouteServiceURL serviceInstance.LastOperation = ccServiceInstance.Entity.LastOperation return nil }
go
func (serviceInstance *ServiceInstance) UnmarshalJSON(data []byte) error { var ccServiceInstance struct { Metadata internal.Metadata Entity struct { Name string `json:"name"` SpaceGUID string `json:"space_guid"` ServiceGUID string `json:"service_guid"` ServicePlanGUID string `json:"service_plan_guid"` Type string `json:"type"` Tags []string `json:"tags"` DashboardURL string `json:"dashboard_url"` RouteServiceURL string `json:"route_service_url"` LastOperation LastOperation `json:"last_operation"` } } err := cloudcontroller.DecodeJSON(data, &ccServiceInstance) if err != nil { return err } serviceInstance.GUID = ccServiceInstance.Metadata.GUID serviceInstance.Name = ccServiceInstance.Entity.Name serviceInstance.SpaceGUID = ccServiceInstance.Entity.SpaceGUID serviceInstance.ServiceGUID = ccServiceInstance.Entity.ServiceGUID serviceInstance.ServicePlanGUID = ccServiceInstance.Entity.ServicePlanGUID serviceInstance.Type = constant.ServiceInstanceType(ccServiceInstance.Entity.Type) serviceInstance.Tags = ccServiceInstance.Entity.Tags serviceInstance.DashboardURL = ccServiceInstance.Entity.DashboardURL serviceInstance.RouteServiceURL = ccServiceInstance.Entity.RouteServiceURL serviceInstance.LastOperation = ccServiceInstance.Entity.LastOperation return nil }
[ "func", "(", "serviceInstance", "*", "ServiceInstance", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccServiceInstance", "struct", "{", "Metadata", "internal", ".", "Metadata", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "SpaceGUID", "string", "`json:\"space_guid\"`", "\n", "ServiceGUID", "string", "`json:\"service_guid\"`", "\n", "ServicePlanGUID", "string", "`json:\"service_plan_guid\"`", "\n", "Type", "string", "`json:\"type\"`", "\n", "Tags", "[", "]", "string", "`json:\"tags\"`", "\n", "DashboardURL", "string", "`json:\"dashboard_url\"`", "\n", "RouteServiceURL", "string", "`json:\"route_service_url\"`", "\n", "LastOperation", "LastOperation", "`json:\"last_operation\"`", "\n", "}", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccServiceInstance", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "serviceInstance", ".", "GUID", "=", "ccServiceInstance", ".", "Metadata", ".", "GUID", "\n", "serviceInstance", ".", "Name", "=", "ccServiceInstance", ".", "Entity", ".", "Name", "\n", "serviceInstance", ".", "SpaceGUID", "=", "ccServiceInstance", ".", "Entity", ".", "SpaceGUID", "\n", "serviceInstance", ".", "ServiceGUID", "=", "ccServiceInstance", ".", "Entity", ".", "ServiceGUID", "\n", "serviceInstance", ".", "ServicePlanGUID", "=", "ccServiceInstance", ".", "Entity", ".", "ServicePlanGUID", "\n", "serviceInstance", ".", "Type", "=", "constant", ".", "ServiceInstanceType", "(", "ccServiceInstance", ".", "Entity", ".", "Type", ")", "\n", "serviceInstance", ".", "Tags", "=", "ccServiceInstance", ".", "Entity", ".", "Tags", "\n", "serviceInstance", ".", "DashboardURL", "=", "ccServiceInstance", ".", "Entity", ".", "DashboardURL", "\n", "serviceInstance", ".", "RouteServiceURL", "=", "ccServiceInstance", ".", "Entity", ".", "RouteServiceURL", "\n", "serviceInstance", ".", "LastOperation", "=", "ccServiceInstance", ".", "Entity", ".", "LastOperation", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Service Instance response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Service", "Instance", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L59-L90
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance.go
CreateServiceInstance
func (client *Client) CreateServiceInstance(spaceGUID, servicePlanGUID, serviceInstance string, parameters map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) { requestBody := createServiceInstanceRequestBody{ Name: serviceInstance, ServicePlanGUID: servicePlanGUID, SpaceGUID: spaceGUID, Parameters: parameters, Tags: tags, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceInstance{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceInstancesRequest, Body: bytes.NewReader(bodyBytes), Query: url.Values{"accepts_incomplete": {"true"}}, }) if err != nil { return ServiceInstance{}, nil, err } var instance ServiceInstance response := cloudcontroller.Response{ DecodeJSONResponseInto: &instance, } err = client.connection.Make(request, &response) return instance, response.Warnings, err }
go
func (client *Client) CreateServiceInstance(spaceGUID, servicePlanGUID, serviceInstance string, parameters map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) { requestBody := createServiceInstanceRequestBody{ Name: serviceInstance, ServicePlanGUID: servicePlanGUID, SpaceGUID: spaceGUID, Parameters: parameters, Tags: tags, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceInstance{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceInstancesRequest, Body: bytes.NewReader(bodyBytes), Query: url.Values{"accepts_incomplete": {"true"}}, }) if err != nil { return ServiceInstance{}, nil, err } var instance ServiceInstance response := cloudcontroller.Response{ DecodeJSONResponseInto: &instance, } err = client.connection.Make(request, &response) return instance, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateServiceInstance", "(", "spaceGUID", ",", "servicePlanGUID", ",", "serviceInstance", "string", ",", "parameters", "map", "[", "string", "]", "interface", "{", "}", ",", "tags", "[", "]", "string", ")", "(", "ServiceInstance", ",", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "createServiceInstanceRequestBody", "{", "Name", ":", "serviceInstance", ",", "ServicePlanGUID", ":", "servicePlanGUID", ",", "SpaceGUID", ":", "spaceGUID", ",", "Parameters", ":", "parameters", ",", "Tags", ":", "tags", ",", "}", "\n\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostServiceInstancesRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "Query", ":", "url", ".", "Values", "{", "\"", "\"", ":", "{", "\"", "\"", "}", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "instance", "ServiceInstance", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "instance", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "instance", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateServiceInstance posts a service instance resource with the provided // attributes to the api and returns the result.
[ "CreateServiceInstance", "posts", "a", "service", "instance", "resource", "with", "the", "provided", "attributes", "to", "the", "api", "and", "returns", "the", "result", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L108-L138
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance.go
GetServiceInstance
func (client *Client) GetServiceInstance(serviceInstanceGUID string) (ServiceInstance, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return ServiceInstance{}, nil, err } var serviceInstance ServiceInstance response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceInstance, } err = client.connection.Make(request, &response) return serviceInstance, response.Warnings, err }
go
func (client *Client) GetServiceInstance(serviceInstanceGUID string) (ServiceInstance, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return ServiceInstance{}, nil, err } var serviceInstance ServiceInstance response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceInstance, } err = client.connection.Make(request, &response) return serviceInstance, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceInstance", "(", "serviceInstanceGUID", "string", ")", "(", "ServiceInstance", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceInstanceRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "serviceInstanceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "serviceInstance", "ServiceInstance", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceInstance", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "serviceInstance", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetServiceInstance returns the service instance with the given GUID. This // service can be either a managed or user provided.
[ "GetServiceInstance", "returns", "the", "service", "instance", "with", "the", "given", "GUID", ".", "This", "service", "can", "be", "either", "a", "managed", "or", "user", "provided", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L142-L158
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance.go
GetSpaceServiceInstances
func (client *Client) GetSpaceServiceInstances(spaceGUID string, includeUserProvidedServices bool, filters ...Filter) ([]ServiceInstance, Warnings, error) { query := ConvertFilterParameters(filters) if includeUserProvidedServices { query.Add("return_user_provided_service_instances", "true") } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceServiceInstancesRequest, URIParams: map[string]string{"guid": spaceGUID}, Query: query, }) if err != nil { return nil, nil, err } var fullInstancesList []ServiceInstance warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error { if instance, ok := item.(ServiceInstance); ok { fullInstancesList = append(fullInstancesList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceInstance{}, Unexpected: item, } } return nil }) return fullInstancesList, warnings, err }
go
func (client *Client) GetSpaceServiceInstances(spaceGUID string, includeUserProvidedServices bool, filters ...Filter) ([]ServiceInstance, Warnings, error) { query := ConvertFilterParameters(filters) if includeUserProvidedServices { query.Add("return_user_provided_service_instances", "true") } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpaceServiceInstancesRequest, URIParams: map[string]string{"guid": spaceGUID}, Query: query, }) if err != nil { return nil, nil, err } var fullInstancesList []ServiceInstance warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error { if instance, ok := item.(ServiceInstance); ok { fullInstancesList = append(fullInstancesList, instance) } else { return ccerror.UnknownObjectInListError{ Expected: ServiceInstance{}, Unexpected: item, } } return nil }) return fullInstancesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaceServiceInstances", "(", "spaceGUID", "string", ",", "includeUserProvidedServices", "bool", ",", "filters", "...", "Filter", ")", "(", "[", "]", "ServiceInstance", ",", "Warnings", ",", "error", ")", "{", "query", ":=", "ConvertFilterParameters", "(", "filters", ")", "\n\n", "if", "includeUserProvidedServices", "{", "query", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpaceServiceInstancesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullInstancesList", "[", "]", "ServiceInstance", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "ServiceInstance", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "instance", ",", "ok", ":=", "item", ".", "(", "ServiceInstance", ")", ";", "ok", "{", "fullInstancesList", "=", "append", "(", "fullInstancesList", ",", "instance", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "ServiceInstance", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullInstancesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSpaceServiceInstances returns back a list of Service Instances based off // of the space and filters provided. User provided services will be included // if includeUserProvidedServices is set to true.
[ "GetSpaceServiceInstances", "returns", "back", "a", "list", "of", "Service", "Instances", "based", "off", "of", "the", "space", "and", "filters", "provided", ".", "User", "provided", "services", "will", "be", "included", "if", "includeUserProvidedServices", "is", "set", "to", "true", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L190-L220
train
cloudfoundry/cli
actor/v2action/service_instance_summary.go
getAndSetSharedInformation
func (actor Actor) getAndSetSharedInformation(summary *ServiceInstanceSummary, spaceGUID string) (Warnings, error) { var ( warnings Warnings err error ) // Part of determining if a service instance is shareable, we need to find // out if the service_instance_sharing feature flag is enabled featureFlags, featureFlagsWarnings, featureFlagsErr := actor.CloudControllerClient.GetConfigFeatureFlags() allWarnings := Warnings(featureFlagsWarnings) if featureFlagsErr != nil { return allWarnings, featureFlagsErr } for _, flag := range featureFlags { if flag.Name == string(constant.FeatureFlagServiceInstanceSharing) { summary.ServiceInstanceSharingFeatureFlag = flag.Enabled } } // Service instance is shared from if: // 1. the source space of the service instance is empty (API returns json null) // 2. the targeted space is not the same as the source space of the service instance AND // we call the shared_from url and it returns a non-empty resource if summary.ServiceInstance.SpaceGUID == "" || summary.ServiceInstance.SpaceGUID != spaceGUID { summary.ServiceInstanceSharedFrom, warnings, err = actor.GetServiceInstanceSharedFromByServiceInstance(summary.ServiceInstance.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { // if the API version does not support service instance sharing, ignore the 404 if _, ok := err.(ccerror.ResourceNotFoundError); !ok { return allWarnings, err } } if summary.ServiceInstanceSharedFrom.SpaceGUID != "" { summary.ServiceInstanceShareType = ServiceInstanceIsSharedFrom } else { summary.ServiceInstanceShareType = ServiceInstanceIsNotShared } return allWarnings, nil } // Service instance is shared to if: // the targeted space is the same as the source space of the service instance AND // we call the shared_to url and get a non-empty list summary.ServiceInstanceSharedTos, warnings, err = actor.GetServiceInstanceSharedTosByServiceInstance(summary.ServiceInstance.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { // if the API version does not support service instance sharing, ignore the 404 if _, ok := err.(ccerror.ResourceNotFoundError); !ok { return allWarnings, err } } if len(summary.ServiceInstanceSharedTos) > 0 { summary.ServiceInstanceShareType = ServiceInstanceIsSharedTo } else { summary.ServiceInstanceShareType = ServiceInstanceIsNotShared } return allWarnings, nil }
go
func (actor Actor) getAndSetSharedInformation(summary *ServiceInstanceSummary, spaceGUID string) (Warnings, error) { var ( warnings Warnings err error ) // Part of determining if a service instance is shareable, we need to find // out if the service_instance_sharing feature flag is enabled featureFlags, featureFlagsWarnings, featureFlagsErr := actor.CloudControllerClient.GetConfigFeatureFlags() allWarnings := Warnings(featureFlagsWarnings) if featureFlagsErr != nil { return allWarnings, featureFlagsErr } for _, flag := range featureFlags { if flag.Name == string(constant.FeatureFlagServiceInstanceSharing) { summary.ServiceInstanceSharingFeatureFlag = flag.Enabled } } // Service instance is shared from if: // 1. the source space of the service instance is empty (API returns json null) // 2. the targeted space is not the same as the source space of the service instance AND // we call the shared_from url and it returns a non-empty resource if summary.ServiceInstance.SpaceGUID == "" || summary.ServiceInstance.SpaceGUID != spaceGUID { summary.ServiceInstanceSharedFrom, warnings, err = actor.GetServiceInstanceSharedFromByServiceInstance(summary.ServiceInstance.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { // if the API version does not support service instance sharing, ignore the 404 if _, ok := err.(ccerror.ResourceNotFoundError); !ok { return allWarnings, err } } if summary.ServiceInstanceSharedFrom.SpaceGUID != "" { summary.ServiceInstanceShareType = ServiceInstanceIsSharedFrom } else { summary.ServiceInstanceShareType = ServiceInstanceIsNotShared } return allWarnings, nil } // Service instance is shared to if: // the targeted space is the same as the source space of the service instance AND // we call the shared_to url and get a non-empty list summary.ServiceInstanceSharedTos, warnings, err = actor.GetServiceInstanceSharedTosByServiceInstance(summary.ServiceInstance.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { // if the API version does not support service instance sharing, ignore the 404 if _, ok := err.(ccerror.ResourceNotFoundError); !ok { return allWarnings, err } } if len(summary.ServiceInstanceSharedTos) > 0 { summary.ServiceInstanceShareType = ServiceInstanceIsSharedTo } else { summary.ServiceInstanceShareType = ServiceInstanceIsNotShared } return allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "getAndSetSharedInformation", "(", "summary", "*", "ServiceInstanceSummary", ",", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "var", "(", "warnings", "Warnings", "\n", "err", "error", "\n", ")", "\n\n", "// Part of determining if a service instance is shareable, we need to find", "// out if the service_instance_sharing feature flag is enabled", "featureFlags", ",", "featureFlagsWarnings", ",", "featureFlagsErr", ":=", "actor", ".", "CloudControllerClient", ".", "GetConfigFeatureFlags", "(", ")", "\n", "allWarnings", ":=", "Warnings", "(", "featureFlagsWarnings", ")", "\n", "if", "featureFlagsErr", "!=", "nil", "{", "return", "allWarnings", ",", "featureFlagsErr", "\n", "}", "\n\n", "for", "_", ",", "flag", ":=", "range", "featureFlags", "{", "if", "flag", ".", "Name", "==", "string", "(", "constant", ".", "FeatureFlagServiceInstanceSharing", ")", "{", "summary", ".", "ServiceInstanceSharingFeatureFlag", "=", "flag", ".", "Enabled", "\n", "}", "\n", "}", "\n\n", "// Service instance is shared from if:", "// 1. the source space of the service instance is empty (API returns json null)", "// 2. the targeted space is not the same as the source space of the service instance AND", "// we call the shared_from url and it returns a non-empty resource", "if", "summary", ".", "ServiceInstance", ".", "SpaceGUID", "==", "\"", "\"", "||", "summary", ".", "ServiceInstance", ".", "SpaceGUID", "!=", "spaceGUID", "{", "summary", ".", "ServiceInstanceSharedFrom", ",", "warnings", ",", "err", "=", "actor", ".", "GetServiceInstanceSharedFromByServiceInstance", "(", "summary", ".", "ServiceInstance", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "// if the API version does not support service instance sharing, ignore the 404", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "!", "ok", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n", "}", "\n\n", "if", "summary", ".", "ServiceInstanceSharedFrom", ".", "SpaceGUID", "!=", "\"", "\"", "{", "summary", ".", "ServiceInstanceShareType", "=", "ServiceInstanceIsSharedFrom", "\n", "}", "else", "{", "summary", ".", "ServiceInstanceShareType", "=", "ServiceInstanceIsNotShared", "\n", "}", "\n\n", "return", "allWarnings", ",", "nil", "\n", "}", "\n\n", "// Service instance is shared to if:", "// the targeted space is the same as the source space of the service instance AND", "// we call the shared_to url and get a non-empty list", "summary", ".", "ServiceInstanceSharedTos", ",", "warnings", ",", "err", "=", "actor", ".", "GetServiceInstanceSharedTosByServiceInstance", "(", "summary", ".", "ServiceInstance", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "// if the API version does not support service instance sharing, ignore the 404", "if", "_", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "ResourceNotFoundError", ")", ";", "!", "ok", "{", "return", "allWarnings", ",", "err", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "summary", ".", "ServiceInstanceSharedTos", ")", ">", "0", "{", "summary", ".", "ServiceInstanceShareType", "=", "ServiceInstanceIsSharedTo", "\n", "}", "else", "{", "summary", ".", "ServiceInstanceShareType", "=", "ServiceInstanceIsNotShared", "\n", "}", "\n\n", "return", "allWarnings", ",", "nil", "\n", "}" ]
// getAndSetSharedInformation gets a service instance's shared from or shared to information,
[ "getAndSetSharedInformation", "gets", "a", "service", "instance", "s", "shared", "from", "or", "shared", "to", "information" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_instance_summary.go#L106-L168
train
cloudfoundry/cli
actor/v3action/package.go
GetApplicationPackages
func (actor *Actor) GetApplicationPackages(appName string, spaceGUID string) ([]Package, Warnings, error) { app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return nil, allWarnings, err } ccv3Packages, warnings, err := actor.CloudControllerClient.GetPackages( ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}}, ) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } var packages []Package for _, ccv3Package := range ccv3Packages { packages = append(packages, Package(ccv3Package)) } return packages, allWarnings, nil }
go
func (actor *Actor) GetApplicationPackages(appName string, spaceGUID string) ([]Package, Warnings, error) { app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID) if err != nil { return nil, allWarnings, err } ccv3Packages, warnings, err := actor.CloudControllerClient.GetPackages( ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}}, ) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } var packages []Package for _, ccv3Package := range ccv3Packages { packages = append(packages, Package(ccv3Package)) } return packages, allWarnings, nil }
[ "func", "(", "actor", "*", "Actor", ")", "GetApplicationPackages", "(", "appName", "string", ",", "spaceGUID", "string", ")", "(", "[", "]", "Package", ",", "Warnings", ",", "error", ")", "{", "app", ",", "allWarnings", ",", "err", ":=", "actor", ".", "GetApplicationByNameAndSpace", "(", "appName", ",", "spaceGUID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "ccv3Packages", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetPackages", "(", "ccv3", ".", "Query", "{", "Key", ":", "ccv3", ".", "AppGUIDFilter", ",", "Values", ":", "[", "]", "string", "{", "app", ".", "GUID", "}", "}", ",", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "var", "packages", "[", "]", "Package", "\n", "for", "_", ",", "ccv3Package", ":=", "range", "ccv3Packages", "{", "packages", "=", "append", "(", "packages", ",", "Package", "(", "ccv3Package", ")", ")", "\n", "}", "\n\n", "return", "packages", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetApplicationPackages returns a list of package of an app.
[ "GetApplicationPackages", "returns", "a", "list", "of", "package", "of", "an", "app", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/package.go#L133-L153
train
cloudfoundry/cli
actor/v3action/package.go
PollPackage
func (actor Actor) PollPackage(pkg Package) (Package, Warnings, error) { var allWarnings Warnings for pkg.State != constant.PackageReady && pkg.State != constant.PackageFailed && pkg.State != constant.PackageExpired { time.Sleep(actor.Config.PollingInterval()) ccPkg, warnings, err := actor.CloudControllerClient.GetPackage(pkg.GUID) log.WithFields(log.Fields{ "package_guid": pkg.GUID, "state": pkg.State, }).Debug("polling package state") allWarnings = append(allWarnings, warnings...) if err != nil { return Package{}, allWarnings, err } pkg = Package(ccPkg) } if pkg.State == constant.PackageFailed { return Package{}, allWarnings, actionerror.PackageProcessingFailedError{} } else if pkg.State == constant.PackageExpired { return Package{}, allWarnings, actionerror.PackageProcessingExpiredError{} } return pkg, allWarnings, nil }
go
func (actor Actor) PollPackage(pkg Package) (Package, Warnings, error) { var allWarnings Warnings for pkg.State != constant.PackageReady && pkg.State != constant.PackageFailed && pkg.State != constant.PackageExpired { time.Sleep(actor.Config.PollingInterval()) ccPkg, warnings, err := actor.CloudControllerClient.GetPackage(pkg.GUID) log.WithFields(log.Fields{ "package_guid": pkg.GUID, "state": pkg.State, }).Debug("polling package state") allWarnings = append(allWarnings, warnings...) if err != nil { return Package{}, allWarnings, err } pkg = Package(ccPkg) } if pkg.State == constant.PackageFailed { return Package{}, allWarnings, actionerror.PackageProcessingFailedError{} } else if pkg.State == constant.PackageExpired { return Package{}, allWarnings, actionerror.PackageProcessingExpiredError{} } return pkg, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "PollPackage", "(", "pkg", "Package", ")", "(", "Package", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n\n", "for", "pkg", ".", "State", "!=", "constant", ".", "PackageReady", "&&", "pkg", ".", "State", "!=", "constant", ".", "PackageFailed", "&&", "pkg", ".", "State", "!=", "constant", ".", "PackageExpired", "{", "time", ".", "Sleep", "(", "actor", ".", "Config", ".", "PollingInterval", "(", ")", ")", "\n", "ccPkg", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetPackage", "(", "pkg", ".", "GUID", ")", "\n", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "pkg", ".", "GUID", ",", "\"", "\"", ":", "pkg", ".", "State", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Package", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "pkg", "=", "Package", "(", "ccPkg", ")", "\n", "}", "\n\n", "if", "pkg", ".", "State", "==", "constant", ".", "PackageFailed", "{", "return", "Package", "{", "}", ",", "allWarnings", ",", "actionerror", ".", "PackageProcessingFailedError", "{", "}", "\n", "}", "else", "if", "pkg", ".", "State", "==", "constant", ".", "PackageExpired", "{", "return", "Package", "{", "}", ",", "allWarnings", ",", "actionerror", ".", "PackageProcessingExpiredError", "{", "}", "\n", "}", "\n\n", "return", "pkg", ",", "allWarnings", ",", "nil", "\n", "}" ]
// PollPackage returns a package of an app.
[ "PollPackage", "returns", "a", "package", "of", "an", "app", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/package.go#L183-L209
train
cloudfoundry/cli
integration/helpers/login.go
GetCredentials
func GetCredentials() (string, string) { username := os.Getenv("CF_INT_USERNAME") if username == "" { username = "admin" } password := os.Getenv("CF_INT_PASSWORD") if password == "" { password = "admin" } return username, password }
go
func GetCredentials() (string, string) { username := os.Getenv("CF_INT_USERNAME") if username == "" { username = "admin" } password := os.Getenv("CF_INT_PASSWORD") if password == "" { password = "admin" } return username, password }
[ "func", "GetCredentials", "(", ")", "(", "string", ",", "string", ")", "{", "username", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "username", "==", "\"", "\"", "{", "username", "=", "\"", "\"", "\n", "}", "\n", "password", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "password", "==", "\"", "\"", "{", "password", "=", "\"", "\"", "\n", "}", "\n", "return", "username", ",", "password", "\n", "}" ]
// GetCredentials returns back the username and the password.
[ "GetCredentials", "returns", "back", "the", "username", "and", "the", "password", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/login.go#L83-L93
train
cloudfoundry/cli
integration/helpers/login.go
SkipIfOIDCCredentialsNotSet
func SkipIfOIDCCredentialsNotSet() (string, string) { oidcUsername := os.Getenv("CF_INT_OIDC_USERNAME") oidcPassword := os.Getenv("CF_INT_OIDC_PASSWORD") if oidcUsername == "" || oidcPassword == "" { Skip("CF_INT_OIDC_USERNAME or CF_INT_OIDC_PASSWORD is not set") } return oidcUsername, oidcPassword }
go
func SkipIfOIDCCredentialsNotSet() (string, string) { oidcUsername := os.Getenv("CF_INT_OIDC_USERNAME") oidcPassword := os.Getenv("CF_INT_OIDC_PASSWORD") if oidcUsername == "" || oidcPassword == "" { Skip("CF_INT_OIDC_USERNAME or CF_INT_OIDC_PASSWORD is not set") } return oidcUsername, oidcPassword }
[ "func", "SkipIfOIDCCredentialsNotSet", "(", ")", "(", "string", ",", "string", ")", "{", "oidcUsername", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "oidcPassword", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n\n", "if", "oidcUsername", "==", "\"", "\"", "||", "oidcPassword", "==", "\"", "\"", "{", "Skip", "(", "\"", "\"", ")", "\n", "}", "\n\n", "return", "oidcUsername", ",", "oidcPassword", "\n", "}" ]
// SkipIfOIDCCredentialsNotSet returns back the username and the password for // OIDC origin, or skips the test if those values are not set.
[ "SkipIfOIDCCredentialsNotSet", "returns", "back", "the", "username", "and", "the", "password", "for", "OIDC", "origin", "or", "skips", "the", "test", "if", "those", "values", "are", "not", "set", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/login.go#L97-L106
train
cloudfoundry/cli
actor/pushaction/domain.go
DefaultDomain
func (actor Actor) DefaultDomain(orgGUID string) (v2action.Domain, Warnings, error) { log.Infoln("getting org domains for org GUID:", orgGUID) // the domains object contains all the shared domains AND all domains private to this org domains, warnings, err := actor.V2Actor.GetOrganizationDomains(orgGUID) if err != nil { log.Errorln("searching for domains in org:", err) return v2action.Domain{}, Warnings(warnings), err } log.Debugf("filtering out internal domains from all found domains: %#v", domains) var externalDomains []v2action.Domain for _, d := range domains { if !d.Internal { externalDomains = append(externalDomains, d) } } if len(externalDomains) == 0 { log.Error("no domains found") return v2action.Domain{}, Warnings(warnings), actionerror.NoDomainsFoundError{OrganizationGUID: orgGUID} } log.Debugf("selecting first external domain as default domain: %#v", externalDomains) return externalDomains[0], Warnings(warnings), nil }
go
func (actor Actor) DefaultDomain(orgGUID string) (v2action.Domain, Warnings, error) { log.Infoln("getting org domains for org GUID:", orgGUID) // the domains object contains all the shared domains AND all domains private to this org domains, warnings, err := actor.V2Actor.GetOrganizationDomains(orgGUID) if err != nil { log.Errorln("searching for domains in org:", err) return v2action.Domain{}, Warnings(warnings), err } log.Debugf("filtering out internal domains from all found domains: %#v", domains) var externalDomains []v2action.Domain for _, d := range domains { if !d.Internal { externalDomains = append(externalDomains, d) } } if len(externalDomains) == 0 { log.Error("no domains found") return v2action.Domain{}, Warnings(warnings), actionerror.NoDomainsFoundError{OrganizationGUID: orgGUID} } log.Debugf("selecting first external domain as default domain: %#v", externalDomains) return externalDomains[0], Warnings(warnings), nil }
[ "func", "(", "actor", "Actor", ")", "DefaultDomain", "(", "orgGUID", "string", ")", "(", "v2action", ".", "Domain", ",", "Warnings", ",", "error", ")", "{", "log", ".", "Infoln", "(", "\"", "\"", ",", "orgGUID", ")", "\n", "// the domains object contains all the shared domains AND all domains private to this org", "domains", ",", "warnings", ",", "err", ":=", "actor", ".", "V2Actor", ".", "GetOrganizationDomains", "(", "orgGUID", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "v2action", ".", "Domain", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "domains", ")", "\n", "var", "externalDomains", "[", "]", "v2action", ".", "Domain", "\n\n", "for", "_", ",", "d", ":=", "range", "domains", "{", "if", "!", "d", ".", "Internal", "{", "externalDomains", "=", "append", "(", "externalDomains", ",", "d", ")", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "externalDomains", ")", "==", "0", "{", "log", ".", "Error", "(", "\"", "\"", ")", "\n", "return", "v2action", ".", "Domain", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "NoDomainsFoundError", "{", "OrganizationGUID", ":", "orgGUID", "}", "\n", "}", "\n\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "externalDomains", ")", "\n", "return", "externalDomains", "[", "0", "]", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// DefaultDomain looks up the shared and then private domains and returns back // the first one in the list as the default.
[ "DefaultDomain", "looks", "up", "the", "shared", "and", "then", "private", "domains", "and", "returns", "back", "the", "first", "one", "in", "the", "list", "as", "the", "default", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/domain.go#L11-L36
train