Skip to content

Commit

Permalink
feat!: rename event templates to 'cloudevents' (#584)
Browse files Browse the repository at this point in the history
* feat!: rename event templates to 'cloudevents'

This commit renames the templates for cloudevents to be named "cloudevents".

BREAKING CHANGE

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: update commands.md doc

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: fix make test-templates

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: missed an e2e test change

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: gitignore and pkged.go

Signed-off-by: Lance Ball <lball@redhat.com>

* fixup: adjust Makefile recipe for pkged.go

Signed-off-by: Lance Ball <lball@redhat.com>
  • Loading branch information
lance authored Oct 13, 2021
1 parent d2ee140 commit 68b0904
Show file tree
Hide file tree
Showing 76 changed files with 75 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/func
/func_*
/templates/go/events/go.sum
/templates/go/cloudevents/go.sum
/templates/go/http/go.sum
/templates/typescript/events/build
/templates/typescript/cloudevents/build
/templates/typescript/http/build
/coverage.out
/bin
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ bin/golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.40.1

pkged.go: $(TEMPLATES)
@rm -rf templates/node/events/node_modules
@rm -rf templates/node/cloudevents/node_modules
@rm -rf templates/node/http/node_modules
@rm -rf templates/python/events/__pycache__
@rm -rf templates/python/cloudevents/__pycache__
@rm -rf templates/python/http/__pycache__
@rm -rf templates/typescript/events/node_modules
@rm -rf templates/typescript/cloudevents/node_modules
@rm -rf templates/typescript/http/node_modules
@rm -rf templates/rust/events/target
@rm -rf templates/rust/cloudevents/target
@rm -rf templates/rust/http/target
@rm -rf templates/quarkus/events/target
@rm -rf templates/quarkus/cloudevents/target
@rm -rf templates/quarkus/http/target
@rm -rf templates/springboot/events/target
@rm -rf templates/springboot/cloudevents/target
@rm -rf templates/springboot/http/target
# Generating pkged.go using pkger
$(PKGER)
Expand All @@ -91,27 +91,27 @@ clean: ## Remove generated artifacts such as binaries and schemas
test-templates: test-go test-node test-python test-quarkus test-rust test-typescript ## Run all template tests

test-go: ## Test Go templates
cd templates/go/events && go test
cd templates/go/cloudevents && go test
cd templates/go/http && go test

test-node: ## Test Node templates
cd templates/node/events && npm ci && npm test && rm -rf node_modules
cd templates/node/cloudevents && npm ci && npm test && rm -rf node_modules
cd templates/node/http && npm ci && npm test && rm -rf node_modules

test-python: ## Test Python templates
cd templates/python/events && pip3 install -r requirements.txt && python3 test_func.py && rm -rf __pycache__
cd templates/python/cloudevents && pip3 install -r requirements.txt && python3 test_func.py && rm -rf __pycache__
cd templates/python/http && python3 test_func.py && rm -rf __pycache__

test-quarkus: ## Test Quarkus templates
cd templates/quarkus/events && mvn test && mvn clean
cd templates/quarkus/cloudevents && mvn test && mvn clean
cd templates/quarkus/http && mvn test && mvn clean

test-rust: ## Test Rust templates
cd templates/rust/events && cargo test && cargo clean
cd templates/rust/cloudevents && cargo test && cargo clean
cd templates/rust/http && cargo test && cargo clean

test-typescript: ## Test Typescript templates
cd templates/typescript/events && npm ci && npm test && rm -rf node_modules build
cd templates/typescript/cloudevents && npm ci && npm test && rm -rf node_modules build
cd templates/typescript/http && npm ci && npm test && rm -rf node_modules build


Expand Down
4 changes: 2 additions & 2 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ EXAMPLES
o Create a Node.js Function in the directory 'myfunc'.
$ {{.Prefix}}func create myfunc
o Create a Go Function which handles Cloud Events in ./myfunc.
$ {{.Prefix}}func create -l go -t events myfunc
o Create a Go Function which handles CloudEvents in ./myfunc.
$ {{.Prefix}}func create -l go -t cloudevents myfunc
`,
SuggestFor: []string{"vreate", "creaet", "craete", "new"},
PreRunE: bindEnv("language", "template", "repository", "confirm"),
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Creates a new Function project at _`path`_. If _`path`_ is unspecified, assumes

Function name must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?').

The files written upon create include an example Function of the specified language runtime, example tests, and a metadata file `func.yaml`. Together, these are referred to as a Template. Included are the templates 'http' and 'events' (default is 'http') for each language runtime. A template can be pulled from a specific Git repository by providing the `--repository` flag, or from a locally installed repository using the repository's name as a prefix. See the [Templates Guide](templates.md) for more information.
The files written upon create include an example Function of the specified language runtime, example tests, and a metadata file `func.yaml`. Together, these are referred to as a Template. Included are the templates 'http' and 'cloudevents' (default is 'http') for each language runtime. A template can be pulled from a specific Git repository by providing the `--repository` flag, or from a locally installed repository using the repository's name as a prefix. See the [Templates Guide](templates.md) for more information.

Similar `kn` command: none.

Expand Down
2 changes: 1 addition & 1 deletion pkged.go

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
51 changes: 51 additions & 0 deletions templates/go/cloudevents/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
github.com/cloudevents/sdk-go/v2 v2.4.0 h1:IkzAOizTvn+M13KWDLFOiTb44YBuwAvbenzSg43bWM4=
github.com/cloudevents/sdk-go/v2 v2.4.0/go.mod h1:MZiMwmAh5tGj+fPFvtHv9hKurKqXtdB9haJYMJ/7GJY=
github.com/cloudevents/sdk-go/v2 v2.5.0 h1:Ts6aLHbBUJfcNcZ4ouAfJ4+Np7SE1Yf2w4ADKRCd7Fo=
github.com/cloudevents/sdk-go/v2 v2.5.0/go.mod h1:nlXhgFkf0uTopxmRXalyMwS2LG70cRGPrxzmjJgSG0U=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/json-iterator/go v1.1.10 h1:Kz6Cvnvv2wGdaG/V8yMvfkmNiXq9Ya2KUv4rouJJr68=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0 h1:ORx85nbTijNz8ljznvCMR1ZBIPKFn3jQrag10X2AsuM=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion templates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestTemplatesList(t *testing.T) {
// by creating a custom repository path for just this test, if
// that becomes a hassle.
expected := []string{
"events",
"cloudevents",
"http",
"customProvider/customTemplate",
"repositoryTests/custom",
Expand Down
2 changes: 1 addition & 1 deletion test/_e2e/cmd_emit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func TestEmitCommand(t *testing.T) {
FunctionName: "emit-test-node",
ProjectPath: filepath.Join(os.TempDir(), "emit-test-node"),
Runtime: "node",
Template: "events",
Template: "cloudevents",
}
knFunc := NewKnFuncShellCli(t)

Expand Down
2 changes: 1 addition & 1 deletion test/_e2e/e2e_functions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestHttpFunction(t *testing.T) {
// for a function that responds to CloudEvents
func TestCloudEventsFunction(t *testing.T) {

project := NewFunctionTestProject(GetRuntime(), "events")
project := NewFunctionTestProject(GetRuntime(), "cloudevents")
knFunc := NewKnFuncShellCli(t)

Create(t, knFunc, project)
Expand Down
4 changes: 3 additions & 1 deletion test/_e2e/trigger_events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var defaultFunctionsCloudEventsValidators = map[string]FunctionCloudEventsValida
// DefaultFunctionEventsTest executes a common test (applied for all runtimes) against a deployed
// functions that responds to CloudEvents
func DefaultFunctionEventsTest(t *testing.T, knFunc *TestShellCmdRunner, project FunctionTestProject) {
if project.Template == "events" && project.IsDeployed {
if project.Template == "cloudevents" && project.IsDeployed {

simpleEvent := SimpleTestEvent{
Type: "e2e.test",
Expand All @@ -85,6 +85,8 @@ func DefaultFunctionEventsTest(t *testing.T, knFunc *TestShellCmdRunner, project
t.Fatalf("Expected status code 200, received %v", statusCode)
}

} else {
t.Fatalf("Expected e2e cloudevents test to run")
}

}

0 comments on commit 68b0904

Please sign in to comment.