repo stringlengths 5 67 | sha stringlengths 40 40 | path stringlengths 4 234 | url stringlengths 85 339 | language stringclasses 6 values | split stringclasses 3 values | doc stringlengths 3 51.2k | sign stringlengths 5 8.01k | problem stringlengths 13 51.2k | output stringlengths 0 3.87M |
|---|---|---|---|---|---|---|---|---|---|
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/relationship.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L153-L174 | go | train | // UpdateOrganizationDefaultIsolationSegmentRelationship sets the default isolation segment
// for an organization on the controller.
// If isoSegGuid is empty it will reset the default isolation segment. | func (client *Client) UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID string, isoSegGUID string) (Relationship, Warnings, error) | // UpdateOrganizationDefaultIsolationSegmentRelationship sets the default isolation segment
// for an organization on the controller.
// If isoSegGuid is empty it will reset the default isolation segment.
func (client *Client) UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID string, isoSegGUID string) (Relationship, Warnings, error) | {
body, err := json.Marshal(Relationship{GUID: isoSegGUID})
if err != nil {
return Relationship{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PatchOrganizationRelationshipDefaultIsolationSegmentRequest,
Body: bytes.NewReader(body),
URIParams: internal.Params{"organization_guid": orgGUID},
})
if err != nil {
return Relationship{}, nil, err
}
var relationship Relationship
response := cloudcontroller.Response{
DecodeJSONResponseInto: &relationship,
}
err = client.connection.Make(request, &response)
return relationship, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/relationship.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L178-L200 | go | train | // UpdateSpaceIsolationSegmentRelationship assigns an isolation segment to a space and
// returns the relationship. | func (client *Client) UpdateSpaceIsolationSegmentRelationship(spaceGUID string, isolationSegmentGUID string) (Relationship, Warnings, error) | // UpdateSpaceIsolationSegmentRelationship assigns an isolation segment to a space and
// returns the relationship.
func (client *Client) UpdateSpaceIsolationSegmentRelationship(spaceGUID string, isolationSegmentGUID string) (Relationship, Warnings, error) | {
body, err := json.Marshal(Relationship{GUID: isolationSegmentGUID})
if err != nil {
return Relationship{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PatchSpaceRelationshipIsolationSegmentRequest,
URIParams: internal.Params{"space_guid": spaceGUID},
Body: bytes.NewReader(body),
})
if err != nil {
return Relationship{}, nil, err
}
var relationship Relationship
response := cloudcontroller.Response{
DecodeJSONResponseInto: &relationship,
}
err = client.connection.Make(request, &response)
return relationship, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/ui_unix.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/ui_unix.go#L84-L91 | go | train | // echoOn turns back on the terminal echo. | func echoOn(fd []uintptr) | // echoOn turns back on the terminal echo.
func echoOn(fd []uintptr) | {
// Turn on the terminal echo.
pid, e := syscall.ForkExec(sttyArg0, sttyArgvEOn, &syscall.ProcAttr{Dir: execCWDir, Files: fd})
if e == nil {
_, _ = syscall.Wait4(pid, &ws, 0, nil)
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/ui_unix.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/ui_unix.go#L96-L102 | go | train | // catchSignal tries to catch SIGKILL, SIGQUIT and SIGINT so that we can turn terminal
// echo back on before the program ends. Otherwise the user is left with echo off on
// their terminal. | func catchSignal(fd []uintptr, sig chan os.Signal) | // catchSignal tries to catch SIGKILL, SIGQUIT and SIGINT so that we can turn terminal
// echo back on before the program ends. Otherwise the user is left with echo off on
// their terminal.
func catchSignal(fd []uintptr, sig chan os.Signal) | {
select {
case <-sig:
echoOn(fd)
os.Exit(2)
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7pushaction/actor.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7pushaction/actor.go#L32-L72 | go | train | // NewActor returns a new actor. | func NewActor(v2Actor V2Actor, v3Actor V7Actor, sharedActor SharedActor) *Actor | // NewActor returns a new actor.
func NewActor(v2Actor V2Actor, v3Actor V7Actor, sharedActor SharedActor) *Actor | {
actor := &Actor{
SharedActor: sharedActor,
V2Actor: v2Actor,
V7Actor: v3Actor,
startWithProtocol: regexp.MustCompile(ProtocolRegexp),
urlValidator: regexp.MustCompile(URLRegexp),
}
actor.PushPlanFuncs = []UpdatePushPlanFunc{
SetupApplicationForPushPlan,
SetupDockerImageCredentialsForPushPlan,
SetupBitsPathForPushPlan,
actor.SetupAllResourcesForPushPlan,
SetupNoStartForPushPlan,
SetupSkipRouteCreationForPushPlan,
SetupScaleWebProcessForPushPlan,
SetupUpdateWebProcessForPushPlan,
}
actor.ChangeApplicationFuncs = []ChangeApplicationFunc{
actor.UpdateApplication,
actor.UpdateRoutesForApplication,
actor.ScaleWebProcessForApplication,
actor.UpdateWebProcessForApplication,
actor.CreateBitsPackageForApplication,
actor.CreateDockerPackageForApplication,
}
actor.StartFuncs = []ChangeApplicationFunc{
actor.StagePackageForApplication,
actor.SetDropletForApplication,
}
actor.NoStartFuncs = []ChangeApplicationFunc{
actor.StopApplication,
}
return actor
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/task.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/task.go#L18-L27 | go | train | // RunTask runs the provided command in the application environment associated
// with the provided application GUID. | func (actor Actor) RunTask(appGUID string, task Task) (Task, Warnings, error) | // RunTask runs the provided command in the application environment associated
// with the provided application GUID.
func (actor Actor) RunTask(appGUID string, task Task) (Task, Warnings, error) | {
createdTask, warnings, err := actor.CloudControllerClient.CreateApplicationTask(appGUID, ccv3.Task(task))
if err != nil {
if e, ok := err.(ccerror.TaskWorkersUnavailableError); ok {
return Task{}, Warnings(warnings), actionerror.TaskWorkersUnavailableError{Message: e.Error()}
}
}
return Task(createdTask), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/task.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/task.go#L31-L50 | go | train | // GetApplicationTasks returns a list of tasks associated with the provided
// appplication GUID. | func (actor Actor) GetApplicationTasks(appGUID string, sortOrder SortOrder) ([]Task, Warnings, error) | // GetApplicationTasks returns a list of tasks associated with the provided
// appplication GUID.
func (actor Actor) GetApplicationTasks(appGUID string, sortOrder SortOrder) ([]Task, Warnings, error) | {
tasks, warnings, err := actor.CloudControllerClient.GetApplicationTasks(appGUID)
actorWarnings := Warnings(warnings)
if err != nil {
return nil, actorWarnings, err
}
allTasks := []Task{}
for _, task := range tasks {
allTasks = append(allTasks, Task(task))
}
if sortOrder == Descending {
sort.Slice(allTasks, func(i int, j int) bool { return allTasks[i].SequenceID > allTasks[j].SequenceID })
} else {
sort.Slice(allTasks, func(i int, j int) bool { return allTasks[i].SequenceID < allTasks[j].SequenceID })
}
return allTasks, actorWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/organization.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L32-L51 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Organization response. | func (org *Organization) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Organization response.
func (org *Organization) UnmarshalJSON(data []byte) error | {
var ccOrg struct {
Metadata internal.Metadata `json:"metadata"`
Entity struct {
Name string `json:"name"`
QuotaDefinitionGUID string `json:"quota_definition_guid"`
DefaultIsolationSegmentGUID string `json:"default_isolation_segment_guid"`
} `json:"entity"`
}
err := cloudcontroller.DecodeJSON(data, &ccOrg)
if err != nil {
return err
}
org.GUID = ccOrg.Metadata.GUID
org.Name = ccOrg.Entity.Name
org.QuotaDefinitionGUID = ccOrg.Entity.QuotaDefinitionGUID
org.DefaultIsolationSegmentGUID = ccOrg.Entity.DefaultIsolationSegmentGUID
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/organization.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L113-L129 | go | train | // GetOrganization returns an Organization associated with the provided GUID. | func (client *Client) GetOrganization(guid string) (Organization, Warnings, error) | // GetOrganization returns an Organization associated with the provided GUID.
func (client *Client) GetOrganization(guid string) (Organization, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetOrganizationRequest,
URIParams: Params{"organization_guid": guid},
})
if err != nil {
return Organization{}, nil, err
}
var org Organization
response := cloudcontroller.Response{
DecodeJSONResponseInto: &org,
}
err = client.connection.Make(request, &response)
return org, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/organization.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L133-L159 | go | train | // GetOrganizations returns back a list of Organizations based off of the
// provided filters. | func (client *Client) GetOrganizations(filters ...Filter) ([]Organization, Warnings, error) | // GetOrganizations returns back a list of Organizations based off of the
// provided filters.
func (client *Client) GetOrganizations(filters ...Filter) ([]Organization, Warnings, error) | {
allQueries := ConvertFilterParameters(filters)
allQueries.Add("order-by", "name")
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetOrganizationsRequest,
Query: allQueries,
})
if err != nil {
return nil, nil, err
}
var fullOrgsList []Organization
warnings, err := client.paginate(request, Organization{}, func(item interface{}) error {
if org, ok := item.(Organization); ok {
fullOrgsList = append(fullOrgsList, org)
} else {
return ccerror.UnknownObjectInListError{
Expected: Organization{},
Unexpected: item,
}
}
return nil
})
return fullOrgsList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/organization.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L166-L179 | go | train | // UpdateOrganizationManager assigns the org manager role to the UAA user or client with the provided ID. | func (client *Client) UpdateOrganizationManager(guid string, uaaID string) (Warnings, error) | // UpdateOrganizationManager assigns the org manager role to the UAA user or client with the provided ID.
func (client *Client) UpdateOrganizationManager(guid string, uaaID string) (Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutOrganizationManagerRequest,
URIParams: Params{"organization_guid": guid, "manager_guid": uaaID},
})
if err != nil {
return nil, err
}
response := cloudcontroller.Response{}
err = client.connection.Make(request, &response)
return response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/organization.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L182-L205 | go | train | // UpdateOrganizationManagerByUsername assigns the org manager role to the user with the provided name. | func (client *Client) UpdateOrganizationManagerByUsername(guid string, username string) (Warnings, error) | // UpdateOrganizationManagerByUsername assigns the org manager role to the user with the provided name.
func (client *Client) UpdateOrganizationManagerByUsername(guid string, username string) (Warnings, error) | {
requestBody := updateOrgManagerByUsernameRequestBody{
Username: username,
}
body, err := json.Marshal(requestBody)
if err != nil {
return nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutOrganizationManagerByUsernameRequest,
Body: bytes.NewReader(body),
URIParams: Params{"organization_guid": guid},
})
if err != nil {
return nil, err
}
response := cloudcontroller.Response{}
err = client.connection.Make(request, &response)
return response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/organization.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/organization.go#L230-L253 | go | train | // UpdateOrganizationUserByUsername makes the user with the given username a member of
// the org. | func (client Client) UpdateOrganizationUserByUsername(orgGUID string, username string) (Warnings, error) | // UpdateOrganizationUserByUsername makes the user with the given username a member of
// the org.
func (client Client) UpdateOrganizationUserByUsername(orgGUID string, username string) (Warnings, error) | {
requestBody := updateOrgUserByUsernameRequestBody{
Username: username,
}
body, err := json.Marshal(requestBody)
if err != nil {
return Warnings{}, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutOrganizationUserByUsernameRequest,
Body: bytes.NewReader(body),
URIParams: Params{"organization_guid": orgGUID},
})
if err != nil {
return Warnings{}, err
}
response := cloudcontroller.Response{}
err = client.connection.Make(request, &response)
return response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/query.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/query.go#L52-L59 | go | train | // FormatQueryParameters converts a Query object into a collection that
// cloudcontroller.Request can accept. | func FormatQueryParameters(queries []Query) url.Values | // FormatQueryParameters converts a Query object into a collection that
// cloudcontroller.Request can accept.
func FormatQueryParameters(queries []Query) url.Values | {
params := url.Values{}
for _, query := range queries {
params.Add(string(query.Key), strings.Join(query.Values, ","))
}
return params
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/uaa/noaabridge/token_refresher.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/noaabridge/token_refresher.go#L31-L36 | go | train | // NewTokenRefresher returns back a pointer to a TokenRefresher. | func NewTokenRefresher(uaaClient UAAClient, cache TokenCache) *TokenRefresher | // NewTokenRefresher returns back a pointer to a TokenRefresher.
func NewTokenRefresher(uaaClient UAAClient, cache TokenCache) *TokenRefresher | {
return &TokenRefresher{
uaaClient: uaaClient,
cache: cache,
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/uaa/noaabridge/token_refresher.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/noaabridge/token_refresher.go#L41-L50 | go | train | // RefreshAuthToken refreshes the current Authorization Token and stores the
// Access and Refresh token in it's cache. The returned Authorization Token
// includes the type prefixed by a space. | func (t *TokenRefresher) RefreshAuthToken() (string, error) | // RefreshAuthToken refreshes the current Authorization Token and stores the
// Access and Refresh token in it's cache. The returned Authorization Token
// includes the type prefixed by a space.
func (t *TokenRefresher) RefreshAuthToken() (string, error) | {
tokens, err := t.uaaClient.RefreshAccessToken(t.cache.RefreshToken())
if err != nil {
return "", err
}
t.cache.SetAccessToken(tokens.AuthorizationToken())
t.cache.SetRefreshToken(tokens.RefreshToken)
return tokens.AuthorizationToken(), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/pipebomb.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/pipebomb.go#L18-L20 | go | train | // Seek returns a PipeSeekError; allowing the top level calling function to
// handle the retry instead of seeking back to the beginning of the Reader. | func (*Pipebomb) Seek(offset int64, whence int) (int64, error) | // Seek returns a PipeSeekError; allowing the top level calling function to
// handle the retry instead of seeking back to the beginning of the Reader.
func (*Pipebomb) Seek(offset int64, whence int) (int64, error) | {
return 0, ccerror.PipeSeekError{}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/pipebomb.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/pipebomb.go#L24-L27 | go | train | // NewPipeBomb returns an io.WriteCloser that can be used to stream data to a
// the Pipebomb. | func NewPipeBomb() (*Pipebomb, io.WriteCloser) | // NewPipeBomb returns an io.WriteCloser that can be used to stream data to a
// the Pipebomb.
func NewPipeBomb() (*Pipebomb, io.WriteCloser) | {
writerOutput, writerInput := io.Pipe()
return &Pipebomb{ReadCloser: writerOutput}, writerInput
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_binding.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L18-L22 | go | train | // BindServiceByApplicationAndServiceInstance binds the service instance to an application. | func (actor Actor) BindServiceByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (Warnings, error) | // BindServiceByApplicationAndServiceInstance binds the service instance to an application.
func (actor Actor) BindServiceByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (Warnings, error) | {
_, warnings, err := actor.CloudControllerClient.CreateServiceBinding(appGUID, serviceInstanceGUID, "", false, nil)
return Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_binding.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L25-L43 | go | train | // BindServiceBySpace binds the service instance to an application for a given space. | func (actor Actor) BindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string, bindingName string, parameters map[string]interface{}) (ServiceBinding, Warnings, error) | // BindServiceBySpace binds the service instance to an application for a given space.
func (actor Actor) BindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string, bindingName string, parameters map[string]interface{}) (ServiceBinding, Warnings, error) | {
var allWarnings Warnings
app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return ServiceBinding{}, allWarnings, err
}
serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return ServiceBinding{}, allWarnings, err
}
serviceBinding, ccv2Warnings, err := actor.CloudControllerClient.CreateServiceBinding(app.GUID, serviceInstance.GUID, bindingName, true, parameters)
allWarnings = append(allWarnings, ccv2Warnings...)
return ServiceBinding(serviceBinding), allWarnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_binding.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L47-L73 | go | train | // GetServiceBindingByApplicationAndServiceInstance returns a service binding
// given an application GUID and and service instance GUID. | func (actor Actor) GetServiceBindingByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (ServiceBinding, Warnings, error) | // GetServiceBindingByApplicationAndServiceInstance returns a service binding
// given an application GUID and and service instance GUID.
func (actor Actor) GetServiceBindingByApplicationAndServiceInstance(appGUID string, serviceInstanceGUID string) (ServiceBinding, Warnings, error) | {
serviceBindings, warnings, err := actor.CloudControllerClient.GetServiceBindings(
ccv2.Filter{
Type: constant.AppGUIDFilter,
Operator: constant.EqualOperator,
Values: []string{appGUID},
},
ccv2.Filter{
Type: constant.ServiceInstanceGUIDFilter,
Operator: constant.EqualOperator,
Values: []string{serviceInstanceGUID},
},
)
if err != nil {
return ServiceBinding{}, Warnings(warnings), err
}
if len(serviceBindings) == 0 {
return ServiceBinding{}, Warnings(warnings), actionerror.ServiceBindingNotFoundError{
AppGUID: appGUID,
ServiceInstanceGUID: serviceInstanceGUID,
}
}
return ServiceBinding(serviceBindings[0]), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_binding.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_binding.go#L77-L102 | go | train | // UnbindServiceBySpace deletes the service binding between an application and
// service instance for a given space. | func (actor Actor) UnbindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string) (ServiceBinding, Warnings, error) | // UnbindServiceBySpace deletes the service binding between an application and
// service instance for a given space.
func (actor Actor) UnbindServiceBySpace(appName string, serviceInstanceName string, spaceGUID string) (ServiceBinding, Warnings, error) | {
var allWarnings Warnings
app, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return ServiceBinding{}, allWarnings, err
}
serviceInstance, warnings, err := actor.GetServiceInstanceByNameAndSpace(serviceInstanceName, spaceGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return ServiceBinding{}, allWarnings, err
}
serviceBinding, warnings, err := actor.GetServiceBindingByApplicationAndServiceInstance(app.GUID, serviceInstance.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return ServiceBinding{}, allWarnings, err
}
deletedBinding, ccWarnings, err := actor.CloudControllerClient.DeleteServiceBinding(serviceBinding.GUID, true)
allWarnings = append(allWarnings, ccWarnings...)
return ServiceBinding(deletedBinding), allWarnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/sha.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/sha.go#L13-L23 | go | train | // Sha1Sum calculates the SHA1 sum of a file. | func Sha1Sum(path string) string | // Sha1Sum calculates the SHA1 sum of a file.
func Sha1Sum(path string) string | {
f, err := os.Open(path)
Expect(err).ToNot(HaveOccurred())
defer f.Close()
hash := sha1.New()
_, err = io.Copy(hash, f)
Expect(err).ToNot(HaveOccurred())
return fmt.Sprintf("%x", hash.Sum(nil))
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/push_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/push_command.go#L227-L275 | go | train | // GetCommandLineSettings generates a push CommandLineSettings object from the
// command's command line flags. It also validates those settings, preventing
// contradictory flags. | func (cmd PushCommand) GetCommandLineSettings() (pushaction.CommandLineSettings, error) | // GetCommandLineSettings generates a push CommandLineSettings object from the
// command's command line flags. It also validates those settings, preventing
// contradictory flags.
func (cmd PushCommand) GetCommandLineSettings() (pushaction.CommandLineSettings, error) | {
err := cmd.validateArgs()
if err != nil {
return pushaction.CommandLineSettings{}, err
}
pwd, err := os.Getwd()
if err != nil {
return pushaction.CommandLineSettings{}, err
}
dockerPassword := cmd.Config.DockerPassword()
if dockerPassword != "" {
cmd.UI.DisplayText("Using docker repository password from environment variable CF_DOCKER_PASSWORD.")
} else if cmd.DockerUsername != "" {
cmd.UI.DisplayText("Environment variable CF_DOCKER_PASSWORD not set.")
dockerPassword, err = cmd.UI.DisplayPasswordPrompt("Docker password")
if err != nil {
return pushaction.CommandLineSettings{}, err
}
}
config := pushaction.CommandLineSettings{
Buildpacks: cmd.Buildpacks, // -b
Command: cmd.Command.FilteredString, // -c
CurrentDirectory: pwd,
DefaultRouteDomain: cmd.Domain, // -d
DefaultRouteHostname: cmd.Hostname, // -n/--hostname
DiskQuota: cmd.DiskQuota.Value, // -k
DockerImage: cmd.DockerImage.Path, // -o
DockerPassword: dockerPassword, // ENV - CF_DOCKER_PASSWORD
DockerUsername: cmd.DockerUsername, // --docker-username
DropletPath: string(cmd.DropletPath), // --droplet
HealthCheckTimeout: cmd.HealthCheckTimeout, // -t
HealthCheckType: cmd.HealthCheckType.Type, // -u/--health-check-type
Instances: cmd.Instances.NullInt, // -i
Memory: cmd.Memory.Value, // -m
Name: cmd.OptionalArgs.AppName, // arg
NoHostname: cmd.NoHostname, // --no-hostname
NoRoute: cmd.NoRoute, // --no-route
ProvidedAppPath: string(cmd.AppPath), // -p
RandomRoute: cmd.RandomRoute, // --random-route
RoutePath: cmd.RoutePath.Path, // --route-path
StackName: cmd.StackName, // -s
}
log.Debugln("Command Line Settings:", config)
return config, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/client.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/client.go#L123-L132 | go | train | // NewClient returns a new Client. | func NewClient(config Config) *Client | // NewClient returns a new Client.
func NewClient(config Config) *Client | {
userAgent := fmt.Sprintf("%s/%s (%s; %s %s)", config.AppName, config.AppVersion, runtime.Version(), runtime.GOARCH, runtime.GOOS)
return &Client{
clock: new(internal.RealTime),
userAgent: userAgent,
jobPollingInterval: config.JobPollingInterval,
jobPollingTimeout: config.JobPollingTimeout,
wrappers: append([]ConnectionWrapper{newErrorWrapper()}, config.Wrappers...),
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/shared/noaa_client.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/noaa_client.go#L41-L67 | go | train | // NewNOAAClient returns back a configured NOAA Client. | func NewNOAAClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) *consumer.Consumer | // NewNOAAClient returns back a configured NOAA Client.
func NewNOAAClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) *consumer.Consumer | {
client := consumer.New(
apiURL,
&tls.Config{
InsecureSkipVerify: config.SkipSSLValidation(),
},
http.ProxyFromEnvironment,
)
client.RefreshTokenFrom(noaabridge.NewTokenRefresher(uaaClient, config))
client.SetMaxRetryCount(config.NOAARequestRetryCount())
noaaDebugPrinter := DebugPrinter{}
// if verbose, set debug printer on noaa client
verbose, location := config.Verbose()
client.SetDebugPrinter(&noaaDebugPrinter)
if verbose {
noaaDebugPrinter.addOutput(ui.RequestLoggerTerminalDisplay())
}
if location != nil {
noaaDebugPrinter.addOutput(ui.RequestLoggerFileWriter(location))
}
return client
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/configv3/home_dir_windows.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/home_dir_windows.go#L21-L32 | go | train | // See: http://stackoverflow.com/questions/7922270/obtain-users-home-directory
// we can't cross compile using cgo and use user.Current() | func homeDirectory() string | // See: http://stackoverflow.com/questions/7922270/obtain-users-home-directory
// we can't cross compile using cgo and use user.Current()
func homeDirectory() string | {
var homeDir string
switch {
case os.Getenv("CF_HOME") != "":
homeDir = os.Getenv("CF_HOME")
case os.Getenv("HOMEDRIVE")+os.Getenv("HOMEPATH") != "":
homeDir = os.Getenv("HOMEDRIVE") + os.Getenv("HOMEPATH")
default:
homeDir = os.Getenv("USERPROFILE")
}
return homeDir
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/uaa/error_converter.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/error_converter.go#L21-L29 | go | train | // Make converts RawHTTPStatusError, which represents responses with 4xx and
// 5xx status codes, to specific errors. | func (e *errorWrapper) Make(request *http.Request, passedResponse *Response) error | // Make converts RawHTTPStatusError, which represents responses with 4xx and
// 5xx status codes, to specific errors.
func (e *errorWrapper) Make(request *http.Request, passedResponse *Response) error | {
err := e.connection.Make(request, passedResponse)
if rawHTTPStatusErr, ok := err.(RawHTTPStatusError); ok {
return convert(rawHTTPStatusErr)
}
return err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/uaa/error_converter.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/error_converter.go#L32-L35 | go | train | // Wrap wraps a UAA connection in this error handling wrapper. | func (e *errorWrapper) Wrap(innerconnection Connection) Connection | // Wrap wraps a UAA connection in this error handling wrapper.
func (e *errorWrapper) Wrap(innerconnection Connection) Connection | {
e.connection = innerconnection
return e
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/reporters.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/reporters.go#L61-L107 | go | train | // WriteFailureSummary aggregates test failures from all parallel nodes, sorts
// them, and writes the result to a file. | func WriteFailureSummary(outputRoot, filename string) | // WriteFailureSummary aggregates test failures from all parallel nodes, sorts
// them, and writes the result to a file.
func WriteFailureSummary(outputRoot, filename string) | {
outfile, err := os.Create(filepath.Join(outputRoot, filename))
failureSummaries := make([]string, 0)
if err != nil {
panic(err)
}
err = filepath.Walk(outputRoot, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if info.IsDir() {
return nil
}
if strings.Contains(path, "summary") {
return nil
}
defer os.Remove(path)
allFailures, err := ioutil.ReadFile(path)
if err != nil {
return err
}
failures := strings.Split(string(allFailures), "\n")
failureSummaries = append(failureSummaries, failures...)
return nil
})
if err != nil {
panic(err)
}
sort.Strings(failureSummaries)
anyFailures := false
var previousLine string
for _, line := range failureSummaries {
if line != "" && line != previousLine {
anyFailures = true
previousLine = line
fmt.Fprintln(outfile, line)
}
}
if !anyFailures {
err = os.Remove(filepath.Join(outputRoot, filename))
}
if err != nil {
panic(err)
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/ui.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/ui.go#L272-L300 | go | train | // Print formats the table and then prints it to the UI specified at
// the time of the construction. Afterwards the table is cleared,
// becoming ready for another round of rows and printing. | func (u *UITable) Print() error | // Print formats the table and then prints it to the UI specified at
// the time of the construction. Afterwards the table is cleared,
// becoming ready for another round of rows and printing.
func (u *UITable) Print() error | {
result := &bytes.Buffer{}
t := u.Table
err := t.PrintTo(result)
if err != nil {
return err
}
// DevNote. With the change to printing into a buffer all
// lines now come with a terminating \n. The t.ui.Say() below
// will then add another \n to that. To avoid this additional
// line we chop off the last \n from the output (if there is
// any). Operating on the slice avoids string copying.
//
// WIBNI if the terminal API had a variant of Say not assuming
// that each output is a single line.
r := result.Bytes()
if len(r) > 0 {
r = r[0 : len(r)-1]
}
// Only generate output for a non-empty table.
if len(r) > 0 {
u.UI.Say("%s", string(r))
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/stack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/stack.go#L13-L21 | go | train | // GetStack returns the stack information associated with the provided stack GUID. | func (actor Actor) GetStack(guid string) (Stack, Warnings, error) | // GetStack returns the stack information associated with the provided stack GUID.
func (actor Actor) GetStack(guid string) (Stack, Warnings, error) | {
stack, warnings, err := actor.CloudControllerClient.GetStack(guid)
if _, ok := err.(ccerror.ResourceNotFoundError); ok {
return Stack{}, Warnings(warnings), actionerror.StackNotFoundError{GUID: guid}
}
return Stack(stack), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/stack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/stack.go#L24-L39 | go | train | // GetStackByName returns the provided stack | func (actor Actor) GetStackByName(stackName string) (Stack, Warnings, error) | // GetStackByName returns the provided stack
func (actor Actor) GetStackByName(stackName string) (Stack, Warnings, error) | {
stacks, warnings, err := actor.CloudControllerClient.GetStacks(ccv2.Filter{
Type: constant.NameFilter,
Operator: constant.EqualOperator,
Values: []string{stackName},
})
if err != nil {
return Stack{}, Warnings(warnings), err
}
if len(stacks) == 0 {
return Stack{}, Warnings(warnings), actionerror.StackNotFoundError{Name: stackName}
}
return Stack(stacks[0]), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L54-L76 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Job response. | func (job *Job) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Job response.
func (job *Job) UnmarshalJSON(data []byte) error | {
var ccJob struct {
Entity struct {
Error string `json:"error"`
ErrorDetails struct {
Description string `json:"description"`
} `json:"error_details"`
GUID string `json:"guid"`
Status string `json:"status"`
} `json:"entity"`
Metadata internal.Metadata `json:"metadata"`
}
err := cloudcontroller.DecodeJSON(data, &ccJob)
if err != nil {
return err
}
job.Error = ccJob.Entity.Error
job.ErrorDetails.Description = ccJob.Entity.ErrorDetails.Description
job.GUID = ccJob.Entity.GUID
job.Status = constant.JobStatus(ccJob.Entity.Status)
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L128-L144 | go | train | // GetJob returns a job for the provided GUID. | func (client *Client) GetJob(jobGUID string) (Job, Warnings, error) | // GetJob returns a job for the provided GUID.
func (client *Client) GetJob(jobGUID string) (Job, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetJobRequest,
URIParams: Params{"job_guid": jobGUID},
})
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
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L149-L184 | go | train | // PollJob will keep polling the given job until the job has terminated, an
// error is encountered, or config.OverallPollingTimeout is reached. In the
// last case, a JobTimeoutError is returned. | func (client *Client) PollJob(job Job) (Warnings, error) | // PollJob will keep polling the given job until the job has terminated, an
// error is encountered, or config.OverallPollingTimeout is reached. In the
// last case, a JobTimeoutError is returned.
func (client *Client) PollJob(job Job) (Warnings, error) | {
originalJobGUID := job.GUID
var (
err error
warnings Warnings
allWarnings Warnings
)
startTime := time.Now()
for time.Now().Sub(startTime) < client.jobPollingTimeout {
job, warnings, err = client.GetJob(job.GUID)
allWarnings = append(allWarnings, Warnings(warnings)...)
if err != nil {
return allWarnings, err
}
if job.Failed() {
return allWarnings, ccerror.V2JobFailedError{
JobGUID: originalJobGUID,
Message: job.ErrorDetails.Description,
}
}
if job.Finished() {
return allWarnings, nil
}
time.Sleep(client.jobPollingInterval)
}
return allWarnings, ccerror.JobTimeoutError{
JobGUID: originalJobGUID,
Timeout: client.jobPollingTimeout,
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L194-L204 | go | train | // UploadApplicationPackage uploads the newResources and a list of existing
// resources to the cloud controller. A job that combines the requested/newly
// uploaded bits is returned. The function will act differently given the
// following Readers:
// io.ReadSeeker: Will function properly on retry.
// io.Reader: Will return a ccerror.PipeSeekError on retry.
// nil: Will not add the "application" section to the request.
// newResourcesLength is ignored in this case. | func (client *Client) UploadApplicationPackage(appGUID string, existingResources []Resource, newResources Reader, newResourcesLength int64) (Job, Warnings, error) | // UploadApplicationPackage uploads the newResources and a list of existing
// resources to the cloud controller. A job that combines the requested/newly
// uploaded bits is returned. The function will act differently given the
// following Readers:
// io.ReadSeeker: Will function properly on retry.
// io.Reader: Will return a ccerror.PipeSeekError on retry.
// nil: Will not add the "application" section to the request.
// newResourcesLength is ignored in this case.
func (client *Client) UploadApplicationPackage(appGUID string, existingResources []Resource, newResources Reader, newResourcesLength int64) (Job, Warnings, error) | {
if existingResources == nil {
return Job{}, nil, ccerror.NilObjectError{Object: "existingResources"}
}
if newResources == nil {
return client.uploadExistingResourcesOnly(appGUID, existingResources)
}
return client.uploadNewAndExistingResources(appGUID, existingResources, newResources, newResourcesLength)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/job.go#L209-L230 | go | train | // UploadDroplet defines and uploads a previously staged droplet that an
// application will run, using a multipart PUT request. The uploaded file
// should be a gzipped tar file. | func (client *Client) UploadDroplet(appGUID string, droplet io.Reader, dropletLength int64) (Job, Warnings, error) | // UploadDroplet defines and uploads a previously staged droplet that an
// application will run, using a multipart PUT request. The uploaded file
// should be a gzipped tar file.
func (client *Client) UploadDroplet(appGUID string, droplet io.Reader, dropletLength int64) (Job, Warnings, error) | {
contentLength, err := client.calculateDropletRequestSize(dropletLength)
if err != nil {
return Job{}, nil, err
}
contentType, body, writeErrors := client.createMultipartBodyAndHeaderForDroplet(droplet)
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutDropletRequest,
URIParams: Params{"app_guid": appGUID},
Body: body,
})
if err != nil {
return Job{}, nil, err
}
request.Header.Set("Content-Type", contentType)
request.ContentLength = contentLength
return client.uploadAsynchronously(request, writeErrors)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/process_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process_instance.go#L44-L82 | go | train | // UnmarshalJSON helps unmarshal a V3 Cloud Controller Instance response. | func (instance *ProcessInstance) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a V3 Cloud Controller Instance response.
func (instance *ProcessInstance) UnmarshalJSON(data []byte) error | {
var inputInstance struct {
Details string `json:"details"`
DiskQuota uint64 `json:"disk_quota"`
Index int64 `json:"index"`
IsolationSegment string `json:"isolation_segment"`
MemQuota uint64 `json:"mem_quota"`
State string `json:"state"`
Type string `json:"type"`
Uptime int64 `json:"uptime"`
Usage struct {
CPU float64 `json:"cpu"`
Mem uint64 `json:"mem"`
Disk uint64 `json:"disk"`
} `json:"usage"`
}
err := cloudcontroller.DecodeJSON(data, &inputInstance)
if err != nil {
return err
}
instance.CPU = inputInstance.Usage.CPU
instance.Details = inputInstance.Details
instance.DiskQuota = inputInstance.DiskQuota
instance.DiskUsage = inputInstance.Usage.Disk
instance.Index = inputInstance.Index
instance.IsolationSegment = inputInstance.IsolationSegment
instance.MemoryQuota = inputInstance.MemQuota
instance.MemoryUsage = inputInstance.Usage.Mem
instance.State = constant.ProcessInstanceState(inputInstance.State)
instance.Type = inputInstance.Type
instance.Uptime, err = time.ParseDuration(fmt.Sprintf("%ds", inputInstance.Uptime))
if err != nil {
return err
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/process_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process_instance.go#L86-L103 | go | train | // DeleteApplicationProcessInstance deletes/stops a particular application's
// process instance. | func (client *Client) DeleteApplicationProcessInstance(appGUID string, processType string, instanceIndex int) (Warnings, error) | // DeleteApplicationProcessInstance deletes/stops a particular application's
// process instance.
func (client *Client) DeleteApplicationProcessInstance(appGUID string, processType string, instanceIndex int) (Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.DeleteApplicationProcessInstanceRequest,
URIParams: map[string]string{
"app_guid": appGUID,
"type": processType,
"index": strconv.Itoa(instanceIndex),
},
})
if err != nil {
return nil, err
}
var response cloudcontroller.Response
err = client.connection.Make(request, &response)
return response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/process_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/process_instance.go#L106-L129 | go | train | // GetProcessInstances lists instance stats for a given process. | func (client *Client) GetProcessInstances(processGUID string) ([]ProcessInstance, Warnings, error) | // GetProcessInstances lists instance stats for a given process.
func (client *Client) GetProcessInstances(processGUID string) ([]ProcessInstance, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetProcessStatsRequest,
URIParams: map[string]string{"process_guid": processGUID},
})
if err != nil {
return nil, nil, err
}
var fullInstancesList []ProcessInstance
warnings, err := client.paginate(request, ProcessInstance{}, func(item interface{}) error {
if instance, ok := item.(ProcessInstance); ok {
fullInstancesList = append(fullInstancesList, instance)
} else {
return ccerror.UnknownObjectInListError{
Expected: ProcessInstance{},
Unexpected: item,
}
}
return nil
})
return fullInstancesList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L53-L67 | go | train | // GetApplicationByNameAndSpace returns the application with the given
// name in the given space. | func (actor Actor) GetApplicationByNameAndSpace(appName string, spaceGUID string) (Application, Warnings, error) | // GetApplicationByNameAndSpace returns the application with the given
// name in the given space.
func (actor Actor) GetApplicationByNameAndSpace(appName string, spaceGUID string) (Application, Warnings, error) | {
apps, warnings, err := actor.CloudControllerClient.GetApplications(
ccv3.Query{Key: ccv3.NameFilter, Values: []string{appName}},
ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}},
)
if err != nil {
return Application{}, Warnings(warnings), err
}
if len(apps) == 0 {
return Application{}, Warnings(warnings), actionerror.ApplicationNotFoundError{Name: appName}
}
return actor.convertCCToActorApplication(apps[0]), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L87-L101 | go | train | // GetApplicationsByGUIDs returns all applications with the provided GUIDs. | func (actor Actor) GetApplicationsByGUIDs(appGUIDs ...string) ([]Application, Warnings, error) | // GetApplicationsByGUIDs returns all applications with the provided GUIDs.
func (actor Actor) GetApplicationsByGUIDs(appGUIDs ...string) ([]Application, Warnings, error) | {
ccApps, warnings, err := actor.CloudControllerClient.GetApplications(
ccv3.Query{Key: ccv3.GUIDFilter, Values: appGUIDs},
)
if err != nil {
return []Application{}, Warnings(warnings), err
}
var apps []Application
for _, ccApp := range ccApps {
apps = append(apps, actor.convertCCToActorApplication(ccApp))
}
return apps, Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L145-L149 | go | train | // RestartApplication restarts an application. | func (actor Actor) RestartApplication(appGUID string) (Warnings, error) | // RestartApplication restarts an application.
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) | {
_, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID)
return Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application.go#L182-L196 | go | train | // UpdateApplication updates the buildpacks on an application | func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) | // UpdateApplication updates the buildpacks on an application
func (actor Actor) UpdateApplication(app Application) (Application, Warnings, error) | {
ccApp := ccv3.Application{
GUID: app.GUID,
StackName: app.StackName,
LifecycleType: app.LifecycleType,
LifecycleBuildpacks: app.LifecycleBuildpacks,
}
updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplication(ccApp)
if err != nil {
return Application{}, Warnings(warnings), err
}
return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/router/wrapper/uaa_authentication.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/wrapper/uaa_authentication.go#L36-L41 | go | train | // NewUAAAuthentication returns a pointer to a UAAAuthentication wrapper with
// the client and a token cache. | func NewUAAAuthentication(client UAAClient, cache TokenCache) *UAAAuthentication | // NewUAAAuthentication returns a pointer to a UAAAuthentication wrapper with
// the client and a token cache.
func NewUAAAuthentication(client UAAClient, cache TokenCache) *UAAAuthentication | {
return &UAAAuthentication{
client: client,
cache: cache,
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/router/wrapper/uaa_authentication.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/wrapper/uaa_authentication.go#L46-L74 | go | train | // Make adds authentication headers to the passed in request and then calls the
// wrapped connection's Make. If the client is not set on the wrapper, it will
// not add any header or handle any authentication errors. | func (t *UAAAuthentication) Make(request *router.Request, passedResponse *router.Response) error | // Make adds authentication headers to the passed in request and then calls the
// wrapped connection's Make. If the client is not set on the wrapper, it will
// not add any header or handle any authentication errors.
func (t *UAAAuthentication) Make(request *router.Request, passedResponse *router.Response) error | {
if t.client == nil {
return t.connection.Make(request, passedResponse)
}
request.Header.Set("Authorization", t.cache.AccessToken())
requestErr := t.connection.Make(request, passedResponse)
if _, ok := requestErr.(routererror.InvalidAuthTokenError); ok {
tokens, err := t.client.RefreshAccessToken(t.cache.RefreshToken())
if err != nil {
return err
}
t.cache.SetAccessToken(tokens.AuthorizationToken())
t.cache.SetRefreshToken(tokens.RefreshToken)
if request.Body != nil {
err = request.ResetBody()
if err != nil {
return err
}
}
request.Header.Set("Authorization", t.cache.AccessToken())
requestErr = t.connection.Make(request, passedResponse)
}
return requestErr
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/router/wrapper/uaa_authentication.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/router/wrapper/uaa_authentication.go#L82-L85 | go | train | // Wrap sets the connection on the UAAAuthentication and returns itself | func (t *UAAAuthentication) Wrap(innerconnection router.Connection) router.Connection | // Wrap sets the connection on the UAAAuthentication and returns itself
func (t *UAAAuthentication) Wrap(innerconnection router.Connection) router.Connection | {
t.connection = innerconnection
return t
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/configv3/write_config.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/write_config.go#L14-L48 | go | train | // WriteConfig creates the .cf directory and then writes the config.json. The
// location of .cf directory is written in the same way LoadConfig reads .cf
// directory. | func WriteConfig(c *Config) error | // WriteConfig creates the .cf directory and then writes the config.json. The
// location of .cf directory is written in the same way LoadConfig reads .cf
// directory.
func WriteConfig(c *Config) error | {
rawConfig, err := json.MarshalIndent(c.ConfigFile, "", " ")
if err != nil {
return err
}
dir := configDirectory()
err = os.MkdirAll(dir, 0700)
if err != nil {
return err
}
// Developer Note: The following is untested! Change at your own risk.
// Setup notifications of termination signals to channel sig, create a process to
// watch for these signals so we can remove transient config temp files.
sig := make(chan os.Signal, 10)
signal.Notify(sig, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM, os.Interrupt)
defer signal.Stop(sig)
tempConfigFile, err := ioutil.TempFile(dir, "temp-config")
if err != nil {
return err
}
tempConfigFile.Close()
tempConfigFileName := tempConfigFile.Name()
go catchSignal(sig, tempConfigFileName)
err = ioutil.WriteFile(tempConfigFileName, rawConfig, 0600)
if err != nil {
return err
}
return os.Rename(tempConfigFileName, ConfigFilePath())
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/configv3/write_config.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/write_config.go#L54-L58 | go | train | // catchSignal tries to catch SIGHUP, SIGINT, SIGKILL, SIGQUIT and SIGTERM, and
// Interrupt for removing temporarily created config files before the program
// ends. Note: we cannot intercept a `kill -9`, so a well-timed `kill -9`
// will allow a temp config file to linger. | func catchSignal(sig chan os.Signal, tempConfigFileName string) | // catchSignal tries to catch SIGHUP, SIGINT, SIGKILL, SIGQUIT and SIGTERM, and
// Interrupt for removing temporarily created config files before the program
// ends. Note: we cannot intercept a `kill -9`, so a well-timed `kill -9`
// will allow a temp config file to linger.
func catchSignal(sig chan os.Signal, tempConfigFileName string) | {
<-sig
_ = os.Remove(tempConfigFileName)
os.Exit(2)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/space.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/space.go#L21-L47 | go | train | // ResetSpaceIsolationSegment disassociates a space from an isolation segment.
//
// If the space's organization has a default isolation segment, return its
// name. Otherwise return the empty string. | func (actor Actor) ResetSpaceIsolationSegment(orgGUID string, spaceGUID string) (string, Warnings, error) | // ResetSpaceIsolationSegment disassociates a space from an isolation segment.
//
// If the space's organization has a default isolation segment, return its
// name. Otherwise return the empty string.
func (actor Actor) ResetSpaceIsolationSegment(orgGUID string, spaceGUID string) (string, Warnings, error) | {
var allWarnings Warnings
_, apiWarnings, err := actor.CloudControllerClient.UpdateSpaceIsolationSegmentRelationship(spaceGUID, "")
allWarnings = append(allWarnings, apiWarnings...)
if err != nil {
return "", allWarnings, err
}
isoSegRelationship, apiWarnings, err := actor.CloudControllerClient.GetOrganizationDefaultIsolationSegment(orgGUID)
allWarnings = append(allWarnings, apiWarnings...)
if err != nil {
return "", allWarnings, err
}
var isoSegName string
if isoSegRelationship.GUID != "" {
isolationSegment, apiWarnings, err := actor.CloudControllerClient.GetIsolationSegment(isoSegRelationship.GUID)
allWarnings = append(allWarnings, apiWarnings...)
if err != nil {
return "", allWarnings, err
}
isoSegName = isolationSegment.Name
}
return isoSegName, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/shared/new_v3_based_clients.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/new_v3_based_clients.go#L14-L93 | go | train | // NewV3BasedClients creates a new V3 Cloud Controller client and UAA client using the
// passed in config. | func NewV3BasedClients(config command.Config, ui command.UI, targetCF bool, minVersionV3 string) (*ccv3.Client, *uaa.Client, error) | // NewV3BasedClients creates a new V3 Cloud Controller client and UAA client using the
// passed in config.
func NewV3BasedClients(config command.Config, ui command.UI, targetCF bool, minVersionV3 string) (*ccv3.Client, *uaa.Client, error) | {
ccWrappers := []ccv3.ConnectionWrapper{}
verbose, location := config.Verbose()
if verbose {
ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay()))
}
if location != nil {
ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location)))
}
authWrapper := ccWrapper.NewUAAAuthentication(nil, config)
ccWrappers = append(ccWrappers, authWrapper)
ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount()))
ccClient := ccv3.NewClient(ccv3.Config{
AppName: config.BinaryName(),
AppVersion: config.BinaryVersion(),
JobPollingTimeout: config.OverallPollingTimeout(),
JobPollingInterval: config.PollingInterval(),
Wrappers: ccWrappers,
})
if !targetCF {
return ccClient, nil, nil
}
if config.Target() == "" {
return nil, nil, translatableerror.NoAPISetError{
BinaryName: config.BinaryName(),
}
}
_, err := ccClient.TargetCF(ccv3.TargetSettings{
URL: config.Target(),
SkipSSLValidation: config.SkipSSLValidation(),
DialTimeout: config.DialTimeout(),
})
if err != nil {
return nil, nil, err
}
if minVersionV3 != "" {
err = command.MinimumCCAPIVersionCheck(ccClient.CloudControllerAPIVersion(), minVersionV3)
if err != nil {
if _, ok := err.(translatableerror.MinimumCFAPIVersionNotMetError); ok {
return nil, nil, translatableerror.V3V2SwitchError{}
}
return nil, nil, err
}
}
if ccClient.UAA() == "" {
return nil, nil, translatableerror.UAAEndpointNotFoundError{}
}
uaaClient := uaa.NewClient(config)
if verbose {
uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay()))
}
if location != nil {
uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location)))
}
uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(uaaClient, config)
uaaClient.WrapConnection(uaaAuthWrapper)
uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount()))
err = uaaClient.SetupResources(ccClient.UAA())
if err != nil {
return nil, nil, err
}
uaaAuthWrapper.SetClient(uaaClient)
authWrapper.SetClient(uaaClient)
return ccClient, uaaClient, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_broker.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_broker.go#L12-L15 | go | train | // CreateServiceBroker returns a ServiceBroker and any warnings or errors. | func (actor Actor) CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID string) (ServiceBroker, Warnings, error) | // CreateServiceBroker returns a ServiceBroker and any warnings or errors.
func (actor Actor) CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID string) (ServiceBroker, Warnings, error) | {
serviceBroker, warnings, err := actor.CloudControllerClient.CreateServiceBroker(serviceBrokerName, username, password, brokerURI, spaceGUID)
return ServiceBroker(serviceBroker), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_broker.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_broker.go#L18-L30 | go | train | // GetServiceBrokers returns all ServiceBrokers and any warnings or errors. | func (actor Actor) GetServiceBrokers() ([]ServiceBroker, Warnings, error) | // GetServiceBrokers returns all ServiceBrokers and any warnings or errors.
func (actor Actor) GetServiceBrokers() ([]ServiceBroker, Warnings, error) | {
brokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers()
if err != nil {
return nil, Warnings(warnings), err
}
var brokersToReturn []ServiceBroker
for _, b := range brokers {
brokersToReturn = append(brokersToReturn, ServiceBroker(b))
}
return brokersToReturn, Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_broker.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_broker.go#L33-L49 | go | train | // GetServiceBrokerByName returns a ServiceBroker and any warnings or errors. | func (actor Actor) GetServiceBrokerByName(brokerName string) (ServiceBroker, Warnings, error) | // GetServiceBrokerByName returns a ServiceBroker and any warnings or errors.
func (actor Actor) GetServiceBrokerByName(brokerName string) (ServiceBroker, Warnings, error) | {
serviceBrokers, warnings, err := actor.CloudControllerClient.GetServiceBrokers(ccv2.Filter{
Type: constant.NameFilter,
Operator: constant.EqualOperator,
Values: []string{brokerName},
})
if err != nil {
return ServiceBroker{}, Warnings(warnings), err
}
if len(serviceBrokers) == 0 {
return ServiceBroker{}, Warnings(warnings), actionerror.ServiceBrokerNotFoundError{Name: brokerName}
}
return ServiceBroker(serviceBrokers[0]), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/space_summary.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space_summary.go#L43-L59 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Space Summary response. | func (spaceSummary *SpaceSummary) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Space Summary response.
func (spaceSummary *SpaceSummary) UnmarshalJSON(data []byte) error | {
var ccSpaceSummary struct {
Applications []SpaceSummaryApplication `json:"apps"`
Name string `json:"name"`
ServiceInstances []SpaceSummaryServiceInstance `json:"services"`
}
err := cloudcontroller.DecodeJSON(data, &ccSpaceSummary)
if err != nil {
return err
}
spaceSummary.Name = ccSpaceSummary.Name
spaceSummary.Applications = ccSpaceSummary.Applications
spaceSummary.ServiceInstances = ccSpaceSummary.ServiceInstances
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/space_summary.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/space_summary.go#L62-L78 | go | train | // GetSpaceSummary returns the summary of the space with the given GUID. | func (client *Client) GetSpaceSummary(spaceGUID string) (SpaceSummary, Warnings, error) | // GetSpaceSummary returns the summary of the space with the given GUID.
func (client *Client) GetSpaceSummary(spaceGUID string) (SpaceSummary, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetSpaceSummaryRequest,
URIParams: Params{"space_guid": spaceGUID},
})
if err != nil {
return SpaceSummary{}, nil, err
}
var spaceSummary SpaceSummary
response := cloudcontroller.Response{
DecodeJSONResponseInto: &spaceSummary,
}
err = client.connection.Make(request, &response)
return spaceSummary, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/target_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L121-L138 | go | train | // setOrgAndSpace sets organization and space | func (cmd *TargetCommand) setOrgAndSpace() error | // setOrgAndSpace sets organization and space
func (cmd *TargetCommand) setOrgAndSpace() error | {
org, warnings, err := cmd.Actor.GetOrganizationByName(cmd.Organization)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
space, warnings, err := cmd.Actor.GetSpaceByOrganizationAndName(org.GUID, cmd.Space)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
cmd.Config.SetOrganizationInformation(org.GUID, cmd.Organization)
cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH)
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/target_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L141-L152 | go | train | // setOrg sets organization | func (cmd *TargetCommand) setOrg() error | // setOrg sets organization
func (cmd *TargetCommand) setOrg() error | {
org, warnings, err := cmd.Actor.GetOrganizationByName(cmd.Organization)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
cmd.Config.SetOrganizationInformation(org.GUID, cmd.Organization)
cmd.Config.UnsetSpaceInformation()
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/target_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L156-L169 | go | train | // autoTargetSpace targets the space if there is only one space in the org
// and no space arg was provided. | func (cmd *TargetCommand) autoTargetSpace(orgGUID string) error | // autoTargetSpace targets the space if there is only one space in the org
// and no space arg was provided.
func (cmd *TargetCommand) autoTargetSpace(orgGUID string) error | {
spaces, warnings, err := cmd.Actor.GetOrganizationSpaces(orgGUID)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
if len(spaces) == 1 {
space := spaces[0]
cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH)
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/target_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L172-L186 | go | train | // setSpace sets space | func (cmd *TargetCommand) setSpace() error | // setSpace sets space
func (cmd *TargetCommand) setSpace() error | {
if !cmd.Config.HasTargetedOrganization() {
return translatableerror.NoOrganizationTargetedError{BinaryName: cmd.Config.BinaryName()}
}
space, warnings, err := cmd.Actor.GetSpaceByOrganizationAndName(cmd.Config.TargetedOrganization().GUID, cmd.Space)
cmd.UI.DisplayWarnings(warnings)
if err != nil {
return err
}
cmd.Config.SetSpaceInformation(space.GUID, space.Name, space.AllowSSH)
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/target_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/target_command.go#L189-L208 | go | train | // displayTargetTable neatly displays target information. | func (cmd *TargetCommand) displayTargetTable(user configv3.User) | // displayTargetTable neatly displays target information.
func (cmd *TargetCommand) displayTargetTable(user configv3.User) | {
table := [][]string{
{cmd.UI.TranslateText("api endpoint:"), cmd.Config.Target()},
{cmd.UI.TranslateText("api version:"), cmd.Actor.CloudControllerAPIVersion()},
{cmd.UI.TranslateText("user:"), user.Name},
}
if cmd.Config.HasTargetedOrganization() {
table = append(table, []string{
cmd.UI.TranslateText("org:"), cmd.Config.TargetedOrganization().Name,
})
}
if cmd.Config.HasTargetedSpace() {
table = append(table, []string{
cmd.UI.TranslateText("space:"), cmd.Config.TargetedSpace().Name,
})
}
cmd.UI.DisplayKeyValueTable("", table, 3)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/actionerror/plugin_not_found_in_repository_error.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/actionerror/plugin_not_found_in_repository_error.go#L13-L15 | go | train | // Error outputs the plugin not found in repository error message. | func (e PluginNotFoundInRepositoryError) Error() string | // Error outputs the plugin not found in repository error message.
func (e PluginNotFoundInRepositoryError) Error() string | {
return fmt.Sprintf("Plugin %s not found in repository %s", e.PluginName, e.RepositoryName)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_plan.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_plan.go#L36-L59 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Service Plan response. | func (servicePlan *ServicePlan) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Service Plan response.
func (servicePlan *ServicePlan) UnmarshalJSON(data []byte) error | {
var ccServicePlan struct {
Metadata internal.Metadata
Entity struct {
Name string `json:"name"`
ServiceGUID string `json:"service_guid"`
Public bool `json:"public"`
Description string `json:"description"`
Free bool `json:"free"`
}
}
err := cloudcontroller.DecodeJSON(data, &ccServicePlan)
if err != nil {
return err
}
servicePlan.GUID = ccServicePlan.Metadata.GUID
servicePlan.Name = ccServicePlan.Entity.Name
servicePlan.ServiceGUID = ccServicePlan.Entity.ServiceGUID
servicePlan.Public = ccServicePlan.Entity.Public
servicePlan.Description = ccServicePlan.Entity.Description
servicePlan.Free = ccServicePlan.Entity.Free
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_plan.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_plan.go#L62-L78 | go | train | // GetServicePlan returns the service plan with the given GUID. | func (client *Client) GetServicePlan(servicePlanGUID string) (ServicePlan, Warnings, error) | // GetServicePlan returns the service plan with the given GUID.
func (client *Client) GetServicePlan(servicePlanGUID string) (ServicePlan, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServicePlanRequest,
URIParams: Params{"service_plan_guid": servicePlanGUID},
})
if err != nil {
return ServicePlan{}, nil, err
}
var servicePlan ServicePlan
response := cloudcontroller.Response{
DecodeJSONResponseInto: &servicePlan,
}
err = client.connection.Make(request, &response)
return servicePlan, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L27-L50 | go | train | // GetEffectiveIsolationSegmentBySpace returns the space's effective isolation
// segment.
//
// If the space has its own isolation segment, that will be returned.
//
// If the space does not have one, the organization's default isolation segment
// (GUID passed in) will be returned.
//
// If the space does not have one and the passed in organization default
// isolation segment GUID is empty, a NoRelationshipError will be returned. | func (actor Actor) GetEffectiveIsolationSegmentBySpace(spaceGUID string, orgDefaultIsolationSegmentGUID string) (IsolationSegment, Warnings, error) | // GetEffectiveIsolationSegmentBySpace returns the space's effective isolation
// segment.
//
// If the space has its own isolation segment, that will be returned.
//
// If the space does not have one, the organization's default isolation segment
// (GUID passed in) will be returned.
//
// If the space does not have one and the passed in organization default
// isolation segment GUID is empty, a NoRelationshipError will be returned.
func (actor Actor) GetEffectiveIsolationSegmentBySpace(spaceGUID string, orgDefaultIsolationSegmentGUID string) (IsolationSegment, Warnings, error) | {
relationship, warnings, err := actor.CloudControllerClient.GetSpaceIsolationSegment(spaceGUID)
allWarnings := append(Warnings{}, warnings...)
if err != nil {
return IsolationSegment{}, allWarnings, err
}
effectiveGUID := relationship.GUID
if effectiveGUID == "" {
if orgDefaultIsolationSegmentGUID != "" {
effectiveGUID = orgDefaultIsolationSegmentGUID
} else {
return IsolationSegment{}, allWarnings, actionerror.NoRelationshipError{}
}
}
isolationSegment, warnings, err := actor.CloudControllerClient.GetIsolationSegment(effectiveGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return IsolationSegment{}, allWarnings, err
}
return IsolationSegment(isolationSegment), allWarnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L53-L59 | go | train | // CreateIsolationSegmentByName creates a given isolation segment. | func (actor Actor) CreateIsolationSegmentByName(isolationSegment IsolationSegment) (Warnings, error) | // CreateIsolationSegmentByName creates a given isolation segment.
func (actor Actor) CreateIsolationSegmentByName(isolationSegment IsolationSegment) (Warnings, error) | {
_, warnings, err := actor.CloudControllerClient.CreateIsolationSegment(ccv3.IsolationSegment(isolationSegment))
if _, ok := err.(ccerror.UnprocessableEntityError); ok {
return Warnings(warnings), actionerror.IsolationSegmentAlreadyExistsError{Name: isolationSegment.Name}
}
return Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L62-L71 | go | train | // DeleteIsolationSegmentByName deletes the given isolation segment. | func (actor Actor) DeleteIsolationSegmentByName(name string) (Warnings, error) | // DeleteIsolationSegmentByName deletes the given isolation segment.
func (actor Actor) DeleteIsolationSegmentByName(name string) (Warnings, error) | {
isolationSegment, warnings, err := actor.GetIsolationSegmentByName(name)
allWarnings := append(Warnings{}, warnings...)
if err != nil {
return allWarnings, err
}
apiWarnings, err := actor.CloudControllerClient.DeleteIsolationSegment(isolationSegment.GUID)
return append(allWarnings, apiWarnings...), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L75-L90 | go | train | // EntitleIsolationSegmentToOrganizationByName entitles the given organization
// to use the specified isolation segment | func (actor Actor) EntitleIsolationSegmentToOrganizationByName(isolationSegmentName string, orgName string) (Warnings, error) | // EntitleIsolationSegmentToOrganizationByName entitles the given organization
// to use the specified isolation segment
func (actor Actor) EntitleIsolationSegmentToOrganizationByName(isolationSegmentName string, orgName string) (Warnings, error) | {
isolationSegment, warnings, err := actor.GetIsolationSegmentByName(isolationSegmentName)
allWarnings := append(Warnings{}, warnings...)
if err != nil {
return allWarnings, err
}
organization, warnings, err := actor.GetOrganizationByName(orgName)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return allWarnings, err
}
_, apiWarnings, err := actor.CloudControllerClient.EntitleIsolationSegmentToOrganizations(isolationSegment.GUID, []string{organization.GUID})
return append(allWarnings, apiWarnings...), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L103-L116 | go | train | // GetIsolationSegmentByName returns the requested isolation segment. | func (actor Actor) GetIsolationSegmentByName(name string) (IsolationSegment, Warnings, error) | // GetIsolationSegmentByName returns the requested isolation segment.
func (actor Actor) GetIsolationSegmentByName(name string) (IsolationSegment, Warnings, error) | {
isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments(
ccv3.Query{Key: ccv3.NameFilter, Values: []string{name}},
)
if err != nil {
return IsolationSegment{}, Warnings(warnings), err
}
if len(isolationSegments) == 0 {
return IsolationSegment{}, Warnings(warnings), actionerror.IsolationSegmentNotFoundError{Name: name}
}
return IsolationSegment(isolationSegments[0]), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L119-L147 | go | train | // GetIsolationSegmentSummaries returns all isolation segments and their entitled orgs | func (actor Actor) GetIsolationSegmentSummaries() ([]IsolationSegmentSummary, Warnings, error) | // GetIsolationSegmentSummaries returns all isolation segments and their entitled orgs
func (actor Actor) GetIsolationSegmentSummaries() ([]IsolationSegmentSummary, Warnings, error) | {
isolationSegments, warnings, err := actor.CloudControllerClient.GetIsolationSegments()
allWarnings := append(Warnings{}, warnings...)
if err != nil {
return nil, allWarnings, err
}
var isolationSegmentSummaries []IsolationSegmentSummary
for _, isolationSegment := range isolationSegments {
isolationSegmentSummary := IsolationSegmentSummary{
Name: isolationSegment.Name,
EntitledOrgs: []string{},
}
orgs, warnings, err := actor.CloudControllerClient.GetIsolationSegmentOrganizations(isolationSegment.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return nil, allWarnings, err
}
for _, org := range orgs {
isolationSegmentSummary.EntitledOrgs = append(isolationSegmentSummary.EntitledOrgs, org.Name)
}
isolationSegmentSummaries = append(isolationSegmentSummaries, isolationSegmentSummary)
}
return isolationSegmentSummaries, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L188-L191 | go | train | // SetOrganizationDefaultIsolationSegment sets a default isolation segment on
// an organization. | func (actor Actor) SetOrganizationDefaultIsolationSegment(orgGUID string, isoSegGUID string) (Warnings, error) | // SetOrganizationDefaultIsolationSegment sets a default isolation segment on
// an organization.
func (actor Actor) SetOrganizationDefaultIsolationSegment(orgGUID string, isoSegGUID string) (Warnings, error) | {
_, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, isoSegGUID)
return Warnings(apiWarnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/isolation_segment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/isolation_segment.go#L195-L198 | go | train | // ResetOrganizationDefaultIsolationSegment resets the default isolation segment fon
// an organization. | func (actor Actor) ResetOrganizationDefaultIsolationSegment(orgGUID string) (Warnings, error) | // ResetOrganizationDefaultIsolationSegment resets the default isolation segment fon
// an organization.
func (actor Actor) ResetOrganizationDefaultIsolationSegment(orgGUID string) (Warnings, error) | {
_, apiWarnings, err := actor.CloudControllerClient.UpdateOrganizationDefaultIsolationSegmentRelationship(orgGUID, "")
return Warnings(apiWarnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L50-L81 | go | train | // MarshalJSON converts a Package into a Cloud Controller Package. | func (p Package) MarshalJSON() ([]byte, error) | // MarshalJSON converts a Package into a Cloud Controller Package.
func (p Package) MarshalJSON() ([]byte, error) | {
type ccPackageData struct {
Image string `json:"image,omitempty"`
Username string `json:"username,omitempty"`
Password string `json:"password,omitempty"`
}
var ccPackage struct {
GUID string `json:"guid,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Links APILinks `json:"links,omitempty"`
Relationships Relationships `json:"relationships,omitempty"`
State constant.PackageState `json:"state,omitempty"`
Type constant.PackageType `json:"type,omitempty"`
Data *ccPackageData `json:"data,omitempty"`
}
ccPackage.GUID = p.GUID
ccPackage.CreatedAt = p.CreatedAt
ccPackage.Links = p.Links
ccPackage.Relationships = p.Relationships
ccPackage.State = p.State
ccPackage.Type = p.Type
if p.DockerImage != "" {
ccPackage.Data = &ccPackageData{
Image: p.DockerImage,
Username: p.DockerUsername,
Password: p.DockerPassword,
}
}
return json.Marshal(ccPackage)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L84-L114 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Package response. | func (p *Package) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Package response.
func (p *Package) UnmarshalJSON(data []byte) error | {
var ccPackage struct {
GUID string `json:"guid,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
Links APILinks `json:"links,omitempty"`
Relationships Relationships `json:"relationships,omitempty"`
State constant.PackageState `json:"state,omitempty"`
Type constant.PackageType `json:"type,omitempty"`
Data struct {
Image string `json:"image"`
Username string `json:"username"`
Password string `json:"password"`
} `json:"data"`
}
err := cloudcontroller.DecodeJSON(data, &ccPackage)
if err != nil {
return err
}
p.GUID = ccPackage.GUID
p.CreatedAt = ccPackage.CreatedAt
p.Links = ccPackage.Links
p.Relationships = ccPackage.Relationships
p.State = ccPackage.State
p.Type = ccPackage.Type
p.DockerImage = ccPackage.Data.Image
p.DockerUsername = ccPackage.Data.Username
p.DockerPassword = ccPackage.Data.Password
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L118-L139 | go | train | // CreatePackage creates a package with the given settings, Type and the
// ApplicationRelationship must be set. | func (client *Client) CreatePackage(pkg Package) (Package, Warnings, error) | // CreatePackage creates a package with the given settings, Type and the
// ApplicationRelationship must be set.
func (client *Client) CreatePackage(pkg Package) (Package, Warnings, error) | {
bodyBytes, err := json.Marshal(pkg)
if err != nil {
return Package{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostPackageRequest,
Body: bytes.NewReader(bodyBytes),
})
if err != nil {
return Package{}, nil, err
}
var responsePackage Package
response := cloudcontroller.Response{
DecodeJSONResponseInto: &responsePackage,
}
err = client.connection.Make(request, &response)
return responsePackage, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L142-L158 | go | train | // GetPackage returns the package with the given GUID. | func (client *Client) GetPackage(packageGUID string) (Package, Warnings, error) | // GetPackage returns the package with the given GUID.
func (client *Client) GetPackage(packageGUID string) (Package, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetPackageRequest,
URIParams: internal.Params{"package_guid": packageGUID},
})
if err != nil {
return Package{}, nil, err
}
var responsePackage Package
response := cloudcontroller.Response{
DecodeJSONResponseInto: &responsePackage,
}
err = client.connection.Make(request, &response)
return responsePackage, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L161-L184 | go | train | // GetPackages returns the list of packages. | func (client *Client) GetPackages(query ...Query) ([]Package, Warnings, error) | // GetPackages returns the list of packages.
func (client *Client) GetPackages(query ...Query) ([]Package, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetPackagesRequest,
Query: query,
})
if err != nil {
return nil, nil, err
}
var fullPackagesList []Package
warnings, err := client.paginate(request, Package{}, func(item interface{}) error {
if pkg, ok := item.(Package); ok {
fullPackagesList = append(fullPackagesList, pkg)
} else {
return ccerror.UnknownObjectInListError{
Expected: Package{},
Unexpected: item,
}
}
return nil
})
return fullPackagesList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L195-L210 | go | train | // UploadBitsPackage uploads the newResources and a list of existing resources
// to the cloud controller. An updated package is returned. The function will
// act differently given the following Readers:
// - io.ReadSeeker: Will function properly on retry.
// - io.Reader: Will return a ccerror.PipeSeekError on retry.
// - nil: Will not add the "application" section to the request. The newResourcesLength is ignored in this case.
//
// Note: In order to determine if package creation is successful, poll the
// Package's state field for more information. | func (client *Client) UploadBitsPackage(pkg Package, matchedResources []Resource, newResources io.Reader, newResourcesLength int64) (Package, Warnings, error) | // UploadBitsPackage uploads the newResources and a list of existing resources
// to the cloud controller. An updated package is returned. The function will
// act differently given the following Readers:
// - io.ReadSeeker: Will function properly on retry.
// - io.Reader: Will return a ccerror.PipeSeekError on retry.
// - nil: Will not add the "application" section to the request. The newResourcesLength is ignored in this case.
//
// Note: In order to determine if package creation is successful, poll the
// Package's state field for more information.
func (client *Client) UploadBitsPackage(pkg Package, matchedResources []Resource, newResources io.Reader, newResourcesLength int64) (Package, Warnings, error) | {
link, ok := pkg.Links["upload"]
if !ok {
return Package{}, nil, ccerror.UploadLinkNotFoundError{PackageGUID: pkg.GUID}
}
if matchedResources == nil {
return Package{}, nil, ccerror.NilObjectError{Object: "matchedResources"}
}
if newResources == nil {
return client.uploadExistingResourcesOnly(link, matchedResources)
}
return client.uploadNewAndExistingResources(link, matchedResources, newResources, newResourcesLength)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/package.go#L214-L243 | go | train | // UploadPackage uploads a file to a given package's Upload resource. Note:
// fileToUpload is read entirely into memory prior to sending data to CC. | func (client *Client) UploadPackage(pkg Package, fileToUpload string) (Package, Warnings, error) | // UploadPackage uploads a file to a given package's Upload resource. Note:
// fileToUpload is read entirely into memory prior to sending data to CC.
func (client *Client) UploadPackage(pkg Package, fileToUpload string) (Package, Warnings, error) | {
link, ok := pkg.Links["upload"]
if !ok {
return Package{}, nil, ccerror.UploadLinkNotFoundError{PackageGUID: pkg.GUID}
}
body, contentType, err := client.createUploadStream(fileToUpload, "bits")
if err != nil {
return Package{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
URL: link.HREF,
Method: link.Method,
Body: body,
})
if err != nil {
return Package{}, nil, err
}
request.Header.Set("Content-Type", contentType)
var responsePackage Package
response := cloudcontroller.Response{
DecodeJSONResponseInto: &responsePackage,
}
err = client.connection.Make(request, &response)
return responsePackage, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/wrapper/retry_request.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/wrapper/retry_request.go#L25-L48 | go | train | // Make retries the request if it comes back with a 5XX status code. | func (retry *RetryRequest) Make(request *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error | // Make retries the request if it comes back with a 5XX status code.
func (retry *RetryRequest) Make(request *cloudcontroller.Request, passedResponse *cloudcontroller.Response) error | {
var err error
for i := 0; i < retry.maxRetries+1; i++ {
err = retry.connection.Make(request, passedResponse)
if err == nil {
return nil
}
if retry.skipRetry(request.Method, passedResponse.HTTPResponse) {
break
}
// Reset the request body prior to the next retry
resetErr := request.ResetBody()
if resetErr != nil {
if _, ok := resetErr.(ccerror.PipeSeekError); ok {
return ccerror.PipeSeekError{Err: err}
}
return resetErr
}
}
return err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/wrapper/retry_request.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/wrapper/retry_request.go#L51-L54 | go | train | // Wrap sets the connection in the RetryRequest and returns itself. | func (retry *RetryRequest) Wrap(innerconnection cloudcontroller.Connection) cloudcontroller.Connection | // Wrap sets the connection in the RetryRequest and returns itself.
func (retry *RetryRequest) Wrap(innerconnection cloudcontroller.Connection) cloudcontroller.Connection | {
retry.connection = innerconnection
return retry
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_broker.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_broker.go#L27-L48 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Service Broker response. | func (serviceBroker *ServiceBroker) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Service Broker response.
func (serviceBroker *ServiceBroker) UnmarshalJSON(data []byte) error | {
var ccServiceBroker struct {
Metadata internal.Metadata
Entity struct {
Name string `json:"name"`
BrokerURL string `json:"broker_url"`
AuthUsername string `json:"auth_username"`
SpaceGUID string `json:"space_guid"`
} `json:"entity"`
}
err := cloudcontroller.DecodeJSON(data, &ccServiceBroker)
if err != nil {
return err
}
serviceBroker.Name = ccServiceBroker.Entity.Name
serviceBroker.GUID = ccServiceBroker.Metadata.GUID
serviceBroker.BrokerURL = ccServiceBroker.Entity.BrokerURL
serviceBroker.AuthUsername = ccServiceBroker.Entity.AuthUsername
serviceBroker.SpaceGUID = ccServiceBroker.Entity.SpaceGUID
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_broker.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_broker.go#L60-L91 | go | train | // CreateServiceBroker posts a service broker resource with the provided
// attributes to the api and returns the result. | func (client *Client) CreateServiceBroker(brokerName, username, password, url, spaceGUID string) (ServiceBroker, Warnings, error) | // CreateServiceBroker posts a service broker resource with the provided
// attributes to the api and returns the result.
func (client *Client) CreateServiceBroker(brokerName, username, password, url, spaceGUID string) (ServiceBroker, Warnings, error) | {
requestBody := createServiceBrokerRequestBody{
Name: brokerName,
BrokerURL: url,
AuthUsername: username,
AuthPassword: password,
SpaceGUID: spaceGUID,
}
bodyBytes, err := json.Marshal(requestBody)
if err != nil {
return ServiceBroker{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostServiceBrokerRequest,
Body: bytes.NewReader(bodyBytes),
})
if err != nil {
return ServiceBroker{}, nil, err
}
var serviceBroker ServiceBroker
response := cloudcontroller.Response{
DecodeJSONResponseInto: &serviceBroker,
}
err = client.connection.Make(request, &response)
return serviceBroker, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_broker.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_broker.go#L95-L119 | go | train | // GetServiceBrokers returns back a list of Service Brokers given the provided
// filters. | func (client *Client) GetServiceBrokers(filters ...Filter) ([]ServiceBroker, Warnings, error) | // GetServiceBrokers returns back a list of Service Brokers given the provided
// filters.
func (client *Client) GetServiceBrokers(filters ...Filter) ([]ServiceBroker, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceBrokersRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return nil, nil, err
}
var fullBrokersList []ServiceBroker
warnings, err := client.paginate(request, ServiceBroker{}, func(item interface{}) error {
if broker, ok := item.(ServiceBroker); ok {
fullBrokersList = append(fullBrokersList, broker)
} else {
return ccerror.UnknownObjectInListError{
Expected: ServiceBroker{},
Unexpected: item,
}
}
return nil
})
return fullBrokersList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/util/glob/glob.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/util/glob/glob.go#L33-L64 | go | train | // Supports unix/ruby-style glob patterns:
// - `?` matches a single char in a single path component
// - `*` matches zero or more chars in a single path component
// - `**` matches zero or more chars in zero or more components | func translateGlob(pat string) (string, error) | // Supports unix/ruby-style glob patterns:
// - `?` matches a single char in a single path component
// - `*` matches zero or more chars in a single path component
// - `**` matches zero or more chars in zero or more components
func translateGlob(pat string) (string, error) | {
if !globRe.MatchString(pat) {
return "", Error(pat)
}
outs := make([]string, len(pat))
i, double := 0, false
for _, c := range pat {
switch c {
default:
outs[i] = string(c)
double = false
case '.', '+', '-', '^', '$', '[', ']', '(', ')':
outs[i] = `\` + string(c)
double = false
case '?':
outs[i] = `[^/]`
double = false
case '*':
if double {
outs[i-1] = `.*`
} else {
outs[i] = `[^/]*`
}
double = !double
}
i++
}
outs = outs[0:i]
return "^" + strings.Join(outs, "") + "$", nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/util/glob/glob.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/util/glob/glob.go#L68-L80 | go | train | // CompileGlob translates pat into a form more convenient for
// matching against paths in the store. | func CompileGlob(pat string) (glob Glob, err error) | // CompileGlob translates pat into a form more convenient for
// matching against paths in the store.
func CompileGlob(pat string) (glob Glob, err error) | {
pat = toSlash(pat)
s, err := translateGlob(pat)
if err != nil {
return
}
r, err := regexp.Compile(s)
if err != nil {
return
}
glob = Glob{pat, r}
return
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/util/glob/glob.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/util/glob/glob.go#L84-L90 | go | train | // MustCompileGlob is like CompileGlob, but it panics if an error occurs,
// simplifying safe initialization of global variables holding glob patterns. | func MustCompileGlob(pat string) Glob | // MustCompileGlob is like CompileGlob, but it panics if an error occurs,
// simplifying safe initialization of global variables holding glob patterns.
func MustCompileGlob(pat string) Glob | {
g, err := CompileGlob(pat)
if err != nil {
panic(err)
}
return g
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/buildpack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/buildpack.go#L42-L85 | go | train | // GetBuildpackByNameAndStack returns a buildpack with the provided name and
// stack. If `buildpackStack` is not specified, and there are multiple
// buildpacks with the same name, it will return the one with no stack, if
// present. | func (actor Actor) GetBuildpackByNameAndStack(buildpackName string, buildpackStack string) (Buildpack, Warnings, error) | // GetBuildpackByNameAndStack returns a buildpack with the provided name and
// stack. If `buildpackStack` is not specified, and there are multiple
// buildpacks with the same name, it will return the one with no stack, if
// present.
func (actor Actor) GetBuildpackByNameAndStack(buildpackName string, buildpackStack string) (Buildpack, Warnings, error) | {
var (
ccv3Buildpacks []ccv3.Buildpack
warnings ccv3.Warnings
err error
)
if buildpackStack == "" {
ccv3Buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks(ccv3.Query{
Key: ccv3.NameFilter,
Values: []string{buildpackName},
})
} else {
ccv3Buildpacks, warnings, err = actor.CloudControllerClient.GetBuildpacks(
ccv3.Query{
Key: ccv3.NameFilter,
Values: []string{buildpackName},
},
ccv3.Query{
Key: ccv3.StackFilter,
Values: []string{buildpackStack},
},
)
}
if err != nil {
return Buildpack{}, Warnings(warnings), err
}
if len(ccv3Buildpacks) == 0 {
return Buildpack{}, Warnings(warnings), actionerror.BuildpackNotFoundError{BuildpackName: buildpackName, StackName: buildpackStack}
}
if len(ccv3Buildpacks) > 1 {
for _, buildpack := range ccv3Buildpacks {
if buildpack.Stack == "" {
return Buildpack(buildpack), Warnings(warnings), nil
}
}
return Buildpack{}, Warnings(warnings), actionerror.MultipleBuildpacksFoundError{BuildpackName: buildpackName}
}
return Buildpack(ccv3Buildpacks[0]), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/droplet.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/droplet.go#L23-L39 | go | train | // SetApplicationDropletByApplicationNameAndSpace sets the droplet for an application. | func (actor Actor) SetApplicationDropletByApplicationNameAndSpace(appName string, spaceGUID string, dropletGUID string) (Warnings, error) | // SetApplicationDropletByApplicationNameAndSpace sets the droplet for an application.
func (actor Actor) SetApplicationDropletByApplicationNameAndSpace(appName string, spaceGUID string, dropletGUID string) (Warnings, error) | {
allWarnings := Warnings{}
application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return allWarnings, err
}
_, apiWarnings, err := actor.CloudControllerClient.SetApplicationDroplet(application.GUID, dropletGUID)
actorWarnings := Warnings(apiWarnings)
allWarnings = append(allWarnings, actorWarnings...)
if newErr, ok := err.(ccerror.UnprocessableEntityError); ok {
return allWarnings, actionerror.AssignDropletError{Message: newErr.Message}
}
return allWarnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/droplet.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/droplet.go#L52-L75 | go | train | // GetApplicationDroplets returns the list of droplets that belong to applicaiton. | func (actor Actor) GetApplicationDroplets(appName string, spaceGUID string) ([]Droplet, Warnings, error) | // GetApplicationDroplets returns the list of droplets that belong to applicaiton.
func (actor Actor) GetApplicationDroplets(appName string, spaceGUID string) ([]Droplet, Warnings, error) | {
allWarnings := Warnings{}
application, warnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return nil, allWarnings, err
}
ccv3Droplets, apiWarnings, err := actor.CloudControllerClient.GetDroplets(
ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{application.GUID}},
)
actorWarnings := Warnings(apiWarnings)
allWarnings = append(allWarnings, actorWarnings...)
if err != nil {
return nil, allWarnings, err
}
var droplets []Droplet
for _, ccv3Droplet := range ccv3Droplets {
droplets = append(droplets, actor.convertCCToActorDroplet(ccv3Droplet))
}
return droplets, allWarnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/resource.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/resource.go#L31-L44 | go | train | // MarshalJSON converts a resource into a Cloud Controller Resource. | func (r Resource) MarshalJSON() ([]byte, error) | // MarshalJSON converts a resource into a Cloud Controller Resource.
func (r Resource) MarshalJSON() ([]byte, error) | {
var ccResource struct {
Filename string `json:"fn,omitempty"`
Mode string `json:"mode,omitempty"`
SHA1 string `json:"sha1"`
Size int64 `json:"size"`
}
ccResource.Filename = r.Filename
ccResource.Size = r.Size
ccResource.SHA1 = r.SHA1
ccResource.Mode = strconv.FormatUint(uint64(r.Mode), 8)
return json.Marshal(ccResource)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/resource.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/resource.go#L74-L97 | go | train | // UpdateResourceMatch returns the resources that exist on the cloud foundry instance
// from the set of resources given. | func (client *Client) UpdateResourceMatch(resourcesToMatch []Resource) ([]Resource, Warnings, error) | // UpdateResourceMatch returns the resources that exist on the cloud foundry instance
// from the set of resources given.
func (client *Client) UpdateResourceMatch(resourcesToMatch []Resource) ([]Resource, Warnings, error) | {
body, err := json.Marshal(resourcesToMatch)
if err != nil {
return nil, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutResourceMatchRequest,
Body: bytes.NewReader(body),
})
if err != nil {
return nil, nil, err
}
request.Header.Set("Content-Type", "application/json")
var matchedResources []Resource
response := cloudcontroller.Response{
DecodeJSONResponseInto: &matchedResources,
}
err = client.connection.Make(request, &response)
return matchedResources, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/plugin/wrapper/request_logger.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/plugin/wrapper/request_logger.go#L63-L66 | go | train | // Wrap sets the connection on the RequestLogger and returns itself | func (logger *RequestLogger) Wrap(innerconnection plugin.Connection) plugin.Connection | // Wrap sets the connection on the RequestLogger and returns itself
func (logger *RequestLogger) Wrap(innerconnection plugin.Connection) plugin.Connection | {
logger.connection = innerconnection
return logger
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/application_summary.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/application_summary.go#L14-L40 | go | train | // GetApplicationSummaryByNameAndSpace returns an application with process and
// instance stats. | func (actor Actor) GetApplicationSummaryByNameAndSpace(appName string, spaceGUID string, withObfuscatedValues bool) (ApplicationSummary, Warnings, error) | // GetApplicationSummaryByNameAndSpace returns an application with process and
// instance stats.
func (actor Actor) GetApplicationSummaryByNameAndSpace(appName string, spaceGUID string, withObfuscatedValues bool) (ApplicationSummary, Warnings, error) | {
app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
if err != nil {
return ApplicationSummary{}, allWarnings, err
}
processSummaries, processWarnings, err := actor.getProcessSummariesForApp(app.GUID, withObfuscatedValues)
allWarnings = append(allWarnings, processWarnings...)
if err != nil {
return ApplicationSummary{}, allWarnings, err
}
droplet, warnings, err := actor.GetCurrentDropletByApplication(app.GUID)
allWarnings = append(allWarnings, Warnings(warnings)...)
if err != nil {
if _, ok := err.(actionerror.DropletNotFoundError); !ok {
return ApplicationSummary{}, allWarnings, err
}
}
summary := ApplicationSummary{
Application: app,
ProcessSummaries: processSummaries,
CurrentDroplet: droplet,
}
return summary, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/uaa/user.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/uaa/user.go#L41-L85 | go | train | // CreateUser creates a new UAA user account with the provided password. | func (client *Client) CreateUser(user string, password string, origin string) (User, error) | // CreateUser creates a new UAA user account with the provided password.
func (client *Client) CreateUser(user string, password string, origin string) (User, error) | {
userRequest := newUserRequestBody{
Username: user,
Password: password,
Origin: origin,
Name: userName{
FamilyName: user,
GivenName: user,
},
Emails: []email{
{
Value: user,
Primary: true,
},
},
}
bodyBytes, err := json.Marshal(userRequest)
if err != nil {
return User{}, err
}
request, err := client.newRequest(requestOptions{
RequestName: internal.PostUserRequest,
Header: http.Header{
"Content-Type": {"application/json"},
},
Body: bytes.NewBuffer(bodyBytes),
})
if err != nil {
return User{}, err
}
var userResponse newUserResponse
response := Response{
Result: &userResponse,
}
err = client.connection.Make(request, &response)
if err != nil {
return User{}, err
}
return User(userResponse), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/resource.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/resource.go#L30-L89 | go | train | // ResourceMatch returns a set of matched resources and unmatched resources in
// the order they were given in allResources. | func (actor Actor) ResourceMatch(allResources []Resource) ([]Resource, []Resource, Warnings, error) | // ResourceMatch returns a set of matched resources and unmatched resources in
// the order they were given in allResources.
func (actor Actor) ResourceMatch(allResources []Resource) ([]Resource, []Resource, Warnings, error) | {
resourcesToSend := [][]ccv2.Resource{{}}
var currentList, sendCount int
for _, resource := range allResources {
// Skip if resource is a directory, symlink, or empty file.
if resource.Size == 0 {
continue
}
resourcesToSend[currentList] = append(
resourcesToSend[currentList],
ccv2.Resource(resource),
)
sendCount++
if len(resourcesToSend[currentList]) == MaxResourceMatchChunkSize {
currentList++
resourcesToSend = append(resourcesToSend, []ccv2.Resource{})
}
}
log.WithFields(log.Fields{
"total_resources": len(allResources),
"resources_to_match": sendCount,
"chunks": len(resourcesToSend),
}).Debug("sending resource match stats")
matchedCCResources := map[string]ccv2.Resource{}
var allWarnings Warnings
for _, chunk := range resourcesToSend {
if len(chunk) == 0 {
log.Debug("chunk size 0, stopping resource match requests")
break
}
returnedResources, warnings, err := actor.CloudControllerClient.UpdateResourceMatch(chunk)
allWarnings = append(allWarnings, warnings...)
if err != nil {
log.Errorln("during resource matching", err)
return nil, nil, allWarnings, err
}
for _, resource := range returnedResources {
matchedCCResources[resource.SHA1] = resource
}
}
log.WithField("matched_resource_count", len(matchedCCResources)).Debug("total number of matched resources")
var matchedResources, unmatchedResources []Resource
for _, resource := range allResources {
if _, ok := matchedCCResources[resource.SHA1]; ok {
matchedResources = append(matchedResources, resource)
} else {
unmatchedResources = append(unmatchedResources, resource)
}
}
return matchedResources, unmatchedResources, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/cloud_controller_connection.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/cloud_controller_connection.go#L31-L46 | go | train | // NewConnection returns a new CloudControllerConnection with provided
// configuration. | func NewConnection(config Config) *CloudControllerConnection | // NewConnection returns a new CloudControllerConnection with provided
// configuration.
func NewConnection(config Config) *CloudControllerConnection | {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: config.SkipSSLValidation,
},
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
KeepAlive: 30 * time.Second,
Timeout: config.DialTimeout,
}).DialContext,
}
return &CloudControllerConnection{
HTTPClient: &http.Client{Transport: tr},
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/cloud_controller_connection.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/cloud_controller_connection.go#L90-L106 | go | train | // handleWarnings looks for the "X-Cf-Warnings" header in the cloud controller
// response and URI decodes them. The value can contain multiple warnings that
// are comma separated. | func (*CloudControllerConnection) handleWarnings(response *http.Response) ([]string, error) | // handleWarnings looks for the "X-Cf-Warnings" header in the cloud controller
// response and URI decodes them. The value can contain multiple warnings that
// are comma separated.
func (*CloudControllerConnection) handleWarnings(response *http.Response) ([]string, error) | {
rawWarnings := response.Header.Get("X-Cf-Warnings")
if len(rawWarnings) == 0 {
return nil, nil
}
var warnings []string
for _, rawWarning := range strings.Split(rawWarnings, ",") {
warning, err := url.QueryUnescape(rawWarning)
if err != nil {
return nil, err
}
warnings = append(warnings, strings.Trim(warning, " "))
}
return warnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/actors/push.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/actors/push.go#L55-L106 | go | train | // ProcessPath takes in a director of app files or a zip file which contains
// the app files. If given a zip file, it will extract the zip to a temporary
// location, call the provided callback with that location, and then clean up
// the location after the callback has been executed.
//
// This was done so that the caller of ProcessPath wouldn't need to know if it
// was a zip file or an app dir that it was given, and the caller would not be
// responsible for cleaning up the temporary directory ProcessPath creates when
// given a zip. | func (actor PushActorImpl) ProcessPath(dirOrZipFile string, f func(string) error) error | // ProcessPath takes in a director of app files or a zip file which contains
// the app files. If given a zip file, it will extract the zip to a temporary
// location, call the provided callback with that location, and then clean up
// the location after the callback has been executed.
//
// This was done so that the caller of ProcessPath wouldn't need to know if it
// was a zip file or an app dir that it was given, and the caller would not be
// responsible for cleaning up the temporary directory ProcessPath creates when
// given a zip.
func (actor PushActorImpl) ProcessPath(dirOrZipFile string, f func(string) error) error | {
if !actor.zipper.IsZipFile(dirOrZipFile) {
if filepath.IsAbs(dirOrZipFile) {
appDir, err := filepath.EvalSymlinks(dirOrZipFile)
if err != nil {
return err
}
err = f(appDir)
if err != nil {
return err
}
} else {
absPath, err := filepath.Abs(dirOrZipFile)
if err != nil {
return err
}
appDir, err := filepath.EvalSymlinks(absPath)
if err != nil {
return err
}
err = f(appDir)
if err != nil {
return err
}
}
return nil
}
tempDir, err := ioutil.TempDir("", "unzipped-app")
if err != nil {
return err
}
err = actor.zipper.Unzip(dirOrZipFile, tempDir)
if err != nil {
return err
}
err = f(tempDir)
if err != nil {
return err
}
err = os.RemoveAll(tempDir)
if err != nil {
return err
}
return nil
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.