Skip to content

Commit

Permalink
Merge pull request apache#20 from lzbj/development
Browse files Browse the repository at this point in the history
Add travis CI support as minimum gate.
  • Loading branch information
paulcastro authored Nov 3, 2016
2 parents 89b11c3 + 89252c7 commit 74b626d
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 88 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# A Travis CI configuration file.

language: go

go:
- 1.7

install:
- go get -u github.com/golang/lint/golint

script:
- make lint
- make build
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ format:
@echo "Formatting"
go fmt ./...

lint:
lint: format
@echo "Linting"
golint .

Expand Down
2 changes: 1 addition & 1 deletion cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package cmd

import (
"fmt"
"github.com/spf13/cobra"
"github.com/openwhisk/wsktool/utils"
"github.com/spf13/cobra"
yaml "gopkg.in/yaml.v2"
"io/ioutil"
"os"
Expand Down
164 changes: 82 additions & 82 deletions cmd/servicedeployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* 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 cmd

import (
"fmt"
"github.com/openwhisk/wsktool/utils"
"github.com/openwhisk/go-whisk/whisk"
"github.com/openwhisk/wsktool/utils"
"io/ioutil"
"net/http"
"os"
Expand Down Expand Up @@ -81,103 +81,103 @@ func (deployer *ServiceDeployer) ReadDirectory(directoryPath string) error {
}
err = deployer.CreatePackageFromDirectory(baseName)

} else {
err = deployer.CreateActionFromFile(filePath)
}
} else {
err = deployer.CreateActionFromFile(filePath)
}
return err
})
}
return err
})

utils.Check(err)
return nil
}
utils.Check(err)
return nil
}

func (deployer *ServiceDeployer) CreatePackageFromDirectory(directoryName string) error {
fmt.Println("Making a package ", directoryName)
return nil
}
func (deployer *ServiceDeployer) CreatePackageFromDirectory(directoryName string) error {
fmt.Println("Making a package ", directoryName)
return nil
}

func (deployer *ServiceDeployer) CreateActionFromFile(filePath string) error {
ext := path.Ext(filePath)
baseName := path.Base(filePath)
name := strings.TrimSuffix(baseName, filepath.Ext(baseName))
func (deployer *ServiceDeployer) CreateActionFromFile(filePath string) error {
ext := path.Ext(filePath)
baseName := path.Base(filePath)
name := strings.TrimSuffix(baseName, filepath.Ext(baseName))

// process source code files
if ext == ".swift" || ext == ".js" || ext == ".py" {
// process source code files
if ext == ".swift" || ext == ".js" || ext == ".py" {

if _, ok := deployer.actions[name]; ok {
return fmt.Errorf("Found a duplicate name %s when scanning file directory", name)
if _, ok := deployer.actions[name]; ok {
return fmt.Errorf("Found a duplicate name %s when scanning file directory", name)

} else {
} else {

kind := "nodejs:default"
kind := "nodejs:default"

switch ext {
case ".swift":
kind = "swift:default"
case ".js":
kind = "nodejs:default"
case ".py":
kind = "python"
}
switch ext {
case ".swift":
kind = "swift:default"
case ".js":
kind = "nodejs:default"
case ".py":
kind = "python"
}

dat, err := ioutil.ReadFile(filePath)
utils.Check(err)
dat, err := ioutil.ReadFile(filePath)
utils.Check(err)

action := new(whisk.Action)
action.Exec = new(whisk.Exec)
action.Exec.Code = string(dat)
action.Exec.Kind = kind
action.Name = name
action.Publish = false
action := new(whisk.Action)
action.Exec = new(whisk.Exec)
action.Exec.Code = string(dat)
action.Exec.Kind = kind
action.Name = name
action.Publish = false

deployer.actions[name] = action
}
}
return nil
deployer.actions[name] = action
}
}
return nil
}

// DeployActions into OpenWhisk
func (deployer *ServiceDeployer) DeployActions() error {
// DeployActions into OpenWhisk
func (deployer *ServiceDeployer) DeployActions() error {

for _, action := range deployer.actions {
fmt.Println("Got action ", action.Exec.Code)
deployer.createAction(action)
}
return nil
}
for _, action := range deployer.actions {
fmt.Println("Got action ", action.Exec.Code)
deployer.createAction(action)
}
return nil
}

// Utility function to call go-whisk framework to make action
func (deployer *ServiceDeployer) createAction(action *whisk.Action) {
// Utility function to call go-whisk framework to make action
func (deployer *ServiceDeployer) createAction(action *whisk.Action) {

baseURL, err := utils.GetURLBase(deployer.apihost)
if err != nil {
fmt.Println("Got error making baseUrl ", err)
}
baseURL, err := utils.GetURLBase(deployer.apihost)
if err != nil {
fmt.Println("Got error making baseUrl ", err)
}

clientConfig := &whisk.Config{
AuthToken: deployer.authtoken,
Namespace: deployer.namespace,
BaseURL: baseURL,
Version: "v1",
Insecure: false, // true if you want to ignore certificate signing
}
clientConfig := &whisk.Config{
AuthToken: deployer.authtoken,
Namespace: deployer.namespace,
BaseURL: baseURL,
Version: "v1",
Insecure: false, // true if you want to ignore certificate signing
}

// Setup network client
client, err := whisk.NewClient(http.DefaultClient, clientConfig)
if err != nil {
fmt.Println("Got error making whisk client ", err)
}
// Setup network client
client, err := whisk.NewClient(http.DefaultClient, clientConfig)
if err != nil {
fmt.Println("Got error making whisk client ", err)
}

action.Namespace = deployer.namespace
action.Publish = false
// action.Parameters =
// action.Annotations =
// action.Limits =

// call ActionService Thru Client
_, _, err = client.Actions.Insert(action, false, true)
if err != nil {
fmt.Println("Got error inserting action ", err)
}
}
action.Namespace = deployer.namespace
action.Publish = false
// action.Parameters =
// action.Annotations =
// action.Limits =

// call ActionService Thru Client
_, _, err = client.Actions.Insert(action, false, true)
if err != nil {
fmt.Println("Got error inserting action ", err)
}
}
2 changes: 1 addition & 1 deletion tests/deployment_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tests

import (
"../utils"
"github.com/openwhisk/wsktool/utils"
"io/ioutil"
"testing"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/util_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tests

import (
"../utils"
"github.com/openwhisk/wsktool/utils"
"testing"
)

Expand Down
3 changes: 1 addition & 2 deletions utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package utils

import (
"bufio"
"io/ioutil"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -106,7 +106,6 @@ func GetURLBase(host string) (*url.URL, error) {
return url, err
}


func ReadProps(path string) (map[string]string, error) {

props := map[string]string{}
Expand Down

0 comments on commit 74b626d

Please sign in to comment.