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 | types/null_uint64.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/types/null_uint64.go#L16-L30 | go | train | // ParseStringValue is used to parse a user provided flag argument. | func (n *NullUint64) ParseStringValue(val string) error | // ParseStringValue is used to parse a user provided flag argument.
func (n *NullUint64) ParseStringValue(val string) error | {
if val == "" {
return nil
}
uint64Val, err := strconv.ParseUint(val, 10, 64)
if err != nil {
return err
}
n.Value = uint64Val
n.IsSet = true
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | plugin/plugin_examples/basic_plugin.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/plugin/plugin_examples/basic_plugin.go#L27-L32 | go | train | // Run must be implemented by any plugin because it is part of the
// plugin interface defined by the core CLI.
//
// Run(....) is the entry point when the core CLI is invoking a command defined
// by a plugin. The first parameter, plugin.CliConnection, is a struct that can
// be used to invoke cli commands. The second paramter, args, is a slice of
// strings. args[0] will be the name of the command, and will be followed by
// any additional arguments a cli user typed in.
//
// Any error handling should be handled with the plugin itself (this means printing
// user facing errors). The CLI will exit 0 if the plugin exits 0 and will exit
// 1 should the plugin exits nonzero. | func (c *BasicPlugin) Run(cliConnection plugin.CliConnection, args []string) | // Run must be implemented by any plugin because it is part of the
// plugin interface defined by the core CLI.
//
// Run(....) is the entry point when the core CLI is invoking a command defined
// by a plugin. The first parameter, plugin.CliConnection, is a struct that can
// be used to invoke cli commands. The second paramter, args, is a slice of
// strings. args[0] will be the name of the command, and will be followed by
// any additional arguments a cli user typed in.
//
// Any error handling should be handled with the plugin itself (this means printing
// user facing errors). The CLI will exit 0 if the plugin exits 0 and will exit
// 1 should the plugin exits nonzero.
func (c *BasicPlugin) Run(cliConnection plugin.CliConnection, args []string) | {
// Ensure that we called the command basic-plugin-command
if args[0] == "basic-plugin-command" {
fmt.Println("Running the basic-plugin-command")
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | plugin/plugin_examples/basic_plugin.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/plugin/plugin_examples/basic_plugin.go#L46-L72 | go | train | // GetMetadata must be implemented as part of the plugin interface
// defined by the core CLI.
//
// GetMetadata() returns a PluginMetadata struct. The first field, Name,
// determines the name of the plugin which should generally be without spaces.
// If there are spaces in the name a user will need to properly quote the name
// during uninstall otherwise the name will be treated as seperate arguments.
// The second value is a slice of Command structs. Our slice only contains one
// Command Struct, but could contain any number of them. The first field Name
// defines the command `cf basic-plugin-command` once installed into the CLI. The
// second field, HelpText, is used by the core CLI to display help information
// to the user in the core commands `cf help`, `cf`, or `cf -h`. | func (c *BasicPlugin) GetMetadata() plugin.PluginMetadata | // GetMetadata must be implemented as part of the plugin interface
// defined by the core CLI.
//
// GetMetadata() returns a PluginMetadata struct. The first field, Name,
// determines the name of the plugin which should generally be without spaces.
// If there are spaces in the name a user will need to properly quote the name
// during uninstall otherwise the name will be treated as seperate arguments.
// The second value is a slice of Command structs. Our slice only contains one
// Command Struct, but could contain any number of them. The first field Name
// defines the command `cf basic-plugin-command` once installed into the CLI. The
// second field, HelpText, is used by the core CLI to display help information
// to the user in the core commands `cf help`, `cf`, or `cf -h`.
func (c *BasicPlugin) GetMetadata() plugin.PluginMetadata | {
return plugin.PluginMetadata{
Name: "MyBasicPlugin",
Version: plugin.VersionType{
Major: 1,
Minor: 0,
Build: 0,
},
MinCliVersion: plugin.VersionType{
Major: 6,
Minor: 7,
Build: 0,
},
Commands: []plugin.Command{
{
Name: "basic-plugin-command",
HelpText: "Basic plugin command's help text",
// UsageDetails is optional
// It is used to show help of usage of each command
UsageDetails: plugin.Usage{
Usage: "basic-plugin-command\n cf basic-plugin-command",
},
},
},
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L26-L59 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Security Group response | func (securityGroup *SecurityGroup) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Security Group response
func (securityGroup *SecurityGroup) UnmarshalJSON(data []byte) error | {
var ccSecurityGroup struct {
Metadata internal.Metadata `json:"metadata"`
Entity struct {
GUID string `json:"guid"`
Name string `json:"name"`
Rules []struct {
Description string `json:"description"`
Destination string `json:"destination"`
Ports string `json:"ports"`
Protocol string `json:"protocol"`
} `json:"rules"`
RunningDefault bool `json:"running_default"`
StagingDefault bool `json:"staging_default"`
} `json:"entity"`
}
err := cloudcontroller.DecodeJSON(data, &ccSecurityGroup)
if err != nil {
return err
}
securityGroup.GUID = ccSecurityGroup.Metadata.GUID
securityGroup.Name = ccSecurityGroup.Entity.Name
securityGroup.Rules = make([]SecurityGroupRule, len(ccSecurityGroup.Entity.Rules))
for i, ccRule := range ccSecurityGroup.Entity.Rules {
securityGroup.Rules[i].Description = ccRule.Description
securityGroup.Rules[i].Destination = ccRule.Destination
securityGroup.Rules[i].Ports = ccRule.Ports
securityGroup.Rules[i].Protocol = ccRule.Protocol
}
securityGroup.RunningDefault = ccSecurityGroup.Entity.RunningDefault
securityGroup.StagingDefault = ccSecurityGroup.Entity.StagingDefault
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L64-L81 | go | train | // DeleteSecurityGroupSpace disassociates a security group in the running phase
// for the lifecycle, specified by its GUID, from a space, which is also
// specified by its GUID. | func (client *Client) DeleteSecurityGroupSpace(securityGroupGUID string, spaceGUID string) (Warnings, error) | // DeleteSecurityGroupSpace disassociates a security group in the running phase
// for the lifecycle, specified by its GUID, from a space, which is also
// specified by its GUID.
func (client *Client) DeleteSecurityGroupSpace(securityGroupGUID string, spaceGUID string) (Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.DeleteSecurityGroupSpaceRequest,
URIParams: Params{
"security_group_guid": securityGroupGUID,
"space_guid": spaceGUID,
},
})
if err != nil {
return nil, err
}
response := cloudcontroller.Response{}
err = client.connection.Make(request, &response)
return response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L107-L131 | go | train | // GetSecurityGroups returns a list of Security Groups based off the provided
// filters. | func (client *Client) GetSecurityGroups(filters ...Filter) ([]SecurityGroup, Warnings, error) | // GetSecurityGroups returns a list of Security Groups based off the provided
// filters.
func (client *Client) GetSecurityGroups(filters ...Filter) ([]SecurityGroup, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetSecurityGroupsRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return nil, nil, err
}
var securityGroupsList []SecurityGroup
warnings, err := client.paginate(request, SecurityGroup{}, func(item interface{}) error {
if securityGroup, ok := item.(SecurityGroup); ok {
securityGroupsList = append(securityGroupsList, securityGroup)
} else {
return ccerror.UnknownObjectInListError{
Expected: SecurityGroup{},
Unexpected: item,
}
}
return nil
})
return securityGroupsList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L135-L137 | go | train | // GetSpaceSecurityGroups returns the running Security Groups associated with
// the provided Space GUID. | func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) | // GetSpaceSecurityGroups returns the running Security Groups associated with
// the provided Space GUID.
func (client *Client) GetSpaceSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) | {
return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceSecurityGroupsRequest, filters)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/security_group.go#L141-L143 | go | train | // GetSpaceStagingSecurityGroups returns the staging Security Groups
// associated with the provided Space GUID. | func (client *Client) GetSpaceStagingSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) | // GetSpaceStagingSecurityGroups returns the staging Security Groups
// associated with the provided Space GUID.
func (client *Client) GetSpaceStagingSecurityGroups(spaceGUID string, filters ...Filter) ([]SecurityGroup, Warnings, error) | {
return client.getSpaceSecurityGroupsBySpaceAndLifecycle(spaceGUID, internal.GetSpaceStagingSecurityGroupsRequest, filters)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job.go#L22-L46 | go | train | // Errors returns back a list of | func (job Job) Errors() []error | // Errors returns back a list of
func (job Job) Errors() []error | {
var errs []error
for _, errDetails := range job.RawErrors {
switch errDetails.Code {
case constant.JobErrorCodeBuildpackAlreadyExistsForStack:
errs = append(errs, ccerror.BuildpackAlreadyExistsForStackError{Message: errDetails.Detail})
case constant.JobErrorCodeBuildpackAlreadyExistsWithoutStack:
errs = append(errs, ccerror.BuildpackAlreadyExistsWithoutStackError{Message: errDetails.Detail})
case constant.JobErrorCodeBuildpackStacksDontMatch:
errs = append(errs, ccerror.BuildpackStacksDontMatchError{Message: errDetails.Detail})
case constant.JobErrorCodeBuildpackStackDoesNotExist:
errs = append(errs, ccerror.BuildpackStackDoesNotExistError{Message: errDetails.Detail})
case constant.JobErrorCodeBuildpackZipInvalid:
errs = append(errs, ccerror.BuildpackZipInvalidError{Message: errDetails.Detail})
default:
errs = append(errs, ccerror.V3JobFailedError{
JobGUID: job.GUID,
Code: errDetails.Code,
Detail: errDetails.Detail,
Title: errDetails.Title,
})
}
}
return errs
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job.go#L69-L82 | go | train | // GetJob returns a job for the provided GUID. | func (client *Client) GetJob(jobURL JobURL) (Job, Warnings, error) | // GetJob returns a job for the provided GUID.
func (client *Client) GetJob(jobURL JobURL) (Job, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{URL: string(jobURL)})
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/ccv3/job.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/job.go#L87-L119 | 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(jobURL JobURL) (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(jobURL JobURL) (Warnings, error) | {
var (
err error
warnings Warnings
allWarnings Warnings
job Job
)
startTime := client.clock.Now()
for client.clock.Now().Sub(startTime) < client.jobPollingTimeout {
job, warnings, err = client.GetJob(jobURL)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return allWarnings, err
}
if job.HasFailed() {
firstError := job.Errors()[0]
return allWarnings, firstError
}
if job.IsComplete() {
return allWarnings, nil
}
time.Sleep(client.jobPollingInterval)
}
return allWarnings, ccerror.JobTimeoutError{
JobGUID: job.GUID,
Timeout: client.jobPollingTimeout,
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L74-L85 | 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.GetApplicationsByNamesAndSpace([]string{appName}, spaceGUID)
if err != nil {
if _, ok := err.(actionerror.ApplicationsNotFoundError); ok {
return Application{}, warnings, actionerror.ApplicationNotFoundError{Name: appName}
}
return Application{}, warnings, err
}
return apps[0], warnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L88-L102 | go | train | // GetApplicationsBySpace returns all applications in a space. | func (actor Actor) GetApplicationsBySpace(spaceGUID string) ([]Application, Warnings, error) | // GetApplicationsBySpace returns all applications in a space.
func (actor Actor) GetApplicationsBySpace(spaceGUID string) ([]Application, Warnings, error) | {
ccApps, warnings, err := actor.CloudControllerClient.GetApplications(
ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{spaceGUID}},
)
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/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L106-L126 | go | train | // CreateApplicationInSpace creates and returns the application with the given
// name in the given space. | func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) | // CreateApplicationInSpace creates and returns the application with the given
// name in the given space.
func (actor Actor) CreateApplicationInSpace(app Application, spaceGUID string) (Application, Warnings, error) | {
createdApp, warnings, err := actor.CloudControllerClient.CreateApplication(
ccv3.Application{
LifecycleType: app.LifecycleType,
LifecycleBuildpacks: app.LifecycleBuildpacks,
StackName: app.StackName,
Name: app.Name,
Relationships: ccv3.Relationships{
constant.RelationshipTypeSpace: ccv3.Relationship{GUID: spaceGUID},
},
})
if err != nil {
if _, ok := err.(ccerror.NameNotUniqueInSpaceError); ok {
return Application{}, Warnings(warnings), actionerror.ApplicationAlreadyExistsError{Name: app.Name}
}
return Application{}, Warnings(warnings), err
}
return actor.convertCCToActorApplication(createdApp), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L131-L154 | go | train | // SetApplicationProcessHealthCheckTypeByNameAndSpace sets the health check
// information of the provided processType for an application with the given
// name and space GUID. | func (actor Actor) SetApplicationProcessHealthCheckTypeByNameAndSpace(
appName string,
spaceGUID string,
healthCheckType constant.HealthCheckType,
httpEndpoint string,
processType string,
invocationTimeout int64,
) (Application, Warnings, error) | // SetApplicationProcessHealthCheckTypeByNameAndSpace sets the health check
// information of the provided processType for an application with the given
// name and space GUID.
func (actor Actor) SetApplicationProcessHealthCheckTypeByNameAndSpace(
appName string,
spaceGUID string,
healthCheckType constant.HealthCheckType,
httpEndpoint string,
processType string,
invocationTimeout int64,
) (Application, Warnings, error) | {
app, getWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
if err != nil {
return Application{}, getWarnings, err
}
setWarnings, err := actor.UpdateProcessByTypeAndApplication(
processType,
app.GUID,
Process{
HealthCheckType: healthCheckType,
HealthCheckEndpoint: httpEndpoint,
HealthCheckInvocationTimeout: invocationTimeout,
})
return app, append(getWarnings, setWarnings...), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L157-L161 | go | train | // StopApplication stops an application. | func (actor Actor) StopApplication(appGUID string) (Warnings, error) | // StopApplication stops an application.
func (actor Actor) StopApplication(appGUID string) (Warnings, error) | {
_, warnings, err := actor.CloudControllerClient.UpdateApplicationStop(appGUID)
return Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L164-L171 | go | train | // StartApplication starts an application. | func (actor Actor) StartApplication(appGUID string) (Application, Warnings, error) | // StartApplication starts an application.
func (actor Actor) StartApplication(appGUID string) (Application, Warnings, error) | {
updatedApp, warnings, err := actor.CloudControllerClient.UpdateApplicationStart(appGUID)
if err != nil {
return Application{}, Warnings(warnings), err
}
return actor.convertCCToActorApplication(updatedApp), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/application.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/application.go#L174-L185 | go | train | // RestartApplication restarts an application and waits for it to start. | func (actor Actor) RestartApplication(appGUID string) (Warnings, error) | // RestartApplication restarts an application and waits for it to start.
func (actor Actor) RestartApplication(appGUID string) (Warnings, error) | {
var allWarnings Warnings
_, warnings, err := actor.CloudControllerClient.UpdateApplicationRestart(appGUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return allWarnings, err
}
pollingWarnings, err := actor.PollStart(appGUID)
allWarnings = append(allWarnings, pollingWarnings...)
return allWarnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/actionerror/domain_not_found_error.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/actionerror/domain_not_found_error.go#L13-L22 | go | train | // Error method to display the error message. | func (e DomainNotFoundError) Error() string | // Error method to display the error message.
func (e DomainNotFoundError) Error() string | {
switch {
case e.Name != "":
return fmt.Sprintf("Domain %s not found", e.Name)
case e.GUID != "":
return fmt.Sprintf("Domain with GUID %s not found", e.GUID)
default:
return "Domain not found"
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L23-L36 | go | train | // WithHelloWorldApp creates a simple application to use with your CLI command
// (typically CF Push). When pushing, be aware of specifying '-b
// staticfile_buildpack" so that your app will correctly start up with the
// proper buildpack. | func WithHelloWorldApp(f func(dir string)) | // WithHelloWorldApp creates a simple application to use with your CLI command
// (typically CF Push). When pushing, be aware of specifying '-b
// staticfile_buildpack" so that your app will correctly start up with the
// proper buildpack.
func WithHelloWorldApp(f func(dir string)) | {
dir, err := ioutil.TempDir("", "simple-app")
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(dir)
tempfile := filepath.Join(dir, "index.html")
err = ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666)
Expect(err).ToNot(HaveOccurred())
f(dir)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L41-L62 | go | train | // WithMultiEndpointApp creates a simple application to use with your CLI command
// (typically CF Push). It has multiple endpoints which are helpful when testing
// http healthchecks | func WithMultiEndpointApp(f func(dir string)) | // WithMultiEndpointApp creates a simple application to use with your CLI command
// (typically CF Push). It has multiple endpoints which are helpful when testing
// http healthchecks
func WithMultiEndpointApp(f func(dir string)) | {
dir, err := ioutil.TempDir("", "simple-app")
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(dir)
tempfile := filepath.Join(dir, "index.html")
err = ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %d", rand.Int())), 0666)
Expect(err).ToNot(HaveOccurred())
tempfile = filepath.Join(dir, "other_endpoint.html")
err = ioutil.WriteFile(tempfile, []byte("other endpoint"), 0666)
Expect(err).ToNot(HaveOccurred())
tempfile = filepath.Join(dir, "third_endpoint.html")
err = ioutil.WriteFile(tempfile, []byte("third endpoint"), 0666)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(dir, "Staticfile"), nil, 0666)
Expect(err).ToNot(HaveOccurred())
f(dir)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L68-L79 | go | train | // WithNoResourceMatchedApp creates a simple application to use with your CLI
// command (typically CF Push). When pushing, be aware of specifying '-b
// staticfile_buildpack" so that your app will correctly start up with the
// proper buildpack. | func WithNoResourceMatchedApp(f func(dir string)) | // WithNoResourceMatchedApp creates a simple application to use with your CLI
// command (typically CF Push). When pushing, be aware of specifying '-b
// staticfile_buildpack" so that your app will correctly start up with the
// proper buildpack.
func WithNoResourceMatchedApp(f func(dir string)) | {
dir, err := ioutil.TempDir("", "simple-app")
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(dir)
tempfile := filepath.Join(dir, "index.html")
err = ioutil.WriteFile(tempfile, []byte(fmt.Sprintf("hello world %s", strings.Repeat("a", 65*1024))), 0666)
Expect(err).ToNot(HaveOccurred())
f(dir)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L88-L117 | go | train | // WithProcfileApp creates an application to use with your CLI command
// that contains Procfile defining web and worker processes. | func WithProcfileApp(f func(dir string)) | // WithProcfileApp creates an application to use with your CLI command
// that contains Procfile defining web and worker processes.
func WithProcfileApp(f func(dir string)) | {
dir, err := ioutil.TempDir("", "simple-ruby-app")
Expect(err).ToNot(HaveOccurred())
defer os.RemoveAll(dir)
err = ioutil.WriteFile(filepath.Join(dir, "Procfile"), []byte(`---
web: ruby -run -e httpd . -p $PORT
console: bundle exec irb`,
), 0666)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(dir, "Gemfile"), nil, 0666)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(filepath.Join(dir, "Gemfile.lock"), []byte(`
GEM
specs:
PLATFORMS
ruby
DEPENDENCIES
BUNDLED WITH
1.15.0
`), 0666)
Expect(err).ToNot(HaveOccurred())
f(dir)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L171-L175 | go | train | // AppGUID returns the GUID for an app in the currently targeted space. | func AppGUID(appName string) string | // AppGUID returns the GUID for an app in the currently targeted space.
func AppGUID(appName string) string | {
session := CF("app", appName, "--guid")
Eventually(session).Should(Exit(0))
return strings.TrimSpace(string(session.Out.Contents()))
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L185-L190 | go | train | // WriteManifest will write out a YAML manifest file at the specified path. | func WriteManifest(path string, manifest map[string]interface{}) | // WriteManifest will write out a YAML manifest file at the specified path.
func WriteManifest(path string, manifest map[string]interface{}) | {
body, err := yaml.Marshal(manifest)
Expect(err).ToNot(HaveOccurred())
err = ioutil.WriteFile(path, body, 0666)
Expect(err).ToNot(HaveOccurred())
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/app.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/app.go#L193-L261 | go | train | // Zipit zips the source into a .zip file in the target dir | func Zipit(source, target, prefix string) error | // Zipit zips the source into a .zip file in the target dir
func Zipit(source, target, prefix string) error | {
// Thanks to Svett Ralchev
// http://blog.ralch.com/tutorial/golang-working-with-zip/
zipfile, err := os.Create(target)
if err != nil {
return err
}
defer zipfile.Close()
if prefix != "" {
_, err = io.WriteString(zipfile, prefix)
if err != nil {
return err
}
}
archive := zip.NewWriter(zipfile)
defer archive.Close()
err = filepath.Walk(source, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if path == source {
return nil
}
header, err := zip.FileInfoHeader(info)
if err != nil {
return err
}
header.Name, err = filepath.Rel(source, path)
if err != nil {
return err
}
header.Name = filepath.ToSlash(header.Name)
if info.IsDir() {
header.Name += "/"
header.SetMode(0755)
} else {
header.Method = zip.Deflate
header.SetMode(0744)
}
writer, err := archive.CreateHeader(header)
if err != nil {
return err
}
if info.IsDir() {
return nil
}
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
_, err = io.Copy(writer, file)
return err
})
return err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/filter.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/filter.go#L30-L37 | go | train | // ConvertFilterParameters converts a Filter object into a collection that
// cloudcontroller.Request can accept. | func ConvertFilterParameters(filters []Filter) url.Values | // ConvertFilterParameters converts a Filter object into a collection that
// cloudcontroller.Request can accept.
func ConvertFilterParameters(filters []Filter) url.Values | {
params := url.Values{"q": []string{}}
for _, filter := range filters {
params["q"] = append(params["q"], filter.format())
}
return params
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/pluginaction/plugin_info.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L20-L55 | go | train | // GetPluginInfoFromRepositoriesForPlatform returns the newest version of the specified plugin
// and all the repositories that contain that version. | func (actor Actor) GetPluginInfoFromRepositoriesForPlatform(pluginName string, pluginRepos []configv3.PluginRepository, platform string) (PluginInfo, []string, error) | // GetPluginInfoFromRepositoriesForPlatform returns the newest version of the specified plugin
// and all the repositories that contain that version.
func (actor Actor) GetPluginInfoFromRepositoriesForPlatform(pluginName string, pluginRepos []configv3.PluginRepository, platform string) (PluginInfo, []string, error) | {
var reposWithPlugin []string
var newestPluginInfo PluginInfo
var pluginFoundWithIncompatibleBinary bool
for _, repo := range pluginRepos {
pluginInfo, err := actor.getPluginInfoFromRepositoryForPlatform(pluginName, repo, platform)
switch err.(type) {
case actionerror.PluginNotFoundInRepositoryError:
continue
case actionerror.NoCompatibleBinaryError:
pluginFoundWithIncompatibleBinary = true
continue
case nil:
if len(reposWithPlugin) == 0 || lessThan(newestPluginInfo.Version, pluginInfo.Version) {
newestPluginInfo = pluginInfo
reposWithPlugin = []string{repo.Name}
} else if pluginInfo.Version == newestPluginInfo.Version {
reposWithPlugin = append(reposWithPlugin, repo.Name)
}
default:
return PluginInfo{}, nil, actionerror.FetchingPluginInfoFromRepositoryError{
RepositoryName: repo.Name,
Err: err,
}
}
}
if len(reposWithPlugin) == 0 {
if pluginFoundWithIncompatibleBinary {
return PluginInfo{}, nil, actionerror.NoCompatibleBinaryError{}
}
return PluginInfo{}, nil, actionerror.PluginNotFoundInAnyRepositoryError{PluginName: pluginName}
}
return newestPluginInfo, reposWithPlugin, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/pluginaction/plugin_info.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L58-L60 | go | train | // GetPlatformString exists solely for the purposes of mocking it out for command-layers tests. | func (actor Actor) GetPlatformString(runtimeGOOS string, runtimeGOARCH string) string | // GetPlatformString exists solely for the purposes of mocking it out for command-layers tests.
func (actor Actor) GetPlatformString(runtimeGOOS string, runtimeGOARCH string) string | {
return generic.GeneratePlatform(runtime.GOOS, runtime.GOARCH)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/pluginaction/plugin_info.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pluginaction/plugin_info.go#L64-L96 | go | train | // getPluginInfoFromRepositoryForPlatform returns the plugin info, if found, from
// the specified repository for the specified platform. | func (actor Actor) getPluginInfoFromRepositoryForPlatform(pluginName string, pluginRepo configv3.PluginRepository, platform string) (PluginInfo, error) | // getPluginInfoFromRepositoryForPlatform returns the plugin info, if found, from
// the specified repository for the specified platform.
func (actor Actor) getPluginInfoFromRepositoryForPlatform(pluginName string, pluginRepo configv3.PluginRepository, platform string) (PluginInfo, error) | {
pluginRepository, err := actor.client.GetPluginRepository(pluginRepo.URL)
if err != nil {
return PluginInfo{}, err
}
var pluginFoundWithIncompatibleBinary bool
for _, plugin := range pluginRepository.Plugins {
if plugin.Name == pluginName {
for _, pluginBinary := range plugin.Binaries {
if pluginBinary.Platform == platform {
return PluginInfo{
Name: plugin.Name,
Version: plugin.Version,
URL: pluginBinary.URL,
Checksum: pluginBinary.Checksum,
}, nil
}
}
pluginFoundWithIncompatibleBinary = true
}
}
if pluginFoundWithIncompatibleBinary {
return PluginInfo{}, actionerror.NoCompatibleBinaryError{}
}
return PluginInfo{}, actionerror.PluginNotFoundInRepositoryError{
PluginName: pluginName,
RepositoryName: pluginRepo.Name,
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/generic/executable_filename_windows.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/generic/executable_filename_windows.go#L12-L17 | go | train | // ExecutableFilename appends '.exe' to a filename when necessary in order to
// make it executable on Windows | func ExecutableFilename(name string) string | // ExecutableFilename appends '.exe' to a filename when necessary in order to
// make it executable on Windows
func ExecutableFilename(name string) string | {
if strings.HasSuffix(name, ".exe") {
return name
}
return fmt.Sprintf("%s.exe", name)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/relationship_list.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship_list.go#L50-L72 | go | train | // EntitleIsolationSegmentToOrganizations will create a link between the
// isolation segment and the list of organizations provided. | func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error) | // EntitleIsolationSegmentToOrganizations will create a link between the
// isolation segment and the list of organizations provided.
func (client *Client) EntitleIsolationSegmentToOrganizations(isolationSegmentGUID string, organizationGUIDs []string) (RelationshipList, Warnings, error) | {
body, err := json.Marshal(RelationshipList{GUIDs: organizationGUIDs})
if err != nil {
return RelationshipList{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostIsolationSegmentRelationshipOrganizationsRequest,
URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID},
Body: bytes.NewReader(body),
})
if err != nil {
return RelationshipList{}, nil, err
}
var relationships RelationshipList
response := cloudcontroller.Response{
DecodeJSONResponseInto: &relationships,
}
err = client.connection.Make(request, &response)
return relationships, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/relationship_list.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship_list.go#L76-L99 | go | train | // ShareServiceInstanceToSpaces will create a sharing relationship between
// the service instance and the shared-to space for each space provided. | func (client *Client) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (RelationshipList, Warnings, error) | // ShareServiceInstanceToSpaces will create a sharing relationship between
// the service instance and the shared-to space for each space provided.
func (client *Client) ShareServiceInstanceToSpaces(serviceInstanceGUID string, spaceGUIDs []string) (RelationshipList, Warnings, error) | {
body, err := json.Marshal(RelationshipList{GUIDs: spaceGUIDs})
if err != nil {
return RelationshipList{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostServiceInstanceRelationshipsSharedSpacesRequest,
URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID},
Body: bytes.NewReader(body),
})
if err != nil {
return RelationshipList{}, nil, err
}
var relationships RelationshipList
response := cloudcontroller.Response{
DecodeJSONResponseInto: &relationships,
}
err = client.connection.Make(request, &response)
return relationships, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/panichandler/handler.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/panichandler/handler.go#L17-L77 | go | train | // HandlePanic will recover from any panics and display a friendly error
// message with additional information used for debugging the panic. | func HandlePanic() | // HandlePanic will recover from any panics and display a friendly error
// message with additional information used for debugging the panic.
func HandlePanic() | {
stackTraceBytes := make([]byte, maxStackSizeLimit)
runtime.Stack(stackTraceBytes, true)
stackTrace := "\t" + strings.Replace(string(stackTraceBytes), "\n", "\n\t", -1)
if err := recover(); err != nil {
formattedString := `
Something unexpected happened. This is a bug in {{.Binary}}.
Please re-run the command that caused this exception with the environment
variable CF_TRACE set to true.
Also, please update to the latest cli and try the command again:
https://code.cloudfoundry.org/cli/releases
Please create an issue at: https://code.cloudfoundry.org/cli/issues
Include the below information when creating the issue:
Command
{{.Command}}
CLI Version
{{.Version}}
Error
{{.Error}}
Stack Trace
{{.StackTrace}}
Your Platform Details
e.g. Mac OS X 10.11, Windows 8.1 64-bit, Ubuntu 14.04.3 64-bit
Shell
e.g. Terminal, iTerm, Powershell, Cygwin, gnome-terminal, terminator
`
formattedTemplate := template.Must(template.New("Panic Template").Parse(formattedString))
templateErr := formattedTemplate.Execute(os.Stderr, map[string]interface{}{
"Binary": os.Args[0],
"Command": strings.Join(os.Args, " "),
"Version": version.VersionString(),
"StackTrace": stackTrace,
"Error": err,
})
if templateErr != nil {
fmt.Fprintf(os.Stderr,
"Unable to format panic response: %s\n",
templateErr.Error(),
)
fmt.Fprintf(os.Stderr,
"Version:%s\nCommand:%s\nOriginal Stack Trace:%s\nOriginal Error:%s\n",
version.VersionString(),
strings.Join(os.Args, " "),
stackTrace,
err,
)
}
os.Exit(1)
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/domain.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L38-L59 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Domain response. | func (domain *Domain) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Domain response.
func (domain *Domain) UnmarshalJSON(data []byte) error | {
var ccDomain struct {
Metadata internal.Metadata `json:"metadata"`
Entity struct {
Name string `json:"name"`
RouterGroupGUID string `json:"router_group_guid"`
RouterGroupType string `json:"router_group_type"`
Internal bool `json:"internal"`
} `json:"entity"`
}
err := cloudcontroller.DecodeJSON(data, &ccDomain)
if err != nil {
return err
}
domain.GUID = ccDomain.Metadata.GUID
domain.Name = ccDomain.Entity.Name
domain.RouterGroupGUID = ccDomain.Entity.RouterGroupGUID
domain.RouterGroupType = constant.RouterGroupType(ccDomain.Entity.RouterGroupType)
domain.Internal = ccDomain.Entity.Internal
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/domain.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L119-L140 | go | train | // GetPrivateDomain returns the Private Domain associated with the provided
// Domain GUID. | func (client *Client) GetPrivateDomain(domainGUID string) (Domain, Warnings, error) | // GetPrivateDomain returns the Private Domain associated with the provided
// Domain GUID.
func (client *Client) GetPrivateDomain(domainGUID string) (Domain, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetPrivateDomainRequest,
URIParams: map[string]string{"private_domain_guid": domainGUID},
})
if err != nil {
return Domain{}, nil, err
}
var domain Domain
response := cloudcontroller.Response{
DecodeJSONResponseInto: &domain,
}
err = client.connection.Make(request, &response)
if err != nil {
return Domain{}, response.Warnings, err
}
domain.Type = constant.PrivateDomain
return domain, response.Warnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/domain.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/domain.go#L143-L167 | go | train | // GetPrivateDomains returns the private domains this client has access to. | func (client *Client) GetPrivateDomains(filters ...Filter) ([]Domain, Warnings, error) | // GetPrivateDomains returns the private domains this client has access to.
func (client *Client) GetPrivateDomains(filters ...Filter) ([]Domain, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetPrivateDomainsRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return []Domain{}, nil, err
}
fullDomainsList := []Domain{}
warnings, err := client.paginate(request, Domain{}, func(item interface{}) error {
if domain, ok := item.(Domain); ok {
domain.Type = constant.PrivateDomain
fullDomainsList = append(fullDomainsList, domain)
} else {
return ccerror.UnknownObjectInListError{
Expected: Domain{},
Unexpected: item,
}
}
return nil
})
return fullDomainsList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/common/command_list_v6.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/common/command_list_v6.go#L218-L232 | go | train | // HasCommand returns true if the command name is in the command list. | func (c commandList) HasCommand(name string) bool | // HasCommand returns true if the command name is in the command list.
func (c commandList) HasCommand(name string) bool | {
if name == "" {
return false
}
cType := reflect.TypeOf(c)
_, found := cType.FieldByNameFunc(
func(fieldName string) bool {
field, _ := cType.FieldByName(fieldName)
return field.Tag.Get("command") == name
},
)
return found
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/ui/log_message.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/ui/log_message.go#L27-L50 | go | train | // DisplayLogMessage formats and outputs a given log message. | func (ui *UI) DisplayLogMessage(message LogMessage, displayHeader bool) | // DisplayLogMessage formats and outputs a given log message.
func (ui *UI) DisplayLogMessage(message LogMessage, displayHeader bool) | {
ui.terminalLock.Lock()
defer ui.terminalLock.Unlock()
var header string
if displayHeader {
time := message.Timestamp().In(ui.TimezoneLocation).Format(LogTimestampFormat)
header = fmt.Sprintf("%s [%s/%s] %s ",
time,
message.SourceType(),
message.SourceInstance(),
message.Type(),
)
}
for _, line := range strings.Split(message.Message(), "\n") {
logLine := fmt.Sprintf("%s%s", header, strings.TrimRight(line, "\r\n"))
if message.Type() == "ERR" {
logLine = ui.modifyColor(logLine, color.New(color.FgRed))
}
fmt.Fprintf(ui.Out, " %s\n", logLine)
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/common/install_plugin_command.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/common/install_plugin_command.go#L246-L269 | go | train | // These are specific errors that we output to the user in the context of
// installing from any repository. | func (InstallPluginCommand) handleFetchingPluginInfoFromRepositoriesError(fetchErr actionerror.FetchingPluginInfoFromRepositoryError) error | // These are specific errors that we output to the user in the context of
// installing from any repository.
func (InstallPluginCommand) handleFetchingPluginInfoFromRepositoriesError(fetchErr actionerror.FetchingPluginInfoFromRepositoryError) error | {
switch clientErr := fetchErr.Err.(type) {
case pluginerror.RawHTTPStatusError:
return translatableerror.FetchingPluginInfoFromRepositoriesError{
Message: clientErr.Status,
RepositoryName: fetchErr.RepositoryName,
}
case pluginerror.SSLValidationHostnameError:
return translatableerror.FetchingPluginInfoFromRepositoriesError{
Message: clientErr.Error(),
RepositoryName: fetchErr.RepositoryName,
}
case pluginerror.UnverifiedServerError:
return translatableerror.FetchingPluginInfoFromRepositoriesError{
Message: clientErr.Error(),
RepositoryName: fetchErr.RepositoryName,
}
default:
return clientErr
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/environment.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/environment.go#L30-L45 | go | train | // GetApplicationEnvironment fetches all the environment variables on
// an application by groups. | func (client *Client) GetApplicationEnvironment(appGUID string) (Environment, Warnings, error) | // GetApplicationEnvironment fetches all the environment variables on
// an application by groups.
func (client *Client) GetApplicationEnvironment(appGUID string) (Environment, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
URIParams: internal.Params{"app_guid": appGUID},
RequestName: internal.GetApplicationEnvRequest,
})
if err != nil {
return Environment{}, nil, err
}
var responseEnvVars Environment
response := cloudcontroller.Response{
DecodeJSONResponseInto: &responseEnvVars,
}
err = client.connection.Make(request, &response)
return responseEnvVars, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/shared/new_clients.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/new_clients.go#L16-L90 | go | train | // NewClients creates a new V2 Cloud Controller client and UAA client using the
// passed in config. | func NewClients(config command.Config, ui command.UI, targetCF bool) (*ccv2.Client, *uaa.Client, error) | // NewClients creates a new V2 Cloud Controller client and UAA client using the
// passed in config.
func NewClients(config command.Config, ui command.UI, targetCF bool) (*ccv2.Client, *uaa.Client, error) | {
ccWrappers := []ccv2.ConnectionWrapper{}
verbose, location := config.Verbose()
if verbose {
ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay()))
}
if location != nil {
ccWrappers = append(ccWrappers, ccWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location)))
}
authWrapper := ccWrapper.NewUAAAuthentication(nil, config)
ccWrappers = append(ccWrappers, authWrapper)
ccWrappers = append(ccWrappers, ccWrapper.NewRetryRequest(config.RequestRetryCount()))
ccClient := ccv2.NewClient(ccv2.Config{
AppName: config.BinaryName(),
AppVersion: config.BinaryVersion(),
JobPollingTimeout: config.OverallPollingTimeout(),
JobPollingInterval: config.PollingInterval(),
Wrappers: ccWrappers,
})
if !targetCF {
return ccClient, nil, nil
}
if config.Target() == "" {
return nil, nil, translatableerror.NoAPISetError{
BinaryName: config.BinaryName(),
}
}
_, err := ccClient.TargetCF(ccv2.TargetSettings{
URL: config.Target(),
SkipSSLValidation: config.SkipSSLValidation(),
DialTimeout: config.DialTimeout(),
})
if err != nil {
return nil, nil, err
}
if err = command.WarnIfAPIVersionBelowSupportedMinimum(ccClient.APIVersion(), ui); err != nil {
return nil, nil, err
}
if ccClient.AuthorizationEndpoint() == "" {
return nil, nil, translatableerror.AuthorizationEndpointNotFoundError{}
}
uaaClient := uaa.NewClient(config)
if verbose {
uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay()))
}
if location != nil {
uaaClient.WrapConnection(uaaWrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location)))
}
uaaAuthWrapper := uaaWrapper.NewUAAAuthentication(nil, config)
uaaClient.WrapConnection(uaaAuthWrapper)
uaaClient.WrapConnection(uaaWrapper.NewRetryRequest(config.RequestRetryCount()))
err = uaaClient.SetupResources(ccClient.AuthorizationEndpoint())
if err != nil {
return nil, nil, err
}
uaaAuthWrapper.SetClient(uaaClient)
authWrapper.SetClient(uaaClient)
return ccClient, uaaClient, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/sharedaction/check_target.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/sharedaction/check_target.go#L7-L31 | go | train | // CheckTarget confirms that the user is logged in. Optionally it will also
// check if an organization and space are targeted. | func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error | // CheckTarget confirms that the user is logged in. Optionally it will also
// check if an organization and space are targeted.
func (actor Actor) CheckTarget(targetedOrganizationRequired bool, targetedSpaceRequired bool) error | {
if !actor.IsLoggedIn() {
return actionerror.NotLoggedInError{
BinaryName: actor.Config.BinaryName(),
}
}
if targetedOrganizationRequired {
if !actor.IsOrgTargeted() {
return actionerror.NoOrganizationTargetedError{
BinaryName: actor.Config.BinaryName(),
}
}
if targetedSpaceRequired {
if !actor.IsSpaceTargeted() {
return actionerror.NoSpaceTargetedError{
BinaryName: actor.Config.BinaryName(),
}
}
}
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/name_generator.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/name_generator.go#L11-L27 | go | train | // TODO: Is this working??? | func GenerateHigherName(randomNameGenerator func() string, names ...string) string | // TODO: Is this working???
func GenerateHigherName(randomNameGenerator func() string, names ...string) string | {
name := randomNameGenerator()
var safe bool
for !safe {
safe = true
for _, nameToBeLowerThan := range names {
// regenerate name if name is NOT higher
if !sort.StringsAreSorted([]string{nameToBeLowerThan, name}) {
name = randomNameGenerator()
safe = false
break
}
}
}
return name
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/name_generator.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/name_generator.go#L30-L46 | go | train | // TODO: Is this working??? | func GenerateLowerName(randomNameGenerator func() string, names ...string) string | // TODO: Is this working???
func GenerateLowerName(randomNameGenerator func() string, names ...string) string | {
name := randomNameGenerator()
var safe bool
for !safe {
safe = true
for _, nameToBeHigherThan := range names {
// regenerate name if name is NOT lower
if !sort.StringsAreSorted([]string{name, nameToBeHigherThan}) {
name = randomNameGenerator()
safe = false
break
}
}
}
return name
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/task.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/task.go#L37-L61 | go | train | // CreateApplicationTask runs a command in the Application environment
// associated with the provided Application GUID. | func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error) | // CreateApplicationTask runs a command in the Application environment
// associated with the provided Application GUID.
func (client *Client) CreateApplicationTask(appGUID string, task Task) (Task, Warnings, error) | {
bodyBytes, err := json.Marshal(task)
if err != nil {
return Task{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostApplicationTasksRequest,
URIParams: internal.Params{
"app_guid": appGUID,
},
Body: bytes.NewReader(bodyBytes),
})
if err != nil {
return Task{}, nil, err
}
var responseTask Task
response := cloudcontroller.Response{
DecodeJSONResponseInto: &responseTask,
}
err = client.connection.Make(request, &response)
return responseTask, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/task.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/task.go#L65-L91 | go | train | // GetApplicationTasks returns a list of tasks associated with the provided
// application GUID. Results can be filtered by providing URL queries. | func (client *Client) GetApplicationTasks(appGUID string, query ...Query) ([]Task, Warnings, error) | // GetApplicationTasks returns a list of tasks associated with the provided
// application GUID. Results can be filtered by providing URL queries.
func (client *Client) GetApplicationTasks(appGUID string, query ...Query) ([]Task, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetApplicationTasksRequest,
URIParams: internal.Params{
"app_guid": appGUID,
},
Query: query,
})
if err != nil {
return nil, nil, err
}
var fullTasksList []Task
warnings, err := client.paginate(request, Task{}, func(item interface{}) error {
if task, ok := item.(Task); ok {
fullTasksList = append(fullTasksList, task)
} else {
return ccerror.UnknownObjectInListError{
Expected: Task{},
Unexpected: item,
}
}
return nil
})
return fullTasksList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/task.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/task.go#L94-L116 | go | train | // UpdateTaskCancel cancels a task. | func (client *Client) UpdateTaskCancel(taskGUID string) (Task, Warnings, error) | // UpdateTaskCancel cancels a task.
func (client *Client) UpdateTaskCancel(taskGUID string) (Task, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutTaskCancelRequest,
URIParams: internal.Params{
"task_guid": taskGUID,
},
})
if err != nil {
return Task{}, nil, err
}
var task Task
response := cloudcontroller.Response{
DecodeJSONResponseInto: &task,
}
err = client.connection.Make(request, &response)
if err != nil {
return Task{}, response.Warnings, err
}
return task, response.Warnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v7action/feature_flag.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v7action/feature_flag.go#L12-L28 | go | train | // GetFeatureFlagByName returns a featureFlag with the provided name. | func (actor Actor) GetFeatureFlagByName(featureFlagName string) (FeatureFlag, Warnings, error) | // GetFeatureFlagByName returns a featureFlag with the provided name.
func (actor Actor) GetFeatureFlagByName(featureFlagName string) (FeatureFlag, Warnings, error) | {
var (
ccv3FeatureFlag ccv3.FeatureFlag
warnings ccv3.Warnings
err error
)
ccv3FeatureFlag, warnings, err = actor.CloudControllerClient.GetFeatureFlag(featureFlagName)
if err != nil {
if _, ok := err.(ccerror.FeatureFlagNotFoundError); ok {
return FeatureFlag{}, Warnings(warnings), actionerror.FeatureFlagNotFoundError{FeatureFlagName: featureFlagName}
}
return FeatureFlag{}, Warnings(warnings), err
}
return FeatureFlag(ccv3FeatureFlag), Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L59-L90 | go | train | // UnmarshalJSON helps unmarshal a Cloud Controller Service Instance response. | func (serviceInstance *ServiceInstance) UnmarshalJSON(data []byte) error | // UnmarshalJSON helps unmarshal a Cloud Controller Service Instance response.
func (serviceInstance *ServiceInstance) UnmarshalJSON(data []byte) error | {
var ccServiceInstance struct {
Metadata internal.Metadata
Entity struct {
Name string `json:"name"`
SpaceGUID string `json:"space_guid"`
ServiceGUID string `json:"service_guid"`
ServicePlanGUID string `json:"service_plan_guid"`
Type string `json:"type"`
Tags []string `json:"tags"`
DashboardURL string `json:"dashboard_url"`
RouteServiceURL string `json:"route_service_url"`
LastOperation LastOperation `json:"last_operation"`
}
}
err := cloudcontroller.DecodeJSON(data, &ccServiceInstance)
if err != nil {
return err
}
serviceInstance.GUID = ccServiceInstance.Metadata.GUID
serviceInstance.Name = ccServiceInstance.Entity.Name
serviceInstance.SpaceGUID = ccServiceInstance.Entity.SpaceGUID
serviceInstance.ServiceGUID = ccServiceInstance.Entity.ServiceGUID
serviceInstance.ServicePlanGUID = ccServiceInstance.Entity.ServicePlanGUID
serviceInstance.Type = constant.ServiceInstanceType(ccServiceInstance.Entity.Type)
serviceInstance.Tags = ccServiceInstance.Entity.Tags
serviceInstance.DashboardURL = ccServiceInstance.Entity.DashboardURL
serviceInstance.RouteServiceURL = ccServiceInstance.Entity.RouteServiceURL
serviceInstance.LastOperation = ccServiceInstance.Entity.LastOperation
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L108-L138 | go | train | // CreateServiceInstance posts a service instance resource with the provided
// attributes to the api and returns the result. | func (client *Client) CreateServiceInstance(spaceGUID, servicePlanGUID, serviceInstance string, parameters map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) | // CreateServiceInstance posts a service instance resource with the provided
// attributes to the api and returns the result.
func (client *Client) CreateServiceInstance(spaceGUID, servicePlanGUID, serviceInstance string, parameters map[string]interface{}, tags []string) (ServiceInstance, Warnings, error) | {
requestBody := createServiceInstanceRequestBody{
Name: serviceInstance,
ServicePlanGUID: servicePlanGUID,
SpaceGUID: spaceGUID,
Parameters: parameters,
Tags: tags,
}
bodyBytes, err := json.Marshal(requestBody)
if err != nil {
return ServiceInstance{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostServiceInstancesRequest,
Body: bytes.NewReader(bodyBytes),
Query: url.Values{"accepts_incomplete": {"true"}},
})
if err != nil {
return ServiceInstance{}, nil, err
}
var instance ServiceInstance
response := cloudcontroller.Response{
DecodeJSONResponseInto: &instance,
}
err = client.connection.Make(request, &response)
return instance, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L142-L158 | go | train | // GetServiceInstance returns the service instance with the given GUID. This
// service can be either a managed or user provided. | func (client *Client) GetServiceInstance(serviceInstanceGUID string) (ServiceInstance, Warnings, error) | // GetServiceInstance returns the service instance with the given GUID. This
// service can be either a managed or user provided.
func (client *Client) GetServiceInstance(serviceInstanceGUID string) (ServiceInstance, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceInstanceRequest,
URIParams: Params{"service_instance_guid": serviceInstanceGUID},
})
if err != nil {
return ServiceInstance{}, nil, err
}
var serviceInstance ServiceInstance
response := cloudcontroller.Response{
DecodeJSONResponseInto: &serviceInstance,
}
err = client.connection.Make(request, &response)
return serviceInstance, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L162-L185 | go | train | // GetServiceInstances returns back a list of *managed* Service Instances based
// off of the provided filters. | func (client *Client) GetServiceInstances(filters ...Filter) ([]ServiceInstance, Warnings, error) | // GetServiceInstances returns back a list of *managed* Service Instances based
// off of the provided filters.
func (client *Client) GetServiceInstances(filters ...Filter) ([]ServiceInstance, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetServiceInstancesRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return nil, nil, err
}
var fullInstancesList []ServiceInstance
warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error {
if instance, ok := item.(ServiceInstance); ok {
fullInstancesList = append(fullInstancesList, instance)
} else {
return ccerror.UnknownObjectInListError{
Expected: ServiceInstance{},
Unexpected: item,
}
}
return nil
})
return fullInstancesList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/service_instance.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/service_instance.go#L190-L220 | go | train | // GetSpaceServiceInstances returns back a list of Service Instances based off
// of the space and filters provided. User provided services will be included
// if includeUserProvidedServices is set to true. | func (client *Client) GetSpaceServiceInstances(spaceGUID string, includeUserProvidedServices bool, filters ...Filter) ([]ServiceInstance, Warnings, error) | // GetSpaceServiceInstances returns back a list of Service Instances based off
// of the space and filters provided. User provided services will be included
// if includeUserProvidedServices is set to true.
func (client *Client) GetSpaceServiceInstances(spaceGUID string, includeUserProvidedServices bool, filters ...Filter) ([]ServiceInstance, Warnings, error) | {
query := ConvertFilterParameters(filters)
if includeUserProvidedServices {
query.Add("return_user_provided_service_instances", "true")
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetSpaceServiceInstancesRequest,
URIParams: map[string]string{"guid": spaceGUID},
Query: query,
})
if err != nil {
return nil, nil, err
}
var fullInstancesList []ServiceInstance
warnings, err := client.paginate(request, ServiceInstance{}, func(item interface{}) error {
if instance, ok := item.(ServiceInstance); ok {
fullInstancesList = append(fullInstancesList, instance)
} else {
return ccerror.UnknownObjectInListError{
Expected: ServiceInstance{},
Unexpected: item,
}
}
return nil
})
return fullInstancesList, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_instance_summary.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_instance_summary.go#L106-L168 | go | train | // getAndSetSharedInformation gets a service instance's shared from or shared to information, | func (actor Actor) getAndSetSharedInformation(summary *ServiceInstanceSummary, spaceGUID string) (Warnings, error) | // getAndSetSharedInformation gets a service instance's shared from or shared to information,
func (actor Actor) getAndSetSharedInformation(summary *ServiceInstanceSummary, spaceGUID string) (Warnings, error) | {
var (
warnings Warnings
err error
)
// Part of determining if a service instance is shareable, we need to find
// out if the service_instance_sharing feature flag is enabled
featureFlags, featureFlagsWarnings, featureFlagsErr := actor.CloudControllerClient.GetConfigFeatureFlags()
allWarnings := Warnings(featureFlagsWarnings)
if featureFlagsErr != nil {
return allWarnings, featureFlagsErr
}
for _, flag := range featureFlags {
if flag.Name == string(constant.FeatureFlagServiceInstanceSharing) {
summary.ServiceInstanceSharingFeatureFlag = flag.Enabled
}
}
// Service instance is shared from if:
// 1. the source space of the service instance is empty (API returns json null)
// 2. the targeted space is not the same as the source space of the service instance AND
// we call the shared_from url and it returns a non-empty resource
if summary.ServiceInstance.SpaceGUID == "" || summary.ServiceInstance.SpaceGUID != spaceGUID {
summary.ServiceInstanceSharedFrom, warnings, err = actor.GetServiceInstanceSharedFromByServiceInstance(summary.ServiceInstance.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
// if the API version does not support service instance sharing, ignore the 404
if _, ok := err.(ccerror.ResourceNotFoundError); !ok {
return allWarnings, err
}
}
if summary.ServiceInstanceSharedFrom.SpaceGUID != "" {
summary.ServiceInstanceShareType = ServiceInstanceIsSharedFrom
} else {
summary.ServiceInstanceShareType = ServiceInstanceIsNotShared
}
return allWarnings, nil
}
// Service instance is shared to if:
// the targeted space is the same as the source space of the service instance AND
// we call the shared_to url and get a non-empty list
summary.ServiceInstanceSharedTos, warnings, err = actor.GetServiceInstanceSharedTosByServiceInstance(summary.ServiceInstance.GUID)
allWarnings = append(allWarnings, warnings...)
if err != nil {
// if the API version does not support service instance sharing, ignore the 404
if _, ok := err.(ccerror.ResourceNotFoundError); !ok {
return allWarnings, err
}
}
if len(summary.ServiceInstanceSharedTos) > 0 {
summary.ServiceInstanceShareType = ServiceInstanceIsSharedTo
} else {
summary.ServiceInstanceShareType = ServiceInstanceIsNotShared
}
return allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/package.go#L133-L153 | go | train | // GetApplicationPackages returns a list of package of an app. | func (actor *Actor) GetApplicationPackages(appName string, spaceGUID string) ([]Package, Warnings, error) | // GetApplicationPackages returns a list of package of an app.
func (actor *Actor) GetApplicationPackages(appName string, spaceGUID string) ([]Package, Warnings, error) | {
app, allWarnings, err := actor.GetApplicationByNameAndSpace(appName, spaceGUID)
if err != nil {
return nil, allWarnings, err
}
ccv3Packages, warnings, err := actor.CloudControllerClient.GetPackages(
ccv3.Query{Key: ccv3.AppGUIDFilter, Values: []string{app.GUID}},
)
allWarnings = append(allWarnings, warnings...)
if err != nil {
return nil, allWarnings, err
}
var packages []Package
for _, ccv3Package := range ccv3Packages {
packages = append(packages, Package(ccv3Package))
}
return packages, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v3action/package.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v3action/package.go#L183-L209 | go | train | // PollPackage returns a package of an app. | func (actor Actor) PollPackage(pkg Package) (Package, Warnings, error) | // PollPackage returns a package of an app.
func (actor Actor) PollPackage(pkg Package) (Package, Warnings, error) | {
var allWarnings Warnings
for pkg.State != constant.PackageReady && pkg.State != constant.PackageFailed && pkg.State != constant.PackageExpired {
time.Sleep(actor.Config.PollingInterval())
ccPkg, warnings, err := actor.CloudControllerClient.GetPackage(pkg.GUID)
log.WithFields(log.Fields{
"package_guid": pkg.GUID,
"state": pkg.State,
}).Debug("polling package state")
allWarnings = append(allWarnings, warnings...)
if err != nil {
return Package{}, allWarnings, err
}
pkg = Package(ccPkg)
}
if pkg.State == constant.PackageFailed {
return Package{}, allWarnings, actionerror.PackageProcessingFailedError{}
} else if pkg.State == constant.PackageExpired {
return Package{}, allWarnings, actionerror.PackageProcessingExpiredError{}
}
return pkg, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/login.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/login.go#L83-L93 | go | train | // GetCredentials returns back the username and the password. | func GetCredentials() (string, string) | // GetCredentials returns back the username and the password.
func GetCredentials() (string, string) | {
username := os.Getenv("CF_INT_USERNAME")
if username == "" {
username = "admin"
}
password := os.Getenv("CF_INT_PASSWORD")
if password == "" {
password = "admin"
}
return username, password
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/login.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/login.go#L97-L106 | go | train | // SkipIfOIDCCredentialsNotSet returns back the username and the password for
// OIDC origin, or skips the test if those values are not set. | func SkipIfOIDCCredentialsNotSet() (string, string) | // SkipIfOIDCCredentialsNotSet returns back the username and the password for
// OIDC origin, or skips the test if those values are not set.
func SkipIfOIDCCredentialsNotSet() (string, string) | {
oidcUsername := os.Getenv("CF_INT_OIDC_USERNAME")
oidcPassword := os.Getenv("CF_INT_OIDC_PASSWORD")
if oidcUsername == "" || oidcPassword == "" {
Skip("CF_INT_OIDC_USERNAME or CF_INT_OIDC_PASSWORD is not set")
}
return oidcUsername, oidcPassword
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/wrapper/request_logger.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/wrapper/request_logger.go#L64-L67 | go | train | // Wrap sets the connection on the RequestLogger and returns itself | func (logger *RequestLogger) Wrap(innerconnection cloudcontroller.Connection) cloudcontroller.Connection | // Wrap sets the connection on the RequestLogger and returns itself
func (logger *RequestLogger) Wrap(innerconnection cloudcontroller.Connection) cloudcontroller.Connection | {
logger.connection = innerconnection
return logger
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/pushaction/domain.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/domain.go#L11-L36 | go | train | // DefaultDomain looks up the shared and then private domains and returns back
// the first one in the list as the default. | func (actor Actor) DefaultDomain(orgGUID string) (v2action.Domain, Warnings, error) | // DefaultDomain looks up the shared and then private domains and returns back
// the first one in the list as the default.
func (actor Actor) DefaultDomain(orgGUID string) (v2action.Domain, Warnings, error) | {
log.Infoln("getting org domains for org GUID:", orgGUID)
// the domains object contains all the shared domains AND all domains private to this org
domains, warnings, err := actor.V2Actor.GetOrganizationDomains(orgGUID)
if err != nil {
log.Errorln("searching for domains in org:", err)
return v2action.Domain{}, Warnings(warnings), err
}
log.Debugf("filtering out internal domains from all found domains: %#v", domains)
var externalDomains []v2action.Domain
for _, d := range domains {
if !d.Internal {
externalDomains = append(externalDomains, d)
}
}
if len(externalDomains) == 0 {
log.Error("no domains found")
return v2action.Domain{}, Warnings(warnings), actionerror.NoDomainsFoundError{OrganizationGUID: orgGUID}
}
log.Debugf("selecting first external domain as default domain: %#v", externalDomains)
return externalDomains[0], Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/matchers.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/matchers.go#L19-L30 | go | train | // SayPath is used to assert that a path is printed. On Windows, it uses a
// case-insensitive match and escapes the path. On non-Windows, it evaluates
// the base directory of the path for symlniks. | func SayPath(format string, path string) types.GomegaMatcher | // SayPath is used to assert that a path is printed. On Windows, it uses a
// case-insensitive match and escapes the path. On non-Windows, it evaluates
// the base directory of the path for symlniks.
func SayPath(format string, path string) types.GomegaMatcher | {
theRealDir, err := filepath.EvalSymlinks(filepath.Dir(path))
Expect(err).ToNot(HaveOccurred())
theRealPath := filepath.Join(theRealDir, filepath.Base(path))
if runtime.GOOS == "windows" {
expected := "(?i)" + format
expected = fmt.Sprintf(expected, regexp.QuoteMeta(path))
return gbytes.Say(expected)
}
return gbytes.Say(format, theRealPath)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/plugin/wrapper/retry_request.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/plugin/wrapper/retry_request.go#L26-L52 | go | train | // Make retries the request if it comes back with a 5XX status code. | func (retry *RetryRequest) Make(request *http.Request, passedResponse *plugin.Response, proxyReader plugin.ProxyReader) error | // Make retries the request if it comes back with a 5XX status code.
func (retry *RetryRequest) Make(request *http.Request, passedResponse *plugin.Response, proxyReader plugin.ProxyReader) error | {
var err error
var rawRequestBody []byte
if request.Body != nil {
rawRequestBody, err = ioutil.ReadAll(request.Body)
defer request.Body.Close()
if err != nil {
return err
}
}
for i := 0; i < retry.maxRetries+1; i++ {
if rawRequestBody != nil {
request.Body = ioutil.NopCloser(bytes.NewBuffer(rawRequestBody))
}
err = retry.connection.Make(request, passedResponse, proxyReader)
if err == nil {
return nil
}
if retry.skipRetry(request.Method, passedResponse.HTTPResponse) {
break
}
}
return err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/plugin/wrapper/retry_request.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/plugin/wrapper/retry_request.go#L55-L58 | go | train | // Wrap sets the connection in the RetryRequest and returns itself. | func (retry *RetryRequest) Wrap(innerconnection plugin.Connection) plugin.Connection | // Wrap sets the connection in the RetryRequest and returns itself.
func (retry *RetryRequest) Wrap(innerconnection plugin.Connection) plugin.Connection | {
retry.connection = innerconnection
return retry
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/buildpack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L76-L97 | go | train | // CreateBuildpack creates a new buildpack. | func (client *Client) CreateBuildpack(buildpack Buildpack) (Buildpack, Warnings, error) | // CreateBuildpack creates a new buildpack.
func (client *Client) CreateBuildpack(buildpack Buildpack) (Buildpack, Warnings, error) | {
body, err := json.Marshal(buildpack)
if err != nil {
return Buildpack{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PostBuildpackRequest,
Body: bytes.NewReader(body),
})
if err != nil {
return Buildpack{}, nil, err
}
var createdBuildpack Buildpack
response := cloudcontroller.Response{
DecodeJSONResponseInto: &createdBuildpack,
}
err = client.connection.Make(request, &response)
return createdBuildpack, response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/buildpack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L100-L124 | go | train | // GetBuildpacks searches for a buildpack with the given name and returns it if it exists. | func (client *Client) GetBuildpacks(filters ...Filter) ([]Buildpack, Warnings, error) | // GetBuildpacks searches for a buildpack with the given name and returns it if it exists.
func (client *Client) GetBuildpacks(filters ...Filter) ([]Buildpack, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetBuildpacksRequest,
Query: ConvertFilterParameters(filters),
})
if err != nil {
return nil, nil, err
}
var buildpacks []Buildpack
warnings, err := client.paginate(request, Buildpack{}, func(item interface{}) error {
if buildpack, ok := item.(Buildpack); ok {
buildpacks = append(buildpacks, buildpack)
} else {
return ccerror.UnknownObjectInListError{
Expected: Buildpack{},
Unexpected: item,
}
}
return nil
})
return buildpacks, warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/buildpack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L129-L155 | go | train | // UpdateBuildpack updates the buildpack with the provided GUID and returns the
// updated buildpack. Note: Stack cannot be updated without uploading a new
// buildpack. | func (client *Client) UpdateBuildpack(buildpack Buildpack) (Buildpack, Warnings, error) | // UpdateBuildpack updates the buildpack with the provided GUID and returns the
// updated buildpack. Note: Stack cannot be updated without uploading a new
// buildpack.
func (client *Client) UpdateBuildpack(buildpack Buildpack) (Buildpack, Warnings, error) | {
body, err := json.Marshal(buildpack)
if err != nil {
return Buildpack{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutBuildpackRequest,
URIParams: Params{"buildpack_guid": buildpack.GUID},
Body: bytes.NewReader(body),
})
if err != nil {
return Buildpack{}, nil, err
}
var updatedBuildpack Buildpack
response := cloudcontroller.Response{
DecodeJSONResponseInto: &updatedBuildpack,
}
err = client.connection.Make(request, &response)
if err != nil {
return Buildpack{}, response.Warnings, err
}
return updatedBuildpack, response.Warnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/buildpack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/buildpack.go#L158-L185 | go | train | // UploadBuildpack uploads the contents of a buildpack zip to the server. | func (client *Client) UploadBuildpack(buildpackGUID string, buildpackPath string, buildpack io.Reader, buildpackLength int64) (Warnings, error) | // UploadBuildpack uploads the contents of a buildpack zip to the server.
func (client *Client) UploadBuildpack(buildpackGUID string, buildpackPath string, buildpack io.Reader, buildpackLength int64) (Warnings, error) | {
contentLength, err := buildpacks.CalculateRequestSize(buildpackLength, buildpackPath, "buildpack")
if err != nil {
return nil, err
}
contentType, body, writeErrors := buildpacks.CreateMultipartBodyAndHeader(buildpack, buildpackPath, "buildpack")
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PutBuildpackBitsRequest,
URIParams: Params{"buildpack_guid": buildpackGUID},
Body: body,
})
if err != nil {
return nil, err
}
request.Header.Set("Content-Type", contentType)
request.ContentLength = contentLength
_, warnings, err := client.uploadBuildpackAsynchronously(request, writeErrors)
if err != nil {
return warnings, err
}
return warnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/sorting/alphabetic.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/sorting/alphabetic.go#L10-L34 | go | train | // LessIgnoreCase returns true if first is alphabetically less than second. | func LessIgnoreCase(first string, second string) bool | // LessIgnoreCase returns true if first is alphabetically less than second.
func LessIgnoreCase(first string, second string) bool | {
iRunes := []rune(first)
jRunes := []rune(second)
max := len(iRunes)
if max > len(jRunes) {
max = len(jRunes)
}
for idx := 0; idx < max; idx++ {
ir := iRunes[idx]
jr := jRunes[idx]
lir := unicode.ToLower(ir)
ljr := unicode.ToLower(jr)
if lir == ljr {
continue
}
return lir < ljr
}
return false
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/sorting/alphabetic.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/sorting/alphabetic.go#L38-L42 | go | train | // SortAlphabeticFunc returns a `less()` comparator for sorting strings while
// respecting case. | func SortAlphabeticFunc(list []string) func(i, j int) bool | // SortAlphabeticFunc returns a `less()` comparator for sorting strings while
// respecting case.
func SortAlphabeticFunc(list []string) func(i, j int) bool | {
return func(i, j int) bool {
return LessIgnoreCase(list[i], list[j])
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | integration/helpers/buildpack.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/integration/helpers/buildpack.go#L76-L82 | go | train | // DeleteBuildpackIfOnOldCCAPI deletes the buildpack if the CC API targeted
// by the current test run is <= 2.80.0. Before this version, some entities
// would receive and invalid next_url in paginated requests. Since our test run
// now generally creates more than 50 buildpacks, we need to delete test buildpacks
// after use if we are targeting and older CC API.
// see https://github.com/cloudfoundry/capi-release/releases/tag/1.45.0 | func DeleteBuildpackIfOnOldCCAPI(buildpackName string) | // DeleteBuildpackIfOnOldCCAPI deletes the buildpack if the CC API targeted
// by the current test run is <= 2.80.0. Before this version, some entities
// would receive and invalid next_url in paginated requests. Since our test run
// now generally creates more than 50 buildpacks, we need to delete test buildpacks
// after use if we are targeting and older CC API.
// see https://github.com/cloudfoundry/capi-release/releases/tag/1.45.0
func DeleteBuildpackIfOnOldCCAPI(buildpackName string) | {
minVersion := "2.99.0"
if !IsVersionMet(minVersion) {
deleteSessions := CF("delete-buildpack", buildpackName, "-f")
Eventually(deleteSessions).Should(Exit())
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/security_group.go#L102-L232 | go | train | // GetSecurityGroupsWithOrganizationSpaceAndLifecycle returns a list of security groups
// with org and space information, optionally including staging spaces. | func (actor Actor) GetSecurityGroupsWithOrganizationSpaceAndLifecycle(includeStaging bool) ([]SecurityGroupWithOrganizationSpaceAndLifecycle, Warnings, error) | // GetSecurityGroupsWithOrganizationSpaceAndLifecycle returns a list of security groups
// with org and space information, optionally including staging spaces.
func (actor Actor) GetSecurityGroupsWithOrganizationSpaceAndLifecycle(includeStaging bool) ([]SecurityGroupWithOrganizationSpaceAndLifecycle, Warnings, error) | {
securityGroups, allWarnings, err := actor.CloudControllerClient.GetSecurityGroups()
if err != nil {
return nil, Warnings(allWarnings), err
}
cachedOrgs := make(map[string]Organization)
var secGroupOrgSpaces []SecurityGroupWithOrganizationSpaceAndLifecycle
for _, s := range securityGroups {
securityGroup := SecurityGroup{
GUID: s.GUID,
Name: s.Name,
RunningDefault: s.RunningDefault,
StagingDefault: s.StagingDefault,
}
var getErr error
spaces, warnings, getErr := actor.getSecurityGroupSpacesAndAssignedLifecycles(s.GUID, includeStaging)
allWarnings = append(allWarnings, warnings...)
if getErr != nil {
if _, ok := getErr.(ccerror.ResourceNotFoundError); ok {
allWarnings = append(allWarnings, getErr.Error())
continue
}
return nil, Warnings(allWarnings), getErr
}
if securityGroup.RunningDefault {
secGroupOrgSpaces = append(secGroupOrgSpaces,
SecurityGroupWithOrganizationSpaceAndLifecycle{
SecurityGroup: &securityGroup,
Organization: &Organization{},
Space: &Space{},
Lifecycle: constant.SecurityGroupLifecycleRunning,
})
}
if securityGroup.StagingDefault {
secGroupOrgSpaces = append(secGroupOrgSpaces,
SecurityGroupWithOrganizationSpaceAndLifecycle{
SecurityGroup: &securityGroup,
Organization: &Organization{},
Space: &Space{},
Lifecycle: constant.SecurityGroupLifecycleStaging,
})
}
if len(spaces) == 0 {
if !securityGroup.RunningDefault && !securityGroup.StagingDefault {
secGroupOrgSpaces = append(secGroupOrgSpaces,
SecurityGroupWithOrganizationSpaceAndLifecycle{
SecurityGroup: &securityGroup,
Organization: &Organization{},
Space: &Space{},
})
}
continue
}
for _, sp := range spaces {
space := Space{
GUID: sp.GUID,
Name: sp.Name,
}
var org Organization
if cached, ok := cachedOrgs[sp.OrganizationGUID]; ok {
org = cached
} else {
var getOrgErr error
o, warnings, getOrgErr := actor.CloudControllerClient.GetOrganization(sp.OrganizationGUID)
allWarnings = append(allWarnings, warnings...)
if getOrgErr != nil {
if _, ok := getOrgErr.(ccerror.ResourceNotFoundError); ok {
allWarnings = append(allWarnings, getOrgErr.Error())
continue
}
return nil, Warnings(allWarnings), getOrgErr
}
org = Organization{
GUID: o.GUID,
Name: o.Name,
}
cachedOrgs[org.GUID] = org
}
secGroupOrgSpaces = append(secGroupOrgSpaces,
SecurityGroupWithOrganizationSpaceAndLifecycle{
SecurityGroup: &securityGroup,
Organization: &org,
Space: &space,
Lifecycle: sp.Lifecycle,
})
}
}
// Sort the results alphabetically by security group, then org, then space
sort.Slice(secGroupOrgSpaces,
func(i, j int) bool {
switch {
case secGroupOrgSpaces[i].SecurityGroup.Name < secGroupOrgSpaces[j].SecurityGroup.Name:
return true
case secGroupOrgSpaces[i].SecurityGroup.Name > secGroupOrgSpaces[j].SecurityGroup.Name:
return false
case secGroupOrgSpaces[i].SecurityGroup.RunningDefault && !secGroupOrgSpaces[i].SecurityGroup.RunningDefault:
return true
case !secGroupOrgSpaces[i].SecurityGroup.RunningDefault && secGroupOrgSpaces[i].SecurityGroup.RunningDefault:
return false
case secGroupOrgSpaces[i].Organization.Name < secGroupOrgSpaces[j].Organization.Name:
return true
case secGroupOrgSpaces[i].Organization.Name > secGroupOrgSpaces[j].Organization.Name:
return false
case secGroupOrgSpaces[i].SecurityGroup.StagingDefault && !secGroupOrgSpaces[i].SecurityGroup.StagingDefault:
return true
case !secGroupOrgSpaces[i].SecurityGroup.StagingDefault && secGroupOrgSpaces[i].SecurityGroup.StagingDefault:
return false
case secGroupOrgSpaces[i].Space.Name < secGroupOrgSpaces[j].Space.Name:
return true
case secGroupOrgSpaces[i].Space.Name > secGroupOrgSpaces[j].Space.Name:
return false
}
return secGroupOrgSpaces[i].Lifecycle < secGroupOrgSpaces[j].Lifecycle
})
return secGroupOrgSpaces, Warnings(allWarnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/security_group.go#L236-L239 | go | train | // GetSpaceRunningSecurityGroupsBySpace returns a list of all security groups
// bound to this space in the 'running' lifecycle phase. | func (actor Actor) GetSpaceRunningSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) | // GetSpaceRunningSecurityGroupsBySpace returns a list of all security groups
// bound to this space in the 'running' lifecycle phase.
func (actor Actor) GetSpaceRunningSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) | {
ccv2SecurityGroups, warnings, err := actor.CloudControllerClient.GetSpaceSecurityGroups(spaceGUID)
return processSecurityGroups(spaceGUID, ccv2SecurityGroups, Warnings(warnings), err)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/security_group.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/security_group.go#L243-L246 | go | train | // GetSpaceStagingSecurityGroupsBySpace returns a list of all security groups
// bound to this space in the 'staging' lifecycle phase. with an optional | func (actor Actor) GetSpaceStagingSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) | // GetSpaceStagingSecurityGroupsBySpace returns a list of all security groups
// bound to this space in the 'staging' lifecycle phase. with an optional
func (actor Actor) GetSpaceStagingSecurityGroupsBySpace(spaceGUID string) ([]SecurityGroup, Warnings, error) | {
ccv2SecurityGroups, warnings, err := actor.CloudControllerClient.GetSpaceStagingSecurityGroups(spaceGUID)
return processSecurityGroups(spaceGUID, ccv2SecurityGroups, Warnings(warnings), err)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/util/downloader/file_download.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/util/downloader/file_download.go#L32-L76 | go | train | //this func returns byte written, filename and error | func (d *downloader) DownloadFile(url string) (int64, string, error) | //this func returns byte written, filename and error
func (d *downloader) DownloadFile(url string) (int64, string, error) | {
c := http.Client{
CheckRedirect: func(r *http.Request, via []*http.Request) error {
r.URL.Opaque = r.URL.Path
//some redirect return '/' as url
if strings.Trim(r.URL.Opaque, "/") != "" {
url = r.URL.Opaque
}
return nil
},
}
r, err := c.Get(url)
if err != nil {
return 0, "", err
}
defer r.Body.Close()
if r.StatusCode == 200 {
d.filename = getFilenameFromHeader(r.Header.Get("Content-Disposition"))
if d.filename == "" {
d.filename = getFilenameFromURL(url)
}
f, err := os.Create(filepath.Join(d.saveDir, d.filename))
if err != nil {
return 0, "", err
}
defer f.Close()
size, err := io.Copy(f, r.Body)
if err != nil {
return 0, "", err
}
d.downloaded = true
return size, d.filename, nil
}
return 0, "", fmt.Errorf("Error downloading file from %s", url)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv2/paginated_resources.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv2/paginated_resources.go#L29-L39 | go | train | // Resources unmarshals JSON representing a page of resources and returns a
// slice of the given resource type. | func (pr PaginatedResources) Resources() ([]interface{}, error) | // Resources unmarshals JSON representing a page of resources and returns a
// slice of the given resource type.
func (pr PaginatedResources) Resources() ([]interface{}, error) | {
slicePtr := reflect.New(reflect.SliceOf(pr.resourceType))
err := json.Unmarshal([]byte(pr.ResourcesBytes), slicePtr.Interface())
slice := reflect.Indirect(slicePtr)
contents := make([]interface{}, 0, slice.Len())
for i := 0; i < slice.Len(); i++ {
contents = append(contents, slice.Index(i).Interface())
}
return contents, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/space.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L82-L98 | go | train | // GetOrganizationSpaces returns a list of spaces in the specified org | func (actor Actor) GetOrganizationSpaces(orgGUID string) ([]Space, Warnings, error) | // GetOrganizationSpaces returns a list of spaces in the specified org
func (actor Actor) GetOrganizationSpaces(orgGUID string) ([]Space, Warnings, error) | {
ccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces(ccv2.Filter{
Type: constant.OrganizationGUIDFilter,
Operator: constant.EqualOperator,
Values: []string{orgGUID},
})
if err != nil {
return []Space{}, Warnings(warnings), err
}
spaces := make([]Space, len(ccv2Spaces))
for i, ccv2Space := range ccv2Spaces {
spaces[i] = Space(ccv2Space)
}
return spaces, Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/space.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L101-L127 | go | train | // GetSpaceByOrganizationAndName returns an Space based on the org and name. | func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error) | // GetSpaceByOrganizationAndName returns an Space based on the org and name.
func (actor Actor) GetSpaceByOrganizationAndName(orgGUID string, spaceName string) (Space, Warnings, error) | {
ccv2Spaces, warnings, err := actor.CloudControllerClient.GetSpaces(
ccv2.Filter{
Type: constant.NameFilter,
Operator: constant.EqualOperator,
Values: []string{spaceName},
},
ccv2.Filter{
Type: constant.OrganizationGUIDFilter,
Operator: constant.EqualOperator,
Values: []string{orgGUID},
},
)
if err != nil {
return Space{}, Warnings(warnings), err
}
if len(ccv2Spaces) == 0 {
return Space{}, Warnings(warnings), actionerror.SpaceNotFoundError{Name: spaceName}
}
if len(ccv2Spaces) > 1 {
return Space{}, Warnings(warnings), actionerror.MultipleSpacesFoundError{OrgGUID: orgGUID, Name: spaceName}
}
return Space(ccv2Spaces[0]), Warnings(warnings), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/space.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L131-L137 | go | train | // GrantSpaceManagerByUsername makes the provided user a Space Manager in the
// space with the provided guid. | func (actor Actor) GrantSpaceManagerByUsername(orgGUID string, spaceGUID string, username string) (Warnings, error) | // GrantSpaceManagerByUsername makes the provided user a Space Manager in the
// space with the provided guid.
func (actor Actor) GrantSpaceManagerByUsername(orgGUID string, spaceGUID string, username string) (Warnings, error) | {
if actor.Config.UAAGrantType() == string(uaaconst.GrantTypeClientCredentials) {
return actor.grantSpaceManagerByClientCredentials(orgGUID, spaceGUID, username)
}
return actor.grantSpaceManagerByUsername(orgGUID, spaceGUID, username)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/space.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/space.go#L170-L179 | go | train | // GrantSpaceDeveloperByUsername makes the provided user a Space Developer in the
// space with the provided guid. | func (actor Actor) GrantSpaceDeveloperByUsername(spaceGUID string, username string) (Warnings, error) | // GrantSpaceDeveloperByUsername makes the provided user a Space Developer in the
// space with the provided guid.
func (actor Actor) GrantSpaceDeveloperByUsername(spaceGUID string, username string) (Warnings, error) | {
if actor.Config.UAAGrantType() == string(uaaconst.GrantTypeClientCredentials) {
warnings, err := actor.CloudControllerClient.UpdateSpaceDeveloper(spaceGUID, username)
return Warnings(warnings), err
}
warnings, err := actor.CloudControllerClient.UpdateSpaceDeveloperByUsername(spaceGUID, username)
return Warnings(warnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/pushaction/actor.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/pushaction/actor.go#L29-L39 | go | train | // NewActor returns a new actor. | func NewActor(v2Actor V2Actor, v3Actor V3Actor, sharedActor SharedActor) *Actor | // NewActor returns a new actor.
func NewActor(v2Actor V2Actor, v3Actor V3Actor, sharedActor SharedActor) *Actor | {
return &Actor{
SharedActor: sharedActor,
V2Actor: v2Actor,
V3Actor: v3Actor,
WordGenerator: new(randomword.Generator),
startWithProtocol: regexp.MustCompile(ProtocolRegexp),
urlValidator: regexp.MustCompile(URLRegexp),
}
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | util/configv3/color.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/util/configv3/color.go#L28-L41 | go | train | // ColorEnabled returns the color setting based off:
// 1. The $CF_COLOR environment variable if set (0/1/t/f/true/false)
// 2. The 'ColorEnabled' value in the .cf/config.json if set
// 3. Defaults to ColorAuto if nothing is set | func (config *Config) ColorEnabled() ColorSetting | // ColorEnabled returns the color setting based off:
// 1. The $CF_COLOR environment variable if set (0/1/t/f/true/false)
// 2. The 'ColorEnabled' value in the .cf/config.json if set
// 3. Defaults to ColorAuto if nothing is set
func (config *Config) ColorEnabled() ColorSetting | {
if config.ENV.CFColor != "" {
val, err := strconv.ParseBool(config.ENV.CFColor)
if err == nil {
return config.boolToColorSetting(val)
}
}
val, err := strconv.ParseBool(config.ConfigFile.ColorEnabled)
if err != nil {
return ColorAuto
}
return config.boolToColorSetting(val)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/user.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/user.go#L9-L18 | go | train | // CreateUser creates a new user in UAA and registers it with cloud controller. | func (actor Actor) CreateUser(username string, password string, origin string) (User, Warnings, error) | // CreateUser creates a new user in UAA and registers it with cloud controller.
func (actor Actor) CreateUser(username string, password string, origin string) (User, Warnings, error) | {
uaaUser, err := actor.UAAClient.CreateUser(username, password, origin)
if err != nil {
return User{}, nil, err
}
ccUser, ccWarnings, err := actor.CloudControllerClient.CreateUser(uaaUser.ID)
return User(ccUser), Warnings(ccWarnings), err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | command/v6/shared/new_networking_client.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/command/v6/shared/new_networking_client.go#L12-L40 | go | train | // NewNetworkingClient creates a new cfnetworking client. | func NewNetworkingClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) (*cfnetv1.Client, error) | // NewNetworkingClient creates a new cfnetworking client.
func NewNetworkingClient(apiURL string, config command.Config, uaaClient *uaa.Client, ui command.UI) (*cfnetv1.Client, error) | {
if apiURL == "" {
return nil, translatableerror.CFNetworkingEndpointNotFoundError{}
}
wrappers := []cfnetv1.ConnectionWrapper{}
verbose, location := config.Verbose()
if verbose {
wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerTerminalDisplay()))
}
if location != nil {
wrappers = append(wrappers, wrapper.NewRequestLogger(ui.RequestLoggerFileWriter(location)))
}
authWrapper := wrapper.NewUAAAuthentication(uaaClient, config)
wrappers = append(wrappers, authWrapper)
wrappers = append(wrappers, wrapper.NewRetryRequest(config.RequestRetryCount()))
return cfnetv1.NewClient(cfnetv1.Config{
AppName: config.BinaryName(),
AppVersion: config.BinaryVersion(),
DialTimeout: config.DialTimeout(),
SkipSSLValidation: config.SkipSSLValidation(),
URL: apiURL,
Wrappers: wrappers,
}), nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | actor/v2action/service_plan.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/actor/v2action/service_plan.go#L17-L39 | go | train | // GetServicePlansForService returns a list of plans associated with the service and the broker if provided | func (actor Actor) GetServicePlansForService(serviceName, brokerName string) ([]ServicePlan, Warnings, error) | // GetServicePlansForService returns a list of plans associated with the service and the broker if provided
func (actor Actor) GetServicePlansForService(serviceName, brokerName string) ([]ServicePlan, Warnings, error) | {
service, allWarnings, err := actor.GetServiceByNameAndBrokerName(serviceName, brokerName)
if err != nil {
return []ServicePlan{}, allWarnings, err
}
servicePlans, warnings, err := actor.CloudControllerClient.GetServicePlans(ccv2.Filter{
Type: constant.ServiceGUIDFilter,
Operator: constant.EqualOperator,
Values: []string{service.GUID},
})
allWarnings = append(allWarnings, warnings...)
if err != nil {
return []ServicePlan{}, allWarnings, err
}
var plansToReturn []ServicePlan
for _, plan := range servicePlans {
plansToReturn = append(plansToReturn, ServicePlan(plan))
}
return plansToReturn, allWarnings, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L32-L49 | go | train | // NewTable is the constructor function creating a new printable table
// from a list of headers. The table is also connected to a UI, which
// is where it will print itself to on demand. | func NewTable(headers []string) *Table | // NewTable is the constructor function creating a new printable table
// from a list of headers. The table is also connected to a UI, which
// is where it will print itself to on demand.
func NewTable(headers []string) *Table | {
pt := &Table{
headers: headers,
columnWidth: make([]int, len(headers)),
colSpacing: " ",
transformer: make([]Transformer, len(headers)),
}
// Standard colorization, column 0 is auto-highlighted as some
// name. Everything else has no transformation (== identity
// transform)
for i := range pt.transformer {
pt.transformer[i] = nop
}
if 0 < len(headers) {
pt.transformer[0] = TableContentHeaderColor
}
return pt
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L61-L63 | go | train | // SetTransformer specifies a string transformer to apply to the
// content of the given column in the specified table. | func (t *Table) SetTransformer(columnIndex int, tr Transformer) | // SetTransformer specifies a string transformer to apply to the
// content of the given column in the specified table.
func (t *Table) SetTransformer(columnIndex int, tr Transformer) | {
t.transformer[columnIndex] = tr
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L66-L68 | go | train | // Add extends the table by another row. | func (t *Table) Add(row ...string) | // Add extends the table by another row.
func (t *Table) Add(row ...string) | {
t.rows = append(t.rows, row)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L76-L118 | go | train | // PrintTo is the core functionality for printing the table, placing
// the formatted table into the writer given to it as argument. The
// exported Print() is just a wrapper around this which redirects the
// result into CF data structures.
// Once a table has been printed onto a Writer, it cannot be printed
// again. | func (t *Table) PrintTo(result io.Writer) error | // PrintTo is the core functionality for printing the table, placing
// the formatted table into the writer given to it as argument. The
// exported Print() is just a wrapper around this which redirects the
// result into CF data structures.
// Once a table has been printed onto a Writer, it cannot be printed
// again.
func (t *Table) PrintTo(result io.Writer) error | {
t.rowHeight = make([]int, len(t.rows)+1)
rowIndex := 0
if !t.headerPrinted {
// row transformer header row
err := t.calculateMaxSize(transHeader, rowIndex, t.headers)
if err != nil {
return err
}
rowIndex++
}
for _, row := range t.rows {
// table is row transformer itself, for content rows
err := t.calculateMaxSize(t, rowIndex, row)
if err != nil {
return err
}
rowIndex++
}
rowIndex = 0
if !t.headerPrinted {
err := t.printRow(result, transHeader, rowIndex, t.headers)
if err != nil {
return err
}
t.headerPrinted = true
rowIndex++
}
for row := range t.rows {
err := t.printRow(result, t, rowIndex, t.rows[row])
if err != nil {
return err
}
rowIndex++
}
t.rows = [][]string{}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L124-L175 | go | train | // calculateMaxSize iterates over the collected rows of the specified
// table, and their strings, determining the height of each row (in
// lines), and the width of each column (in characters). The results
// are stored in the table for use by Print. | func (t *Table) calculateMaxSize(transformer rowTransformer, rowIndex int, row []string) error | // calculateMaxSize iterates over the collected rows of the specified
// table, and their strings, determining the height of each row (in
// lines), and the width of each column (in characters). The results
// are stored in the table for use by Print.
func (t *Table) calculateMaxSize(transformer rowTransformer, rowIndex int, row []string) error | {
// Iterate columns
for columnIndex := range row {
// Truncate long row, ignore the additional fields.
if columnIndex >= len(t.headers) {
break
}
// Note that the length of the cell in characters is
// __not__ equivalent to its width. Because it may be
// a multi-line value. We have to split the cell into
// lines and check the width of each such fragment.
// The number of lines founds also goes into the row
// height.
lines := strings.Split(row[columnIndex], "\n")
height := len(lines)
if t.rowHeight[rowIndex] < height {
t.rowHeight[rowIndex] = height
}
for i := range lines {
// (**) See also 'printCellValue' (pCV). Here
// and there we have to apply identical
// transformations to the cell value to get
// matching cell width information. If they do
// not match then pCV may compute a cell width
// larger than the max width found here, a
// negative padding length from that, and
// subsequently return an error. What
// was further missing is trimming before
// entering the user-transform. Especially
// with color transforms any trailing space
// going in will not be removable for print.
//
// This happened for
// https://www.pivotaltracker.com/n/projects/892938/stories/117404629
value := trim(Decolorize(transformer.Transform(columnIndex, trim(lines[i]))))
width, err := visibleSize(value)
if err != nil {
return err
}
if t.columnWidth[columnIndex] < width {
t.columnWidth[columnIndex] = width
}
}
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L179-L255 | go | train | // printRow is responsible for the layouting, transforming and
// printing of the string in a single row | func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex int, row []string) error | // printRow is responsible for the layouting, transforming and
// printing of the string in a single row
func (t *Table) printRow(result io.Writer, transformer rowTransformer, rowIndex int, row []string) error | {
height := t.rowHeight[rowIndex]
// Compute the index of the last column as the min number of
// cells in the header and cells in the current row.
// Note: math.Min seems to be for float only :(
last := len(t.headers) - 1
lastr := len(row) - 1
if lastr < last {
last = lastr
}
// Note how we always print into a line buffer before placing
// the assembled line into the result. This allows us to trim
// superfluous trailing whitespace from the line before making
// it final.
if height <= 1 {
// Easy case, all cells in the row are single-line
line := &bytes.Buffer{}
for columnIndex := range row {
// Truncate long row, ignore the additional fields.
if columnIndex >= len(t.headers) {
break
}
err := t.printCellValue(line, transformer, columnIndex, last, row[columnIndex])
if err != nil {
return err
}
}
fmt.Fprintf(result, "%s\n", trim(string(line.Bytes())))
return nil
}
// We have at least one multi-line cell in this row.
// Treat it a bit like a mini-table.
// Step I. Fill the mini-table. Note how it is stored
// column-major, not row-major.
// [column][row]string
sub := make([][]string, len(t.headers))
for columnIndex := range row {
// Truncate long row, ignore the additional fields.
if columnIndex >= len(t.headers) {
break
}
sub[columnIndex] = strings.Split(row[columnIndex], "\n")
// (*) Extend the column to the full height.
for len(sub[columnIndex]) < height {
sub[columnIndex] = append(sub[columnIndex], "")
}
}
// Step II. Iterate over the rows, then columns to
// collect the output. This assumes that all
// the rows in sub are the same height. See
// (*) above where that is made true.
for rowIndex := range sub[0] {
line := &bytes.Buffer{}
for columnIndex := range sub {
err := t.printCellValue(line, transformer, columnIndex, last, sub[columnIndex][rowIndex])
if err != nil {
return err
}
}
fmt.Fprintf(result, "%s\n", trim(string(line.Bytes())))
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L259-L300 | go | train | // printCellValue pads the specified string to the width of the given
// column, adds the spacing bewtween columns, and returns the result. | func (t *Table) printCellValue(result io.Writer, transformer rowTransformer, col, last int, value string) error | // printCellValue pads the specified string to the width of the given
// column, adds the spacing bewtween columns, and returns the result.
func (t *Table) printCellValue(result io.Writer, transformer rowTransformer, col, last int, value string) error | {
value = trim(transformer.Transform(col, trim(value)))
fmt.Fprint(result, value)
// Pad all columns, but the last in this row (with the size of
// the header row limiting this). This ensures that most of
// the irrelevant spacing is not printed. At the moment
// irrelevant spacing can only occur when printing a row with
// multi-line cells, introducing a physical short line for a
// long logical row. Getting rid of that requires fixing in
// printRow.
//
// Note how the inter-column spacing is also irrelevant for
// that last column.
if col < last {
// (**) See also 'calculateMaxSize' (cMS). Here and
// there we have to apply identical transformations to
// the cell value to get matching cell width
// information. If they do not match then we may here
// compute a cell width larger than the max width
// found by cMS, derive a negative padding length from
// that, and subsequently return an error. What was
// further missing is trimming before entering the
// user-transform. Especially with color transforms
// any trailing space going in will not be removable
// for print.
//
// This happened for
// https://www.pivotaltracker.com/n/projects/892938/stories/117404629
decolorizedLength, err := visibleSize(trim(Decolorize(value)))
if err != nil {
return err
}
padlen := t.columnWidth[col] - decolorizedLength
padding := strings.Repeat(" ", padlen)
fmt.Fprint(result, padding)
fmt.Fprint(result, t.colSpacing)
}
return nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L318-L320 | go | train | // Transform performs the Header highlighting for transformHeader | func (th *transformHeader) Transform(column int, s string) string | // Transform performs the Header highlighting for transformHeader
func (th *transformHeader) Transform(column int, s string) string | {
return HeaderColor(s)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L326-L328 | go | train | // Transform makes a PrintableTable an implementation of
// rowTransformer. It performs the per-column transformation for table
// content, as specified during construction and/or overridden by the
// user of the table, see SetTransformer. | func (t *Table) Transform(column int, s string) string | // Transform makes a PrintableTable an implementation of
// rowTransformer. It performs the per-column transformation for table
// content, as specified during construction and/or overridden by the
// user of the table, see SetTransformer.
func (t *Table) Transform(column int, s string) string | {
return t.transformer[column](s)
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | cf/terminal/table.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/cf/terminal/table.go#L344-L370 | go | train | // visibleSize returns the number of columns the string will cover
// when displayed in the terminal. This is the number of runes,
// i.e. characters, not the number of bytes it consists of. | func visibleSize(s string) (int, error) | // visibleSize returns the number of columns the string will cover
// when displayed in the terminal. This is the number of runes,
// i.e. characters, not the number of bytes it consists of.
func visibleSize(s string) (int, error) | {
// This code re-implements the basic functionality of
// RuneCountInString to account for special cases. Namely
// UTF-8 characters taking up 3 bytes (**) appear as double-width.
//
// (**) I wonder if that is the set of characters outside of
// the BMP <=> the set of characters requiring surrogates (2
// slots) when encoded in UCS-2.
r := strings.NewReader(s)
var size int
for range s {
_, runeSize, err := r.ReadRune()
if err != nil {
return -1, fmt.Errorf("error when calculating visible size of: %s", s)
}
if runeSize == 3 {
size += 2 // Kanji and Katakana characters appear as double-width
} else {
size++
}
}
return size, nil
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/relationship.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L53-L66 | go | train | // DeleteIsolationSegmentOrganization will delete the relationship between
// the isolation segment and the organization provided. | func (client *Client) DeleteIsolationSegmentOrganization(isolationSegmentGUID string, orgGUID string) (Warnings, error) | // DeleteIsolationSegmentOrganization will delete the relationship between
// the isolation segment and the organization provided.
func (client *Client) DeleteIsolationSegmentOrganization(isolationSegmentGUID string, orgGUID string) (Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.DeleteIsolationSegmentRelationshipOrganizationRequest,
URIParams: internal.Params{"isolation_segment_guid": isolationSegmentGUID, "organization_guid": orgGUID},
})
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/relationship.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L70-L82 | go | train | // DeleteServiceInstanceRelationshipsSharedSpace will delete the sharing relationship
// between the service instance and the shared-to space provided. | func (client *Client) DeleteServiceInstanceRelationshipsSharedSpace(serviceInstanceGUID string, spaceGUID string) (Warnings, error) | // DeleteServiceInstanceRelationshipsSharedSpace will delete the sharing relationship
// between the service instance and the shared-to space provided.
func (client *Client) DeleteServiceInstanceRelationshipsSharedSpace(serviceInstanceGUID string, spaceGUID string) (Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.DeleteServiceInstanceRelationshipsSharedSpaceRequest,
URIParams: internal.Params{"service_instance_guid": serviceInstanceGUID, "space_guid": spaceGUID},
})
if err != nil {
return nil, err
}
response := cloudcontroller.Response{}
err = client.connection.Make(request, &response)
return response.Warnings, err
} |
cloudfoundry/cli | 5010c000047f246b870475e2c299556078cdad30 | api/cloudcontroller/ccv3/relationship.go | https://github.com/cloudfoundry/cli/blob/5010c000047f246b870475e2c299556078cdad30/api/cloudcontroller/ccv3/relationship.go#L86-L102 | go | train | // GetOrganizationDefaultIsolationSegment returns the relationship between an
// organization and it's default isolation segment. | func (client *Client) GetOrganizationDefaultIsolationSegment(orgGUID string) (Relationship, Warnings, error) | // GetOrganizationDefaultIsolationSegment returns the relationship between an
// organization and it's default isolation segment.
func (client *Client) GetOrganizationDefaultIsolationSegment(orgGUID string) (Relationship, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetOrganizationRelationshipDefaultIsolationSegmentRequest,
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#L106-L122 | go | train | // GetSpaceIsolationSegment returns the relationship between a space and it's
// isolation segment. | func (client *Client) GetSpaceIsolationSegment(spaceGUID string) (Relationship, Warnings, error) | // GetSpaceIsolationSegment returns the relationship between a space and it's
// isolation segment.
func (client *Client) GetSpaceIsolationSegment(spaceGUID string) (Relationship, Warnings, error) | {
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.GetSpaceRelationshipIsolationSegmentRequest,
URIParams: internal.Params{"space_guid": spaceGUID},
})
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#L125-L148 | go | train | // SetApplicationDroplet sets the specified droplet on the given application. | func (client *Client) SetApplicationDroplet(appGUID string, dropletGUID string) (Relationship, Warnings, error) | // SetApplicationDroplet sets the specified droplet on the given application.
func (client *Client) SetApplicationDroplet(appGUID string, dropletGUID string) (Relationship, Warnings, error) | {
relationship := Relationship{GUID: dropletGUID}
bodyBytes, err := json.Marshal(relationship)
if err != nil {
return Relationship{}, nil, err
}
request, err := client.newHTTPRequest(requestOptions{
RequestName: internal.PatchApplicationCurrentDropletRequest,
URIParams: map[string]string{"app_guid": appGUID},
Body: bytes.NewReader(bodyBytes),
})
if err != nil {
return Relationship{}, nil, err
}
var responseRelationship Relationship
response := cloudcontroller.Response{
DecodeJSONResponseInto: &responseRelationship,
}
err = client.connection.Make(request, &response)
return responseRelationship, response.Warnings, err
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.