-
Notifications
You must be signed in to change notification settings - Fork 3
BREAKING CHANGE: private repository moved to public github. #2
Conversation
Co-authored-by: sydney-ng <sydney.ng@yahoo.com>
main_test.go
Outdated
t.Errorf("can't read " + result2.String() + " text from GetDictionary()") | ||
} | ||
|
||
//removed this test because there wasn't a cf_var4 in mappings.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure to delete this block before merging
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to add the sample mappings.json that includes user-provided search pattern. Check out here:
https://github.com/ibm-developer/ibm-cloud-env/blob/179d3522ac5e764c46d44c693f45a6cb4eca50cd/test/test.js#L12
how the v1/mappings.json is included for testing.
Also, the README needs to be updated to include user-provided search pattern with samples. I realize the ibm-cloud-env repo that is used for node needs to be updated as well. That's on my todo list and I can help with this one.
…object. Added test for GetCredentials function
README.md
Outdated
- Using `cloudfoundry` allows to search for values in VCAP_SERVICES and VCAP_APPLICATIONS environment variables | ||
- Using `env` allows to search for values in environment variables | ||
- Using `file` allows to search for values in text/json files | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add user-provided pattern here too
added user-provided description in supported search patterns types
README.md
Outdated
"env:my-service2-credentials:$.username", | ||
"file:/localdev/my-service1-credentials.json:$.username", | ||
"user-provided:my-service2-instance-name:username" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the above 2 sample search patterns, please add user-provided
to both and put that entry in the first spot. The patterns are read in order and should go in this order:
"searchPatterns": [
"user-provided:conversation:url",
"cloudfoundry:$['conversation'][0].credentials.url",
"env:service_watson_conversation:$.url",
"file:/server/localdev-config.json:$.watson_conversation_url"
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not sure how to use user-provided for the first example. The first example grabs all the credentials, but user-provided can only grab a specific credential, not the entire thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would probably look like this:
"service1-credentials": {
"searchPatterns": [
"user-provided:my-service1-instance-name:service1-credentials"
"cloudfoundry:my-service1-instance-name",
"env:my-service1-credentials",
"file:/localdev/my-service1-credentials.json"
]
},
"service2-username": {
"searchPatterns":[
---> "user-provided:my-service2-instance-name:username"
"cloudfoundry:$.service2[@.name=='my-service2-instance-name'].credentials.username",
"env:my-service2-credentials:$.username",
"file:/localdev/my-service1-credentials.json:$.username",
cloud_env.go
Outdated
func processMappingV2(mappingName string, config gjson.Result){ | ||
config.ForEach(func (key, value gjson.Result) bool { | ||
searchPatterns := value.Get("searchPatterns") | ||
//fmt.Println("search Patterns: " + searchPatterns.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
cloud_env.go
Outdated
var json_data interface{} | ||
json.Unmarshal([]byte(jsonString), &json_data) | ||
res, err := jsonpath.JsonPathLookup(json_data, jsonPath) | ||
// fmt.Println("HERE: ", jsonPath, jsonString, res, err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
mappingsV1_test.go
Outdated
} | ||
} | ||
|
||
func TestCFServiceCredentialsWithInstanceNameV1 (t *testing.T){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this comment need to go or is this method still being worked on?
mappingsV1_test.go
Outdated
t.Errorf("can't read " + result2.String() + " text from GetDictionary()") | ||
} | ||
|
||
//removed this test because there wasn't a cf_var4 in mappings.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
mappings_test.go
Outdated
t.Errorf("can't read " + result2.String() + " text from GetDictionary()") | ||
} | ||
|
||
//removed this test because there wasn't a cf_var4 in mappings.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
mappingsv2_test.go
Outdated
import ( | ||
"testing" | ||
"os" | ||
//"fmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
mappingsv2_test.go
Outdated
} | ||
} | ||
|
||
func TestCFServiceCredentialsWithServiceInstanceV2 (t *testing.T){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this function name orange and the other functions are in purple? Is it because of the space between V2 and the parameters?
mappingsv2_test.go
Outdated
t.Errorf("can't read " + result2 + " text from GetDictionary()") | ||
} | ||
|
||
//removed this test because there wasn't a cf_var4 in mappings.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove comment
README.md
Outdated
IBM Cloud Environment for Go | ||
# IBM Cloud Environment | ||
|
||
The `ibm-cloud-env-golang` module allows to abstract environment variables from various Cloud compute providers, such as, but not limited to, CloudFoundry and Kubernetes, so the application could be environment-agnostic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rephrase: The ibm-cloud-env-golang
module allows for the abstraction of environment variables from various Cloud compute providers, such as, but not limited to, CloudFoundry and Kubernetes, so the application can be environment-agnostic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're not sure how to rephrase this. This paragraph was taken from the IBM-Cloud-Env repositiory
README.md
Outdated
|
||
The `ibm-cloud-env-golang` module allows to abstract environment variables from various Cloud compute providers, such as, but not limited to, CloudFoundry and Kubernetes, so the application could be environment-agnostic. | ||
|
||
The module allows to define an array of search patterns that will be executed one by one until required value is found. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rephrase: The module allows for an array of search patterns that will be executed one by one until required value is found.
README.md
Outdated
- Using `cloudfoundry` allows to search for values in VCAP_SERVICES and VCAP_APPLICATIONS environment variables | ||
- Using `env` allows to search for values in environment variables | ||
- Using `file` allows to search for values in text/json files | ||
- Using `user-provided` allows to search for values in VCAP_SERVICES for service credentials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to line 26, so it's first. Also, rearrange the list in line 25 so user-provided is first.
README.md
Outdated
- env:env-var-name:$.JSONPath - attempts to parse the environment variable "env-var-name" and return a value that corresponds to JSONPath | ||
- file:/server/config.text - returns content of /server/config.text file | ||
- file:/server/config.json:$.JSONPath - reads the content of /server/config.json file, tries to parse it, returns the value that corresponds to JSONPath | ||
- user-provided:service:name - searches through parsed VCAP_SERVICES environment variable and returns the value of the requested service name and credential |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to line 32 so it's first in list
Fixed wording from Pull Request ibm-developer#3
cloud_env.go
Outdated
package IBMCloudEnv | ||
|
||
import ("os" | ||
"fmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix indentation in this import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this whole file needs to be formatted so indentations are consistent and correct.
cloud_env.go
Outdated
} | ||
|
||
func processMappingV2(mappingName string, config gjson.Result){ | ||
config.ForEach(func (key, value gjson.Result) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this syntax right? I'm not familiar, but it looks weird that the bool return type isn't on line 94.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually fine. How that ForEach function works is that it takes a lambda function with a bool return type, so those return bools are for those ForEach lambda functions, not the processMappingV2
README.md
Outdated
- Using `file` allows to search for values in text/json files | ||
|
||
#### Example search patterns | ||
- user-provided:service:name - searches through parsed VCAP_SERVICES environment variable and returns the value of the requested service name and credential |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's make this user-provided:service-instance-name:credential-key
@@ -0,0 +1,45 @@ | |||
package IBMCloudEnv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a copyright statement here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comments
cloud_env.go
Outdated
case PREFIX_PATTERN_USER: | ||
value, OK = processUserProvidedSearchPattern(patternComponents) | ||
break | ||
default: | ||
log.Warnln("Unknown searchPattern prefix", patternComponents[0], "Supported prefixes: cloudfoundry, env, file") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add user-provided in the warning about supported prefixes
Co-authored-by: sydney-ng sydney.ng@yahoo.com