You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by da...@apache.org on 2017/07/03 09:14:13 UTC

[incubator-openwhisk-wskdeploy] branch master updated: Remove duplicated code of configurations. (#280)

This is an automated email from the ASF dual-hosted git repository.

daisyguo pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk-wskdeploy.git


The following commit(s) were added to refs/heads/master by this push:
     new 318abbb  Remove duplicated code of configurations. (#280)
318abbb is described below

commit 318abbb8a02859c2df65bc6f815ec5d11fd9a599
Author: David Liu <da...@cn.ibm.com>
AuthorDate: Mon Jul 3 17:14:11 2017 +0800

    Remove duplicated code of configurations. (#280)
    
    Remove clientconfiguration.go and use whisk.Config instead
---
 config/clientconfiguration.go | 72 -------------------------------------------
 deployers/manifestreader.go   |  5 +--
 2 files changed, 3 insertions(+), 74 deletions(-)

diff --git a/config/clientconfiguration.go b/config/clientconfiguration.go
deleted file mode 100644
index 583728d..0000000
--- a/config/clientconfiguration.go
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package config
-
-import (
-	"bufio"
-	"fmt"
-	"os"
-	"strings"
-
-	"github.com/apache/incubator-openwhisk-client-go/whisk"
-	"github.com/apache/incubator-openwhisk-wskdeploy/utils"
-)
-
-var ClientConfig *whisk.Config
-
-// Load configuration will load properties from a file
-func LoadConfiguration(propPath string) ([]string, error) {
-	props, err := ReadProps(propPath)
-	utils.Check(err)
-	Namespace := props["NAMESPACE"]
-	Apihost := props["APIHOST"]
-	Authtoken := props["AUTH"]
-	return []string{Namespace, Apihost, Authtoken}, nil
-}
-
-func ReadProps(path string) (map[string]string, error) {
-
-	props := map[string]string{}
-
-	file, err := os.Open(path)
-	if err != nil {
-		// If file does not exist, just return props
-		fmt.Printf("Unable to read whisk properties file '%s' (file open error: %s); falling back to default properties\n", path, err)
-		return props, nil
-	}
-	defer file.Close()
-
-	lines := []string{}
-	scanner := bufio.NewScanner(file)
-	for scanner.Scan() {
-		lines = append(lines, scanner.Text())
-	}
-
-	props = map[string]string{}
-	for _, line := range lines {
-		kv := strings.Split(line, "=")
-		if len(kv) != 2 {
-			// Invalid format; skip
-			continue
-		}
-		props[kv[0]] = kv[1]
-	}
-
-	return props, nil
-
-}
diff --git a/deployers/manifestreader.go b/deployers/manifestreader.go
index 7de9bb6..c31faf4 100644
--- a/deployers/manifestreader.go
+++ b/deployers/manifestreader.go
@@ -23,11 +23,12 @@ import (
 	"strings"
 
 	"github.com/apache/incubator-openwhisk-client-go/whisk"
-	"github.com/apache/incubator-openwhisk-wskdeploy/config"
 	"github.com/apache/incubator-openwhisk-wskdeploy/parsers"
 	"github.com/apache/incubator-openwhisk-wskdeploy/utils"
 )
 
+var clientConfig *whisk.Config
+
 type ManifestReader struct {
 	serviceDeployer *ServiceDeployer
 	IsUndeploy      bool
@@ -329,7 +330,7 @@ func (deployer *ManifestReader) getQualifiedName(name string, namespace string)
 		return fmt.Sprintf("%s/%s", namespace, name)
 	} else {
 		if len(namespace) == 0 {
-			namespace = config.ClientConfig.Namespace
+			namespace = clientConfig.Namespace
 		}
 		return fmt.Sprintf("/%s/%s", namespace, name)
 	}

-- 
To stop receiving notification emails like this one, please contact
['"commits@openwhisk.apache.org" <co...@openwhisk.apache.org>'].