Skip to content

Commit

Permalink
Introducing include and exclude in zip action (#991)
Browse files Browse the repository at this point in the history
* adding include in yaml parser

* wip include

* wip

* wip - dir level include

* wip - dir level include

* wip - dir level include

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* include

* deleting debugging statement

* cleaning up

* adding unit test

* adding unit test

* wip

* refactoring

* wip

* wip

* wip

* wip

* adding more unit tests

* fixing unit test

* fixing unit test

* fixing unit test

* adding exclude

* fixing unit test

* adding warning

* adding exclude

* refactoring exclude code

* adding exclude test case

* exclude integration test

* cleaning up

* adding wski18 strings
  • Loading branch information
pritidesai committed Oct 16, 2018
1 parent 4ad4b9c commit 3092f1f
Show file tree
Hide file tree
Showing 48 changed files with 1,283 additions and 95 deletions.
2 changes: 1 addition & 1 deletion parsers/manifest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ func (dm *YAMLParser) readActionFunction(manifestFilePath string, manifestFileNa

if utils.IsDirectory(actionFilePath) {
zipFileName = actionFilePath + "." + runtimes.ZIP_FILE_EXTENSION
err := utils.NewZipWritter(actionFilePath, zipFileName).Zip()
err := utils.NewZipWritter(actionFilePath, zipFileName, action.Include, action.Exclude, filepath.Dir(manifestFilePath)).Zip()
if err != nil {
return actionFilePath, nil, err
}
Expand Down
4 changes: 2 additions & 2 deletions parsers/yamlparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ type Action struct {
Inputs map[string]Parameter `yaml:"inputs"`
Outputs map[string]Parameter `yaml:"outputs"`
Annotations map[string]interface{} `yaml:"annotations,omitempty"`
// TODO() this is propoagated from package to every action within that package
//Parameters map[string]interface{} `yaml:parameters`
Include [][]string `yaml:"include,omitempty"`
Exclude []string `yaml:"exclude,omitempty"`
}

type Limits struct {
Expand Down
13 changes: 13 additions & 0 deletions tests/dat/manifest_validate_inputs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

packages:
helloworld:
actions:
helloNodejs:
function: actions/
runtime: nodejs:6
include:
- ["actions/hello.js"]
- ["actions/hello.js", "actions/hello.js"]
- ["actions/hello.js", "actions/hello.js", "actions/hello.js"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

const hello = "Hello Dear";

module.exports = {
hello: hello
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common = require('./common/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
21 changes: 21 additions & 0 deletions tests/src/integration/zipactionwithexclude/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common = require('./common/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

const hello = "Hello Dear";

module.exports = {
hello: hello
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

const hello = "Hello Dear";

module.exports = {
hello: hello
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

const hello = "Hello Dear";

module.exports = {
hello: hello
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
18 changes: 18 additions & 0 deletions tests/src/integration/zipactionwithexclude/manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one or more contributor
# license agreements; and to You under the Apache License, Version 2.0.

packages:
zipactionwithexclude:
version: 1.0
license: Apache-2.0
actions:
greeting1:
function: actions
runtime: nodejs:6
exclude:
- actions/*
include:
- ["actions/common/utils.js", "common/utils.js"]
- ["actions/index.js", "index.js"]
- ["actions/package.json", "package.json"]

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// +build integration

/*
* 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 tests

import (
"github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/common"
"github.com/stretchr/testify/assert"
"os"
"testing"
)

func TestZipActionWithExclude(t *testing.T) {
wskdeploy := common.NewWskdeploy()
_, err := wskdeploy.Deploy(manifestPath, deploymentPath)
assert.Equal(t, nil, err, "Failed to deploy based on the manifest and deployment files.")
_, err = wskdeploy.Undeploy(manifestPath, deploymentPath)
assert.Equal(t, nil, err, "Failed to undeploy based on the manifest and deployment files.")
}

var (
manifestPath = os.Getenv("GOPATH") + "/src/github.com/apache/incubator-openwhisk-wskdeploy/tests/src/integration/zipactionwithexclude/manifest.yml"
deploymentPath = ""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

const hello = "Hello Dear";

module.exports = {
hello: hello
};

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common = require('./actions/common/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var lib1 = require('./actions/libs/lib1/utils.js')
var lib2 = require('./actions/libs/lib2/utils.js')
var lib3 = require('./actions/libs/lib3/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = lib1.hello || lib2.hello || lib3.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common1 = require('./common/utils.js')
var common2 = require('./common/common1/utils.js')
var common3 = require('./common/common1/copyUtils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common1.hello || common2.hello || common3.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common1 = require('./common/utils.js')
var common2 = require('./common/common1/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common1.hello || common2.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common = require('./common/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the Apache Software Foundation (ASF) under one or more contributor
// license agreements; and to You under the Apache License, Version 2.0.

/**
* Return a simple greeting message for someone.
*
* @param name A person's name.
* @param place Where the person is from.
*/


var common = require('./common/utils.js')

function main(params) {
var name = params.name || params.payload || 'stranger';
var place = params.place || 'somewhere';
var hello = common.hello || 'Hello';
return {payload: hello + ', ' + name + ' from ' + place + '!'};
}
exports.main = main;

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "my-action",
"main": "index.js",
"dependencies" : {
}
}
Loading

0 comments on commit 3092f1f

Please sign in to comment.