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
api/cloudcontroller/ccv2/space.go
UnmarshalJSON
func (space *Space) UnmarshalJSON(data []byte) error { var ccSpace struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` AllowSSH bool `json:"allow_ssh"` SpaceQuotaDefinitionGUID string `json:"space_quota_definition_guid"` OrganizationGUID string `json:"organization_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSpace) if err != nil { return err } space.GUID = ccSpace.Metadata.GUID space.Name = ccSpace.Entity.Name space.AllowSSH = ccSpace.Entity.AllowSSH space.SpaceQuotaDefinitionGUID = ccSpace.Entity.SpaceQuotaDefinitionGUID space.OrganizationGUID = ccSpace.Entity.OrganizationGUID return nil }
go
func (space *Space) UnmarshalJSON(data []byte) error { var ccSpace struct { Metadata internal.Metadata `json:"metadata"` Entity struct { Name string `json:"name"` AllowSSH bool `json:"allow_ssh"` SpaceQuotaDefinitionGUID string `json:"space_quota_definition_guid"` OrganizationGUID string `json:"organization_guid"` } `json:"entity"` } err := cloudcontroller.DecodeJSON(data, &ccSpace) if err != nil { return err } space.GUID = ccSpace.Metadata.GUID space.Name = ccSpace.Entity.Name space.AllowSSH = ccSpace.Entity.AllowSSH space.SpaceQuotaDefinitionGUID = ccSpace.Entity.SpaceQuotaDefinitionGUID space.OrganizationGUID = ccSpace.Entity.OrganizationGUID return nil }
[ "func", "(", "space", "*", "Space", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccSpace", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Name", "string", "`json:\"name\"`", "\n", "AllowSSH", "bool", "`json:\"allow_ssh\"`", "\n", "SpaceQuotaDefinitionGUID", "string", "`json:\"space_quota_definition_guid\"`", "\n", "OrganizationGUID", "string", "`json:\"organization_guid\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccSpace", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "space", ".", "GUID", "=", "ccSpace", ".", "Metadata", ".", "GUID", "\n", "space", ".", "Name", "=", "ccSpace", ".", "Entity", ".", "Name", "\n", "space", ".", "AllowSSH", "=", "ccSpace", ".", "Entity", ".", "AllowSSH", "\n", "space", ".", "SpaceQuotaDefinitionGUID", "=", "ccSpace", ".", "Entity", ".", "SpaceQuotaDefinitionGUID", "\n", "space", ".", "OrganizationGUID", "=", "ccSpace", ".", "Entity", ".", "OrganizationGUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Space response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Space", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L34-L55
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
CreateSpace
func (client *Client) CreateSpace(spaceName string, orgGUID string) (Space, Warnings, error) { requestBody := createSpaceRequestBody{ Name: spaceName, OrganizationGUID: orgGUID, } bodyBytes, _ := json.Marshal(requestBody) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostSpaceRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Space{}, nil, err } var space Space response := cloudcontroller.Response{ DecodeJSONResponseInto: &space, } err = client.connection.Make(request, &response) return space, response.Warnings, err }
go
func (client *Client) CreateSpace(spaceName string, orgGUID string) (Space, Warnings, error) { requestBody := createSpaceRequestBody{ Name: spaceName, OrganizationGUID: orgGUID, } bodyBytes, _ := json.Marshal(requestBody) request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostSpaceRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return Space{}, nil, err } var space Space response := cloudcontroller.Response{ DecodeJSONResponseInto: &space, } err = client.connection.Make(request, &response) return space, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateSpace", "(", "spaceName", "string", ",", "orgGUID", "string", ")", "(", "Space", ",", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "createSpaceRequestBody", "{", "Name", ":", "spaceName", ",", "OrganizationGUID", ":", "orgGUID", ",", "}", "\n\n", "bodyBytes", ",", "_", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostSpaceRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "Space", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "space", "Space", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "space", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "space", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateSpace creates a new space with the provided spaceName in the org with // the provided orgGUID.
[ "CreateSpace", "creates", "a", "new", "space", "with", "the", "provided", "spaceName", "in", "the", "org", "with", "the", "provided", "orgGUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L64-L89
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
DeleteSpace
func (client *Client) DeleteSpace(guid string) (Job, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceRequest, URIParams: Params{"space_guid": guid}, Query: url.Values{ "recursive": {"true"}, "async": {"true"}, }, }) if err != nil { return Job{}, nil, err } var job Job response := cloudcontroller.Response{ DecodeJSONResponseInto: &job, } err = client.connection.Make(request, &response) return job, response.Warnings, err }
go
func (client *Client) DeleteSpace(guid string) (Job, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteSpaceRequest, URIParams: Params{"space_guid": guid}, Query: url.Values{ "recursive": {"true"}, "async": {"true"}, }, }) if err != nil { return Job{}, nil, err } var job Job response := cloudcontroller.Response{ DecodeJSONResponseInto: &job, } err = client.connection.Make(request, &response) return job, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteSpace", "(", "guid", "string", ")", "(", "Job", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteSpaceRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "Query", ":", "url", ".", "Values", "{", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "\"", "\"", ":", "{", "\"", "\"", "}", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Job", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "job", "Job", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "job", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "job", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteSpace deletes the Space associated with the provided // GUID. It will return the Cloud Controller job that is assigned to the // Space deletion.
[ "DeleteSpace", "deletes", "the", "Space", "associated", "with", "the", "provided", "GUID", ".", "It", "will", "return", "the", "Cloud", "Controller", "job", "that", "is", "assigned", "to", "the", "Space", "deletion", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L94-L114
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
GetSecurityGroupSpaces
func (client *Client) GetSecurityGroupSpaces(securityGroupGUID string) ([]Space, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupSpacesRequest, URIParams: map[string]string{"security_group_guid": securityGroupGUID}, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
go
func (client *Client) GetSecurityGroupSpaces(securityGroupGUID string) ([]Space, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSecurityGroupSpacesRequest, URIParams: map[string]string{"security_group_guid": securityGroupGUID}, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSecurityGroupSpaces", "(", "securityGroupGUID", "string", ")", "(", "[", "]", "Space", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSecurityGroupSpacesRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "securityGroupGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullSpacesList", "[", "]", "Space", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Space", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "space", ",", "ok", ":=", "item", ".", "(", "Space", ")", ";", "ok", "{", "fullSpacesList", "=", "append", "(", "fullSpacesList", ",", "space", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Space", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullSpacesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSecurityGroupSpaces returns a list of Spaces based on the provided // SecurityGroup GUID.
[ "GetSecurityGroupSpaces", "returns", "a", "list", "of", "Spaces", "based", "on", "the", "provided", "SecurityGroup", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L118-L141
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
GetSpaces
func (client *Client) GetSpaces(filters ...Filter) ([]Space, Warnings, error) { params := ConvertFilterParameters(filters) params.Add("order-by", "name") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpacesRequest, Query: params, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
go
func (client *Client) GetSpaces(filters ...Filter) ([]Space, Warnings, error) { params := ConvertFilterParameters(filters) params.Add("order-by", "name") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetSpacesRequest, Query: params, }) if err != nil { return nil, nil, err } var fullSpacesList []Space warnings, err := client.paginate(request, Space{}, func(item interface{}) error { if space, ok := item.(Space); ok { fullSpacesList = append(fullSpacesList, space) } else { return ccerror.UnknownObjectInListError{ Expected: Space{}, Unexpected: item, } } return nil }) return fullSpacesList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetSpaces", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Space", ",", "Warnings", ",", "error", ")", "{", "params", ":=", "ConvertFilterParameters", "(", "filters", ")", "\n", "params", ".", "Add", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetSpacesRequest", ",", "Query", ":", "params", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullSpacesList", "[", "]", "Space", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Space", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "space", ",", "ok", ":=", "item", ".", "(", "Space", ")", ";", "ok", "{", "fullSpacesList", "=", "append", "(", "fullSpacesList", ",", "space", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Space", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullSpacesList", ",", "warnings", ",", "err", "\n", "}" ]
// GetSpaces returns a list of Spaces based off of the provided filters.
[ "GetSpaces", "returns", "a", "list", "of", "Spaces", "based", "off", "of", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L171-L196
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
UpdateSpaceDeveloper
func (client *Client) UpdateSpaceDeveloper(spaceGUID string, uaaID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceDeveloperRequest, URIParams: map[string]string{ "space_guid": spaceGUID, "developer_guid": uaaID, }, }) if err != nil { return Warnings{}, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) UpdateSpaceDeveloper(spaceGUID string, uaaID string) (Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceDeveloperRequest, URIParams: map[string]string{ "space_guid": spaceGUID, "developer_guid": uaaID, }, }) if err != nil { return Warnings{}, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateSpaceDeveloper", "(", "spaceGUID", "string", ",", "uaaID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutSpaceDeveloperRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "spaceGUID", ",", "\"", "\"", ":", "uaaID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Warnings", "{", "}", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateSpaceDeveloper grants the space developer role to the user or client // associated with the given UAA ID.
[ "UpdateSpaceDeveloper", "grants", "the", "space", "developer", "role", "to", "the", "user", "or", "client", "associated", "with", "the", "given", "UAA", "ID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L200-L215
train
cloudfoundry/cli
api/cloudcontroller/ccv2/space.go
UpdateSpaceManagerByUsername
func (client *Client) UpdateSpaceManagerByUsername(spaceGUID string, username string) (Warnings, error) { requestBody := updateRoleRequestBody{ Username: username, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return Warnings{}, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceManagerByUsernameRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Body: bytes.NewReader(bodyBytes), }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) UpdateSpaceManagerByUsername(spaceGUID string, username string) (Warnings, error) { requestBody := updateRoleRequestBody{ Username: username, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return Warnings{}, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PutSpaceManagerByUsernameRequest, URIParams: map[string]string{"space_guid": spaceGUID}, Body: bytes.NewReader(bodyBytes), }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateSpaceManagerByUsername", "(", "spaceGUID", "string", ",", "username", "string", ")", "(", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "updateRoleRequestBody", "{", "Username", ":", "username", ",", "}", "\n\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Warnings", "{", "}", ",", "err", "\n", "}", "\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PutSpaceManagerByUsernameRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "spaceGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateSpaceManagerByUsername grants the given username the space manager role.
[ "UpdateSpaceManagerByUsername", "grants", "the", "given", "username", "the", "space", "manager", "role", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space.go#L267-L291
train
cloudfoundry/cli
api/uaa/info.go
NewInfo
func NewInfo(link string) Info { var info Info info.Links.Login = link info.Links.UAA = link return info }
go
func NewInfo(link string) Info { var info Info info.Links.Login = link info.Links.UAA = link return info }
[ "func", "NewInfo", "(", "link", "string", ")", "Info", "{", "var", "info", "Info", "\n", "info", ".", "Links", ".", "Login", "=", "link", "\n", "info", ".", "Links", ".", "UAA", "=", "link", "\n", "return", "info", "\n", "}" ]
// NewInfo returns back a new
[ "NewInfo", "returns", "back", "a", "new" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/info.go#L35-L40
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_key.go
CreateServiceKey
func (client *Client) CreateServiceKey(serviceInstanceGUID string, keyName string, parameters map[string]interface{}) (ServiceKey, Warnings, error) { requestBody := serviceKeyRequestBody{ ServiceInstanceGUID: serviceInstanceGUID, Name: keyName, Parameters: parameters, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceKey{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceKeyRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return ServiceKey{}, nil, err } var serviceKey ServiceKey response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceKey, } err = client.connection.Make(request, &response) return serviceKey, response.Warnings, err }
go
func (client *Client) CreateServiceKey(serviceInstanceGUID string, keyName string, parameters map[string]interface{}) (ServiceKey, Warnings, error) { requestBody := serviceKeyRequestBody{ ServiceInstanceGUID: serviceInstanceGUID, Name: keyName, Parameters: parameters, } bodyBytes, err := json.Marshal(requestBody) if err != nil { return ServiceKey{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostServiceKeyRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return ServiceKey{}, nil, err } var serviceKey ServiceKey response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceKey, } err = client.connection.Make(request, &response) return serviceKey, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateServiceKey", "(", "serviceInstanceGUID", "string", ",", "keyName", "string", ",", "parameters", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "ServiceKey", ",", "Warnings", ",", "error", ")", "{", "requestBody", ":=", "serviceKeyRequestBody", "{", "ServiceInstanceGUID", ":", "serviceInstanceGUID", ",", "Name", ":", "keyName", ",", "Parameters", ":", "parameters", ",", "}", "\n\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "requestBody", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceKey", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostServiceKeyRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceKey", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "serviceKey", "ServiceKey", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceKey", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "serviceKey", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateServiceKey creates a new service key using the provided name and // parameters for the requested service instance.
[ "CreateServiceKey", "creates", "a", "new", "service", "key", "using", "the", "provided", "name", "and", "parameters", "for", "the", "requested", "service", "instance", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_key.go#L56-L83
train
cloudfoundry/cli
actor/pluginaction/install.go
DownloadExecutableBinaryFromURL
func (actor Actor) DownloadExecutableBinaryFromURL(pluginURL string, tempPluginDir string, proxyReader plugin.ProxyReader) (string, error) { tempFile, err := makeTempFile(tempPluginDir) if err != nil { return "", err } err = actor.client.DownloadPlugin(pluginURL, tempFile.Name(), proxyReader) if err != nil { return "", err } return tempFile.Name(), nil }
go
func (actor Actor) DownloadExecutableBinaryFromURL(pluginURL string, tempPluginDir string, proxyReader plugin.ProxyReader) (string, error) { tempFile, err := makeTempFile(tempPluginDir) if err != nil { return "", err } err = actor.client.DownloadPlugin(pluginURL, tempFile.Name(), proxyReader) if err != nil { return "", err } return tempFile.Name(), nil }
[ "func", "(", "actor", "Actor", ")", "DownloadExecutableBinaryFromURL", "(", "pluginURL", "string", ",", "tempPluginDir", "string", ",", "proxyReader", "plugin", ".", "ProxyReader", ")", "(", "string", ",", "error", ")", "{", "tempFile", ",", "err", ":=", "makeTempFile", "(", "tempPluginDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "err", "=", "actor", ".", "client", ".", "DownloadPlugin", "(", "pluginURL", ",", "tempFile", ".", "Name", "(", ")", ",", "proxyReader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n\n", "return", "tempFile", ".", "Name", "(", ")", ",", "nil", "\n", "}" ]
// DownloadExecutableBinaryFromURL fetches a plugin binary from the specified // URL, if it exists.
[ "DownloadExecutableBinaryFromURL", "fetches", "a", "plugin", "binary", "from", "the", "specified", "URL", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/install.go#L63-L75
train
cloudfoundry/cli
actor/pluginaction/install.go
FileExists
func (actor Actor) FileExists(path string) bool { _, err := os.Stat(path) return err == nil }
go
func (actor Actor) FileExists(path string) bool { _, err := os.Stat(path) return err == nil }
[ "func", "(", "actor", "Actor", ")", "FileExists", "(", "path", "string", ")", "bool", "{", "_", ",", "err", ":=", "os", ".", "Stat", "(", "path", ")", "\n", "return", "err", "==", "nil", "\n", "}" ]
// FileExists returns true if the file exists. It returns false if the file // doesn't exist or there is an error checking.
[ "FileExists", "returns", "true", "if", "the", "file", "exists", ".", "It", "returns", "false", "if", "the", "file", "doesn", "t", "exist", "or", "there", "is", "an", "error", "checking", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/install.go#L79-L82
train
cloudfoundry/cli
util/configv3/plugins_config.go
PluginCommands
func (p Plugin) PluginCommands() []PluginCommand { sort.Slice(p.Commands, func(i, j int) bool { return strings.ToLower(p.Commands[i].Name) < strings.ToLower(p.Commands[j].Name) }) return p.Commands }
go
func (p Plugin) PluginCommands() []PluginCommand { sort.Slice(p.Commands, func(i, j int) bool { return strings.ToLower(p.Commands[i].Name) < strings.ToLower(p.Commands[j].Name) }) return p.Commands }
[ "func", "(", "p", "Plugin", ")", "PluginCommands", "(", ")", "[", "]", "PluginCommand", "{", "sort", ".", "Slice", "(", "p", ".", "Commands", ",", "func", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "strings", ".", "ToLower", "(", "p", ".", "Commands", "[", "i", "]", ".", "Name", ")", "<", "strings", ".", "ToLower", "(", "p", ".", "Commands", "[", "j", "]", ".", "Name", ")", "\n", "}", ")", "\n", "return", "p", ".", "Commands", "\n", "}" ]
// PluginCommands returns the plugin's commands sorted by command name.
[ "PluginCommands", "returns", "the", "plugin", "s", "commands", "sorted", "by", "command", "name", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L43-L48
train
cloudfoundry/cli
util/configv3/plugins_config.go
String
func (v PluginVersion) String() string { if v.Major == 0 && v.Minor == 0 && v.Build == 0 { return notApplicable } return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Build) }
go
func (v PluginVersion) String() string { if v.Major == 0 && v.Minor == 0 && v.Build == 0 { return notApplicable } return fmt.Sprintf("%d.%d.%d", v.Major, v.Minor, v.Build) }
[ "func", "(", "v", "PluginVersion", ")", "String", "(", ")", "string", "{", "if", "v", ".", "Major", "==", "0", "&&", "v", ".", "Minor", "==", "0", "&&", "v", ".", "Build", "==", "0", "{", "return", "notApplicable", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "v", ".", "Major", ",", "v", ".", "Minor", ",", "v", ".", "Build", ")", "\n", "}" ]
// String returns the plugin's version in the format x.y.z.
[ "String", "returns", "the", "plugin", "s", "version", "in", "the", "format", "x", ".", "y", ".", "z", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L58-L63
train
cloudfoundry/cli
util/configv3/plugins_config.go
CommandName
func (c PluginCommand) CommandName() string { if c.Name != "" && c.Alias != "" { return fmt.Sprintf("%s, %s", c.Name, c.Alias) } return c.Name }
go
func (c PluginCommand) CommandName() string { if c.Name != "" && c.Alias != "" { return fmt.Sprintf("%s, %s", c.Name, c.Alias) } return c.Name }
[ "func", "(", "c", "PluginCommand", ")", "CommandName", "(", ")", "string", "{", "if", "c", ".", "Name", "!=", "\"", "\"", "&&", "c", ".", "Alias", "!=", "\"", "\"", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "c", ".", "Name", ",", "c", ".", "Alias", ")", "\n", "}", "\n", "return", "c", ".", "Name", "\n", "}" ]
// CommandName returns the name of the plugin. The name is concatenated with // alias if alias is specified.
[ "CommandName", "returns", "the", "name", "of", "the", "plugin", ".", "The", "name", "is", "concatenated", "with", "alias", "if", "alias", "is", "specified", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L75-L80
train
cloudfoundry/cli
util/configv3/plugins_config.go
AddPlugin
func (config *Config) AddPlugin(plugin Plugin) { config.pluginsConfig.Plugins[plugin.Name] = plugin }
go
func (config *Config) AddPlugin(plugin Plugin) { config.pluginsConfig.Plugins[plugin.Name] = plugin }
[ "func", "(", "config", "*", "Config", ")", "AddPlugin", "(", "plugin", "Plugin", ")", "{", "config", ".", "pluginsConfig", ".", "Plugins", "[", "plugin", ".", "Name", "]", "=", "plugin", "\n", "}" ]
// AddPlugin adds the specified plugin to PluginsConfig
[ "AddPlugin", "adds", "the", "specified", "plugin", "to", "PluginsConfig" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L89-L91
train
cloudfoundry/cli
util/configv3/plugins_config.go
GetPlugin
func (config *Config) GetPlugin(pluginName string) (Plugin, bool) { plugin, exists := config.pluginsConfig.Plugins[pluginName] return plugin, exists }
go
func (config *Config) GetPlugin(pluginName string) (Plugin, bool) { plugin, exists := config.pluginsConfig.Plugins[pluginName] return plugin, exists }
[ "func", "(", "config", "*", "Config", ")", "GetPlugin", "(", "pluginName", "string", ")", "(", "Plugin", ",", "bool", ")", "{", "plugin", ",", "exists", ":=", "config", ".", "pluginsConfig", ".", "Plugins", "[", "pluginName", "]", "\n", "return", "plugin", ",", "exists", "\n", "}" ]
// GetPlugin returns the requested plugin and true if it exists.
[ "GetPlugin", "returns", "the", "requested", "plugin", "and", "true", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L98-L101
train
cloudfoundry/cli
util/configv3/plugins_config.go
GetPluginCaseInsensitive
func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) { for name, plugin := range config.pluginsConfig.Plugins { if strings.EqualFold(name, pluginName) { return plugin, true } } return Plugin{}, false }
go
func (config *Config) GetPluginCaseInsensitive(pluginName string) (Plugin, bool) { for name, plugin := range config.pluginsConfig.Plugins { if strings.EqualFold(name, pluginName) { return plugin, true } } return Plugin{}, false }
[ "func", "(", "config", "*", "Config", ")", "GetPluginCaseInsensitive", "(", "pluginName", "string", ")", "(", "Plugin", ",", "bool", ")", "{", "for", "name", ",", "plugin", ":=", "range", "config", ".", "pluginsConfig", ".", "Plugins", "{", "if", "strings", ".", "EqualFold", "(", "name", ",", "pluginName", ")", "{", "return", "plugin", ",", "true", "\n", "}", "\n", "}", "\n\n", "return", "Plugin", "{", "}", ",", "false", "\n", "}" ]
// GetPluginCaseInsensitive finds the first matching plugin name case // insensitive and returns true if it exists.
[ "GetPluginCaseInsensitive", "finds", "the", "first", "matching", "plugin", "name", "case", "insensitive", "and", "returns", "true", "if", "it", "exists", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L105-L113
train
cloudfoundry/cli
util/configv3/plugins_config.go
RemovePlugin
func (config *Config) RemovePlugin(pluginName string) { delete(config.pluginsConfig.Plugins, pluginName) }
go
func (config *Config) RemovePlugin(pluginName string) { delete(config.pluginsConfig.Plugins, pluginName) }
[ "func", "(", "config", "*", "Config", ")", "RemovePlugin", "(", "pluginName", "string", ")", "{", "delete", "(", "config", ".", "pluginsConfig", ".", "Plugins", ",", "pluginName", ")", "\n", "}" ]
// RemovePlugin removes the specified plugin from PluginsConfig idempotently
[ "RemovePlugin", "removes", "the", "specified", "plugin", "from", "PluginsConfig", "idempotently" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L139-L141
train
cloudfoundry/cli
util/configv3/plugins_config.go
WritePluginConfig
func (config *Config) WritePluginConfig() error { // Marshal JSON rawConfig, err := json.MarshalIndent(config.pluginsConfig, "", " ") if err != nil { return err } pluginFileDir := filepath.Join(config.PluginHome()) err = os.MkdirAll(pluginFileDir, 0700) if err != nil { return err } // Write to file return ioutil.WriteFile(filepath.Join(pluginFileDir, "config.json"), rawConfig, 0600) }
go
func (config *Config) WritePluginConfig() error { // Marshal JSON rawConfig, err := json.MarshalIndent(config.pluginsConfig, "", " ") if err != nil { return err } pluginFileDir := filepath.Join(config.PluginHome()) err = os.MkdirAll(pluginFileDir, 0700) if err != nil { return err } // Write to file return ioutil.WriteFile(filepath.Join(pluginFileDir, "config.json"), rawConfig, 0600) }
[ "func", "(", "config", "*", "Config", ")", "WritePluginConfig", "(", ")", "error", "{", "// Marshal JSON", "rawConfig", ",", "err", ":=", "json", ".", "MarshalIndent", "(", "config", ".", "pluginsConfig", ",", "\"", "\"", ",", "\"", "\"", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "pluginFileDir", ":=", "filepath", ".", "Join", "(", "config", ".", "PluginHome", "(", ")", ")", "\n", "err", "=", "os", ".", "MkdirAll", "(", "pluginFileDir", ",", "0700", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// Write to file", "return", "ioutil", ".", "WriteFile", "(", "filepath", ".", "Join", "(", "pluginFileDir", ",", "\"", "\"", ")", ",", "rawConfig", ",", "0600", ")", "\n", "}" ]
// WritePluginConfig writes the plugin config to config.json in the plugin home // directory.
[ "WritePluginConfig", "writes", "the", "plugin", "config", "to", "config", ".", "json", "in", "the", "plugin", "home", "directory", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugins_config.go#L145-L160
train
cloudfoundry/cli
actor/pluginaction/actor.go
NewActor
func NewActor(config Config, client PluginClient) *Actor { return &Actor{config: config, client: client} }
go
func NewActor(config Config, client PluginClient) *Actor { return &Actor{config: config, client: client} }
[ "func", "NewActor", "(", "config", "Config", ",", "client", "PluginClient", ")", "*", "Actor", "{", "return", "&", "Actor", "{", "config", ":", "config", ",", "client", ":", "client", "}", "\n", "}" ]
// NewActor returns a pluginaction Actor
[ "NewActor", "returns", "a", "pluginaction", "Actor" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/actor.go#L11-L13
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
DeleteService
func (client *Client) DeleteService(serviceGUID string, purge bool) (Warnings, error) { queryParams := url.Values{} queryParams.Set("purge", strconv.FormatBool(purge)) queryParams.Set("async", "true") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceRequest, Query: queryParams, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
go
func (client *Client) DeleteService(serviceGUID string, purge bool) (Warnings, error) { queryParams := url.Values{} queryParams.Set("purge", strconv.FormatBool(purge)) queryParams.Set("async", "true") request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteServiceRequest, Query: queryParams, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteService", "(", "serviceGUID", "string", ",", "purge", "bool", ")", "(", "Warnings", ",", "error", ")", "{", "queryParams", ":=", "url", ".", "Values", "{", "}", "\n", "queryParams", ".", "Set", "(", "\"", "\"", ",", "strconv", ".", "FormatBool", "(", "purge", ")", ")", "\n", "queryParams", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteServiceRequest", ",", "Query", ":", "queryParams", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "serviceGUID", "}", ",", "}", ")", "\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", "}" ]
// DeleteService deletes the service with the given GUID, and returns any errors and warnings.
[ "DeleteService", "deletes", "the", "service", "with", "the", "given", "GUID", "and", "returns", "any", "errors", "and", "warnings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L31-L49
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
UnmarshalJSON
func (service *Service) UnmarshalJSON(data []byte) error { var ccService struct { Metadata internal.Metadata Entity struct { Label string `json:"label"` Description string `json:"description"` DocumentationURL string `json:"documentation_url"` ServiceBrokerName string `json:"service_broker_name"` Extra string `json:"extra"` } } err := cloudcontroller.DecodeJSON(data, &ccService) if err != nil { return err } service.GUID = ccService.Metadata.GUID service.Label = ccService.Entity.Label service.Description = ccService.Entity.Description service.DocumentationURL = ccService.Entity.DocumentationURL service.ServiceBrokerName = ccService.Entity.ServiceBrokerName // We explicitly unmarshal the Extra field to type string because CC returns // a stringified JSON object ONLY for the 'extra' key (see test stub JSON // response). This unmarshal strips escaped quotes, at which time we can then // unmarshal into the ServiceExtra object. // If 'extra' is null or not provided, this means sharing is NOT enabled if len(ccService.Entity.Extra) != 0 { extra := ServiceExtra{} err = json.Unmarshal([]byte(ccService.Entity.Extra), &extra) if err != nil { return err } service.Extra.Shareable = extra.Shareable if service.DocumentationURL == "" { service.DocumentationURL = extra.DocumentationURL } } return nil }
go
func (service *Service) UnmarshalJSON(data []byte) error { var ccService struct { Metadata internal.Metadata Entity struct { Label string `json:"label"` Description string `json:"description"` DocumentationURL string `json:"documentation_url"` ServiceBrokerName string `json:"service_broker_name"` Extra string `json:"extra"` } } err := cloudcontroller.DecodeJSON(data, &ccService) if err != nil { return err } service.GUID = ccService.Metadata.GUID service.Label = ccService.Entity.Label service.Description = ccService.Entity.Description service.DocumentationURL = ccService.Entity.DocumentationURL service.ServiceBrokerName = ccService.Entity.ServiceBrokerName // We explicitly unmarshal the Extra field to type string because CC returns // a stringified JSON object ONLY for the 'extra' key (see test stub JSON // response). This unmarshal strips escaped quotes, at which time we can then // unmarshal into the ServiceExtra object. // If 'extra' is null or not provided, this means sharing is NOT enabled if len(ccService.Entity.Extra) != 0 { extra := ServiceExtra{} err = json.Unmarshal([]byte(ccService.Entity.Extra), &extra) if err != nil { return err } service.Extra.Shareable = extra.Shareable if service.DocumentationURL == "" { service.DocumentationURL = extra.DocumentationURL } } return nil }
[ "func", "(", "service", "*", "Service", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccService", "struct", "{", "Metadata", "internal", ".", "Metadata", "\n", "Entity", "struct", "{", "Label", "string", "`json:\"label\"`", "\n", "Description", "string", "`json:\"description\"`", "\n", "DocumentationURL", "string", "`json:\"documentation_url\"`", "\n", "ServiceBrokerName", "string", "`json:\"service_broker_name\"`", "\n", "Extra", "string", "`json:\"extra\"`", "\n", "}", "\n", "}", "\n\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccService", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "service", ".", "GUID", "=", "ccService", ".", "Metadata", ".", "GUID", "\n", "service", ".", "Label", "=", "ccService", ".", "Entity", ".", "Label", "\n", "service", ".", "Description", "=", "ccService", ".", "Entity", ".", "Description", "\n", "service", ".", "DocumentationURL", "=", "ccService", ".", "Entity", ".", "DocumentationURL", "\n", "service", ".", "ServiceBrokerName", "=", "ccService", ".", "Entity", ".", "ServiceBrokerName", "\n\n", "// We explicitly unmarshal the Extra field to type string because CC returns", "// a stringified JSON object ONLY for the 'extra' key (see test stub JSON", "// response). This unmarshal strips escaped quotes, at which time we can then", "// unmarshal into the ServiceExtra object.", "// If 'extra' is null or not provided, this means sharing is NOT enabled", "if", "len", "(", "ccService", ".", "Entity", ".", "Extra", ")", "!=", "0", "{", "extra", ":=", "ServiceExtra", "{", "}", "\n", "err", "=", "json", ".", "Unmarshal", "(", "[", "]", "byte", "(", "ccService", ".", "Entity", ".", "Extra", ")", ",", "&", "extra", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "service", ".", "Extra", ".", "Shareable", "=", "extra", ".", "Shareable", "\n", "if", "service", ".", "DocumentationURL", "==", "\"", "\"", "{", "service", ".", "DocumentationURL", "=", "extra", ".", "DocumentationURL", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Service response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Service", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L52-L93
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
GetService
func (client *Client) GetService(serviceGUID string) (Service, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceRequest, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return Service{}, nil, err } var service Service response := cloudcontroller.Response{ DecodeJSONResponseInto: &service, } err = client.connection.Make(request, &response) return service, response.Warnings, err }
go
func (client *Client) GetService(serviceGUID string) (Service, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceRequest, URIParams: Params{"service_guid": serviceGUID}, }) if err != nil { return Service{}, nil, err } var service Service response := cloudcontroller.Response{ DecodeJSONResponseInto: &service, } err = client.connection.Make(request, &response) return service, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetService", "(", "serviceGUID", "string", ")", "(", "Service", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "serviceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Service", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "service", "Service", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "service", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "service", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetService returns the service with the given GUID.
[ "GetService", "returns", "the", "service", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L96-L112
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service.go
GetServices
func (client *Client) GetServices(filters ...Filter) ([]Service, Warnings, error) { opts := requestOptions{ RequestName: internal.GetServicesRequest, Query: ConvertFilterParameters(filters), } return client.makeServicesRequest(opts) }
go
func (client *Client) GetServices(filters ...Filter) ([]Service, Warnings, error) { opts := requestOptions{ RequestName: internal.GetServicesRequest, Query: ConvertFilterParameters(filters), } return client.makeServicesRequest(opts) }
[ "func", "(", "client", "*", "Client", ")", "GetServices", "(", "filters", "...", "Filter", ")", "(", "[", "]", "Service", ",", "Warnings", ",", "error", ")", "{", "opts", ":=", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServicesRequest", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", "\n\n", "return", "client", ".", "makeServicesRequest", "(", "opts", ")", "\n", "}" ]
// GetServices returns a list of Services given the provided filters.
[ "GetServices", "returns", "a", "list", "of", "Services", "given", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service.go#L115-L122
train
cloudfoundry/cli
actor/v2action/service_plan_visibility.go
GetServicePlanVisibilities
func (actor *Actor) GetServicePlanVisibilities(planGUID string) ([]ServicePlanVisibility, Warnings, error) { visibilities, warnings, err := actor.CloudControllerClient.GetServicePlanVisibilities(ccv2.Filter{ Type: constant.ServicePlanGUIDFilter, Operator: constant.EqualOperator, Values: []string{planGUID}, }) if err != nil { return nil, Warnings(warnings), err } var visibilitesToReturn []ServicePlanVisibility for _, v := range visibilities { visibilitesToReturn = append(visibilitesToReturn, ServicePlanVisibility(v)) } return visibilitesToReturn, Warnings(warnings), nil }
go
func (actor *Actor) GetServicePlanVisibilities(planGUID string) ([]ServicePlanVisibility, Warnings, error) { visibilities, warnings, err := actor.CloudControllerClient.GetServicePlanVisibilities(ccv2.Filter{ Type: constant.ServicePlanGUIDFilter, Operator: constant.EqualOperator, Values: []string{planGUID}, }) if err != nil { return nil, Warnings(warnings), err } var visibilitesToReturn []ServicePlanVisibility for _, v := range visibilities { visibilitesToReturn = append(visibilitesToReturn, ServicePlanVisibility(v)) } return visibilitesToReturn, Warnings(warnings), nil }
[ "func", "(", "actor", "*", "Actor", ")", "GetServicePlanVisibilities", "(", "planGUID", "string", ")", "(", "[", "]", "ServicePlanVisibility", ",", "Warnings", ",", "error", ")", "{", "visibilities", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetServicePlanVisibilities", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "ServicePlanGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "planGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "var", "visibilitesToReturn", "[", "]", "ServicePlanVisibility", "\n", "for", "_", ",", "v", ":=", "range", "visibilities", "{", "visibilitesToReturn", "=", "append", "(", "visibilitesToReturn", ",", "ServicePlanVisibility", "(", "v", ")", ")", "\n", "}", "\n\n", "return", "visibilitesToReturn", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}" ]
// GetServicePlanVisibilities fetches service plan visibilities for a plan by GUID.
[ "GetServicePlanVisibilities", "fetches", "service", "plan", "visibilities", "for", "a", "plan", "by", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_plan_visibility.go#L11-L27
train
cloudfoundry/cli
api/cloudcontroller/ccv3/internal/routing.go
CreatePath
func (r Route) CreatePath(params Params) (string, error) { components := strings.Split(r.Path, "/") for i, c := range components { if len(c) == 0 { continue } if c[0] == ':' { val, ok := params[c[1:]] if !ok { return "", fmt.Errorf("missing param %s", c) } components[i] = val } } u, err := url.Parse(strings.Join(components, "/")) if err != nil { return "", err } return u.String(), nil }
go
func (r Route) CreatePath(params Params) (string, error) { components := strings.Split(r.Path, "/") for i, c := range components { if len(c) == 0 { continue } if c[0] == ':' { val, ok := params[c[1:]] if !ok { return "", fmt.Errorf("missing param %s", c) } components[i] = val } } u, err := url.Parse(strings.Join(components, "/")) if err != nil { return "", err } return u.String(), nil }
[ "func", "(", "r", "Route", ")", "CreatePath", "(", "params", "Params", ")", "(", "string", ",", "error", ")", "{", "components", ":=", "strings", ".", "Split", "(", "r", ".", "Path", ",", "\"", "\"", ")", "\n", "for", "i", ",", "c", ":=", "range", "components", "{", "if", "len", "(", "c", ")", "==", "0", "{", "continue", "\n", "}", "\n", "if", "c", "[", "0", "]", "==", "':'", "{", "val", ",", "ok", ":=", "params", "[", "c", "[", "1", ":", "]", "]", "\n", "if", "!", "ok", "{", "return", "\"", "\"", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "c", ")", "\n", "}", "\n", "components", "[", "i", "]", "=", "val", "\n", "}", "\n", "}", "\n\n", "u", ",", "err", ":=", "url", ".", "Parse", "(", "strings", ".", "Join", "(", "components", ",", "\"", "\"", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "err", "\n", "}", "\n", "return", "u", ".", "String", "(", ")", ",", "nil", "\n", "}" ]
// CreatePath combines the route's path pattern with a Params map // to produce a valid path.
[ "CreatePath", "combines", "the", "route", "s", "path", "pattern", "with", "a", "Params", "map", "to", "produce", "a", "valid", "path", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/internal/routing.go#L73-L93
train
cloudfoundry/cli
api/cloudcontroller/ccv3/internal/routing.go
NewRouter
func NewRouter(routes []Route, resources map[string]string) *Router { mappedRoutes := map[string]Route{} for _, route := range routes { mappedRoutes[route.Name] = route } return &Router{ routes: mappedRoutes, resources: resources, } }
go
func NewRouter(routes []Route, resources map[string]string) *Router { mappedRoutes := map[string]Route{} for _, route := range routes { mappedRoutes[route.Name] = route } return &Router{ routes: mappedRoutes, resources: resources, } }
[ "func", "NewRouter", "(", "routes", "[", "]", "Route", ",", "resources", "map", "[", "string", "]", "string", ")", "*", "Router", "{", "mappedRoutes", ":=", "map", "[", "string", "]", "Route", "{", "}", "\n", "for", "_", ",", "route", ":=", "range", "routes", "{", "mappedRoutes", "[", "route", ".", "Name", "]", "=", "route", "\n", "}", "\n", "return", "&", "Router", "{", "routes", ":", "mappedRoutes", ",", "resources", ":", "resources", ",", "}", "\n", "}" ]
// NewRouter returns a pointer to a new Router.
[ "NewRouter", "returns", "a", "pointer", "to", "a", "new", "Router", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/internal/routing.go#L103-L112
train
cloudfoundry/cli
api/cloudcontroller/ccv3/internal/routing.go
CreateRequest
func (router Router) CreateRequest(name string, params Params, body io.Reader) (*http.Request, error) { route, ok := router.routes[name] if !ok { return &http.Request{}, fmt.Errorf("no route exists with the name %s", name) } uri, err := route.CreatePath(params) if err != nil { return &http.Request{}, err } resource, ok := router.resources[route.Resource] if !ok { return &http.Request{}, fmt.Errorf("no resource exists with the name %s", route.Resource) } url, err := router.urlFrom(resource, uri) if err != nil { return &http.Request{}, err } return http.NewRequest(route.Method, url, body) }
go
func (router Router) CreateRequest(name string, params Params, body io.Reader) (*http.Request, error) { route, ok := router.routes[name] if !ok { return &http.Request{}, fmt.Errorf("no route exists with the name %s", name) } uri, err := route.CreatePath(params) if err != nil { return &http.Request{}, err } resource, ok := router.resources[route.Resource] if !ok { return &http.Request{}, fmt.Errorf("no resource exists with the name %s", route.Resource) } url, err := router.urlFrom(resource, uri) if err != nil { return &http.Request{}, err } return http.NewRequest(route.Method, url, body) }
[ "func", "(", "router", "Router", ")", "CreateRequest", "(", "name", "string", ",", "params", "Params", ",", "body", "io", ".", "Reader", ")", "(", "*", "http", ".", "Request", ",", "error", ")", "{", "route", ",", "ok", ":=", "router", ".", "routes", "[", "name", "]", "\n", "if", "!", "ok", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "name", ")", "\n", "}", "\n\n", "uri", ",", "err", ":=", "route", ".", "CreatePath", "(", "params", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "err", "\n", "}", "\n\n", "resource", ",", "ok", ":=", "router", ".", "resources", "[", "route", ".", "Resource", "]", "\n", "if", "!", "ok", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "route", ".", "Resource", ")", "\n", "}", "\n\n", "url", ",", "err", ":=", "router", ".", "urlFrom", "(", "resource", ",", "uri", ")", "\n", "if", "err", "!=", "nil", "{", "return", "&", "http", ".", "Request", "{", "}", ",", "err", "\n", "}", "\n\n", "return", "http", ".", "NewRequest", "(", "route", ".", "Method", ",", "url", ",", "body", ")", "\n", "}" ]
// CreateRequest returns a request key'd off of the name given. The params are // merged into the URL and body is set as the request body.
[ "CreateRequest", "returns", "a", "request", "key", "d", "off", "of", "the", "name", "given", ".", "The", "params", "are", "merged", "into", "the", "URL", "and", "body", "is", "set", "as", "the", "request", "body", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/internal/routing.go#L116-L138
train
cloudfoundry/cli
api/uaa/client.go
NewClient
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.BinaryName(), config.BinaryVersion(), runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ config: config, connection: NewConnection(config.SkipSSLValidation(), config.UAADisableKeepAlives(), config.DialTimeout()), userAgent: userAgent, } client.WrapConnection(NewErrorWrapper()) return &client }
go
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.BinaryName(), config.BinaryVersion(), runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ config: config, connection: NewConnection(config.SkipSSLValidation(), config.UAADisableKeepAlives(), config.DialTimeout()), userAgent: userAgent, } client.WrapConnection(NewErrorWrapper()) return &client }
[ "func", "NewClient", "(", "config", "Config", ")", "*", "Client", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "config", ".", "BinaryName", "(", ")", ",", "config", ".", "BinaryVersion", "(", ")", ",", "runtime", ".", "Version", "(", ")", ",", "runtime", ".", "GOARCH", ",", "runtime", ".", "GOOS", ",", ")", "\n\n", "client", ":=", "Client", "{", "config", ":", "config", ",", "connection", ":", "NewConnection", "(", "config", ".", "SkipSSLValidation", "(", ")", ",", "config", ".", "UAADisableKeepAlives", "(", ")", ",", "config", ".", "DialTimeout", "(", ")", ")", ",", "userAgent", ":", "userAgent", ",", "}", "\n", "client", ".", "WrapConnection", "(", "NewErrorWrapper", "(", ")", ")", "\n\n", "return", "&", "client", "\n", "}" ]
// NewClient returns a new UAA Client with the provided configuration
[ "NewClient", "returns", "a", "new", "UAA", "Client", "with", "the", "provided", "configuration" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/client.go#L27-L45
train
cloudfoundry/cli
util/ui/ui.go
NewUI
func NewUI(config Config) (*UI, error) { translateFunc, err := GetTranslationFunc(config) if err != nil { return nil, err } location := time.Now().Location() return &UI{ In: os.Stdin, Out: color.Output, OutForInteration: os.Stdout, Err: os.Stderr, colorEnabled: config.ColorEnabled(), translate: translateFunc, terminalLock: &sync.Mutex{}, Exiter: realExiter, fileLock: &sync.Mutex{}, Interactor: realInteract, IsTTY: config.IsTTY(), TerminalWidth: config.TerminalWidth(), TimezoneLocation: location, }, nil }
go
func NewUI(config Config) (*UI, error) { translateFunc, err := GetTranslationFunc(config) if err != nil { return nil, err } location := time.Now().Location() return &UI{ In: os.Stdin, Out: color.Output, OutForInteration: os.Stdout, Err: os.Stderr, colorEnabled: config.ColorEnabled(), translate: translateFunc, terminalLock: &sync.Mutex{}, Exiter: realExiter, fileLock: &sync.Mutex{}, Interactor: realInteract, IsTTY: config.IsTTY(), TerminalWidth: config.TerminalWidth(), TimezoneLocation: location, }, nil }
[ "func", "NewUI", "(", "config", "Config", ")", "(", "*", "UI", ",", "error", ")", "{", "translateFunc", ",", "err", ":=", "GetTranslationFunc", "(", "config", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "location", ":=", "time", ".", "Now", "(", ")", ".", "Location", "(", ")", "\n\n", "return", "&", "UI", "{", "In", ":", "os", ".", "Stdin", ",", "Out", ":", "color", ".", "Output", ",", "OutForInteration", ":", "os", ".", "Stdout", ",", "Err", ":", "os", ".", "Stderr", ",", "colorEnabled", ":", "config", ".", "ColorEnabled", "(", ")", ",", "translate", ":", "translateFunc", ",", "terminalLock", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "Exiter", ":", "realExiter", ",", "fileLock", ":", "&", "sync", ".", "Mutex", "{", "}", ",", "Interactor", ":", "realInteract", ",", "IsTTY", ":", "config", ".", "IsTTY", "(", ")", ",", "TerminalWidth", ":", "config", ".", "TerminalWidth", "(", ")", ",", "TimezoneLocation", ":", "location", ",", "}", ",", "nil", "\n", "}" ]
// NewUI will return a UI object where Out is set to STDOUT, In is set to // STDIN, and Err is set to STDERR
[ "NewUI", "will", "return", "a", "UI", "object", "where", "Out", "is", "set", "to", "STDOUT", "In", "is", "set", "to", "STDIN", "and", "Err", "is", "set", "to", "STDERR" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L99-L122
train
cloudfoundry/cli
util/ui/ui.go
DisplayError
func (ui *UI) DisplayError(err error) { var errMsg string if translatableError, ok := err.(translatableerror.TranslatableError); ok { errMsg = translatableError.Translate(ui.translate) } else { errMsg = err.Error() } fmt.Fprintf(ui.Err, "%s\n", errMsg) ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText("FAILED"), color.New(color.FgRed, color.Bold))) }
go
func (ui *UI) DisplayError(err error) { var errMsg string if translatableError, ok := err.(translatableerror.TranslatableError); ok { errMsg = translatableError.Translate(ui.translate) } else { errMsg = err.Error() } fmt.Fprintf(ui.Err, "%s\n", errMsg) ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText("FAILED"), color.New(color.FgRed, color.Bold))) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayError", "(", "err", "error", ")", "{", "var", "errMsg", "string", "\n", "if", "translatableError", ",", "ok", ":=", "err", ".", "(", "translatableerror", ".", "TranslatableError", ")", ";", "ok", "{", "errMsg", "=", "translatableError", ".", "Translate", "(", "ui", ".", "translate", ")", "\n", "}", "else", "{", "errMsg", "=", "err", ".", "Error", "(", ")", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Err", ",", "\"", "\\n", "\"", ",", "errMsg", ")", "\n\n", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\"", ",", "ui", ".", "modifyColor", "(", "ui", ".", "TranslateText", "(", "\"", "\"", ")", ",", "color", ".", "New", "(", "color", ".", "FgRed", ",", "color", ".", "Bold", ")", ")", ")", "\n", "}" ]
// DisplayError outputs the translated error message to ui.Err if the error // satisfies TranslatableError, otherwise it outputs the original error message // to ui.Err. It also outputs "FAILED" in bold red to ui.Out.
[ "DisplayError", "outputs", "the", "translated", "error", "message", "to", "ui", ".", "Err", "if", "the", "error", "satisfies", "TranslatableError", "otherwise", "it", "outputs", "the", "original", "error", "message", "to", "ui", ".", "Err", ".", "It", "also", "outputs", "FAILED", "in", "bold", "red", "to", "ui", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L157-L170
train
cloudfoundry/cli
util/ui/ui.go
DisplayHeader
func (ui *UI) DisplayHeader(text string) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText(text), color.New(color.Bold))) }
go
func (ui *UI) DisplayHeader(text string) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.modifyColor(ui.TranslateText(text), color.New(color.Bold))) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayHeader", "(", "text", "string", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\"", ",", "ui", ".", "modifyColor", "(", "ui", ".", "TranslateText", "(", "text", ")", ",", "color", ".", "New", "(", "color", ".", "Bold", ")", ")", ")", "\n", "}" ]
// DisplayHeader translates the header, bolds and adds the default color to the // header, and outputs the result to ui.Out.
[ "DisplayHeader", "translates", "the", "header", "bolds", "and", "adds", "the", "default", "color", "to", "the", "header", "and", "outputs", "the", "result", "to", "ui", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L181-L186
train
cloudfoundry/cli
util/ui/ui.go
DisplayNewline
func (ui *UI) DisplayNewline() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "\n") }
go
func (ui *UI) DisplayNewline() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "\n") }
[ "func", "(", "ui", "*", "UI", ")", "DisplayNewline", "(", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\"", ")", "\n", "}" ]
// DisplayNewline outputs a newline to UI.Out.
[ "DisplayNewline", "outputs", "a", "newline", "to", "UI", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L189-L194
train
cloudfoundry/cli
util/ui/ui.go
DisplayOK
func (ui *UI) DisplayOK() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n\n", ui.modifyColor(ui.TranslateText("OK"), color.New(color.FgGreen, color.Bold))) }
go
func (ui *UI) DisplayOK() { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n\n", ui.modifyColor(ui.TranslateText("OK"), color.New(color.FgGreen, color.Bold))) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayOK", "(", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\\n", "\"", ",", "ui", ".", "modifyColor", "(", "ui", ".", "TranslateText", "(", "\"", "\"", ")", ",", "color", ".", "New", "(", "color", ".", "FgGreen", ",", "color", ".", "Bold", ")", ")", ")", "\n", "}" ]
// DisplayOK outputs a bold green translated "OK" to UI.Out.
[ "DisplayOK", "outputs", "a", "bold", "green", "translated", "OK", "to", "UI", ".", "Out", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L197-L202
train
cloudfoundry/cli
util/ui/ui.go
DisplayText
func (ui *UI) DisplayText(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, templateValues...)) }
go
func (ui *UI) DisplayText(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, templateValues...)) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayText", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\"", ",", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "}" ]
// DisplayText translates the template, substitutes in templateValues, and // outputs the result to ui.Out. Only the first map in templateValues is used.
[ "DisplayText", "translates", "the", "template", "substitutes", "in", "templateValues", "and", "outputs", "the", "result", "to", "ui", ".", "Out", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L206-L211
train
cloudfoundry/cli
util/ui/ui.go
DisplayTextWithFlavor
func (ui *UI) DisplayTextWithFlavor(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() firstTemplateValues := getFirstSet(templateValues) for key, value := range firstTemplateValues { firstTemplateValues[key] = ui.modifyColor(fmt.Sprint(value), color.New(color.FgCyan, color.Bold)) } fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, firstTemplateValues)) }
go
func (ui *UI) DisplayTextWithFlavor(template string, templateValues ...map[string]interface{}) { ui.terminalLock.Lock() defer ui.terminalLock.Unlock() firstTemplateValues := getFirstSet(templateValues) for key, value := range firstTemplateValues { firstTemplateValues[key] = ui.modifyColor(fmt.Sprint(value), color.New(color.FgCyan, color.Bold)) } fmt.Fprintf(ui.Out, "%s\n", ui.TranslateText(template, firstTemplateValues)) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayTextWithFlavor", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "ui", ".", "terminalLock", ".", "Lock", "(", ")", "\n", "defer", "ui", ".", "terminalLock", ".", "Unlock", "(", ")", "\n\n", "firstTemplateValues", ":=", "getFirstSet", "(", "templateValues", ")", "\n", "for", "key", ",", "value", ":=", "range", "firstTemplateValues", "{", "firstTemplateValues", "[", "key", "]", "=", "ui", ".", "modifyColor", "(", "fmt", ".", "Sprint", "(", "value", ")", ",", "color", ".", "New", "(", "color", ".", "FgCyan", ",", "color", ".", "Bold", ")", ")", "\n", "}", "\n", "fmt", ".", "Fprintf", "(", "ui", ".", "Out", ",", "\"", "\\n", "\"", ",", "ui", ".", "TranslateText", "(", "template", ",", "firstTemplateValues", ")", ")", "\n", "}" ]
// DisplayTextWithFlavor translates the template, bolds and adds cyan color to // templateValues, substitutes templateValues into the template, and outputs // the result to ui.Out. Only the first map in templateValues is used.
[ "DisplayTextWithFlavor", "translates", "the", "template", "bolds", "and", "adds", "cyan", "color", "to", "templateValues", "substitutes", "templateValues", "into", "the", "template", "and", "outputs", "the", "result", "to", "ui", ".", "Out", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L230-L239
train
cloudfoundry/cli
util/ui/ui.go
DisplayWarning
func (ui *UI) DisplayWarning(template string, templateValues ...map[string]interface{}) { fmt.Fprintf(ui.Err, "%s\n\n", ui.TranslateText(template, templateValues...)) }
go
func (ui *UI) DisplayWarning(template string, templateValues ...map[string]interface{}) { fmt.Fprintf(ui.Err, "%s\n\n", ui.TranslateText(template, templateValues...)) }
[ "func", "(", "ui", "*", "UI", ")", "DisplayWarning", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "fmt", ".", "Fprintf", "(", "ui", ".", "Err", ",", "\"", "\\n", "\\n", "\"", ",", "ui", ".", "TranslateText", "(", "template", ",", "templateValues", "...", ")", ")", "\n", "}" ]
// DisplayWarning translates the warning, substitutes in templateValues, and // outputs to ui.Err. Only the first map in templateValues is used.
[ "DisplayWarning", "translates", "the", "warning", "substitutes", "in", "templateValues", "and", "outputs", "to", "ui", ".", "Err", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L243-L245
train
cloudfoundry/cli
util/ui/ui.go
DisplayWarnings
func (ui *UI) DisplayWarnings(warnings []string) { for _, warning := range warnings { fmt.Fprintf(ui.Err, "%s\n", ui.TranslateText(warning)) } if len(warnings) > 0 { fmt.Fprintln(ui.Err) } }
go
func (ui *UI) DisplayWarnings(warnings []string) { for _, warning := range warnings { fmt.Fprintf(ui.Err, "%s\n", ui.TranslateText(warning)) } if len(warnings) > 0 { fmt.Fprintln(ui.Err) } }
[ "func", "(", "ui", "*", "UI", ")", "DisplayWarnings", "(", "warnings", "[", "]", "string", ")", "{", "for", "_", ",", "warning", ":=", "range", "warnings", "{", "fmt", ".", "Fprintf", "(", "ui", ".", "Err", ",", "\"", "\\n", "\"", ",", "ui", ".", "TranslateText", "(", "warning", ")", ")", "\n", "}", "\n", "if", "len", "(", "warnings", ")", ">", "0", "{", "fmt", ".", "Fprintln", "(", "ui", ".", "Err", ")", "\n", "}", "\n", "}" ]
// DisplayWarnings translates the warnings and outputs to ui.Err.
[ "DisplayWarnings", "translates", "the", "warnings", "and", "outputs", "to", "ui", ".", "Err", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L248-L255
train
cloudfoundry/cli
util/ui/ui.go
TranslateText
func (ui *UI) TranslateText(template string, templateValues ...map[string]interface{}) string { return ui.translate(template, getFirstSet(templateValues)) }
go
func (ui *UI) TranslateText(template string, templateValues ...map[string]interface{}) string { return ui.translate(template, getFirstSet(templateValues)) }
[ "func", "(", "ui", "*", "UI", ")", "TranslateText", "(", "template", "string", ",", "templateValues", "...", "map", "[", "string", "]", "interface", "{", "}", ")", "string", "{", "return", "ui", ".", "translate", "(", "template", ",", "getFirstSet", "(", "templateValues", ")", ")", "\n", "}" ]
// TranslateText passes the template through an internationalization function // to translate it to a pre-configured language, and returns the template with // templateValues substituted in. Only the first map in templateValues is used.
[ "TranslateText", "passes", "the", "template", "through", "an", "internationalization", "function", "to", "translate", "it", "to", "a", "pre", "-", "configured", "language", "and", "returns", "the", "template", "with", "templateValues", "substituted", "in", ".", "Only", "the", "first", "map", "in", "templateValues", "is", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L275-L277
train
cloudfoundry/cli
util/ui/ui.go
UserFriendlyDate
func (ui *UI) UserFriendlyDate(input time.Time) string { return input.Local().Format("Mon 02 Jan 15:04:05 MST 2006") }
go
func (ui *UI) UserFriendlyDate(input time.Time) string { return input.Local().Format("Mon 02 Jan 15:04:05 MST 2006") }
[ "func", "(", "ui", "*", "UI", ")", "UserFriendlyDate", "(", "input", "time", ".", "Time", ")", "string", "{", "return", "input", ".", "Local", "(", ")", ".", "Format", "(", "\"", "\"", ")", "\n", "}" ]
// UserFriendlyDate converts the time to UTC and then formats it to ISO8601.
[ "UserFriendlyDate", "converts", "the", "time", "to", "UTC", "and", "then", "formats", "it", "to", "ISO8601", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui.go#L280-L282
train
cloudfoundry/cli
util/configv3/plugin_repository.go
AddPluginRepository
func (config *Config) AddPluginRepository(name string, url string) { config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories, PluginRepository{Name: name, URL: url}) }
go
func (config *Config) AddPluginRepository(name string, url string) { config.ConfigFile.PluginRepositories = append(config.ConfigFile.PluginRepositories, PluginRepository{Name: name, URL: url}) }
[ "func", "(", "config", "*", "Config", ")", "AddPluginRepository", "(", "name", "string", ",", "url", "string", ")", "{", "config", ".", "ConfigFile", ".", "PluginRepositories", "=", "append", "(", "config", ".", "ConfigFile", ".", "PluginRepositories", ",", "PluginRepository", "{", "Name", ":", "name", ",", "URL", ":", "url", "}", ")", "\n", "}" ]
// AddPluginRepository adds an new repository to the plugin config. It does not // add duplicates to the config.
[ "AddPluginRepository", "adds", "an", "new", "repository", "to", "the", "plugin", "config", ".", "It", "does", "not", "add", "duplicates", "to", "the", "config", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/plugin_repository.go#L24-L27
train
cloudfoundry/cli
util/ui/ui_for_push.go
DisplayChangesForPush
func (ui *UI) DisplayChangesForPush(changeSet []Change) error { if len(changeSet) == 0 { return nil } var columnWidth int for _, change := range changeSet { if width := wordSize(ui.TranslateText(change.Header)); width > columnWidth { columnWidth = width } } for _, change := range changeSet { padding := columnWidth - wordSize(ui.TranslateText(change.Header)) + 3 err := ui.DisplayChangeForPush(change.Header, padding, change.HiddenValue, change.CurrentValue, change.NewValue) if err != nil { return err } } return nil }
go
func (ui *UI) DisplayChangesForPush(changeSet []Change) error { if len(changeSet) == 0 { return nil } var columnWidth int for _, change := range changeSet { if width := wordSize(ui.TranslateText(change.Header)); width > columnWidth { columnWidth = width } } for _, change := range changeSet { padding := columnWidth - wordSize(ui.TranslateText(change.Header)) + 3 err := ui.DisplayChangeForPush(change.Header, padding, change.HiddenValue, change.CurrentValue, change.NewValue) if err != nil { return err } } return nil }
[ "func", "(", "ui", "*", "UI", ")", "DisplayChangesForPush", "(", "changeSet", "[", "]", "Change", ")", "error", "{", "if", "len", "(", "changeSet", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "var", "columnWidth", "int", "\n", "for", "_", ",", "change", ":=", "range", "changeSet", "{", "if", "width", ":=", "wordSize", "(", "ui", ".", "TranslateText", "(", "change", ".", "Header", ")", ")", ";", "width", ">", "columnWidth", "{", "columnWidth", "=", "width", "\n", "}", "\n", "}", "\n\n", "for", "_", ",", "change", ":=", "range", "changeSet", "{", "padding", ":=", "columnWidth", "-", "wordSize", "(", "ui", ".", "TranslateText", "(", "change", ".", "Header", ")", ")", "+", "3", "\n", "err", ":=", "ui", ".", "DisplayChangeForPush", "(", "change", ".", "Header", ",", "padding", ",", "change", ".", "HiddenValue", ",", "change", ".", "CurrentValue", ",", "change", ".", "NewValue", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "}", "\n\n", "return", "nil", "\n", "}" ]
// DisplayChangesForPush will display the set of changes via // DisplayChangeForPush in the order given.
[ "DisplayChangesForPush", "will", "display", "the", "set", "of", "changes", "via", "DisplayChangeForPush", "in", "the", "order", "given", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/ui_for_push.go#L73-L94
train
cloudfoundry/cli
actor/v2action/service_instance.go
CreateServiceInstance
func (actor Actor) CreateServiceInstance(spaceGUID, serviceName, servicePlanName, serviceInstanceName, brokerName string, params map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) { var allWarnings Warnings plan, allWarnings, err := actor.getServicePlanForServiceInSpace(servicePlanName, serviceName, spaceGUID, brokerName) if err != nil { return ServiceInstance{}, allWarnings, err } instance, warnings, err := actor.CloudControllerClient.CreateServiceInstance(spaceGUID, plan.GUID, serviceInstanceName, params, tags) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceInstance{}, allWarnings, err } return ServiceInstance(instance), allWarnings, nil }
go
func (actor Actor) CreateServiceInstance(spaceGUID, serviceName, servicePlanName, serviceInstanceName, brokerName string, params map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) { var allWarnings Warnings plan, allWarnings, err := actor.getServicePlanForServiceInSpace(servicePlanName, serviceName, spaceGUID, brokerName) if err != nil { return ServiceInstance{}, allWarnings, err } instance, warnings, err := actor.CloudControllerClient.CreateServiceInstance(spaceGUID, plan.GUID, serviceInstanceName, params, tags) allWarnings = append(allWarnings, warnings...) if err != nil { return ServiceInstance{}, allWarnings, err } return ServiceInstance(instance), allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "CreateServiceInstance", "(", "spaceGUID", ",", "serviceName", ",", "servicePlanName", ",", "serviceInstanceName", ",", "brokerName", "string", ",", "params", "map", "[", "string", "]", "interface", "{", "}", ",", "tags", "[", "]", "string", ")", "(", "ServiceInstance", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "plan", ",", "allWarnings", ",", "err", ":=", "actor", ".", "getServicePlanForServiceInSpace", "(", "servicePlanName", ",", "serviceName", ",", "spaceGUID", ",", "brokerName", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "instance", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "CreateServiceInstance", "(", "spaceGUID", ",", "plan", ".", "GUID", ",", "serviceInstanceName", ",", "params", ",", "tags", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstance", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "return", "ServiceInstance", "(", "instance", ")", ",", "allWarnings", ",", "nil", "\n", "}" ]
// CreateServiceInstance creates a new service instance with the provided attributes.
[ "CreateServiceInstance", "creates", "a", "new", "service", "instance", "with", "the", "provided", "attributes", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_instance.go#L14-L29
train
cloudfoundry/cli
actor/v2action/route.go
Summary
func (rs Routes) Summary() string { formattedRoutes := []string{} for _, route := range rs { formattedRoutes = append(formattedRoutes, route.String()) } return strings.Join(formattedRoutes, ", ") }
go
func (rs Routes) Summary() string { formattedRoutes := []string{} for _, route := range rs { formattedRoutes = append(formattedRoutes, route.String()) } return strings.Join(formattedRoutes, ", ") }
[ "func", "(", "rs", "Routes", ")", "Summary", "(", ")", "string", "{", "formattedRoutes", ":=", "[", "]", "string", "{", "}", "\n", "for", "_", ",", "route", ":=", "range", "rs", "{", "formattedRoutes", "=", "append", "(", "formattedRoutes", ",", "route", ".", "String", "(", ")", ")", "\n", "}", "\n", "return", "strings", ".", "Join", "(", "formattedRoutes", ",", "\"", "\"", ")", "\n", "}" ]
// Summary converts routes into a comma separated string.
[ "Summary", "converts", "routes", "into", "a", "comma", "separated", "string", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L19-L25
train
cloudfoundry/cli
actor/v2action/route.go
Validate
func (r Route) Validate() error { if r.Domain.IsHTTP() { if r.Port.IsSet { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsShared() && r.Host == "" { return actionerror.NoHostnameAndSharedDomainError{} } } else { // Is TCP Domain if r.Host != "" || r.Path != "" { return actionerror.InvalidTCPRouteSettings{Domain: r.Domain.Name} } } return nil }
go
func (r Route) Validate() error { if r.Domain.IsHTTP() { if r.Port.IsSet { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsShared() && r.Host == "" { return actionerror.NoHostnameAndSharedDomainError{} } } else { // Is TCP Domain if r.Host != "" || r.Path != "" { return actionerror.InvalidTCPRouteSettings{Domain: r.Domain.Name} } } return nil }
[ "func", "(", "r", "Route", ")", "Validate", "(", ")", "error", "{", "if", "r", ".", "Domain", ".", "IsHTTP", "(", ")", "{", "if", "r", ".", "Port", ".", "IsSet", "{", "return", "actionerror", ".", "InvalidHTTPRouteSettings", "{", "Domain", ":", "r", ".", "Domain", ".", "Name", "}", "\n", "}", "\n", "if", "r", ".", "Domain", ".", "IsShared", "(", ")", "&&", "r", ".", "Host", "==", "\"", "\"", "{", "return", "actionerror", ".", "NoHostnameAndSharedDomainError", "{", "}", "\n", "}", "\n", "}", "else", "{", "// Is TCP Domain", "if", "r", ".", "Host", "!=", "\"", "\"", "||", "r", ".", "Path", "!=", "\"", "\"", "{", "return", "actionerror", ".", "InvalidTCPRouteSettings", "{", "Domain", ":", "r", ".", "Domain", ".", "Name", "}", "\n", "}", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// Validate will return an error if there are invalid HTTP or TCP settings for // it's given domain.
[ "Validate", "will", "return", "an", "error", "if", "there", "are", "invalid", "HTTP", "or", "TCP", "settings", "for", "it", "s", "given", "domain", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L43-L57
train
cloudfoundry/cli
actor/v2action/route.go
ValidateWithRandomPort
func (r Route) ValidateWithRandomPort(randomPort bool) error { if r.Domain.IsHTTP() && randomPort { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsTCP() && !r.Port.IsSet && !randomPort { return actionerror.TCPRouteOptionsNotProvidedError{} } return r.Validate() }
go
func (r Route) ValidateWithRandomPort(randomPort bool) error { if r.Domain.IsHTTP() && randomPort { return actionerror.InvalidHTTPRouteSettings{Domain: r.Domain.Name} } if r.Domain.IsTCP() && !r.Port.IsSet && !randomPort { return actionerror.TCPRouteOptionsNotProvidedError{} } return r.Validate() }
[ "func", "(", "r", "Route", ")", "ValidateWithRandomPort", "(", "randomPort", "bool", ")", "error", "{", "if", "r", ".", "Domain", ".", "IsHTTP", "(", ")", "&&", "randomPort", "{", "return", "actionerror", ".", "InvalidHTTPRouteSettings", "{", "Domain", ":", "r", ".", "Domain", ".", "Name", "}", "\n", "}", "\n\n", "if", "r", ".", "Domain", ".", "IsTCP", "(", ")", "&&", "!", "r", ".", "Port", ".", "IsSet", "&&", "!", "randomPort", "{", "return", "actionerror", ".", "TCPRouteOptionsNotProvidedError", "{", "}", "\n", "}", "\n", "return", "r", ".", "Validate", "(", ")", "\n", "}" ]
// ValidateWithRandomPort will return an error if a random port is requested // for an HTTP route, or if the route is TCP, a random port wasn't requested, // and the route has no port set.
[ "ValidateWithRandomPort", "will", "return", "an", "error", "if", "a", "random", "port", "is", "requested", "for", "an", "HTTP", "route", "or", "if", "the", "route", "is", "TCP", "a", "random", "port", "wasn", "t", "requested", "and", "the", "route", "has", "no", "port", "set", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L62-L71
train
cloudfoundry/cli
actor/v2action/route.go
String
func (r Route) String() string { routeString := r.Domain.Name if r.Port.IsSet { routeString = fmt.Sprintf("%s:%d", routeString, r.Port.Value) } else if r.RandomTCPPort() { routeString = fmt.Sprintf("%s:????", routeString) } if r.Host != "" { routeString = fmt.Sprintf("%s.%s", r.Host, routeString) } if r.Path != "" { routeString = path.Join(routeString, r.Path) } return routeString }
go
func (r Route) String() string { routeString := r.Domain.Name if r.Port.IsSet { routeString = fmt.Sprintf("%s:%d", routeString, r.Port.Value) } else if r.RandomTCPPort() { routeString = fmt.Sprintf("%s:????", routeString) } if r.Host != "" { routeString = fmt.Sprintf("%s.%s", r.Host, routeString) } if r.Path != "" { routeString = path.Join(routeString, r.Path) } return routeString }
[ "func", "(", "r", "Route", ")", "String", "(", ")", "string", "{", "routeString", ":=", "r", ".", "Domain", ".", "Name", "\n\n", "if", "r", ".", "Port", ".", "IsSet", "{", "routeString", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "routeString", ",", "r", ".", "Port", ".", "Value", ")", "\n", "}", "else", "if", "r", ".", "RandomTCPPort", "(", ")", "{", "routeString", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "routeString", ")", "\n", "}", "\n\n", "if", "r", ".", "Host", "!=", "\"", "\"", "{", "routeString", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "r", ".", "Host", ",", "routeString", ")", "\n", "}", "\n\n", "if", "r", ".", "Path", "!=", "\"", "\"", "{", "routeString", "=", "path", ".", "Join", "(", "routeString", ",", "r", ".", "Path", ")", "\n", "}", "\n\n", "return", "routeString", "\n", "}" ]
// String formats the route in a human readable format.
[ "String", "formats", "the", "route", "in", "a", "human", "readable", "format", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L74-L92
train
cloudfoundry/cli
actor/v2action/route.go
GetOrphanedRoutesBySpace
func (actor Actor) GetOrphanedRoutesBySpace(spaceGUID string) ([]Route, Warnings, error) { var ( orphanedRoutes []Route allWarnings Warnings ) routes, warnings, err := actor.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, route := range routes { apps, warnings, err := actor.GetRouteApplications(route.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } if len(apps) == 0 { orphanedRoutes = append(orphanedRoutes, route) } } if len(orphanedRoutes) == 0 { return nil, allWarnings, actionerror.OrphanedRoutesNotFoundError{} } return orphanedRoutes, allWarnings, nil }
go
func (actor Actor) GetOrphanedRoutesBySpace(spaceGUID string) ([]Route, Warnings, error) { var ( orphanedRoutes []Route allWarnings Warnings ) routes, warnings, err := actor.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, route := range routes { apps, warnings, err := actor.GetRouteApplications(route.GUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } if len(apps) == 0 { orphanedRoutes = append(orphanedRoutes, route) } } if len(orphanedRoutes) == 0 { return nil, allWarnings, actionerror.OrphanedRoutesNotFoundError{} } return orphanedRoutes, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetOrphanedRoutesBySpace", "(", "spaceGUID", "string", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "var", "(", "orphanedRoutes", "[", "]", "Route", "\n", "allWarnings", "Warnings", "\n", ")", "\n\n", "routes", ",", "warnings", ",", "err", ":=", "actor", ".", "GetSpaceRoutes", "(", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "route", ":=", "range", "routes", "{", "apps", ",", "warnings", ",", "err", ":=", "actor", ".", "GetRouteApplications", "(", "route", ".", "GUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "apps", ")", "==", "0", "{", "orphanedRoutes", "=", "append", "(", "orphanedRoutes", ",", "route", ")", "\n", "}", "\n", "}", "\n\n", "if", "len", "(", "orphanedRoutes", ")", "==", "0", "{", "return", "nil", ",", "allWarnings", ",", "actionerror", ".", "OrphanedRoutesNotFoundError", "{", "}", "\n", "}", "\n\n", "return", "orphanedRoutes", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetOrphanedRoutesBySpace returns a list of orphaned routes associated with // the provided Space GUID.
[ "GetOrphanedRoutesBySpace", "returns", "a", "list", "of", "orphaned", "routes", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L165-L194
train
cloudfoundry/cli
actor/v2action/route.go
GetApplicationRoutes
func (actor Actor) GetApplicationRoutes(applicationGUID string) (Routes, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetApplicationRoutes(applicationGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
go
func (actor Actor) GetApplicationRoutes(applicationGUID string) (Routes, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetApplicationRoutes(applicationGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "GetApplicationRoutes", "(", "applicationGUID", "string", ")", "(", "Routes", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "ccv2Routes", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetApplicationRoutes", "(", "applicationGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "routes", ",", "domainWarnings", ",", "err", ":=", "actor", ".", "applyDomain", "(", "ccv2Routes", ")", "\n\n", "return", "routes", ",", "append", "(", "allWarnings", ",", "domainWarnings", "...", ")", ",", "err", "\n", "}" ]
// GetApplicationRoutes returns a list of routes associated with the provided // Application GUID.
[ "GetApplicationRoutes", "returns", "a", "list", "of", "routes", "associated", "with", "the", "provided", "Application", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L198-L209
train
cloudfoundry/cli
actor/v2action/route.go
GetSpaceRoutes
func (actor Actor) GetSpaceRoutes(spaceGUID string) ([]Route, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
go
func (actor Actor) GetSpaceRoutes(spaceGUID string) ([]Route, Warnings, error) { var allWarnings Warnings ccv2Routes, warnings, err := actor.CloudControllerClient.GetSpaceRoutes(spaceGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } routes, domainWarnings, err := actor.applyDomain(ccv2Routes) return routes, append(allWarnings, domainWarnings...), err }
[ "func", "(", "actor", "Actor", ")", "GetSpaceRoutes", "(", "spaceGUID", "string", ")", "(", "[", "]", "Route", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n", "ccv2Routes", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaceRoutes", "(", "spaceGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "routes", ",", "domainWarnings", ",", "err", ":=", "actor", ".", "applyDomain", "(", "ccv2Routes", ")", "\n\n", "return", "routes", ",", "append", "(", "allWarnings", ",", "domainWarnings", "...", ")", ",", "err", "\n", "}" ]
// GetSpaceRoutes returns a list of routes associated with the provided Space // GUID.
[ "GetSpaceRoutes", "returns", "a", "list", "of", "routes", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L213-L224
train
cloudfoundry/cli
actor/v2action/route.go
DeleteUnmappedRoutes
func (actor Actor) DeleteUnmappedRoutes(spaceGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.DeleteSpaceUnmappedRoutes(spaceGUID) return Warnings(warnings), err }
go
func (actor Actor) DeleteUnmappedRoutes(spaceGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.DeleteSpaceUnmappedRoutes(spaceGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "DeleteUnmappedRoutes", "(", "spaceGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "DeleteSpaceUnmappedRoutes", "(", "spaceGUID", ")", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// DeleteUnmappedRoutes deletes the unmapped routes associated with the provided Space GUID.
[ "DeleteUnmappedRoutes", "deletes", "the", "unmapped", "routes", "associated", "with", "the", "provided", "Space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L227-L230
train
cloudfoundry/cli
actor/v2action/route.go
FindRouteBoundToSpaceWithSettings
func (actor Actor) FindRouteBoundToSpaceWithSettings(route Route) (Route, Warnings, error) { existingRoute, warnings, err := actor.GetRouteByComponents(route) if routeNotFoundErr, ok := err.(actionerror.RouteNotFoundError); ok { // This check only works for API versions 2.55 or higher. It will return // false for anything below that. log.Infof("checking route existence for: %s\n", route) exists, checkRouteWarnings, chkErr := actor.CheckRoute(route) if chkErr != nil { log.Errorln("check route:", err) return Route{}, append(Warnings(warnings), checkRouteWarnings...), chkErr } // This will happen if the route exists in a space to which the user does // not have access. if exists { log.Errorf("unable to find route %s in current space", route.String()) return Route{}, append(Warnings(warnings), checkRouteWarnings...), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Warnf("negative existence check for route %s - returning partial route", route.String()) log.Debugf("partialRoute: %#v", route) return Route{}, append(Warnings(warnings), checkRouteWarnings...), routeNotFoundErr } else if err != nil { log.Errorln("finding route:", err) return Route{}, Warnings(warnings), err } if existingRoute.SpaceGUID != route.SpaceGUID { log.WithFields(log.Fields{ "targeted_space_guid": route.SpaceGUID, "existing_space_guid": existingRoute.SpaceGUID, }).Errorf("route exists in different space the user has access to") return Route{}, Warnings(warnings), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Debugf("found route: %#v", existingRoute) return existingRoute, Warnings(warnings), err }
go
func (actor Actor) FindRouteBoundToSpaceWithSettings(route Route) (Route, Warnings, error) { existingRoute, warnings, err := actor.GetRouteByComponents(route) if routeNotFoundErr, ok := err.(actionerror.RouteNotFoundError); ok { // This check only works for API versions 2.55 or higher. It will return // false for anything below that. log.Infof("checking route existence for: %s\n", route) exists, checkRouteWarnings, chkErr := actor.CheckRoute(route) if chkErr != nil { log.Errorln("check route:", err) return Route{}, append(Warnings(warnings), checkRouteWarnings...), chkErr } // This will happen if the route exists in a space to which the user does // not have access. if exists { log.Errorf("unable to find route %s in current space", route.String()) return Route{}, append(Warnings(warnings), checkRouteWarnings...), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Warnf("negative existence check for route %s - returning partial route", route.String()) log.Debugf("partialRoute: %#v", route) return Route{}, append(Warnings(warnings), checkRouteWarnings...), routeNotFoundErr } else if err != nil { log.Errorln("finding route:", err) return Route{}, Warnings(warnings), err } if existingRoute.SpaceGUID != route.SpaceGUID { log.WithFields(log.Fields{ "targeted_space_guid": route.SpaceGUID, "existing_space_guid": existingRoute.SpaceGUID, }).Errorf("route exists in different space the user has access to") return Route{}, Warnings(warnings), actionerror.RouteInDifferentSpaceError{Route: route.String()} } log.Debugf("found route: %#v", existingRoute) return existingRoute, Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "FindRouteBoundToSpaceWithSettings", "(", "route", "Route", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "existingRoute", ",", "warnings", ",", "err", ":=", "actor", ".", "GetRouteByComponents", "(", "route", ")", "\n", "if", "routeNotFoundErr", ",", "ok", ":=", "err", ".", "(", "actionerror", ".", "RouteNotFoundError", ")", ";", "ok", "{", "// This check only works for API versions 2.55 or higher. It will return", "// false for anything below that.", "log", ".", "Infof", "(", "\"", "\\n", "\"", ",", "route", ")", "\n", "exists", ",", "checkRouteWarnings", ",", "chkErr", ":=", "actor", ".", "CheckRoute", "(", "route", ")", "\n", "if", "chkErr", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "Route", "{", "}", ",", "append", "(", "Warnings", "(", "warnings", ")", ",", "checkRouteWarnings", "...", ")", ",", "chkErr", "\n", "}", "\n\n", "// This will happen if the route exists in a space to which the user does", "// not have access.", "if", "exists", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "route", ".", "String", "(", ")", ")", "\n", "return", "Route", "{", "}", ",", "append", "(", "Warnings", "(", "warnings", ")", ",", "checkRouteWarnings", "...", ")", ",", "actionerror", ".", "RouteInDifferentSpaceError", "{", "Route", ":", "route", ".", "String", "(", ")", "}", "\n", "}", "\n\n", "log", ".", "Warnf", "(", "\"", "\"", ",", "route", ".", "String", "(", ")", ")", "\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "route", ")", "\n", "return", "Route", "{", "}", ",", "append", "(", "Warnings", "(", "warnings", ")", ",", "checkRouteWarnings", "...", ")", ",", "routeNotFoundErr", "\n", "}", "else", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "existingRoute", ".", "SpaceGUID", "!=", "route", ".", "SpaceGUID", "{", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "route", ".", "SpaceGUID", ",", "\"", "\"", ":", "existingRoute", ".", "SpaceGUID", ",", "}", ")", ".", "Errorf", "(", "\"", "\"", ")", "\n", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "RouteInDifferentSpaceError", "{", "Route", ":", "route", ".", "String", "(", ")", "}", "\n", "}", "\n\n", "log", ".", "Debugf", "(", "\"", "\"", ",", "existingRoute", ")", "\n", "return", "existingRoute", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// FindRouteBoundToSpaceWithSettings finds the route with the given host, // domain and space. If it is unable to find the route, it will check if it // exists anywhere in the system. When the route exists in another space, // RouteInDifferentSpaceError is returned. Use this when you know the space // GUID.
[ "FindRouteBoundToSpaceWithSettings", "finds", "the", "route", "with", "the", "given", "host", "domain", "and", "space", ".", "If", "it", "is", "unable", "to", "find", "the", "route", "it", "will", "check", "if", "it", "exists", "anywhere", "in", "the", "system", ".", "When", "the", "route", "exists", "in", "another", "space", "RouteInDifferentSpaceError", "is", "returned", ".", "Use", "this", "when", "you", "know", "the", "space", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L248-L285
train
cloudfoundry/cli
actor/v2action/route.go
GetRouteByComponents
func (actor Actor) GetRouteByComponents(route Route) (Route, Warnings, error) { // TODO: validation should probably be done separately (?) if route.Domain.IsTCP() && !route.Port.IsSet { return Route{}, nil, actionerror.PortNotProvidedForQueryError{} } if route.Domain.IsShared() && route.Domain.IsHTTP() && route.Host == "" { return Route{}, nil, actionerror.NoHostnameAndSharedDomainError{} } queries := []ccv2.Filter{ { Type: constant.DomainGUIDFilter, Operator: constant.EqualOperator, Values: []string{route.Domain.GUID}, }, { Type: constant.HostFilter, Operator: constant.EqualOperator, Values: []string{route.Host}, }, { Type: constant.PathFilter, Operator: constant.EqualOperator, Values: []string{route.Path}, }, } if route.Port.IsSet { queries = append(queries, ccv2.Filter{ Type: constant.PortFilter, Operator: constant.EqualOperator, Values: []string{fmt.Sprint(route.Port.Value)}, }) } ccv2Routes, warnings, err := actor.CloudControllerClient.GetRoutes(queries...) if err != nil { return Route{}, Warnings(warnings), err } if len(ccv2Routes) == 0 { return Route{}, Warnings(warnings), actionerror.RouteNotFoundError{ Host: route.Host, DomainGUID: route.Domain.GUID, Path: route.Path, Port: route.Port.Value, } } return CCToActorRoute(ccv2Routes[0], route.Domain), Warnings(warnings), err }
go
func (actor Actor) GetRouteByComponents(route Route) (Route, Warnings, error) { // TODO: validation should probably be done separately (?) if route.Domain.IsTCP() && !route.Port.IsSet { return Route{}, nil, actionerror.PortNotProvidedForQueryError{} } if route.Domain.IsShared() && route.Domain.IsHTTP() && route.Host == "" { return Route{}, nil, actionerror.NoHostnameAndSharedDomainError{} } queries := []ccv2.Filter{ { Type: constant.DomainGUIDFilter, Operator: constant.EqualOperator, Values: []string{route.Domain.GUID}, }, { Type: constant.HostFilter, Operator: constant.EqualOperator, Values: []string{route.Host}, }, { Type: constant.PathFilter, Operator: constant.EqualOperator, Values: []string{route.Path}, }, } if route.Port.IsSet { queries = append(queries, ccv2.Filter{ Type: constant.PortFilter, Operator: constant.EqualOperator, Values: []string{fmt.Sprint(route.Port.Value)}, }) } ccv2Routes, warnings, err := actor.CloudControllerClient.GetRoutes(queries...) if err != nil { return Route{}, Warnings(warnings), err } if len(ccv2Routes) == 0 { return Route{}, Warnings(warnings), actionerror.RouteNotFoundError{ Host: route.Host, DomainGUID: route.Domain.GUID, Path: route.Path, Port: route.Port.Value, } } return CCToActorRoute(ccv2Routes[0], route.Domain), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetRouteByComponents", "(", "route", "Route", ")", "(", "Route", ",", "Warnings", ",", "error", ")", "{", "// TODO: validation should probably be done separately (?)", "if", "route", ".", "Domain", ".", "IsTCP", "(", ")", "&&", "!", "route", ".", "Port", ".", "IsSet", "{", "return", "Route", "{", "}", ",", "nil", ",", "actionerror", ".", "PortNotProvidedForQueryError", "{", "}", "\n", "}", "\n\n", "if", "route", ".", "Domain", ".", "IsShared", "(", ")", "&&", "route", ".", "Domain", ".", "IsHTTP", "(", ")", "&&", "route", ".", "Host", "==", "\"", "\"", "{", "return", "Route", "{", "}", ",", "nil", ",", "actionerror", ".", "NoHostnameAndSharedDomainError", "{", "}", "\n", "}", "\n\n", "queries", ":=", "[", "]", "ccv2", ".", "Filter", "{", "{", "Type", ":", "constant", ".", "DomainGUIDFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "route", ".", "Domain", ".", "GUID", "}", ",", "}", ",", "{", "Type", ":", "constant", ".", "HostFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "route", ".", "Host", "}", ",", "}", ",", "{", "Type", ":", "constant", ".", "PathFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "route", ".", "Path", "}", ",", "}", ",", "}", "\n\n", "if", "route", ".", "Port", ".", "IsSet", "{", "queries", "=", "append", "(", "queries", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "PortFilter", ",", "Operator", ":", "constant", ".", "EqualOperator", ",", "Values", ":", "[", "]", "string", "{", "fmt", ".", "Sprint", "(", "route", ".", "Port", ".", "Value", ")", "}", ",", "}", ")", "\n", "}", "\n\n", "ccv2Routes", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetRoutes", "(", "queries", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "if", "len", "(", "ccv2Routes", ")", "==", "0", "{", "return", "Route", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "RouteNotFoundError", "{", "Host", ":", "route", ".", "Host", ",", "DomainGUID", ":", "route", ".", "Domain", ".", "GUID", ",", "Path", ":", "route", ".", "Path", ",", "Port", ":", "route", ".", "Port", ".", "Value", ",", "}", "\n", "}", "\n\n", "return", "CCToActorRoute", "(", "ccv2Routes", "[", "0", "]", ",", "route", ".", "Domain", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetRouteByComponents returns the route with the matching host, domain, path, // and port. Use this when you don't know the space GUID. // TCP routes require a port to be uniquely identified // HTTP routes using shared domains require a hostname or path to be uniquely identified
[ "GetRouteByComponents", "returns", "the", "route", "with", "the", "matching", "host", "domain", "path", "and", "port", ".", "Use", "this", "when", "you", "don", "t", "know", "the", "space", "GUID", ".", "TCP", "routes", "require", "a", "port", "to", "be", "uniquely", "identified", "HTTP", "routes", "using", "shared", "domains", "require", "a", "hostname", "or", "path", "to", "be", "uniquely", "identified" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/route.go#L291-L340
train
cloudfoundry/cli
actor/sharedaction/resource.go
ToV3Resource
func (r Resource) ToV3Resource() V3Resource { return V3Resource{ FilePath: r.Filename, Mode: r.Mode, Checksum: ccv3.Checksum{Value: r.SHA1}, SizeInBytes: r.Size, } }
go
func (r Resource) ToV3Resource() V3Resource { return V3Resource{ FilePath: r.Filename, Mode: r.Mode, Checksum: ccv3.Checksum{Value: r.SHA1}, SizeInBytes: r.Size, } }
[ "func", "(", "r", "Resource", ")", "ToV3Resource", "(", ")", "V3Resource", "{", "return", "V3Resource", "{", "FilePath", ":", "r", ".", "Filename", ",", "Mode", ":", "r", ".", "Mode", ",", "Checksum", ":", "ccv3", ".", "Checksum", "{", "Value", ":", "r", ".", "SHA1", "}", ",", "SizeInBytes", ":", "r", ".", "Size", ",", "}", "\n", "}" ]
// ToV3Resource converts a sharedaction Resource to V3 Resource format
[ "ToV3Resource", "converts", "a", "sharedaction", "Resource", "to", "V3", "Resource", "format" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L49-L56
train
cloudfoundry/cli
actor/sharedaction/resource.go
ToV2Resource
func (r V3Resource) ToV2Resource() Resource { return Resource{ Filename: r.FilePath, Mode: r.Mode, SHA1: r.Checksum.Value, Size: r.SizeInBytes, } }
go
func (r V3Resource) ToV2Resource() Resource { return Resource{ Filename: r.FilePath, Mode: r.Mode, SHA1: r.Checksum.Value, Size: r.SizeInBytes, } }
[ "func", "(", "r", "V3Resource", ")", "ToV2Resource", "(", ")", "Resource", "{", "return", "Resource", "{", "Filename", ":", "r", ".", "FilePath", ",", "Mode", ":", "r", ".", "Mode", ",", "SHA1", ":", "r", ".", "Checksum", ".", "Value", ",", "Size", ":", "r", ".", "SizeInBytes", ",", "}", "\n", "}" ]
// ToV2Resource converts a V3 Resource to V2 Resource format
[ "ToV2Resource", "converts", "a", "V3", "Resource", "to", "V2", "Resource", "format" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L59-L66
train
cloudfoundry/cli
actor/sharedaction/resource.go
GatherArchiveResources
func (actor Actor) GatherArchiveResources(archivePath string) ([]Resource, error) { var resources []Resource archive, err := os.Open(archivePath) if err != nil { return nil, err } defer archive.Close() reader, err := actor.newArchiveReader(archive) if err != nil { return nil, err } gitIgnore, err := actor.generateArchiveCFIgnoreMatcher(reader.File) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } for _, archivedFile := range reader.File { filename := filepath.ToSlash(archivedFile.Name) if gitIgnore.MatchesPath(filename) { continue } resource := Resource{Filename: filename} info := archivedFile.FileInfo() switch { case info.IsDir(): resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: resource.Mode = info.Mode() default: fileReader, err := archivedFile.Open() if err != nil { return nil, err } defer fileReader.Close() hash := sha1.New() _, err = io.Copy(hash, fileReader) if err != nil { return nil, err } resource.Mode = DefaultArchiveFilePermissions resource.SHA1 = fmt.Sprintf("%x", hash.Sum(nil)) resource.Size = archivedFile.FileInfo().Size() } resources = append(resources, resource) } if len(resources) <= 1 { return nil, actionerror.EmptyArchiveError{Path: archivePath} } return resources, nil }
go
func (actor Actor) GatherArchiveResources(archivePath string) ([]Resource, error) { var resources []Resource archive, err := os.Open(archivePath) if err != nil { return nil, err } defer archive.Close() reader, err := actor.newArchiveReader(archive) if err != nil { return nil, err } gitIgnore, err := actor.generateArchiveCFIgnoreMatcher(reader.File) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } for _, archivedFile := range reader.File { filename := filepath.ToSlash(archivedFile.Name) if gitIgnore.MatchesPath(filename) { continue } resource := Resource{Filename: filename} info := archivedFile.FileInfo() switch { case info.IsDir(): resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: resource.Mode = info.Mode() default: fileReader, err := archivedFile.Open() if err != nil { return nil, err } defer fileReader.Close() hash := sha1.New() _, err = io.Copy(hash, fileReader) if err != nil { return nil, err } resource.Mode = DefaultArchiveFilePermissions resource.SHA1 = fmt.Sprintf("%x", hash.Sum(nil)) resource.Size = archivedFile.FileInfo().Size() } resources = append(resources, resource) } if len(resources) <= 1 { return nil, actionerror.EmptyArchiveError{Path: archivePath} } return resources, nil }
[ "func", "(", "actor", "Actor", ")", "GatherArchiveResources", "(", "archivePath", "string", ")", "(", "[", "]", "Resource", ",", "error", ")", "{", "var", "resources", "[", "]", "Resource", "\n\n", "archive", ",", "err", ":=", "os", ".", "Open", "(", "archivePath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "archive", ".", "Close", "(", ")", "\n\n", "reader", ",", "err", ":=", "actor", ".", "newArchiveReader", "(", "archive", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "gitIgnore", ",", "err", ":=", "actor", ".", "generateArchiveCFIgnoreMatcher", "(", "reader", ".", "File", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "archivedFile", ":=", "range", "reader", ".", "File", "{", "filename", ":=", "filepath", ".", "ToSlash", "(", "archivedFile", ".", "Name", ")", "\n", "if", "gitIgnore", ".", "MatchesPath", "(", "filename", ")", "{", "continue", "\n", "}", "\n\n", "resource", ":=", "Resource", "{", "Filename", ":", "filename", "}", "\n", "info", ":=", "archivedFile", ".", "FileInfo", "(", ")", "\n\n", "switch", "{", "case", "info", ".", "IsDir", "(", ")", ":", "resource", ".", "Mode", "=", "DefaultFolderPermissions", "\n", "case", "info", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "os", ".", "ModeSymlink", ":", "resource", ".", "Mode", "=", "info", ".", "Mode", "(", ")", "\n", "default", ":", "fileReader", ",", "err", ":=", "archivedFile", ".", "Open", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", "fileReader", ".", "Close", "(", ")", "\n\n", "hash", ":=", "sha1", ".", "New", "(", ")", "\n\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "hash", ",", "fileReader", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "resource", ".", "Mode", "=", "DefaultArchiveFilePermissions", "\n", "resource", ".", "SHA1", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "hash", ".", "Sum", "(", "nil", ")", ")", "\n", "resource", ".", "Size", "=", "archivedFile", ".", "FileInfo", "(", ")", ".", "Size", "(", ")", "\n", "}", "\n\n", "resources", "=", "append", "(", "resources", ",", "resource", ")", "\n", "}", "\n", "if", "len", "(", "resources", ")", "<=", "1", "{", "return", "nil", ",", "actionerror", ".", "EmptyArchiveError", "{", "Path", ":", "archivePath", "}", "\n", "}", "\n", "return", "resources", ",", "nil", "\n", "}" ]
// GatherArchiveResources returns a list of resources for an archive.
[ "GatherArchiveResources", "returns", "a", "list", "of", "resources", "for", "an", "archive", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L69-L128
train
cloudfoundry/cli
actor/sharedaction/resource.go
GatherDirectoryResources
func (actor Actor) GatherDirectoryResources(sourceDir string) ([]Resource, error) { var ( resources []Resource gitIgnore *ignore.GitIgnore ) gitIgnore, err := actor.generateDirectoryCFIgnoreMatcher(sourceDir) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } evalDir, err := filepath.EvalSymlinks(sourceDir) if err != nil { log.Errorln("evaluating symlink:", err) return nil, err } walkErr := filepath.Walk(evalDir, func(fullPath string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(evalDir, fullPath) if err != nil { return err } // if file ignored continue to the next file if gitIgnore.MatchesPath(relPath) { return nil } if relPath == "." { return nil } resource := Resource{ Filename: filepath.ToSlash(relPath), } switch { case info.IsDir(): // If the file is a directory resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: // If the file is a Symlink we just set the mode of the file // We won't be using any sha information since we don't do // any resource matching on symlinks. resource.Mode = fixMode(info.Mode()) default: // If the file is regular we want to open // and calculate the sha of the file file, err := os.Open(fullPath) if err != nil { return err } defer file.Close() sum := sha1.New() _, err = io.Copy(sum, file) if err != nil { return err } resource.Mode = fixMode(info.Mode()) resource.SHA1 = fmt.Sprintf("%x", sum.Sum(nil)) resource.Size = info.Size() } resources = append(resources, resource) return nil }) if len(resources) == 0 { return nil, actionerror.EmptyDirectoryError{Path: sourceDir} } return resources, walkErr }
go
func (actor Actor) GatherDirectoryResources(sourceDir string) ([]Resource, error) { var ( resources []Resource gitIgnore *ignore.GitIgnore ) gitIgnore, err := actor.generateDirectoryCFIgnoreMatcher(sourceDir) if err != nil { log.Errorln("reading .cfignore file:", err) return nil, err } evalDir, err := filepath.EvalSymlinks(sourceDir) if err != nil { log.Errorln("evaluating symlink:", err) return nil, err } walkErr := filepath.Walk(evalDir, func(fullPath string, info os.FileInfo, err error) error { if err != nil { return err } relPath, err := filepath.Rel(evalDir, fullPath) if err != nil { return err } // if file ignored continue to the next file if gitIgnore.MatchesPath(relPath) { return nil } if relPath == "." { return nil } resource := Resource{ Filename: filepath.ToSlash(relPath), } switch { case info.IsDir(): // If the file is a directory resource.Mode = DefaultFolderPermissions case info.Mode()&os.ModeSymlink == os.ModeSymlink: // If the file is a Symlink we just set the mode of the file // We won't be using any sha information since we don't do // any resource matching on symlinks. resource.Mode = fixMode(info.Mode()) default: // If the file is regular we want to open // and calculate the sha of the file file, err := os.Open(fullPath) if err != nil { return err } defer file.Close() sum := sha1.New() _, err = io.Copy(sum, file) if err != nil { return err } resource.Mode = fixMode(info.Mode()) resource.SHA1 = fmt.Sprintf("%x", sum.Sum(nil)) resource.Size = info.Size() } resources = append(resources, resource) return nil }) if len(resources) == 0 { return nil, actionerror.EmptyDirectoryError{Path: sourceDir} } return resources, walkErr }
[ "func", "(", "actor", "Actor", ")", "GatherDirectoryResources", "(", "sourceDir", "string", ")", "(", "[", "]", "Resource", ",", "error", ")", "{", "var", "(", "resources", "[", "]", "Resource", "\n", "gitIgnore", "*", "ignore", ".", "GitIgnore", "\n", ")", "\n\n", "gitIgnore", ",", "err", ":=", "actor", ".", "generateDirectoryCFIgnoreMatcher", "(", "sourceDir", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "evalDir", ",", "err", ":=", "filepath", ".", "EvalSymlinks", "(", "sourceDir", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "err", "\n", "}", "\n\n", "walkErr", ":=", "filepath", ".", "Walk", "(", "evalDir", ",", "func", "(", "fullPath", "string", ",", "info", "os", ".", "FileInfo", ",", "err", "error", ")", "error", "{", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "relPath", ",", "err", ":=", "filepath", ".", "Rel", "(", "evalDir", ",", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "// if file ignored continue to the next file", "if", "gitIgnore", ".", "MatchesPath", "(", "relPath", ")", "{", "return", "nil", "\n", "}", "\n\n", "if", "relPath", "==", "\"", "\"", "{", "return", "nil", "\n", "}", "\n\n", "resource", ":=", "Resource", "{", "Filename", ":", "filepath", ".", "ToSlash", "(", "relPath", ")", ",", "}", "\n\n", "switch", "{", "case", "info", ".", "IsDir", "(", ")", ":", "// If the file is a directory", "resource", ".", "Mode", "=", "DefaultFolderPermissions", "\n", "case", "info", ".", "Mode", "(", ")", "&", "os", ".", "ModeSymlink", "==", "os", ".", "ModeSymlink", ":", "// If the file is a Symlink we just set the mode of the file", "// We won't be using any sha information since we don't do", "// any resource matching on symlinks.", "resource", ".", "Mode", "=", "fixMode", "(", "info", ".", "Mode", "(", ")", ")", "\n", "default", ":", "// If the file is regular we want to open", "// and calculate the sha of the file", "file", ",", "err", ":=", "os", ".", "Open", "(", "fullPath", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "file", ".", "Close", "(", ")", "\n\n", "sum", ":=", "sha1", ".", "New", "(", ")", "\n", "_", ",", "err", "=", "io", ".", "Copy", "(", "sum", ",", "file", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "resource", ".", "Mode", "=", "fixMode", "(", "info", ".", "Mode", "(", ")", ")", "\n", "resource", ".", "SHA1", "=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "sum", ".", "Sum", "(", "nil", ")", ")", "\n", "resource", ".", "Size", "=", "info", ".", "Size", "(", ")", "\n", "}", "\n\n", "resources", "=", "append", "(", "resources", ",", "resource", ")", "\n", "return", "nil", "\n", "}", ")", "\n\n", "if", "len", "(", "resources", ")", "==", "0", "{", "return", "nil", ",", "actionerror", ".", "EmptyDirectoryError", "{", "Path", ":", "sourceDir", "}", "\n", "}", "\n\n", "return", "resources", ",", "walkErr", "\n", "}" ]
// GatherDirectoryResources returns a list of resources for a directory.
[ "GatherDirectoryResources", "returns", "a", "list", "of", "resources", "for", "a", "directory", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/resource.go#L131-L210
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
MarshalJSON
func (application Application) MarshalJSON() ([]byte, error) { ccApp := struct { Buildpack *string `json:"buildpack,omitempty"` Command *string `json:"command,omitempty"` DiskQuota *uint64 `json:"disk_quota,omitempty"` DockerCredentials *DockerCredentials `json:"docker_credentials,omitempty"` DockerImage string `json:"docker_image,omitempty"` EnvironmentVariables map[string]string `json:"environment_json,omitempty"` HealthCheckHTTPEndpoint *string `json:"health_check_http_endpoint,omitempty"` HealthCheckTimeout uint64 `json:"health_check_timeout,omitempty"` HealthCheckType constant.ApplicationHealthCheckType `json:"health_check_type,omitempty"` Instances *int `json:"instances,omitempty"` Memory *uint64 `json:"memory,omitempty"` Name string `json:"name,omitempty"` SpaceGUID string `json:"space_guid,omitempty"` StackGUID string `json:"stack_guid,omitempty"` State constant.ApplicationState `json:"state,omitempty"` }{ DockerImage: application.DockerImage, EnvironmentVariables: application.EnvironmentVariables, HealthCheckTimeout: application.HealthCheckTimeout, HealthCheckType: application.HealthCheckType, Name: application.Name, SpaceGUID: application.SpaceGUID, StackGUID: application.StackGUID, State: application.State, } if application.Buildpack.IsSet { ccApp.Buildpack = &application.Buildpack.Value } if application.Command.IsSet { ccApp.Command = &application.Command.Value } if application.DiskQuota.IsSet { ccApp.DiskQuota = &application.DiskQuota.Value } if application.DockerCredentials.Username != "" || application.DockerCredentials.Password != "" { ccApp.DockerCredentials = &DockerCredentials{ Username: application.DockerCredentials.Username, Password: application.DockerCredentials.Password, } } if application.Instances.IsSet { ccApp.Instances = &application.Instances.Value } if application.HealthCheckType != "" { ccApp.HealthCheckHTTPEndpoint = &application.HealthCheckHTTPEndpoint } if application.Memory.IsSet { ccApp.Memory = &application.Memory.Value } return json.Marshal(ccApp) }
go
func (application Application) MarshalJSON() ([]byte, error) { ccApp := struct { Buildpack *string `json:"buildpack,omitempty"` Command *string `json:"command,omitempty"` DiskQuota *uint64 `json:"disk_quota,omitempty"` DockerCredentials *DockerCredentials `json:"docker_credentials,omitempty"` DockerImage string `json:"docker_image,omitempty"` EnvironmentVariables map[string]string `json:"environment_json,omitempty"` HealthCheckHTTPEndpoint *string `json:"health_check_http_endpoint,omitempty"` HealthCheckTimeout uint64 `json:"health_check_timeout,omitempty"` HealthCheckType constant.ApplicationHealthCheckType `json:"health_check_type,omitempty"` Instances *int `json:"instances,omitempty"` Memory *uint64 `json:"memory,omitempty"` Name string `json:"name,omitempty"` SpaceGUID string `json:"space_guid,omitempty"` StackGUID string `json:"stack_guid,omitempty"` State constant.ApplicationState `json:"state,omitempty"` }{ DockerImage: application.DockerImage, EnvironmentVariables: application.EnvironmentVariables, HealthCheckTimeout: application.HealthCheckTimeout, HealthCheckType: application.HealthCheckType, Name: application.Name, SpaceGUID: application.SpaceGUID, StackGUID: application.StackGUID, State: application.State, } if application.Buildpack.IsSet { ccApp.Buildpack = &application.Buildpack.Value } if application.Command.IsSet { ccApp.Command = &application.Command.Value } if application.DiskQuota.IsSet { ccApp.DiskQuota = &application.DiskQuota.Value } if application.DockerCredentials.Username != "" || application.DockerCredentials.Password != "" { ccApp.DockerCredentials = &DockerCredentials{ Username: application.DockerCredentials.Username, Password: application.DockerCredentials.Password, } } if application.Instances.IsSet { ccApp.Instances = &application.Instances.Value } if application.HealthCheckType != "" { ccApp.HealthCheckHTTPEndpoint = &application.HealthCheckHTTPEndpoint } if application.Memory.IsSet { ccApp.Memory = &application.Memory.Value } return json.Marshal(ccApp) }
[ "func", "(", "application", "Application", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ccApp", ":=", "struct", "{", "Buildpack", "*", "string", "`json:\"buildpack,omitempty\"`", "\n", "Command", "*", "string", "`json:\"command,omitempty\"`", "\n", "DiskQuota", "*", "uint64", "`json:\"disk_quota,omitempty\"`", "\n", "DockerCredentials", "*", "DockerCredentials", "`json:\"docker_credentials,omitempty\"`", "\n", "DockerImage", "string", "`json:\"docker_image,omitempty\"`", "\n", "EnvironmentVariables", "map", "[", "string", "]", "string", "`json:\"environment_json,omitempty\"`", "\n", "HealthCheckHTTPEndpoint", "*", "string", "`json:\"health_check_http_endpoint,omitempty\"`", "\n", "HealthCheckTimeout", "uint64", "`json:\"health_check_timeout,omitempty\"`", "\n", "HealthCheckType", "constant", ".", "ApplicationHealthCheckType", "`json:\"health_check_type,omitempty\"`", "\n", "Instances", "*", "int", "`json:\"instances,omitempty\"`", "\n", "Memory", "*", "uint64", "`json:\"memory,omitempty\"`", "\n", "Name", "string", "`json:\"name,omitempty\"`", "\n", "SpaceGUID", "string", "`json:\"space_guid,omitempty\"`", "\n", "StackGUID", "string", "`json:\"stack_guid,omitempty\"`", "\n", "State", "constant", ".", "ApplicationState", "`json:\"state,omitempty\"`", "\n", "}", "{", "DockerImage", ":", "application", ".", "DockerImage", ",", "EnvironmentVariables", ":", "application", ".", "EnvironmentVariables", ",", "HealthCheckTimeout", ":", "application", ".", "HealthCheckTimeout", ",", "HealthCheckType", ":", "application", ".", "HealthCheckType", ",", "Name", ":", "application", ".", "Name", ",", "SpaceGUID", ":", "application", ".", "SpaceGUID", ",", "StackGUID", ":", "application", ".", "StackGUID", ",", "State", ":", "application", ".", "State", ",", "}", "\n\n", "if", "application", ".", "Buildpack", ".", "IsSet", "{", "ccApp", ".", "Buildpack", "=", "&", "application", ".", "Buildpack", ".", "Value", "\n", "}", "\n\n", "if", "application", ".", "Command", ".", "IsSet", "{", "ccApp", ".", "Command", "=", "&", "application", ".", "Command", ".", "Value", "\n", "}", "\n\n", "if", "application", ".", "DiskQuota", ".", "IsSet", "{", "ccApp", ".", "DiskQuota", "=", "&", "application", ".", "DiskQuota", ".", "Value", "\n", "}", "\n\n", "if", "application", ".", "DockerCredentials", ".", "Username", "!=", "\"", "\"", "||", "application", ".", "DockerCredentials", ".", "Password", "!=", "\"", "\"", "{", "ccApp", ".", "DockerCredentials", "=", "&", "DockerCredentials", "{", "Username", ":", "application", ".", "DockerCredentials", ".", "Username", ",", "Password", ":", "application", ".", "DockerCredentials", ".", "Password", ",", "}", "\n", "}", "\n\n", "if", "application", ".", "Instances", ".", "IsSet", "{", "ccApp", ".", "Instances", "=", "&", "application", ".", "Instances", ".", "Value", "\n", "}", "\n\n", "if", "application", ".", "HealthCheckType", "!=", "\"", "\"", "{", "ccApp", ".", "HealthCheckHTTPEndpoint", "=", "&", "application", ".", "HealthCheckHTTPEndpoint", "\n", "}", "\n\n", "if", "application", ".", "Memory", ".", "IsSet", "{", "ccApp", ".", "Memory", "=", "&", "application", ".", "Memory", ".", "Value", "\n", "}", "\n\n", "return", "json", ".", "Marshal", "(", "ccApp", ")", "\n", "}" ]
// MarshalJSON converts an application into a Cloud Controller Application.
[ "MarshalJSON", "converts", "an", "application", "into", "a", "Cloud", "Controller", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L89-L149
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
CreateApplication
func (client *Client) CreateApplication(app Application) (Application, Warnings, error) { body, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRequest, Body: bytes.NewReader(body), }) if err != nil { return Application{}, nil, err } var updatedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &updatedApp, } err = client.connection.Make(request, &response) return updatedApp, response.Warnings, err }
go
func (client *Client) CreateApplication(app Application) (Application, Warnings, error) { body, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRequest, Body: bytes.NewReader(body), }) if err != nil { return Application{}, nil, err } var updatedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &updatedApp, } err = client.connection.Make(request, &response) return updatedApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "CreateApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "body", ",", "err", ":=", "json", ".", "Marshal", "(", "app", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostAppRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "body", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "updatedApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "updatedApp", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "updatedApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// CreateApplication creates a cloud controller application in with the given // settings. SpaceGUID and Name are the only required fields.
[ "CreateApplication", "creates", "a", "cloud", "controller", "application", "in", "with", "the", "given", "settings", ".", "SpaceGUID", "and", "Name", "are", "the", "only", "required", "fields", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L227-L248
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
GetApplication
func (client *Client) GetApplication(guid string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetAppRequest, URIParams: Params{"app_guid": guid}, }) if err != nil { return Application{}, nil, err } var app Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &app, } err = client.connection.Make(request, &response) return app, response.Warnings, err }
go
func (client *Client) GetApplication(guid string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetAppRequest, URIParams: Params{"app_guid": guid}, }) if err != nil { return Application{}, nil, err } var app Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &app, } err = client.connection.Make(request, &response) return app, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplication", "(", "guid", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetAppRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "guid", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "app", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "app", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "app", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetApplication returns back an Application.
[ "GetApplication", "returns", "back", "an", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L251-L267
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
GetRouteApplications
func (client *Client) GetRouteApplications(routeGUID string, filters ...Filter) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteAppsRequest, URIParams: map[string]string{"route_guid": routeGUID}, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullAppsList []Application warnings, err := client.paginate(request, Application{}, func(item interface{}) error { if app, ok := item.(Application); ok { fullAppsList = append(fullAppsList, app) } else { return ccerror.UnknownObjectInListError{ Expected: Application{}, Unexpected: item, } } return nil }) return fullAppsList, warnings, err }
go
func (client *Client) GetRouteApplications(routeGUID string, filters ...Filter) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetRouteAppsRequest, URIParams: map[string]string{"route_guid": routeGUID}, Query: ConvertFilterParameters(filters), }) if err != nil { return nil, nil, err } var fullAppsList []Application warnings, err := client.paginate(request, Application{}, func(item interface{}) error { if app, ok := item.(Application); ok { fullAppsList = append(fullAppsList, app) } else { return ccerror.UnknownObjectInListError{ Expected: Application{}, Unexpected: item, } } return nil }) return fullAppsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetRouteApplications", "(", "routeGUID", "string", ",", "filters", "...", "Filter", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetRouteAppsRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "routeGUID", "}", ",", "Query", ":", "ConvertFilterParameters", "(", "filters", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullAppsList", "[", "]", "Application", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Application", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "app", ",", "ok", ":=", "item", ".", "(", "Application", ")", ";", "ok", "{", "fullAppsList", "=", "append", "(", "fullAppsList", ",", "app", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Application", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullAppsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetRouteApplications returns a list of Applications based off a route // GUID and the provided filters.
[ "GetRouteApplications", "returns", "a", "list", "of", "Applications", "based", "off", "a", "route", "GUID", "and", "the", "provided", "filters", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L298-L322
train
cloudfoundry/cli
api/cloudcontroller/ccv2/application.go
RestageApplication
func (client *Client) RestageApplication(app Application) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRestageRequest, URIParams: Params{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var restagedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &restagedApp, } err = client.connection.Make(request, &response) return restagedApp, response.Warnings, err }
go
func (client *Client) RestageApplication(app Application) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostAppRestageRequest, URIParams: Params{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var restagedApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &restagedApp, } err = client.connection.Make(request, &response) return restagedApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "RestageApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostAppRestageRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "app", ".", "GUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "restagedApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "restagedApp", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "restagedApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// RestageApplication restages the application with the given GUID.
[ "RestageApplication", "restages", "the", "application", "with", "the", "given", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/application.go#L325-L341
train
cloudfoundry/cli
actor/pushaction/application.go
CalculatedBuildpacks
func (app Application) CalculatedBuildpacks() []string { buildpack := app.CalculatedBuildpack() switch { case app.Buildpacks != nil: return app.Buildpacks case len(buildpack) > 0: return []string{buildpack} default: return nil } }
go
func (app Application) CalculatedBuildpacks() []string { buildpack := app.CalculatedBuildpack() switch { case app.Buildpacks != nil: return app.Buildpacks case len(buildpack) > 0: return []string{buildpack} default: return nil } }
[ "func", "(", "app", "Application", ")", "CalculatedBuildpacks", "(", ")", "[", "]", "string", "{", "buildpack", ":=", "app", ".", "CalculatedBuildpack", "(", ")", "\n", "switch", "{", "case", "app", ".", "Buildpacks", "!=", "nil", ":", "return", "app", ".", "Buildpacks", "\n", "case", "len", "(", "buildpack", ")", ">", "0", ":", "return", "[", "]", "string", "{", "buildpack", "}", "\n", "default", ":", "return", "nil", "\n", "}", "\n", "}" ]
// CalculatedBuildpacks will return back the buildpacks for the application.
[ "CalculatedBuildpacks", "will", "return", "back", "the", "buildpacks", "for", "the", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/application.go#L22-L32
train
cloudfoundry/cli
actor/pushaction/application.go
ignoreSameStackGUID
func (actor Actor) ignoreSameStackGUID(config ApplicationConfig, v2App v2action.Application) v2action.Application { if config.CurrentApplication.StackGUID == config.DesiredApplication.StackGUID { v2App.StackGUID = "" } return v2App }
go
func (actor Actor) ignoreSameStackGUID(config ApplicationConfig, v2App v2action.Application) v2action.Application { if config.CurrentApplication.StackGUID == config.DesiredApplication.StackGUID { v2App.StackGUID = "" } return v2App }
[ "func", "(", "actor", "Actor", ")", "ignoreSameStackGUID", "(", "config", "ApplicationConfig", ",", "v2App", "v2action", ".", "Application", ")", "v2action", ".", "Application", "{", "if", "config", ".", "CurrentApplication", ".", "StackGUID", "==", "config", ".", "DesiredApplication", ".", "StackGUID", "{", "v2App", ".", "StackGUID", "=", "\"", "\"", "\n", "}", "\n\n", "return", "v2App", "\n", "}" ]
// Apps updates with both docker image and stack guids fail. So do not send // StackGUID unless it is necessary.
[ "Apps", "updates", "with", "both", "docker", "image", "and", "stack", "guids", "fail", ".", "So", "do", "not", "send", "StackGUID", "unless", "it", "is", "necessary", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/application.go#L155-L161
train
cloudfoundry/cli
api/plugin/client.go
NewClient
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, connection: NewConnection(config.SkipSSLValidation, config.DialTimeout), } return &client }
go
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, connection: NewConnection(config.SkipSSLValidation, config.DialTimeout), } return &client }
[ "func", "NewClient", "(", "config", "Config", ")", "*", "Client", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "config", ".", "AppName", ",", "config", ".", "AppVersion", ",", "runtime", ".", "Version", "(", ")", ",", "runtime", ".", "GOARCH", ",", "runtime", ".", "GOOS", ",", ")", "\n", "client", ":=", "Client", "{", "userAgent", ":", "userAgent", ",", "connection", ":", "NewConnection", "(", "config", ".", "SkipSSLValidation", ",", "config", ".", "DialTimeout", ")", ",", "}", "\n\n", "return", "&", "client", "\n", "}" ]
// NewClient returns a new plugin Client.
[ "NewClient", "returns", "a", "new", "plugin", "Client", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/plugin/client.go#L39-L53
train
cloudfoundry/cli
actor/v7pushaction/update_application_settings.go
UpdateApplicationSettings
func (actor Actor) UpdateApplicationSettings(pushPlans []PushPlan) ([]PushPlan, Warnings, error) { appNames := actor.getAppNames(pushPlans) applications, getWarnings, err := actor.V7Actor.GetApplicationsByNamesAndSpace(appNames, pushPlans[0].SpaceGUID) warnings := Warnings(getWarnings) if err != nil { log.Errorln("Looking up applications:", err) return nil, warnings, err } nameToApp := actor.generateAppNameToApplicationMapping(applications) var updatedPushPlans []PushPlan for _, pushPlan := range pushPlans { app := nameToApp[pushPlan.Application.Name] pushPlan.Application.GUID = app.GUID pushPlan.Application.State = app.State updatedPushPlans = append(updatedPushPlans, pushPlan) } return updatedPushPlans, warnings, err }
go
func (actor Actor) UpdateApplicationSettings(pushPlans []PushPlan) ([]PushPlan, Warnings, error) { appNames := actor.getAppNames(pushPlans) applications, getWarnings, err := actor.V7Actor.GetApplicationsByNamesAndSpace(appNames, pushPlans[0].SpaceGUID) warnings := Warnings(getWarnings) if err != nil { log.Errorln("Looking up applications:", err) return nil, warnings, err } nameToApp := actor.generateAppNameToApplicationMapping(applications) var updatedPushPlans []PushPlan for _, pushPlan := range pushPlans { app := nameToApp[pushPlan.Application.Name] pushPlan.Application.GUID = app.GUID pushPlan.Application.State = app.State updatedPushPlans = append(updatedPushPlans, pushPlan) } return updatedPushPlans, warnings, err }
[ "func", "(", "actor", "Actor", ")", "UpdateApplicationSettings", "(", "pushPlans", "[", "]", "PushPlan", ")", "(", "[", "]", "PushPlan", ",", "Warnings", ",", "error", ")", "{", "appNames", ":=", "actor", ".", "getAppNames", "(", "pushPlans", ")", "\n", "applications", ",", "getWarnings", ",", "err", ":=", "actor", ".", "V7Actor", ".", "GetApplicationsByNamesAndSpace", "(", "appNames", ",", "pushPlans", "[", "0", "]", ".", "SpaceGUID", ")", "\n", "warnings", ":=", "Warnings", "(", "getWarnings", ")", "\n", "if", "err", "!=", "nil", "{", "log", ".", "Errorln", "(", "\"", "\"", ",", "err", ")", "\n", "return", "nil", ",", "warnings", ",", "err", "\n", "}", "\n\n", "nameToApp", ":=", "actor", ".", "generateAppNameToApplicationMapping", "(", "applications", ")", "\n\n", "var", "updatedPushPlans", "[", "]", "PushPlan", "\n", "for", "_", ",", "pushPlan", ":=", "range", "pushPlans", "{", "app", ":=", "nameToApp", "[", "pushPlan", ".", "Application", ".", "Name", "]", "\n", "pushPlan", ".", "Application", ".", "GUID", "=", "app", ".", "GUID", "\n", "pushPlan", ".", "Application", ".", "State", "=", "app", ".", "State", "\n\n", "updatedPushPlans", "=", "append", "(", "updatedPushPlans", ",", "pushPlan", ")", "\n", "}", "\n\n", "return", "updatedPushPlans", ",", "warnings", ",", "err", "\n", "}" ]
// UpdateApplicationSettings syncs the Application state and GUID with the API.
[ "UpdateApplicationSettings", "syncs", "the", "Application", "state", "and", "GUID", "with", "the", "API", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/update_application_settings.go#L10-L31
train
cloudfoundry/cli
cf/api/logs/noaa_message_queue.go
Less
func (pq *NoaaMessageQueue) Less(i, j int) bool { return *pq.messages[i].Timestamp < *pq.messages[j].Timestamp }
go
func (pq *NoaaMessageQueue) Less(i, j int) bool { return *pq.messages[i].Timestamp < *pq.messages[j].Timestamp }
[ "func", "(", "pq", "*", "NoaaMessageQueue", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "*", "pq", ".", "messages", "[", "i", "]", ".", "Timestamp", "<", "*", "pq", ".", "messages", "[", "j", "]", ".", "Timestamp", "\n", "}" ]
// implement sort interface so we can sort messages as we receive them in PushMessage
[ "implement", "sort", "interface", "so", "we", "can", "sort", "messages", "as", "we", "receive", "them", "in", "PushMessage" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/api/logs/noaa_message_queue.go#L27-L29
train
cloudfoundry/cli
actor/v7pushaction/create_push_plans.go
CreatePushPlans
func (actor Actor) CreatePushPlans(appNameArg string, spaceGUID string, orgGUID string, parser ManifestParser, overrides FlagOverrides) ([]PushPlan, error) { var pushPlans []PushPlan eligibleApps, err := actor.getEligibleApplications(parser, appNameArg) if err != nil { return nil, err } for _, manifestApplication := range eligibleApps { plan := PushPlan{ OrgGUID: orgGUID, SpaceGUID: spaceGUID, } // List of PushPlanFuncs is defined in NewActor for _, updatePlan := range actor.PushPlanFuncs { var err error plan, err = updatePlan(plan, overrides, manifestApplication) if err != nil { return nil, err } } pushPlans = append(pushPlans, plan) } return pushPlans, nil }
go
func (actor Actor) CreatePushPlans(appNameArg string, spaceGUID string, orgGUID string, parser ManifestParser, overrides FlagOverrides) ([]PushPlan, error) { var pushPlans []PushPlan eligibleApps, err := actor.getEligibleApplications(parser, appNameArg) if err != nil { return nil, err } for _, manifestApplication := range eligibleApps { plan := PushPlan{ OrgGUID: orgGUID, SpaceGUID: spaceGUID, } // List of PushPlanFuncs is defined in NewActor for _, updatePlan := range actor.PushPlanFuncs { var err error plan, err = updatePlan(plan, overrides, manifestApplication) if err != nil { return nil, err } } pushPlans = append(pushPlans, plan) } return pushPlans, nil }
[ "func", "(", "actor", "Actor", ")", "CreatePushPlans", "(", "appNameArg", "string", ",", "spaceGUID", "string", ",", "orgGUID", "string", ",", "parser", "ManifestParser", ",", "overrides", "FlagOverrides", ")", "(", "[", "]", "PushPlan", ",", "error", ")", "{", "var", "pushPlans", "[", "]", "PushPlan", "\n\n", "eligibleApps", ",", "err", ":=", "actor", ".", "getEligibleApplications", "(", "parser", ",", "appNameArg", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "manifestApplication", ":=", "range", "eligibleApps", "{", "plan", ":=", "PushPlan", "{", "OrgGUID", ":", "orgGUID", ",", "SpaceGUID", ":", "spaceGUID", ",", "}", "\n\n", "// List of PushPlanFuncs is defined in NewActor", "for", "_", ",", "updatePlan", ":=", "range", "actor", ".", "PushPlanFuncs", "{", "var", "err", "error", "\n", "plan", ",", "err", "=", "updatePlan", "(", "plan", ",", "overrides", ",", "manifestApplication", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "pushPlans", "=", "append", "(", "pushPlans", ",", "plan", ")", "\n", "}", "\n\n", "return", "pushPlans", ",", "nil", "\n", "}" ]
// CreatePushPlans returns a set of PushPlan objects based off the inputs // provided. It's assumed that all flag and argument and manifest combinations // have been validated prior to calling this function.
[ "CreatePushPlans", "returns", "a", "set", "of", "PushPlan", "objects", "based", "off", "the", "inputs", "provided", ".", "It", "s", "assumed", "that", "all", "flag", "and", "argument", "and", "manifest", "combinations", "have", "been", "validated", "prior", "to", "calling", "this", "function", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/create_push_plans.go#L10-L37
train
cloudfoundry/cli
api/cloudcontroller/ccv3/buildpack.go
DeleteBuildpack
func (client Client) DeleteBuildpack(buildpackGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteBuildpackRequest, URIParams: map[string]string{ "buildpack_guid": buildpackGUID, }, }) if err != nil { return "", nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
go
func (client Client) DeleteBuildpack(buildpackGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteBuildpackRequest, URIParams: map[string]string{ "buildpack_guid": buildpackGUID, }, }) if err != nil { return "", nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
[ "func", "(", "client", "Client", ")", "DeleteBuildpack", "(", "buildpackGUID", "string", ")", "(", "JobURL", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteBuildpackRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "buildpackGUID", ",", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "JobURL", "(", "response", ".", "ResourceLocationURL", ")", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteBuildpack deletes the buildpack with the provided guid.
[ "DeleteBuildpack", "deletes", "the", "buildpack", "with", "the", "provided", "guid", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/buildpack.go#L122-L137
train
cloudfoundry/cli
actor/v7pushaction/resource_match.go
MatchResources
func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) { matches, warnings, err := actor.V7Actor.ResourceMatch(resources) mapChecksumToResource := map[string]sharedaction.V3Resource{} for _, resource := range matches { mapChecksumToResource[resource.Checksum.Value] = resource } var unmatches []sharedaction.V3Resource for _, resource := range resources { if _, ok := mapChecksumToResource[resource.Checksum.Value]; !ok { unmatches = append(unmatches, resource) } } return matches, unmatches, Warnings(warnings), err }
go
func (actor Actor) MatchResources(resources []sharedaction.V3Resource) ([]sharedaction.V3Resource, []sharedaction.V3Resource, Warnings, error) { matches, warnings, err := actor.V7Actor.ResourceMatch(resources) mapChecksumToResource := map[string]sharedaction.V3Resource{} for _, resource := range matches { mapChecksumToResource[resource.Checksum.Value] = resource } var unmatches []sharedaction.V3Resource for _, resource := range resources { if _, ok := mapChecksumToResource[resource.Checksum.Value]; !ok { unmatches = append(unmatches, resource) } } return matches, unmatches, Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "MatchResources", "(", "resources", "[", "]", "sharedaction", ".", "V3Resource", ")", "(", "[", "]", "sharedaction", ".", "V3Resource", ",", "[", "]", "sharedaction", ".", "V3Resource", ",", "Warnings", ",", "error", ")", "{", "matches", ",", "warnings", ",", "err", ":=", "actor", ".", "V7Actor", ".", "ResourceMatch", "(", "resources", ")", "\n\n", "mapChecksumToResource", ":=", "map", "[", "string", "]", "sharedaction", ".", "V3Resource", "{", "}", "\n", "for", "_", ",", "resource", ":=", "range", "matches", "{", "mapChecksumToResource", "[", "resource", ".", "Checksum", ".", "Value", "]", "=", "resource", "\n", "}", "\n\n", "var", "unmatches", "[", "]", "sharedaction", ".", "V3Resource", "\n", "for", "_", ",", "resource", ":=", "range", "resources", "{", "if", "_", ",", "ok", ":=", "mapChecksumToResource", "[", "resource", ".", "Checksum", ".", "Value", "]", ";", "!", "ok", "{", "unmatches", "=", "append", "(", "unmatches", ",", "resource", ")", "\n", "}", "\n", "}", "\n\n", "return", "matches", ",", "unmatches", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// MatchResources returns back a list of matched and unmatched resources for the provided resources.
[ "MatchResources", "returns", "back", "a", "list", "of", "matched", "and", "unmatched", "resources", "for", "the", "provided", "resources", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/resource_match.go#L6-L22
train
cloudfoundry/cli
api/cloudcontroller/ccv2/user.go
UnmarshalJSON
func (user *User) UnmarshalJSON(data []byte) error { var ccUser struct { Metadata internal.Metadata `json:"metadata"` } err := cloudcontroller.DecodeJSON(data, &ccUser) if err != nil { return err } user.GUID = ccUser.Metadata.GUID return nil }
go
func (user *User) UnmarshalJSON(data []byte) error { var ccUser struct { Metadata internal.Metadata `json:"metadata"` } err := cloudcontroller.DecodeJSON(data, &ccUser) if err != nil { return err } user.GUID = ccUser.Metadata.GUID return nil }
[ "func", "(", "user", "*", "User", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccUser", "struct", "{", "Metadata", "internal", ".", "Metadata", "`json:\"metadata\"`", "\n", "}", "\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccUser", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "user", ".", "GUID", "=", "ccUser", ".", "Metadata", ".", "GUID", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller User response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "User", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/user.go#L18-L29
train
cloudfoundry/cli
api/cloudcontroller/ccv2/user.go
CreateUser
func (client *Client) CreateUser(uaaUserID string) (User, Warnings, error) { type userRequestBody struct { GUID string `json:"guid"` } bodyBytes, err := json.Marshal(userRequestBody{ GUID: uaaUserID, }) if err != nil { return User{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostUserRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return User{}, nil, err } var user User response := cloudcontroller.Response{ DecodeJSONResponseInto: &user, } err = client.connection.Make(request, &response) if err != nil { return User{}, response.Warnings, err } return user, response.Warnings, nil }
go
func (client *Client) CreateUser(uaaUserID string) (User, Warnings, error) { type userRequestBody struct { GUID string `json:"guid"` } bodyBytes, err := json.Marshal(userRequestBody{ GUID: uaaUserID, }) if err != nil { return User{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostUserRequest, Body: bytes.NewReader(bodyBytes), }) if err != nil { return User{}, nil, err } var user User response := cloudcontroller.Response{ DecodeJSONResponseInto: &user, } err = client.connection.Make(request, &response) if err != nil { return User{}, response.Warnings, err } return user, response.Warnings, nil }
[ "func", "(", "client", "*", "Client", ")", "CreateUser", "(", "uaaUserID", "string", ")", "(", "User", ",", "Warnings", ",", "error", ")", "{", "type", "userRequestBody", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "}", "\n\n", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "userRequestBody", "{", "GUID", ":", "uaaUserID", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostUserRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "user", "User", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "user", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "User", "{", "}", ",", "response", ".", "Warnings", ",", "err", "\n", "}", "\n\n", "return", "user", ",", "response", ".", "Warnings", ",", "nil", "\n", "}" ]
// CreateUser creates a new Cloud Controller User from the provided UAA user // ID.
[ "CreateUser", "creates", "a", "new", "Cloud", "Controller", "User", "from", "the", "provided", "UAA", "user", "ID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/user.go#L33-L64
train
cloudfoundry/cli
api/router/client.go
NewClient
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, router: rata.NewRequestGenerator(config.RoutingEndpoint, internal.APIRoutes), connection: NewConnection(config.ConnectionConfig), } for _, wrapper := range config.Wrappers { client.connection = wrapper.Wrap(client.connection) } return &client }
go
func NewClient(config Config) *Client { userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS, ) client := Client{ userAgent: userAgent, router: rata.NewRequestGenerator(config.RoutingEndpoint, internal.APIRoutes), connection: NewConnection(config.ConnectionConfig), } for _, wrapper := range config.Wrappers { client.connection = wrapper.Wrap(client.connection) } return &client }
[ "func", "NewClient", "(", "config", "Config", ")", "*", "Client", "{", "userAgent", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "config", ".", "AppName", ",", "config", ".", "AppVersion", ",", "runtime", ".", "Version", "(", ")", ",", "runtime", ".", "GOARCH", ",", "runtime", ".", "GOOS", ",", ")", "\n\n", "client", ":=", "Client", "{", "userAgent", ":", "userAgent", ",", "router", ":", "rata", ".", "NewRequestGenerator", "(", "config", ".", "RoutingEndpoint", ",", "internal", ".", "APIRoutes", ")", ",", "connection", ":", "NewConnection", "(", "config", ".", "ConnectionConfig", ")", ",", "}", "\n\n", "for", "_", ",", "wrapper", ":=", "range", "config", ".", "Wrappers", "{", "client", ".", "connection", "=", "wrapper", ".", "Wrap", "(", "client", ".", "connection", ")", "\n", "}", "\n\n", "return", "&", "client", "\n", "}" ]
// NewClient returns a new Router Client.
[ "NewClient", "returns", "a", "new", "Router", "Client", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/client.go#L42-L62
train
cloudfoundry/cli
api/cloudcontroller/ccv2/service_instance_shared_from.go
GetServiceInstanceSharedFrom
func (client *Client) GetServiceInstanceSharedFrom(serviceInstanceGUID string) (ServiceInstanceSharedFrom, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedFromRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return ServiceInstanceSharedFrom{}, nil, err } var serviceInstanceSharedFrom ServiceInstanceSharedFrom response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceInstanceSharedFrom, } err = client.connection.Make(request, &response) return serviceInstanceSharedFrom, response.Warnings, err }
go
func (client *Client) GetServiceInstanceSharedFrom(serviceInstanceGUID string) (ServiceInstanceSharedFrom, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetServiceInstanceSharedFromRequest, URIParams: Params{"service_instance_guid": serviceInstanceGUID}, }) if err != nil { return ServiceInstanceSharedFrom{}, nil, err } var serviceInstanceSharedFrom ServiceInstanceSharedFrom response := cloudcontroller.Response{ DecodeJSONResponseInto: &serviceInstanceSharedFrom, } err = client.connection.Make(request, &response) return serviceInstanceSharedFrom, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetServiceInstanceSharedFrom", "(", "serviceInstanceGUID", "string", ")", "(", "ServiceInstanceSharedFrom", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetServiceInstanceSharedFromRequest", ",", "URIParams", ":", "Params", "{", "\"", "\"", ":", "serviceInstanceGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "ServiceInstanceSharedFrom", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "serviceInstanceSharedFrom", "ServiceInstanceSharedFrom", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "serviceInstanceSharedFrom", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "return", "serviceInstanceSharedFrom", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// GetServiceInstanceSharedFrom returns back a ServiceInstanceSharedFrom // object.
[ "GetServiceInstanceSharedFrom", "returns", "back", "a", "ServiceInstanceSharedFrom", "object", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance_shared_from.go#L26-L42
train
cloudfoundry/cli
api/cloudcontroller/ccv3/feature_flag.go
GetFeatureFlags
func (client *Client) GetFeatureFlags() ([]FeatureFlag, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetFeatureFlagsRequest, }) if err != nil { return nil, nil, err } var fullFeatureFlagList []FeatureFlag warnings, err := client.paginate(request, FeatureFlag{}, func(item interface{}) error { if featureFlag, ok := item.(FeatureFlag); ok { fullFeatureFlagList = append(fullFeatureFlagList, featureFlag) } else { return ccerror.UnknownObjectInListError{ Expected: FeatureFlag{}, Unexpected: item, } } return nil }) return fullFeatureFlagList, warnings, err }
go
func (client *Client) GetFeatureFlags() ([]FeatureFlag, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetFeatureFlagsRequest, }) if err != nil { return nil, nil, err } var fullFeatureFlagList []FeatureFlag warnings, err := client.paginate(request, FeatureFlag{}, func(item interface{}) error { if featureFlag, ok := item.(FeatureFlag); ok { fullFeatureFlagList = append(fullFeatureFlagList, featureFlag) } else { return ccerror.UnknownObjectInListError{ Expected: FeatureFlag{}, Unexpected: item, } } return nil }) return fullFeatureFlagList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetFeatureFlags", "(", ")", "(", "[", "]", "FeatureFlag", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetFeatureFlagsRequest", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullFeatureFlagList", "[", "]", "FeatureFlag", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "FeatureFlag", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "featureFlag", ",", "ok", ":=", "item", ".", "(", "FeatureFlag", ")", ";", "ok", "{", "fullFeatureFlagList", "=", "append", "(", "fullFeatureFlagList", ",", "featureFlag", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "FeatureFlag", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullFeatureFlagList", ",", "warnings", ",", "err", "\n\n", "}" ]
// GetFeatureFlags lists feature flags.
[ "GetFeatureFlags", "lists", "feature", "flags", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/feature_flag.go#L51-L75
train
cloudfoundry/cli
command/v7/ssh_command.go
EvaluateTTYOption
func (cmd SSHCommand) EvaluateTTYOption() (sharedaction.TTYOption, error) { var count int option := sharedaction.RequestTTYAuto if cmd.DisablePseudoTTY { option = sharedaction.RequestTTYNo count++ } if cmd.ForcePseudoTTY { option = sharedaction.RequestTTYForce count++ } if cmd.RequestPseudoTTY { option = sharedaction.RequestTTYYes count++ } if count > 1 { return option, translatableerror.ArgumentCombinationError{Args: []string{ "--disable-pseudo-tty", "-T", "--force-pseudo-tty", "--request-pseudo-tty", "-t", }} } return option, nil }
go
func (cmd SSHCommand) EvaluateTTYOption() (sharedaction.TTYOption, error) { var count int option := sharedaction.RequestTTYAuto if cmd.DisablePseudoTTY { option = sharedaction.RequestTTYNo count++ } if cmd.ForcePseudoTTY { option = sharedaction.RequestTTYForce count++ } if cmd.RequestPseudoTTY { option = sharedaction.RequestTTYYes count++ } if count > 1 { return option, translatableerror.ArgumentCombinationError{Args: []string{ "--disable-pseudo-tty", "-T", "--force-pseudo-tty", "--request-pseudo-tty", "-t", }} } return option, nil }
[ "func", "(", "cmd", "SSHCommand", ")", "EvaluateTTYOption", "(", ")", "(", "sharedaction", ".", "TTYOption", ",", "error", ")", "{", "var", "count", "int", "\n\n", "option", ":=", "sharedaction", ".", "RequestTTYAuto", "\n", "if", "cmd", ".", "DisablePseudoTTY", "{", "option", "=", "sharedaction", ".", "RequestTTYNo", "\n", "count", "++", "\n", "}", "\n", "if", "cmd", ".", "ForcePseudoTTY", "{", "option", "=", "sharedaction", ".", "RequestTTYForce", "\n", "count", "++", "\n", "}", "\n", "if", "cmd", ".", "RequestPseudoTTY", "{", "option", "=", "sharedaction", ".", "RequestTTYYes", "\n", "count", "++", "\n", "}", "\n\n", "if", "count", ">", "1", "{", "return", "option", ",", "translatableerror", ".", "ArgumentCombinationError", "{", "Args", ":", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", ",", "}", "}", "\n", "}", "\n\n", "return", "option", ",", "nil", "\n", "}" ]
// EvaluateTTYOption determines which TTY options are mutually exclusive and // returns an error accordingly.
[ "EvaluateTTYOption", "determines", "which", "TTY", "options", "are", "mutually", "exclusive", "and", "returns", "an", "error", "accordingly", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v7/ssh_command.go#L118-L142
train
cloudfoundry/cli
actor/v2action/space_quota.go
GetSpaceQuotaByName
func (actor Actor) GetSpaceQuotaByName(quotaName, orgGUID string) (SpaceQuota, Warnings, error) { quotas, warnings, err := actor.CloudControllerClient.GetSpaceQuotas(orgGUID) if err != nil { return SpaceQuota{}, Warnings(warnings), err } for _, quota := range quotas { if quota.Name == quotaName { return SpaceQuota(quota), Warnings(warnings), nil } } return SpaceQuota{}, Warnings(warnings), actionerror.SpaceQuotaNotFoundByNameError{Name: quotaName} }
go
func (actor Actor) GetSpaceQuotaByName(quotaName, orgGUID string) (SpaceQuota, Warnings, error) { quotas, warnings, err := actor.CloudControllerClient.GetSpaceQuotas(orgGUID) if err != nil { return SpaceQuota{}, Warnings(warnings), err } for _, quota := range quotas { if quota.Name == quotaName { return SpaceQuota(quota), Warnings(warnings), nil } } return SpaceQuota{}, Warnings(warnings), actionerror.SpaceQuotaNotFoundByNameError{Name: quotaName} }
[ "func", "(", "actor", "Actor", ")", "GetSpaceQuotaByName", "(", "quotaName", ",", "orgGUID", "string", ")", "(", "SpaceQuota", ",", "Warnings", ",", "error", ")", "{", "quotas", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSpaceQuotas", "(", "orgGUID", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "SpaceQuota", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "quota", ":=", "range", "quotas", "{", "if", "quota", ".", "Name", "==", "quotaName", "{", "return", "SpaceQuota", "(", "quota", ")", ",", "Warnings", "(", "warnings", ")", ",", "nil", "\n", "}", "\n", "}", "\n\n", "return", "SpaceQuota", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "SpaceQuotaNotFoundByNameError", "{", "Name", ":", "quotaName", "}", "\n", "}" ]
// GetSpaceQuotaByName finds the quota by name and returns an error if not found
[ "GetSpaceQuotaByName", "finds", "the", "quota", "by", "name", "and", "returns", "an", "error", "if", "not", "found" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space_quota.go#L22-L36
train
cloudfoundry/cli
actor/v2action/space_quota.go
SetSpaceQuota
func (actor Actor) SetSpaceQuota(spaceGUID, quotaGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.SetSpaceQuota(spaceGUID, quotaGUID) return Warnings(warnings), err }
go
func (actor Actor) SetSpaceQuota(spaceGUID, quotaGUID string) (Warnings, error) { warnings, err := actor.CloudControllerClient.SetSpaceQuota(spaceGUID, quotaGUID) return Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "SetSpaceQuota", "(", "spaceGUID", ",", "quotaGUID", "string", ")", "(", "Warnings", ",", "error", ")", "{", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "SetSpaceQuota", "(", "spaceGUID", ",", "quotaGUID", ")", "\n", "return", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// SetSpaceQuota sets the space quota for the corresponding space
[ "SetSpaceQuota", "sets", "the", "space", "quota", "for", "the", "corresponding", "space" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space_quota.go#L39-L42
train
cloudfoundry/cli
actor/v2action/domain.go
GetDomain
func (actor Actor) GetDomain(domainGUID string) (Domain, Warnings, error) { var allWarnings Warnings domain, warnings, err := actor.GetSharedDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil case actionerror.DomainNotFoundError: default: return Domain{}, allWarnings, err } domain, warnings, err = actor.GetPrivateDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil default: return Domain{}, allWarnings, err } }
go
func (actor Actor) GetDomain(domainGUID string) (Domain, Warnings, error) { var allWarnings Warnings domain, warnings, err := actor.GetSharedDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil case actionerror.DomainNotFoundError: default: return Domain{}, allWarnings, err } domain, warnings, err = actor.GetPrivateDomain(domainGUID) allWarnings = append(allWarnings, warnings...) switch err.(type) { case nil: return domain, allWarnings, nil default: return Domain{}, allWarnings, err } }
[ "func", "(", "actor", "Actor", ")", "GetDomain", "(", "domainGUID", "string", ")", "(", "Domain", ",", "Warnings", ",", "error", ")", "{", "var", "allWarnings", "Warnings", "\n\n", "domain", ",", "warnings", ",", "err", ":=", "actor", ".", "GetSharedDomain", "(", "domainGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "domain", ",", "allWarnings", ",", "nil", "\n", "case", "actionerror", ".", "DomainNotFoundError", ":", "default", ":", "return", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "domain", ",", "warnings", ",", "err", "=", "actor", ".", "GetPrivateDomain", "(", "domainGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "switch", "err", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "domain", ",", "allWarnings", ",", "nil", "\n", "default", ":", "return", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "}" ]
// GetDomain returns the shared or private domain associated with the provided // Domain GUID.
[ "GetDomain", "returns", "the", "shared", "or", "private", "domain", "associated", "with", "the", "provided", "Domain", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L45-L66
train
cloudfoundry/cli
actor/v2action/domain.go
GetDomainsByNameAndOrganization
func (actor Actor) GetDomainsByNameAndOrganization(domainNames []string, orgGUID string) ([]Domain, Warnings, error) { if len(domainNames) == 0 { return nil, nil, nil } var domains []Domain var allWarnings Warnings // TODO: If the following causes URI length problems, break domainNames into // batched (based on character length?) and loop over them. sharedDomains, warnings, err := actor.CloudControllerClient.GetSharedDomains(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range sharedDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } privateDomains, warnings, err := actor.CloudControllerClient.GetOrganizationPrivateDomains( orgGUID, ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range privateDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } return domains, allWarnings, err }
go
func (actor Actor) GetDomainsByNameAndOrganization(domainNames []string, orgGUID string) ([]Domain, Warnings, error) { if len(domainNames) == 0 { return nil, nil, nil } var domains []Domain var allWarnings Warnings // TODO: If the following causes URI length problems, break domainNames into // batched (based on character length?) and loop over them. sharedDomains, warnings, err := actor.CloudControllerClient.GetSharedDomains(ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range sharedDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } privateDomains, warnings, err := actor.CloudControllerClient.GetOrganizationPrivateDomains( orgGUID, ccv2.Filter{ Type: constant.NameFilter, Operator: constant.InOperator, Values: domainNames, }) allWarnings = append(allWarnings, warnings...) if err != nil { return nil, allWarnings, err } for _, domain := range privateDomains { domains = append(domains, Domain(domain)) actor.saveDomain(domain) } return domains, allWarnings, err }
[ "func", "(", "actor", "Actor", ")", "GetDomainsByNameAndOrganization", "(", "domainNames", "[", "]", "string", ",", "orgGUID", "string", ")", "(", "[", "]", "Domain", ",", "Warnings", ",", "error", ")", "{", "if", "len", "(", "domainNames", ")", "==", "0", "{", "return", "nil", ",", "nil", ",", "nil", "\n", "}", "\n\n", "var", "domains", "[", "]", "Domain", "\n", "var", "allWarnings", "Warnings", "\n\n", "// TODO: If the following causes URI length problems, break domainNames into", "// batched (based on character length?) and loop over them.", "sharedDomains", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSharedDomains", "(", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "InOperator", ",", "Values", ":", "domainNames", ",", "}", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "domain", ":=", "range", "sharedDomains", "{", "domains", "=", "append", "(", "domains", ",", "Domain", "(", "domain", ")", ")", "\n", "actor", ".", "saveDomain", "(", "domain", ")", "\n", "}", "\n\n", "privateDomains", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetOrganizationPrivateDomains", "(", "orgGUID", ",", "ccv2", ".", "Filter", "{", "Type", ":", "constant", ".", "NameFilter", ",", "Operator", ":", "constant", ".", "InOperator", ",", "Values", ":", "domainNames", ",", "}", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "allWarnings", ",", "err", "\n", "}", "\n\n", "for", "_", ",", "domain", ":=", "range", "privateDomains", "{", "domains", "=", "append", "(", "domains", ",", "Domain", "(", "domain", ")", ")", "\n", "actor", ".", "saveDomain", "(", "domain", ")", "\n", "}", "\n\n", "return", "domains", ",", "allWarnings", ",", "err", "\n", "}" ]
// GetDomainsByNameAndOrganization returns back a list of domains given a list // of domains names and the organization GUID. If no domains are given, than this // command will not lookup any domains.
[ "GetDomainsByNameAndOrganization", "returns", "back", "a", "list", "of", "domains", "given", "a", "list", "of", "domains", "names", "and", "the", "organization", "GUID", ".", "If", "no", "domains", "are", "given", "than", "this", "command", "will", "not", "lookup", "any", "domains", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L71-L115
train
cloudfoundry/cli
actor/v2action/domain.go
GetSharedDomain
func (actor Actor) GetSharedDomain(domainGUID string) (Domain, Warnings, error) { if domain, found := actor.loadDomain(domainGUID); found { log.WithFields(log.Fields{ "domain": domain.Name, "GUID": domain.GUID, }).Debug("using domain from cache") return domain, nil, nil } domain, warnings, err := actor.CloudControllerClient.GetSharedDomain(domainGUID) if isResourceNotFoundError(err) { return Domain{}, Warnings(warnings), actionerror.DomainNotFoundError{GUID: domainGUID} } actor.saveDomain(domain) return Domain(domain), Warnings(warnings), err }
go
func (actor Actor) GetSharedDomain(domainGUID string) (Domain, Warnings, error) { if domain, found := actor.loadDomain(domainGUID); found { log.WithFields(log.Fields{ "domain": domain.Name, "GUID": domain.GUID, }).Debug("using domain from cache") return domain, nil, nil } domain, warnings, err := actor.CloudControllerClient.GetSharedDomain(domainGUID) if isResourceNotFoundError(err) { return Domain{}, Warnings(warnings), actionerror.DomainNotFoundError{GUID: domainGUID} } actor.saveDomain(domain) return Domain(domain), Warnings(warnings), err }
[ "func", "(", "actor", "Actor", ")", "GetSharedDomain", "(", "domainGUID", "string", ")", "(", "Domain", ",", "Warnings", ",", "error", ")", "{", "if", "domain", ",", "found", ":=", "actor", ".", "loadDomain", "(", "domainGUID", ")", ";", "found", "{", "log", ".", "WithFields", "(", "log", ".", "Fields", "{", "\"", "\"", ":", "domain", ".", "Name", ",", "\"", "\"", ":", "domain", ".", "GUID", ",", "}", ")", ".", "Debug", "(", "\"", "\"", ")", "\n", "return", "domain", ",", "nil", ",", "nil", "\n", "}", "\n\n", "domain", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSharedDomain", "(", "domainGUID", ")", "\n", "if", "isResourceNotFoundError", "(", "err", ")", "{", "return", "Domain", "{", "}", ",", "Warnings", "(", "warnings", ")", ",", "actionerror", ".", "DomainNotFoundError", "{", "GUID", ":", "domainGUID", "}", "\n", "}", "\n\n", "actor", ".", "saveDomain", "(", "domain", ")", "\n", "return", "Domain", "(", "domain", ")", ",", "Warnings", "(", "warnings", ")", ",", "err", "\n", "}" ]
// GetSharedDomain returns the shared domain associated with the provided // Domain GUID.
[ "GetSharedDomain", "returns", "the", "shared", "domain", "associated", "with", "the", "provided", "Domain", "GUID", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L146-L162
train
cloudfoundry/cli
actor/v2action/domain.go
GetOrganizationDomains
func (actor Actor) GetOrganizationDomains(orgGUID string) ([]Domain, Warnings, error) { var ( allWarnings Warnings allDomains []Domain ) domains, warnings, err := actor.CloudControllerClient.GetSharedDomains() allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } domains, warnings, err = actor.CloudControllerClient.GetOrganizationPrivateDomains(orgGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } return allDomains, allWarnings, nil }
go
func (actor Actor) GetOrganizationDomains(orgGUID string) ([]Domain, Warnings, error) { var ( allWarnings Warnings allDomains []Domain ) domains, warnings, err := actor.CloudControllerClient.GetSharedDomains() allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } domains, warnings, err = actor.CloudControllerClient.GetOrganizationPrivateDomains(orgGUID) allWarnings = append(allWarnings, warnings...) if err != nil { return []Domain{}, allWarnings, err } for _, domain := range domains { allDomains = append(allDomains, Domain(domain)) } return allDomains, allWarnings, nil }
[ "func", "(", "actor", "Actor", ")", "GetOrganizationDomains", "(", "orgGUID", "string", ")", "(", "[", "]", "Domain", ",", "Warnings", ",", "error", ")", "{", "var", "(", "allWarnings", "Warnings", "\n", "allDomains", "[", "]", "Domain", "\n", ")", "\n\n", "domains", ",", "warnings", ",", "err", ":=", "actor", ".", "CloudControllerClient", ".", "GetSharedDomains", "(", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "domain", ":=", "range", "domains", "{", "allDomains", "=", "append", "(", "allDomains", ",", "Domain", "(", "domain", ")", ")", "\n", "}", "\n\n", "domains", ",", "warnings", ",", "err", "=", "actor", ".", "CloudControllerClient", ".", "GetOrganizationPrivateDomains", "(", "orgGUID", ")", "\n", "allWarnings", "=", "append", "(", "allWarnings", ",", "warnings", "...", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "[", "]", "Domain", "{", "}", ",", "allWarnings", ",", "err", "\n", "}", "\n", "for", "_", ",", "domain", ":=", "range", "domains", "{", "allDomains", "=", "append", "(", "allDomains", ",", "Domain", "(", "domain", ")", ")", "\n", "}", "\n\n", "return", "allDomains", ",", "allWarnings", ",", "nil", "\n", "}" ]
// GetOrganizationDomains returns the shared and private domains associated // with an organization.
[ "GetOrganizationDomains", "returns", "the", "shared", "and", "private", "domains", "associated", "with", "an", "organization", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/domain.go#L186-L213
train
cloudfoundry/cli
actor/v7action/process_instance.go
StartTime
func (instance *ProcessInstance) StartTime() time.Time { return time.Now().Add(-instance.Uptime) }
go
func (instance *ProcessInstance) StartTime() time.Time { return time.Now().Add(-instance.Uptime) }
[ "func", "(", "instance", "*", "ProcessInstance", ")", "StartTime", "(", ")", "time", ".", "Time", "{", "return", "time", ".", "Now", "(", ")", ".", "Add", "(", "-", "instance", ".", "Uptime", ")", "\n", "}" ]
// StartTime returns the time that the instance started.
[ "StartTime", "returns", "the", "time", "that", "the", "instance", "started", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/process_instance.go#L21-L23
train
cloudfoundry/cli
command/plugin/shared/new_client.go
NewClient
func NewClient(config command.Config, ui command.UI, skipSSLValidation bool) *plugin.Client { verbose, location := config.Verbose() pluginClient := plugin.NewClient(plugin.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), DialTimeout: config.DialTimeout(), SkipSSLValidation: skipSSLValidation, }) if verbose { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } pluginClient.WrapConnection(wrapper.NewRetryRequest(config.RequestRetryCount())) return pluginClient }
go
func NewClient(config command.Config, ui command.UI, skipSSLValidation bool) *plugin.Client { verbose, location := config.Verbose() pluginClient := plugin.NewClient(plugin.Config{ AppName: config.BinaryName(), AppVersion: config.BinaryVersion(), DialTimeout: config.DialTimeout(), SkipSSLValidation: skipSSLValidation, }) if verbose { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay())) } if location != nil { pluginClient.WrapConnection(wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location))) } pluginClient.WrapConnection(wrapper.NewRetryRequest(config.RequestRetryCount())) return pluginClient }
[ "func", "NewClient", "(", "config", "command", ".", "Config", ",", "ui", "command", ".", "UI", ",", "skipSSLValidation", "bool", ")", "*", "plugin", ".", "Client", "{", "verbose", ",", "location", ":=", "config", ".", "Verbose", "(", ")", "\n\n", "pluginClient", ":=", "plugin", ".", "NewClient", "(", "plugin", ".", "Config", "{", "AppName", ":", "config", ".", "BinaryName", "(", ")", ",", "AppVersion", ":", "config", ".", "BinaryVersion", "(", ")", ",", "DialTimeout", ":", "config", ".", "DialTimeout", "(", ")", ",", "SkipSSLValidation", ":", "skipSSLValidation", ",", "}", ")", "\n\n", "if", "verbose", "{", "pluginClient", ".", "WrapConnection", "(", "wrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerTerminalDisplay", "(", ")", ")", ")", "\n", "}", "\n", "if", "location", "!=", "nil", "{", "pluginClient", ".", "WrapConnection", "(", "wrapper", ".", "NewRequestLogger", "(", "ui", ".", "RequestLoggerFileWriter", "(", "location", ")", ")", ")", "\n", "}", "\n\n", "pluginClient", ".", "WrapConnection", "(", "wrapper", ".", "NewRetryRequest", "(", "config", ".", "RequestRetryCount", "(", ")", ")", ")", "\n\n", "return", "pluginClient", "\n", "}" ]
// NewClient creates a new V2 Cloud Controller client and UAA client using the // passed in config.
[ "NewClient", "creates", "a", "new", "V2", "Cloud", "Controller", "client", "and", "UAA", "client", "using", "the", "passed", "in", "config", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/plugin/shared/new_client.go#L11-L32
train
cloudfoundry/cli
api/uaa/resources.go
SetupResources
func (client *Client) SetupResources(bootstrapURL string) error { request, err := client.newRequest(requestOptions{ Method: http.MethodGet, URL: fmt.Sprintf("%s/login", bootstrapURL), }) if err != nil { return err } info := NewInfo(bootstrapURL) response := Response{ Result: &info, } err = client.connection.Make(request, &response) if err != nil { return err } resources := map[string]string{ "uaa": info.UAALink(), "authorization_endpoint": bootstrapURL, } client.router = internal.NewRouter(internal.APIRoutes, resources) client.Info = info client.config.SetUAAEndpoint(info.UAALink()) return nil }
go
func (client *Client) SetupResources(bootstrapURL string) error { request, err := client.newRequest(requestOptions{ Method: http.MethodGet, URL: fmt.Sprintf("%s/login", bootstrapURL), }) if err != nil { return err } info := NewInfo(bootstrapURL) response := Response{ Result: &info, } err = client.connection.Make(request, &response) if err != nil { return err } resources := map[string]string{ "uaa": info.UAALink(), "authorization_endpoint": bootstrapURL, } client.router = internal.NewRouter(internal.APIRoutes, resources) client.Info = info client.config.SetUAAEndpoint(info.UAALink()) return nil }
[ "func", "(", "client", "*", "Client", ")", "SetupResources", "(", "bootstrapURL", "string", ")", "error", "{", "request", ",", "err", ":=", "client", ".", "newRequest", "(", "requestOptions", "{", "Method", ":", "http", ".", "MethodGet", ",", "URL", ":", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "bootstrapURL", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "info", ":=", "NewInfo", "(", "bootstrapURL", ")", "\n", "response", ":=", "Response", "{", "Result", ":", "&", "info", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "resources", ":=", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "info", ".", "UAALink", "(", ")", ",", "\"", "\"", ":", "bootstrapURL", ",", "}", "\n\n", "client", ".", "router", "=", "internal", ".", "NewRouter", "(", "internal", ".", "APIRoutes", ",", "resources", ")", "\n", "client", ".", "Info", "=", "info", "\n\n", "client", ".", "config", ".", "SetUAAEndpoint", "(", "info", ".", "UAALink", "(", ")", ")", "\n\n", "return", "nil", "\n", "}" ]
// SetupResources configures the client to use the specified settings and diescopers the UAA and Authentication resources
[ "SetupResources", "configures", "the", "client", "to", "use", "the", "specified", "settings", "and", "diescopers", "the", "UAA", "and", "Authentication", "resources" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/resources.go#L11-L42
train
cloudfoundry/cli
actor/sharedaction/help.go
CommandInfoByName
func (Actor) CommandInfoByName(commandList interface{}, commandName string) (CommandInfo, error) { field, found := reflect.TypeOf(commandList).FieldByNameFunc( func(fieldName string) bool { field, _ := reflect.TypeOf(commandList).FieldByName(fieldName) return field.Tag.Get("command") == commandName || field.Tag.Get("alias") == commandName }, ) if !found { return CommandInfo{}, actionerror.InvalidCommandError{CommandName: commandName} } tag := field.Tag cmd := CommandInfo{ Name: tag.Get("command"), Description: tag.Get("description"), Alias: tag.Get("alias"), Flags: []CommandFlag{}, Environment: []EnvironmentVariable{}, } command := field.Type for i := 0; i < command.NumField(); i++ { fieldTag := command.Field(i).Tag if fieldTag.Get("hidden") != "" { continue } if fieldTag.Get("usage") != "" { cmd.Usage = fieldTag.Get("usage") continue } if fieldTag.Get("related_commands") != "" { relatedCommands := strings.Split(fieldTag.Get("related_commands"), ", ") sort.Slice(relatedCommands, sorting.SortAlphabeticFunc(relatedCommands)) cmd.RelatedCommands = relatedCommands continue } if fieldTag.Get("description") != "" { cmd.Flags = append(cmd.Flags, CommandFlag{ Short: fieldTag.Get("short"), Long: fieldTag.Get("long"), Description: fieldTag.Get("description"), Default: fieldTag.Get("default"), }) } if fieldTag.Get("environmentName") != "" { cmd.Environment = append(cmd.Environment, EnvironmentVariable{ Name: fieldTag.Get("environmentName"), DefaultValue: fieldTag.Get("environmentDefault"), Description: fieldTag.Get("environmentDescription"), }) } } return cmd, nil }
go
func (Actor) CommandInfoByName(commandList interface{}, commandName string) (CommandInfo, error) { field, found := reflect.TypeOf(commandList).FieldByNameFunc( func(fieldName string) bool { field, _ := reflect.TypeOf(commandList).FieldByName(fieldName) return field.Tag.Get("command") == commandName || field.Tag.Get("alias") == commandName }, ) if !found { return CommandInfo{}, actionerror.InvalidCommandError{CommandName: commandName} } tag := field.Tag cmd := CommandInfo{ Name: tag.Get("command"), Description: tag.Get("description"), Alias: tag.Get("alias"), Flags: []CommandFlag{}, Environment: []EnvironmentVariable{}, } command := field.Type for i := 0; i < command.NumField(); i++ { fieldTag := command.Field(i).Tag if fieldTag.Get("hidden") != "" { continue } if fieldTag.Get("usage") != "" { cmd.Usage = fieldTag.Get("usage") continue } if fieldTag.Get("related_commands") != "" { relatedCommands := strings.Split(fieldTag.Get("related_commands"), ", ") sort.Slice(relatedCommands, sorting.SortAlphabeticFunc(relatedCommands)) cmd.RelatedCommands = relatedCommands continue } if fieldTag.Get("description") != "" { cmd.Flags = append(cmd.Flags, CommandFlag{ Short: fieldTag.Get("short"), Long: fieldTag.Get("long"), Description: fieldTag.Get("description"), Default: fieldTag.Get("default"), }) } if fieldTag.Get("environmentName") != "" { cmd.Environment = append(cmd.Environment, EnvironmentVariable{ Name: fieldTag.Get("environmentName"), DefaultValue: fieldTag.Get("environmentDefault"), Description: fieldTag.Get("environmentDescription"), }) } } return cmd, nil }
[ "func", "(", "Actor", ")", "CommandInfoByName", "(", "commandList", "interface", "{", "}", ",", "commandName", "string", ")", "(", "CommandInfo", ",", "error", ")", "{", "field", ",", "found", ":=", "reflect", ".", "TypeOf", "(", "commandList", ")", ".", "FieldByNameFunc", "(", "func", "(", "fieldName", "string", ")", "bool", "{", "field", ",", "_", ":=", "reflect", ".", "TypeOf", "(", "commandList", ")", ".", "FieldByName", "(", "fieldName", ")", "\n", "return", "field", ".", "Tag", ".", "Get", "(", "\"", "\"", ")", "==", "commandName", "||", "field", ".", "Tag", ".", "Get", "(", "\"", "\"", ")", "==", "commandName", "\n", "}", ",", ")", "\n\n", "if", "!", "found", "{", "return", "CommandInfo", "{", "}", ",", "actionerror", ".", "InvalidCommandError", "{", "CommandName", ":", "commandName", "}", "\n", "}", "\n\n", "tag", ":=", "field", ".", "Tag", "\n", "cmd", ":=", "CommandInfo", "{", "Name", ":", "tag", ".", "Get", "(", "\"", "\"", ")", ",", "Description", ":", "tag", ".", "Get", "(", "\"", "\"", ")", ",", "Alias", ":", "tag", ".", "Get", "(", "\"", "\"", ")", ",", "Flags", ":", "[", "]", "CommandFlag", "{", "}", ",", "Environment", ":", "[", "]", "EnvironmentVariable", "{", "}", ",", "}", "\n\n", "command", ":=", "field", ".", "Type", "\n", "for", "i", ":=", "0", ";", "i", "<", "command", ".", "NumField", "(", ")", ";", "i", "++", "{", "fieldTag", ":=", "command", ".", "Field", "(", "i", ")", ".", "Tag", "\n\n", "if", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "continue", "\n", "}", "\n\n", "if", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "cmd", ".", "Usage", "=", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "\n", "continue", "\n", "}", "\n\n", "if", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "relatedCommands", ":=", "strings", ".", "Split", "(", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "\"", "\"", ")", "\n", "sort", ".", "Slice", "(", "relatedCommands", ",", "sorting", ".", "SortAlphabeticFunc", "(", "relatedCommands", ")", ")", "\n", "cmd", ".", "RelatedCommands", "=", "relatedCommands", "\n", "continue", "\n", "}", "\n\n", "if", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "cmd", ".", "Flags", "=", "append", "(", "cmd", ".", "Flags", ",", "CommandFlag", "{", "Short", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "Long", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "Description", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "Default", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "}", ")", "\n", "}", "\n\n", "if", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "cmd", ".", "Environment", "=", "append", "(", "cmd", ".", "Environment", ",", "EnvironmentVariable", "{", "Name", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "DefaultValue", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "Description", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "}", ")", "\n", "}", "\n", "}", "\n\n", "return", "cmd", ",", "nil", "\n", "}" ]
// CommandInfoByName returns the help information for a particular commandName in // the commandList.
[ "CommandInfoByName", "returns", "the", "help", "information", "for", "a", "particular", "commandName", "in", "the", "commandList", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/help.go#L60-L120
train
cloudfoundry/cli
actor/sharedaction/help.go
CommandInfos
func (Actor) CommandInfos(commandList interface{}) map[string]CommandInfo { handler := reflect.TypeOf(commandList) infos := make(map[string]CommandInfo, handler.NumField()) for i := 0; i < handler.NumField(); i++ { fieldTag := handler.Field(i).Tag commandName := fieldTag.Get("command") infos[commandName] = CommandInfo{ Name: commandName, Description: fieldTag.Get("description"), Alias: fieldTag.Get("alias"), } } return infos }
go
func (Actor) CommandInfos(commandList interface{}) map[string]CommandInfo { handler := reflect.TypeOf(commandList) infos := make(map[string]CommandInfo, handler.NumField()) for i := 0; i < handler.NumField(); i++ { fieldTag := handler.Field(i).Tag commandName := fieldTag.Get("command") infos[commandName] = CommandInfo{ Name: commandName, Description: fieldTag.Get("description"), Alias: fieldTag.Get("alias"), } } return infos }
[ "func", "(", "Actor", ")", "CommandInfos", "(", "commandList", "interface", "{", "}", ")", "map", "[", "string", "]", "CommandInfo", "{", "handler", ":=", "reflect", ".", "TypeOf", "(", "commandList", ")", "\n\n", "infos", ":=", "make", "(", "map", "[", "string", "]", "CommandInfo", ",", "handler", ".", "NumField", "(", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "handler", ".", "NumField", "(", ")", ";", "i", "++", "{", "fieldTag", ":=", "handler", ".", "Field", "(", "i", ")", ".", "Tag", "\n", "commandName", ":=", "fieldTag", ".", "Get", "(", "\"", "\"", ")", "\n", "infos", "[", "commandName", "]", "=", "CommandInfo", "{", "Name", ":", "commandName", ",", "Description", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "Alias", ":", "fieldTag", ".", "Get", "(", "\"", "\"", ")", ",", "}", "\n", "}", "\n\n", "return", "infos", "\n", "}" ]
// CommandInfos returns a slice of CommandInfo that only fills in // the Name and Description for all the commands in commandList
[ "CommandInfos", "returns", "a", "slice", "of", "CommandInfo", "that", "only", "fills", "in", "the", "Name", "and", "Description", "for", "all", "the", "commands", "in", "commandList" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/help.go#L124-L139
train
cloudfoundry/cli
api/cloudcontroller/ccv3/resource.go
UnmarshalJSON
func (r *Resource) UnmarshalJSON(data []byte) error { var ccResource struct { FilePath string `json:"path,omitempty"` Mode string `json:"mode,omitempty"` Checksum Checksum `json:"checksum"` SizeInBytes int64 `json:"size_in_bytes"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.FilePath = ccResource.FilePath r.SizeInBytes = ccResource.SizeInBytes r.Checksum = ccResource.Checksum mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
go
func (r *Resource) UnmarshalJSON(data []byte) error { var ccResource struct { FilePath string `json:"path,omitempty"` Mode string `json:"mode,omitempty"` Checksum Checksum `json:"checksum"` SizeInBytes int64 `json:"size_in_bytes"` } err := cloudcontroller.DecodeJSON(data, &ccResource) if err != nil { return err } r.FilePath = ccResource.FilePath r.SizeInBytes = ccResource.SizeInBytes r.Checksum = ccResource.Checksum mode, err := strconv.ParseUint(ccResource.Mode, 8, 32) if err != nil { return err } r.Mode = os.FileMode(mode) return nil }
[ "func", "(", "r", "*", "Resource", ")", "UnmarshalJSON", "(", "data", "[", "]", "byte", ")", "error", "{", "var", "ccResource", "struct", "{", "FilePath", "string", "`json:\"path,omitempty\"`", "\n", "Mode", "string", "`json:\"mode,omitempty\"`", "\n", "Checksum", "Checksum", "`json:\"checksum\"`", "\n", "SizeInBytes", "int64", "`json:\"size_in_bytes\"`", "\n", "}", "\n\n", "err", ":=", "cloudcontroller", ".", "DecodeJSON", "(", "data", ",", "&", "ccResource", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "r", ".", "FilePath", "=", "ccResource", ".", "FilePath", "\n", "r", ".", "SizeInBytes", "=", "ccResource", ".", "SizeInBytes", "\n", "r", ".", "Checksum", "=", "ccResource", ".", "Checksum", "\n", "mode", ",", "err", ":=", "strconv", ".", "ParseUint", "(", "ccResource", ".", "Mode", ",", "8", ",", "32", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "r", ".", "Mode", "=", "os", ".", "FileMode", "(", "mode", ")", "\n", "return", "nil", "\n", "}" ]
// UnmarshalJSON helps unmarshal a Cloud Controller Resource response.
[ "UnmarshalJSON", "helps", "unmarshal", "a", "Cloud", "Controller", "Resource", "response", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/resource.go#L58-L81
train
cloudfoundry/cli
api/cloudcontroller/ccv3/job_url.go
DeleteApplication
func (client *Client) DeleteApplication(appGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteApplicationRequest, URIParams: internal.Params{"app_guid": appGUID}, }) if err != nil { return "", nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
go
func (client *Client) DeleteApplication(appGUID string) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.DeleteApplicationRequest, URIParams: internal.Params{"app_guid": appGUID}, }) if err != nil { return "", nil, err } response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "DeleteApplication", "(", "appGUID", "string", ")", "(", "JobURL", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "DeleteApplicationRequest", ",", "URIParams", ":", "internal", ".", "Params", "{", "\"", "\"", ":", "appGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "JobURL", "(", "response", ".", "ResourceLocationURL", ")", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// DeleteApplication deletes the app with the given app GUID. Returns back a // resulting job URL to poll.
[ "DeleteApplication", "deletes", "the", "app", "with", "the", "given", "app", "GUID", ".", "Returns", "back", "a", "resulting", "job", "URL", "to", "poll", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job_url.go#L14-L27
train
cloudfoundry/cli
api/cloudcontroller/ccv3/job_url.go
UpdateApplicationApplyManifest
func (client *Client) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionApplyManifest, URIParams: map[string]string{"app_guid": appGUID}, Body: bytes.NewReader(rawManifest), }) if err != nil { return "", nil, err } request.Header.Set("Content-Type", "application/x-yaml") response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
go
func (client *Client) UpdateApplicationApplyManifest(appGUID string, rawManifest []byte) (JobURL, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionApplyManifest, URIParams: map[string]string{"app_guid": appGUID}, Body: bytes.NewReader(rawManifest), }) if err != nil { return "", nil, err } request.Header.Set("Content-Type", "application/x-yaml") response := cloudcontroller.Response{} err = client.connection.Make(request, &response) return JobURL(response.ResourceLocationURL), response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateApplicationApplyManifest", "(", "appGUID", "string", ",", "rawManifest", "[", "]", "byte", ")", "(", "JobURL", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationActionApplyManifest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "appGUID", "}", ",", "Body", ":", "bytes", ".", "NewReader", "(", "rawManifest", ")", ",", "}", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ".", "Header", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "JobURL", "(", "response", ".", "ResourceLocationURL", ")", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateApplicationApplyManifest applies the manifest to the given // application. Returns back a resulting job URL to poll.
[ "UpdateApplicationApplyManifest", "applies", "the", "manifest", "to", "the", "given", "application", ".", "Returns", "back", "a", "resulting", "job", "URL", "to", "poll", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job_url.go#L31-L48
train
cloudfoundry/cli
util/ui/i18n.go
GetTranslationFunc
func GetTranslationFunc(reader LocaleReader) (TranslateFunc, error) { locale, err := determineLocale(reader) if err != nil { locale = defaultLocale } rawTranslation, err := loadAssetFromResources(locale) if err != nil { rawTranslation, err = loadAssetFromResources(defaultLocale) if err != nil { return nil, err } } return generateTranslationFunc(rawTranslation) }
go
func GetTranslationFunc(reader LocaleReader) (TranslateFunc, error) { locale, err := determineLocale(reader) if err != nil { locale = defaultLocale } rawTranslation, err := loadAssetFromResources(locale) if err != nil { rawTranslation, err = loadAssetFromResources(defaultLocale) if err != nil { return nil, err } } return generateTranslationFunc(rawTranslation) }
[ "func", "GetTranslationFunc", "(", "reader", "LocaleReader", ")", "(", "TranslateFunc", ",", "error", ")", "{", "locale", ",", "err", ":=", "determineLocale", "(", "reader", ")", "\n", "if", "err", "!=", "nil", "{", "locale", "=", "defaultLocale", "\n", "}", "\n\n", "rawTranslation", ",", "err", ":=", "loadAssetFromResources", "(", "locale", ")", "\n", "if", "err", "!=", "nil", "{", "rawTranslation", ",", "err", "=", "loadAssetFromResources", "(", "defaultLocale", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "}", "\n\n", "return", "generateTranslationFunc", "(", "rawTranslation", ")", "\n", "}" ]
// GetTranslationFunc will return back a function that can be used to translate // strings into the currently set locale.
[ "GetTranslationFunc", "will", "return", "back", "a", "function", "that", "can", "be", "used", "to", "translate", "strings", "into", "the", "currently", "set", "locale", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/i18n.go#L48-L63
train
cloudfoundry/cli
integration/helpers/user.go
GetUsers
func GetUsers() []User { var userPagesResponse struct { NextURL *string `json:"next_url"` Resources []struct { Metadata struct { GUID string `json:"guid"` CreatedAt time.Time `json:"created_at"` } `json:"metadata"` Entity struct { Username string `json:"username"` } `json:"entity"` } `json:"resources"` } var allUsers []User nextURL := "/v2/users?results-per-page=50" for { session := CF("curl", nextURL) Eventually(session).Should(Exit(0)) err := json.Unmarshal(session.Out.Contents(), &userPagesResponse) Expect(err).NotTo(HaveOccurred()) for _, resource := range userPagesResponse.Resources { allUsers = append(allUsers, User{ GUID: resource.Metadata.GUID, CreatedAt: resource.Metadata.CreatedAt, Username: resource.Entity.Username, }) } if userPagesResponse.NextURL == nil { break } nextURL = *userPagesResponse.NextURL } return allUsers }
go
func GetUsers() []User { var userPagesResponse struct { NextURL *string `json:"next_url"` Resources []struct { Metadata struct { GUID string `json:"guid"` CreatedAt time.Time `json:"created_at"` } `json:"metadata"` Entity struct { Username string `json:"username"` } `json:"entity"` } `json:"resources"` } var allUsers []User nextURL := "/v2/users?results-per-page=50" for { session := CF("curl", nextURL) Eventually(session).Should(Exit(0)) err := json.Unmarshal(session.Out.Contents(), &userPagesResponse) Expect(err).NotTo(HaveOccurred()) for _, resource := range userPagesResponse.Resources { allUsers = append(allUsers, User{ GUID: resource.Metadata.GUID, CreatedAt: resource.Metadata.CreatedAt, Username: resource.Entity.Username, }) } if userPagesResponse.NextURL == nil { break } nextURL = *userPagesResponse.NextURL } return allUsers }
[ "func", "GetUsers", "(", ")", "[", "]", "User", "{", "var", "userPagesResponse", "struct", "{", "NextURL", "*", "string", "`json:\"next_url\"`", "\n", "Resources", "[", "]", "struct", "{", "Metadata", "struct", "{", "GUID", "string", "`json:\"guid\"`", "\n", "CreatedAt", "time", ".", "Time", "`json:\"created_at\"`", "\n", "}", "`json:\"metadata\"`", "\n", "Entity", "struct", "{", "Username", "string", "`json:\"username\"`", "\n", "}", "`json:\"entity\"`", "\n", "}", "`json:\"resources\"`", "\n", "}", "\n\n", "var", "allUsers", "[", "]", "User", "\n", "nextURL", ":=", "\"", "\"", "\n\n", "for", "{", "session", ":=", "CF", "(", "\"", "\"", ",", "nextURL", ")", "\n", "Eventually", "(", "session", ")", ".", "Should", "(", "Exit", "(", "0", ")", ")", "\n\n", "err", ":=", "json", ".", "Unmarshal", "(", "session", ".", "Out", ".", "Contents", "(", ")", ",", "&", "userPagesResponse", ")", "\n", "Expect", "(", "err", ")", ".", "NotTo", "(", "HaveOccurred", "(", ")", ")", "\n", "for", "_", ",", "resource", ":=", "range", "userPagesResponse", ".", "Resources", "{", "allUsers", "=", "append", "(", "allUsers", ",", "User", "{", "GUID", ":", "resource", ".", "Metadata", ".", "GUID", ",", "CreatedAt", ":", "resource", ".", "Metadata", ".", "CreatedAt", ",", "Username", ":", "resource", ".", "Entity", ".", "Username", ",", "}", ")", "\n", "}", "\n\n", "if", "userPagesResponse", ".", "NextURL", "==", "nil", "{", "break", "\n", "}", "\n", "nextURL", "=", "*", "userPagesResponse", ".", "NextURL", "\n", "}", "\n\n", "return", "allUsers", "\n", "}" ]
// GetUsers returns all the users in the targeted environment
[ "GetUsers", "returns", "all", "the", "users", "in", "the", "targeted", "environment" ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/user.go#L18-L56
train
cloudfoundry/cli
api/cloudcontroller/ccv3/info.go
rootResponse
func (client *Client) rootResponse() (Info, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ Method: http.MethodGet, URL: client.cloudControllerURL, }) if err != nil { return Info{}, nil, err } var rootResponse Info response := cloudcontroller.Response{ DecodeJSONResponseInto: &rootResponse, } err = client.connection.Make(request, &response) if unknownSourceErr, ok := err.(ccerror.UnknownHTTPSourceError); ok && unknownSourceErr.StatusCode == http.StatusNotFound { return Info{}, nil, ccerror.APINotFoundError{URL: client.cloudControllerURL} } return rootResponse, response.Warnings, err }
go
func (client *Client) rootResponse() (Info, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ Method: http.MethodGet, URL: client.cloudControllerURL, }) if err != nil { return Info{}, nil, err } var rootResponse Info response := cloudcontroller.Response{ DecodeJSONResponseInto: &rootResponse, } err = client.connection.Make(request, &response) if unknownSourceErr, ok := err.(ccerror.UnknownHTTPSourceError); ok && unknownSourceErr.StatusCode == http.StatusNotFound { return Info{}, nil, ccerror.APINotFoundError{URL: client.cloudControllerURL} } return rootResponse, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "rootResponse", "(", ")", "(", "Info", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "Method", ":", "http", ".", "MethodGet", ",", "URL", ":", "client", ".", "cloudControllerURL", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Info", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "rootResponse", "Info", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "rootResponse", ",", "}", "\n\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n", "if", "unknownSourceErr", ",", "ok", ":=", "err", ".", "(", "ccerror", ".", "UnknownHTTPSourceError", ")", ";", "ok", "&&", "unknownSourceErr", ".", "StatusCode", "==", "http", ".", "StatusNotFound", "{", "return", "Info", "{", "}", ",", "nil", ",", "ccerror", ".", "APINotFoundError", "{", "URL", ":", "client", ".", "cloudControllerURL", "}", "\n", "}", "\n\n", "return", "rootResponse", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// rootResponse returns the CC API root document.
[ "rootResponse", "returns", "the", "CC", "API", "root", "document", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/info.go#L135-L155
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
MarshalJSON
func (a Application) MarshalJSON() ([]byte, error) { ccApp := ccApplication{ Name: a.Name, Relationships: a.Relationships, Metadata: a.Metadata, } if a.LifecycleType == constant.AppLifecycleTypeDocker { ccApp.setDockerLifecycle() } else if a.LifecycleType == constant.AppLifecycleTypeBuildpack { if len(a.LifecycleBuildpacks) > 0 || a.StackName != "" { if a.hasAutodetectedBuildpack() { ccApp.setAutodetectedBuildpackLifecycle(a) } else { ccApp.setBuildpackLifecycle(a) } } } return json.Marshal(ccApp) }
go
func (a Application) MarshalJSON() ([]byte, error) { ccApp := ccApplication{ Name: a.Name, Relationships: a.Relationships, Metadata: a.Metadata, } if a.LifecycleType == constant.AppLifecycleTypeDocker { ccApp.setDockerLifecycle() } else if a.LifecycleType == constant.AppLifecycleTypeBuildpack { if len(a.LifecycleBuildpacks) > 0 || a.StackName != "" { if a.hasAutodetectedBuildpack() { ccApp.setAutodetectedBuildpackLifecycle(a) } else { ccApp.setBuildpackLifecycle(a) } } } return json.Marshal(ccApp) }
[ "func", "(", "a", "Application", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ccApp", ":=", "ccApplication", "{", "Name", ":", "a", ".", "Name", ",", "Relationships", ":", "a", ".", "Relationships", ",", "Metadata", ":", "a", ".", "Metadata", ",", "}", "\n\n", "if", "a", ".", "LifecycleType", "==", "constant", ".", "AppLifecycleTypeDocker", "{", "ccApp", ".", "setDockerLifecycle", "(", ")", "\n", "}", "else", "if", "a", ".", "LifecycleType", "==", "constant", ".", "AppLifecycleTypeBuildpack", "{", "if", "len", "(", "a", ".", "LifecycleBuildpacks", ")", ">", "0", "||", "a", ".", "StackName", "!=", "\"", "\"", "{", "if", "a", ".", "hasAutodetectedBuildpack", "(", ")", "{", "ccApp", ".", "setAutodetectedBuildpackLifecycle", "(", "a", ")", "\n", "}", "else", "{", "ccApp", ".", "setBuildpackLifecycle", "(", "a", ")", "\n", "}", "\n", "}", "\n", "}", "\n\n", "return", "json", ".", "Marshal", "(", "ccApp", ")", "\n", "}" ]
// MarshalJSON converts an Application into a Cloud Controller Application.
[ "MarshalJSON", "converts", "an", "Application", "into", "a", "Cloud", "Controller", "Application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L34-L54
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
GetApplications
func (client *Client) GetApplications(query ...Query) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullAppsList []Application warnings, err := client.paginate(request, Application{}, func(item interface{}) error { if app, ok := item.(Application); ok { fullAppsList = append(fullAppsList, app) } else { return ccerror.UnknownObjectInListError{ Expected: Application{}, Unexpected: item, } } return nil }) return fullAppsList, warnings, err }
go
func (client *Client) GetApplications(query ...Query) ([]Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.GetApplicationsRequest, Query: query, }) if err != nil { return nil, nil, err } var fullAppsList []Application warnings, err := client.paginate(request, Application{}, func(item interface{}) error { if app, ok := item.(Application); ok { fullAppsList = append(fullAppsList, app) } else { return ccerror.UnknownObjectInListError{ Expected: Application{}, Unexpected: item, } } return nil }) return fullAppsList, warnings, err }
[ "func", "(", "client", "*", "Client", ")", "GetApplications", "(", "query", "...", "Query", ")", "(", "[", "]", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "GetApplicationsRequest", ",", "Query", ":", "query", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "fullAppsList", "[", "]", "Application", "\n", "warnings", ",", "err", ":=", "client", ".", "paginate", "(", "request", ",", "Application", "{", "}", ",", "func", "(", "item", "interface", "{", "}", ")", "error", "{", "if", "app", ",", "ok", ":=", "item", ".", "(", "Application", ")", ";", "ok", "{", "fullAppsList", "=", "append", "(", "fullAppsList", ",", "app", ")", "\n", "}", "else", "{", "return", "ccerror", ".", "UnknownObjectInListError", "{", "Expected", ":", "Application", "{", "}", ",", "Unexpected", ":", "item", ",", "}", "\n", "}", "\n", "return", "nil", "\n", "}", ")", "\n\n", "return", "fullAppsList", ",", "warnings", ",", "err", "\n", "}" ]
// GetApplications lists applications with optional queries.
[ "GetApplications", "lists", "applications", "with", "optional", "queries", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L156-L179
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
UpdateApplication
func (client *Client) UpdateApplication(app Application) (Application, Warnings, error) { bodyBytes, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchApplicationRequest, Body: bytes.NewReader(bodyBytes), URIParams: map[string]string{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
go
func (client *Client) UpdateApplication(app Application) (Application, Warnings, error) { bodyBytes, err := json.Marshal(app) if err != nil { return Application{}, nil, err } request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PatchApplicationRequest, Body: bytes.NewReader(bodyBytes), URIParams: map[string]string{"app_guid": app.GUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateApplication", "(", "app", "Application", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "bodyBytes", ",", "err", ":=", "json", ".", "Marshal", "(", "app", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PatchApplicationRequest", ",", "Body", ":", "bytes", ".", "NewReader", "(", "bodyBytes", ")", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "app", ".", "GUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseApp", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responseApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateApplication updates an application with the given settings.
[ "UpdateApplication", "updates", "an", "application", "with", "the", "given", "settings", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L182-L204
train
cloudfoundry/cli
api/cloudcontroller/ccv3/application.go
UpdateApplicationRestart
func (client *Client) UpdateApplicationRestart(appGUID string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionRestartRequest, URIParams: map[string]string{"app_guid": appGUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
go
func (client *Client) UpdateApplicationRestart(appGUID string) (Application, Warnings, error) { request, err := client.newHTTPRequest(requestOptions{ RequestName: internal.PostApplicationActionRestartRequest, URIParams: map[string]string{"app_guid": appGUID}, }) if err != nil { return Application{}, nil, err } var responseApp Application response := cloudcontroller.Response{ DecodeJSONResponseInto: &responseApp, } err = client.connection.Make(request, &response) return responseApp, response.Warnings, err }
[ "func", "(", "client", "*", "Client", ")", "UpdateApplicationRestart", "(", "appGUID", "string", ")", "(", "Application", ",", "Warnings", ",", "error", ")", "{", "request", ",", "err", ":=", "client", ".", "newHTTPRequest", "(", "requestOptions", "{", "RequestName", ":", "internal", ".", "PostApplicationActionRestartRequest", ",", "URIParams", ":", "map", "[", "string", "]", "string", "{", "\"", "\"", ":", "appGUID", "}", ",", "}", ")", "\n", "if", "err", "!=", "nil", "{", "return", "Application", "{", "}", ",", "nil", ",", "err", "\n", "}", "\n\n", "var", "responseApp", "Application", "\n", "response", ":=", "cloudcontroller", ".", "Response", "{", "DecodeJSONResponseInto", ":", "&", "responseApp", ",", "}", "\n", "err", "=", "client", ".", "connection", ".", "Make", "(", "request", ",", "&", "response", ")", "\n\n", "return", "responseApp", ",", "response", ".", "Warnings", ",", "err", "\n", "}" ]
// UpdateApplicationRestart restarts the given application.
[ "UpdateApplicationRestart", "restarts", "the", "given", "application", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/application.go#L207-L223
train
cloudfoundry/cli
actor/v2action/application.go
CalculatedBuildpack
func (application Application) CalculatedBuildpack() string { if application.Buildpack.IsSet { return application.Buildpack.Value } return application.DetectedBuildpack.Value }
go
func (application Application) CalculatedBuildpack() string { if application.Buildpack.IsSet { return application.Buildpack.Value } return application.DetectedBuildpack.Value }
[ "func", "(", "application", "Application", ")", "CalculatedBuildpack", "(", ")", "string", "{", "if", "application", ".", "Buildpack", ".", "IsSet", "{", "return", "application", ".", "Buildpack", ".", "Value", "\n", "}", "\n\n", "return", "application", ".", "DetectedBuildpack", ".", "Value", "\n", "}" ]
// CalculatedBuildpack returns the buildpack that will be used.
[ "CalculatedBuildpack", "returns", "the", "buildpack", "that", "will", "be", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L25-L31
train
cloudfoundry/cli
actor/v2action/application.go
CalculatedCommand
func (application Application) CalculatedCommand() string { if application.Command.IsSet { return application.Command.Value } return application.DetectedStartCommand.Value }
go
func (application Application) CalculatedCommand() string { if application.Command.IsSet { return application.Command.Value } return application.DetectedStartCommand.Value }
[ "func", "(", "application", "Application", ")", "CalculatedCommand", "(", ")", "string", "{", "if", "application", ".", "Command", ".", "IsSet", "{", "return", "application", ".", "Command", ".", "Value", "\n", "}", "\n\n", "return", "application", ".", "DetectedStartCommand", ".", "Value", "\n", "}" ]
// CalculatedCommand returns the command that will be used.
[ "CalculatedCommand", "returns", "the", "command", "that", "will", "be", "used", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L34-L40
train
cloudfoundry/cli
actor/v2action/application.go
StagingFailedMessage
func (application Application) StagingFailedMessage() string { if application.StagingFailedDescription != "" { return application.StagingFailedDescription } return application.StagingFailedReason }
go
func (application Application) StagingFailedMessage() string { if application.StagingFailedDescription != "" { return application.StagingFailedDescription } return application.StagingFailedReason }
[ "func", "(", "application", "Application", ")", "StagingFailedMessage", "(", ")", "string", "{", "if", "application", ".", "StagingFailedDescription", "!=", "\"", "\"", "{", "return", "application", ".", "StagingFailedDescription", "\n", "}", "\n\n", "return", "application", ".", "StagingFailedReason", "\n", "}" ]
// StagingFailedMessage returns the verbose description of the failure or // the reason if the verbose description is empty.
[ "StagingFailedMessage", "returns", "the", "verbose", "description", "of", "the", "failure", "or", "the", "reason", "if", "the", "verbose", "description", "is", "empty", "." ]
5010c000047f246b870475e2c299556078cdad30
https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/application.go#L64-L70
train