Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

BREAKING CHANGE: private repository moved to public github. #2

Merged
merged 34 commits into from
Jul 30, 2018

Conversation

adamcbrown
Copy link
Contributor

Co-authored-by: sydney-ng sydney.ng@yahoo.com

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

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

Copy link

@jkingoliver jkingoliver left a 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.

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

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"

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"
]

Copy link
Contributor Author

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

Copy link

@jkingoliver jkingoliver Jul 24, 2018

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())

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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

}
}

func TestCFServiceCredentialsWithInstanceNameV1 (t *testing.T){

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?

t.Errorf("can't read " + result2.String() + " text from GetDictionary()")
}

//removed this test because there wasn't a cf_var4 in mappings.json

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

import (
"testing"
"os"
//"fmt"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

}
}

func TestCFServiceCredentialsWithServiceInstanceV2 (t *testing.T){

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?

t.Errorf("can't read " + result2 + " text from GetDictionary()")
}

//removed this test because there wasn't a cf_var4 in mappings.json

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.

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.

Copy link
Contributor Author

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.

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

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

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

cloud_env.go Outdated
package IBMCloudEnv

import ("os"
"fmt"

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

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 {

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.

Copy link
Contributor Author

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

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

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

Copy link

@jkingoliver jkingoliver left a 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")

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

@jkingoliver jkingoliver merged commit f4bcbfc into ibm-developer:master Jul 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants