Skip to content

Commit

Permalink
Added the changes suggested in the pull request.
Browse files Browse the repository at this point in the history
- Errors no longer overwrite, they bubble up
- Files are now checked for existance before reading

[#89843658]
  • Loading branch information
mmb committed May 29, 2015
1 parent dd5eed9 commit 2e57610
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 42 deletions.
14 changes: 11 additions & 3 deletions cf/commands/service/bind_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,16 @@ func (cmd *BindService) Metadata() command_metadata.CommandMetadata {
}
EXAMPLE:
CF_NAME bind-service myapp mydb -c '{"permissions":"read-only"}'
CF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json`),
Linux/Mac:
CF_NAME bind-service myapp mydb -c '{"permissions":"read-only"}'
Windows Command Line
CF_NAME bind-service myapp mydb -c "{\"permissions\":\"read-only\"}"
Windows PowerShell
CF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'
CF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json`),
Flags: []cli.Flag{
flag_helpers.NewStringFlag("c", T("Valid JSON object containing service-specific configuration parameters, provided either in-line or in a file. For a list of supported configuration parameters, see documentation for the particular service offering.")),
},
Expand Down Expand Up @@ -92,7 +100,7 @@ func (cmd *BindService) Run(c *cli.Context) {

paramsMap, err := json.ParseJsonFromFileOrString(params)
if err != nil {
cmd.ui.Failed("Invalid JSON provided in -c argument")
cmd.ui.Failed("Invalid JSON provided in -c argument: " + err.Error())
}

cmd.ui.Say(T("Binding service {{.ServiceInstanceName}} to app {{.AppName}} in org {{.OrgName}} / space {{.SpaceName}} as {{.CurrentUser}}...",
Expand Down
2 changes: 1 addition & 1 deletion cf/commands/service/bind_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ var _ = Describe("bind-service command", func() {

Expect(ui.Outputs).To(ContainSubstrings(
[]string{"FAILED"},
[]string{"Invalid JSON provided in -c argument"},
[]string{"Invalid JSON provided in -c argument: Incorrect json format: invalid character 'b' looking for beginning of value"},
))
})
})
Expand Down
12 changes: 10 additions & 2 deletions cf/commands/service/create_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ func (cmd CreateService) Metadata() command_metadata.CommandMetadata {
}
EXAMPLE:
CF_NAME create-service db-service silver mydb -c '{"ram_gb":4}'
CF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json
Linux/Mac:
CF_NAME create-service db-service silver -c '{"ram_gb":4}'
Windows Command Line
CF_NAME create-service db-service silver -c "{\"ram_gb\":4}"
Windows PowerShell
CF_NAME create-service db-service silver -c '{\"ram_gb\":4}'
CF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json
TIP:
Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps`),
Expand Down
8 changes: 4 additions & 4 deletions cf/i18n/resources/de_DE.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@
"modified": false
},
{
"id": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n CF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"translation": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n CF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"id": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n\n\tWindows Command Line\n\t\tCF_NAME bind-service myapp mydb -c \"{\\\"permissions\\\":\\\"read-only\\\"}\"\n\n\tWindows PowerShell\n\t\tCF_NAME bind-service myapp mydb -c '{\\\"permissions\\\":\\\"read-only\\\"}'\n\t\n\tCF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"translation": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n\n\tWindows Command Line\n\t\tCF_NAME bind-service myapp mydb -c \"{\\\"permissions\\\":\\\"read-only\\\"}\"\n\n\tWindows PowerShell\n\t\tCF_NAME bind-service myapp mydb -c '{\\\"permissions\\\":\\\"read-only\\\"}'\n\t\n\tCF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"modified": false
},
{
Expand Down Expand Up @@ -635,8 +635,8 @@
"modified": false
},
{
"id": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME create-service db-service silver mydb -c '{\"ram_gb\":4}'\n CF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"translation": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME create-service db-service silver mydb -c '{\"ram_gb\":4}'\n CF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"id": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME create-service db-service silver -c '{\"ram_gb\":4}'\n\n\tWindows Command Line\n\t\tCF_NAME create-service db-service silver -c \"{\\\"ram_gb\\\":4}\"\n\n\tWindows PowerShell\n\t\tCF_NAME create-service db-service silver -c '{\\\"ram_gb\\\":4}'\n\n\tCF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"translation": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME create-service db-service silver -c '{\"ram_gb\":4}'\n\n\tWindows Command Line\n\t\tCF_NAME create-service db-service silver -c \"{\\\"ram_gb\\\":4}\"\n\n\tWindows PowerShell\n\t\tCF_NAME create-service db-service silver -c '{\\\"ram_gb\\\":4}'\n\n\tCF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"modified": false
},
{
Expand Down
8 changes: 4 additions & 4 deletions cf/i18n/resources/en_US.all.json
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@
"modified": false
},
{
"id": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n CF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"translation": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n CF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"id": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n\n\tWindows Command Line\n\t\tCF_NAME bind-service myapp mydb -c \"{\\\"permissions\\\":\\\"read-only\\\"}\"\n\n\tWindows PowerShell\n\t\tCF_NAME bind-service myapp mydb -c '{\\\"permissions\\\":\\\"read-only\\\"}'\n\t\n\tCF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"translation": "CF_NAME bind-service APP_NAME SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME bind-service APP_NAME SERVICE_INSTANCE -c PATH_TO_FILE\n\n Example of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME bind-service myapp mydb -c '{\"permissions\":\"read-only\"}'\n\n\tWindows Command Line\n\t\tCF_NAME bind-service myapp mydb -c \"{\\\"permissions\\\":\\\"read-only\\\"}\"\n\n\tWindows PowerShell\n\t\tCF_NAME bind-service myapp mydb -c '{\\\"permissions\\\":\\\"read-only\\\"}'\n\t\n\tCF_NAME bind-service myapp mydb -c ~/workspace/tmp/instance_config.json",
"modified": false
},
{
Expand Down Expand Up @@ -635,8 +635,8 @@
"modified": false
},
{
"id": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME create-service db-service silver mydb -c '{\"ram_gb\":4}'\n CF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"translation": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n CF_NAME create-service db-service silver mydb -c '{\"ram_gb\":4}'\n CF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"id": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME create-service db-service silver -c '{\"ram_gb\":4}'\n\n\tWindows Command Line\n\t\tCF_NAME create-service db-service silver -c \"{\\\"ram_gb\\\":4}\"\n\n\tWindows PowerShell\n\t\tCF_NAME create-service db-service silver -c '{\\\"ram_gb\\\":4}'\n\n\tCF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"translation": "CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE [-c PARAMETERS_AS_JSON]\n\n Optionally provide service-specific configuration parameters in a valid JSON object in-line:\n CF_NAME create-service SERVICE PLAN SERVICE_INSTANCE -c '{\"name\":\"value\",\"name\":\"value\"}'\n\n Optionally provide a file containing service-specific configuration parameters in a valid JSON object. The path to the parameters file can be an absolute or relative path to a file.\n CF_NAME create-service SERVICE_INSTANCE -c PATH_TO_FILE\n\n\tExample of valid JSON object:\n {\n \"cluster_nodes\": {\n \"count\": 5,\n \"memory_mb\": 1024\n }\n }\n\nEXAMPLE:\n\tLinux/Mac:\n\t\tCF_NAME create-service db-service silver -c '{\"ram_gb\":4}'\n\n\tWindows Command Line\n\t\tCF_NAME create-service db-service silver -c \"{\\\"ram_gb\\\":4}\"\n\n\tWindows PowerShell\n\t\tCF_NAME create-service db-service silver -c '{\\\"ram_gb\\\":4}'\n\n\tCF_NAME create-service db-service silver mydb -c ~/workspace/tmp/instance_config.json\n\nTIP:\n Use 'CF_NAME create-user-provided-service' to make user-provided services available to cf apps",
"modified": false
},
{
Expand Down
Loading

0 comments on commit 2e57610

Please sign in to comment.