Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Golang Cloud Functions in Functionbeat to use Golang 1.16.x on GCP #28251

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d

*Functionbeat*

- Update Google Cloud Functions to use 1.16.x environment on GCP to avoid import errors. {pull}28251[28251]

*Elastic Logging Plugin*

Expand Down
18 changes: 12 additions & 6 deletions x-pack/functionbeat/dev-tools/packaging/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,18 +65,24 @@ shared:
pkg/functionbeat-aws:
source: 'provider/aws/build/golang-crossbuild/aws-linux-amd64'
mode: 0755
pkg/pubsub/vendor:
source: 'provider/gcp/build/pubsub/vendor'
mode: 0644
pkg/storage/vendor:
source: 'provider/gcp/build/storage/vendor'
mode: 0644
pkg/pubsub/pubsub.go:
source: 'provider/gcp/pubsub/pubsub.go'
mode: 0655
pkg/pubsub/go.mod:
source: 'provider/gcp/pubsub/go.mod'
mode: 0644
pkg/pubsub/go.sum:
source: 'provider/gcp/pubsub/go.sum'
mode: 0644
pkg/storage/storage.go:
source: 'provider/gcp/storage/storage.go'
mode: 0655
pkg/storage/go.mod:
source: 'provider/gcp/storage/go.mod'
mode: 0644
pkg/storage/go.sum:
source: 'provider/gcp/storage/go.sum'
mode: 0644

# specs is a list of named packaging "flavors".
specs:
Expand Down
13 changes: 8 additions & 5 deletions x-pack/functionbeat/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

//go:build mage
// +build mage

package main
Expand Down Expand Up @@ -166,11 +167,13 @@ func BuildPkgForFunctions() error {
err := os.RemoveAll("pkg")

filesToCopy := map[string]string{
filepath.Join("provider", "aws", "functionbeat-aws"): filepath.Join("pkg", "functionbeat-aws"),
filepath.Join("provider", "gcp", "pubsub", "pubsub.go"): filepath.Join("pkg", "pubsub", "pubsub.go"),
filepath.Join("provider", "gcp", "storage", "storage.go"): filepath.Join("pkg", "storage", "storage.go"),
filepath.Join("provider", "gcp", "build", "pubsub", "vendor"): filepath.Join("pkg", "pubsub", "vendor"),
filepath.Join("provider", "gcp", "build", "storage", "vendor"): filepath.Join("pkg", "storage", "vendor"),
filepath.Join("provider", "aws", "functionbeat-aws"): filepath.Join("pkg", "functionbeat-aws"),
filepath.Join("provider", "gcp", "pubsub", "pubsub.go"): filepath.Join("pkg", "pubsub", "pubsub.go"),
filepath.Join("provider", "gcp", "pubsub", "go.mod"): filepath.Join("pkg", "pubsub", "go.mod"),
filepath.Join("provider", "gcp", "pubsub", "go.sum"): filepath.Join("pkg", "pubsub", "go.sum"),
filepath.Join("provider", "gcp", "storage", "storage.go"): filepath.Join("pkg", "storage", "storage.go"),
filepath.Join("provider", "gcp", "storage", "go.mod"): filepath.Join("pkg", "storage", "go.mod"),
filepath.Join("provider", "gcp", "storage", "go.sum"): filepath.Join("pkg", "storage", "go.sum"),
}
for src, dest := range filesToCopy {
c := &devtools.CopyTask{
Expand Down
7 changes: 4 additions & 3 deletions x-pack/functionbeat/manager/gcp/template_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
)

const (
runtime = "go113" // Golang 1.13
runtime = "go116" // Golang 1.16
archiveURL = "gs://%s/%s" // path to the function archive
locationTemplate = "projects/%s/locations/%s" // full name of the location
functionName = locationTemplate + "/functions/%s" // full name of the functions
Expand Down Expand Up @@ -190,6 +190,7 @@ func zipResources() map[string][]bundle.Resource {

func zipResourcesOfFunc(typeName string) []bundle.Resource {
root := filepath.Join("pkg", typeName)
vendor := bundle.Folder(filepath.Join("pkg", typeName, "vendor"), filepath.Join("pkg", typeName), 0644)
return append(vendor, &bundle.LocalFile{Path: filepath.Join(root, typeName+".go"), FileMode: 0755})
goMod := &bundle.LocalFile{Path: filepath.Join(root, "go.mod"), FileMode: 0755}
goSum := &bundle.LocalFile{Path: filepath.Join(root, "go.sum"), FileMode: 0755}
return []bundle.Resource{goMod, goSum, &bundle.LocalFile{Path: filepath.Join(root, typeName+".go"), FileMode: 0755}}
}
17 changes: 17 additions & 0 deletions x-pack/functionbeat/provider/gcp/pubsub/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module github.com/elastic/beats/x-pack/functionbeat/provider/gcp/pubsub

go 1.16

require (
cloud.google.com/go/functions v1.0.0 // indirect
cloud.google.com/go/pubsub v1.17.0
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/elastic/beats/v7 v7.15.0
gopkg.in/jcmturner/aescts.v1 v1.0.1 // indirect
gopkg.in/jcmturner/dnsutils.v1 v1.0.1 // indirect
gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
gopkg.in/jcmturner/rpc.v1 v1.1.0 // indirect
)

replace github.com/Shopify/sarama => github.com/elastic/sarama v1.19.1-0.20210823122811-11c3ef800752
Loading