You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2019/01/11 14:30:55 UTC

[GitHub] mdeuser closed pull request #1023: Enable programatic support for additional request headers

mdeuser closed pull request #1023: Enable programatic support for additional request headers
URL: https://github.com/apache/incubator-openwhisk-wskdeploy/pull/1023
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/deployers/whiskclient.go b/deployers/whiskclient.go
index 7d01bdac..2f5aa287 100644
--- a/deployers/whiskclient.go
+++ b/deployers/whiskclient.go
@@ -40,12 +40,13 @@ const (
 )
 
 var (
-	credential       = PropertyValue{}
-	namespace        = PropertyValue{}
-	apiHost          = PropertyValue{}
-	key              = PropertyValue{}
-	cert             = PropertyValue{}
-	apigwAccessToken = PropertyValue{}
+	credential        = PropertyValue{}
+	namespace         = PropertyValue{}
+	apiHost           = PropertyValue{}
+	key               = PropertyValue{}
+	cert              = PropertyValue{}
+	apigwAccessToken  = PropertyValue{}
+	additionalHeaders = make(http.Header)
 )
 
 type PropertyValue struct {
@@ -80,6 +81,10 @@ var CreateNewClient = func(config_input *whisk.Config) (*whisk.Client, error) {
 	return whisk.NewClient(netClient, config_input)
 }
 
+func AddAdditionalHeader(hdrName string, hdrValue string) {
+	additionalHeaders.Add(hdrName, hdrValue)
+}
+
 func resetWhiskConfig() {
 	credential = PropertyValue{}
 	namespace = PropertyValue{}
@@ -223,14 +228,15 @@ func NewWhiskConfig(proppath string, deploymentPath string, manifestPath string)
 	}
 
 	clientConfig = &whisk.Config{
-		AuthToken:        credential.Value, //Authtoken
-		Namespace:        namespace.Value,  //Namespace
-		Host:             apiHost.Value,
-		Version:          "v1", // TODO() should not be hardcoded, should warn user of default
-		Cert:             cert.Value,
-		Key:              key.Value,
-		Insecure:         mode, // true if you want to ignore certificate signing
-		ApigwAccessToken: apigwAccessToken.Value,
+		AuthToken:         credential.Value, //Authtoken
+		Namespace:         namespace.Value,  //Namespace
+		Host:              apiHost.Value,
+		Version:           "v1", // TODO() should not be hardcoded, should warn user of default
+		Cert:              cert.Value,
+		Key:               key.Value,
+		Insecure:          mode, // true if you want to ignore certificate signing
+		ApigwAccessToken:  apigwAccessToken.Value,
+		AdditionalHeaders: additionalHeaders,
 	}
 
 	// validate we have credential, apihost and namespace
diff --git a/deployers/whiskclient_test.go b/deployers/whiskclient_test.go
index 7f23378b..4e7477fd 100644
--- a/deployers/whiskclient_test.go
+++ b/deployers/whiskclient_test.go
@@ -273,3 +273,14 @@ func TestValidateClientConfig(t *testing.T) {
 
 	// TODO() test remainder of validateClientConfig() processing
 }
+
+func TestNewWhiskConfigWithAdditionalHeaders(t *testing.T) {
+	propPath := ""
+	manifestPath := ""
+	deploymentPath := ""
+	newHeader := "NewHeader"
+	newHeaderValue := "NewValue"
+	AddAdditionalHeader(newHeader, newHeaderValue)
+	config, _ := NewWhiskConfig(propPath, deploymentPath, manifestPath)
+	assert.Equal(t, newHeaderValue, config.AdditionalHeaders.Get(newHeader), "Failed to set an addtional header")
+}


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services