Skip to content

Commit

Permalink
[DO NOT MERGE] testing jammy builder
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Vasek <[email protected]>
  • Loading branch information
matejvasek committed Aug 8, 2023
1 parent 6b3fdba commit 1256907
Show file tree
Hide file tree
Showing 12 changed files with 7,163 additions and 7,205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-e2e-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: E2E Test
strategy:
matrix:
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript"]
runtime: ["node", "go", "python", "quarkus", "springboot", "typescript", "rust"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand Down
14,270 changes: 7,132 additions & 7,138 deletions generate/zz_filesystem_generated.go

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions pkg/builders/buildpacks/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ import (
// DefaultName when no WithName option is provided to NewBuilder
const DefaultName = builders.Pack

var DefaultBaseBuilder = "gcr.io/paketo-buildpacks/builder:base"
var DefaultRustBuilder = "gcr.io/paketo-buildpacks/builder:full-cf"
var DefaultBaseBuilder = "ghcr.io/knative/builder-jammy-base:latest"
var DefaultTinyBuilder = "ghcr.io/knative/builder-jammy-tiny:latest"

var (
DefaultBuilderImages = map[string]string{
"node": DefaultBaseBuilder,
"nodejs": DefaultBaseBuilder,
"typescript": DefaultBaseBuilder,
"go": DefaultBaseBuilder,
"go": DefaultTinyBuilder,
"python": DefaultBaseBuilder,
"quarkus": DefaultBaseBuilder,
"rust": DefaultRustBuilder,
"quarkus": DefaultTinyBuilder,
"rust": DefaultBaseBuilder,
"springboot": DefaultBaseBuilder,
}

Expand All @@ -50,11 +50,10 @@ var (
"docker.io/paketobuildpacks/",
"ghcr.io/vmware-tanzu/function-buildpacks-for-knative/",
"gcr.io/buildpacks/",
"ghcr.io/knative/",
}

defaultBuildpacks = map[string][]string{
"go": {"paketo-buildpacks/go-dist", "ghcr.io/boson-project/go-function-buildpack:tip"},
}
defaultBuildpacks = map[string][]string{}
)

// Builder will build Function using Pack.
Expand Down
4 changes: 2 additions & 2 deletions pkg/k8s/security_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ func defaultPodSecurityContext() *corev1.PodSecurityContext {
if IsOpenShift() {
return nil
}
runAsUser := int64(1000)
runAsGroup := int64(1000)
runAsUser := int64(1001)
runAsGroup := int64(1002)
return &corev1.PodSecurityContext{
RunAsUser: &runAsUser,
RunAsGroup: &runAsGroup,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
default: "false"
- name: USER_ID
description: The user ID of the builder image user.
default: "1000"
default: "1001"
- name: GROUP_ID
description: The group ID of the builder image user.
default: "0"
Expand All @@ -74,7 +74,7 @@ spec:
stepTemplate:
env:
- name: CNB_PLATFORM_API
value: "0.4"
value: "0.10"

steps:
- name: prepare
Expand Down Expand Up @@ -168,7 +168,6 @@ spec:
- "-layers=/layers"
- "-platform=/platform"
- "-report=/layers/report.toml"
- "-process-type=$(params.PROCESS_TYPE)"
- "-skip-restore=$(params.SKIP_RESTORE)"
- "-previous-image=$(params.APP_IMAGE)"
- "-run-image=$(params.RUN_IMAGE)"
Expand All @@ -179,7 +178,7 @@ spec:
- name: $(params.PLATFORM_DIR)
mountPath: /platform
securityContext:
runAsUser: 1000
runAsUser: 1001
#################################################################
##### "runAsGroup" has been changed to "0" for Knative Functions
runAsGroup: 0
Expand Down
3 changes: 2 additions & 1 deletion pkg/pipelines/tekton/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/util/uuid"
"knative.dev/pkg/apis"

"knative.dev/func/pkg/builders/buildpacks"
"knative.dev/func/pkg/docker"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/k8s"
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestGitlab(t *testing.T) {
URL: strings.TrimSuffix(glabEnv.HTTPProjectURL, ".git"),
Revision: "devel",
},
BuilderImages: map[string]string{"pack": "docker.io/paketobuildpacks/builder:tiny"},
BuilderImages: map[string]string{"pack": buildpacks.DefaultTinyBuilder},
Builder: "pack",
PVCSize: "256Mi",
},
Expand Down
41 changes: 9 additions & 32 deletions pkg/pipelines/tekton/pipelines_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"testing"
"time"

"knative.dev/func/pkg/builders/buildpacks"
"knative.dev/func/pkg/docker"
fn "knative.dev/func/pkg/functions"
"knative.dev/func/pkg/pipelines/tekton"
Expand Down Expand Up @@ -153,12 +154,12 @@ func createSimpleGoProject(t *testing.T, ns string) fn.Function {
t.Fatal(err)
}

err = os.WriteFile(filepath.Join(projDir, "main.go"), []byte(simpleGOSvc), 0644)
err = os.WriteFile(filepath.Join(projDir, "handle.go"), []byte(simpleGOSvc), 0644)
if err != nil {
t.Fatal(err)
}

err = os.WriteFile(filepath.Join(projDir, "go.mod"), []byte("module web\n\ngo 1.20\n"), 0644)
err = os.WriteFile(filepath.Join(projDir, "go.mod"), []byte("module function\n\ngo 1.20\n"), 0644)
if err != nil {
t.Fatal(err)
}
Expand All @@ -173,7 +174,7 @@ func createSimpleGoProject(t *testing.T, ns string) fn.Function {
Invoke: "none",
Build: fn.BuildSpec{
BuilderImages: map[string]string{
"pack": "docker.io/paketobuildpacks/builder:base",
"pack": buildpacks.DefaultTinyBuilder,
"s2i": "registry.access.redhat.com/ubi8/go-toolset",
},
},
Expand All @@ -189,40 +190,16 @@ func createSimpleGoProject(t *testing.T, ns string) fn.Function {
return f
}

const simpleGOSvc = `package main
const simpleGOSvc = `package function
import (
"context"
"net"
"net/http"
"os"
"os/signal"
"syscall"
)
func main() {
sigs := make(chan os.Signal, 5)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
s := http.Server{
Handler: http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
resp.Header().Add("Content-Type", "text/plain")
resp.WriteHeader(200)
_, _ = resp.Write([]byte("OK"))
}),
}
go func() {
<-sigs
_ = s.Shutdown(context.Background())
}()
port := "8080"
if p, ok := os.LookupEnv("PORT"); ok {
port = p
}
l, err := net.Listen("tcp4", ":"+port)
if err != nil {
panic(err)
}
_ = s.Serve(l)
func Handle(ctx context.Context, resp http.ResponseWriter, req *http.Request) {
resp.Header().Add("Content-Type", "text/plain")
resp.WriteHeader(200)
_, _ = resp.Write([]byte("Hello World!\n"))
}
`
12 changes: 0 additions & 12 deletions pkg/pipelines/tekton/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"knative.dev/func/pkg/builders"
"knative.dev/func/pkg/builders/buildpacks"
"knative.dev/func/pkg/builders/s2i"
fn "knative.dev/func/pkg/functions"
)
Expand All @@ -32,17 +31,6 @@ func validatePipeline(f fn.Function) (string, error) {
return "", ErrRuntimeRequired
}

if f.Runtime == "go" || f.Runtime == "rust" {
builder := f.Build.BuilderImages[builders.Pack]
defaultBuilder := buildpacks.DefaultBuilderImages[f.Runtime]
if builder != "" && builder != defaultBuilder {
warningMsg = fmt.Sprintf("runtime %q is not supported for on cluster build with default builders, "+
"continuing with the custom builder provided", f.Runtime)
} else {
return "", ErrRuntimeNotSupported{f.Runtime}
}
}

if len(f.Build.Buildpacks) > 0 {
return "", ErrBuilpacksNotSupported
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/pipelines/tekton/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func Test_validatePipeline(t *testing.T) {
wantErr: true,
},
{
name: "Unsupported runtime - Go - pack builder - without additional Buildpacks",
name: "Supported runtime - Go - pack builder",
function: fn.Function{Build: fn.BuildSpec{Builder: builders.Pack}, Runtime: "go"},
wantErr: true,
wantErr: false,
},
{
name: "Unsupported runtime - Go - pack builder - with additional Buildpacks",
Expand All @@ -95,9 +95,9 @@ func Test_validatePipeline(t *testing.T) {
wantErr: false,
},
{
name: "Unsupported runtime - Rust - pack builder - without additional Buildpacks",
name: "Supported runtime - Rust - pack builder",
function: fn.Function{Build: fn.BuildSpec{Builder: builders.Pack}, Runtime: "rust"},
wantErr: true,
wantErr: false,
},
{
name: "Unsupported runtime - Rust - s2i builder",
Expand Down
2 changes: 0 additions & 2 deletions templates/rust/manifest.yaml

This file was deleted.

1 change: 1 addition & 0 deletions test/e2e/scenario_runtime-http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
var runtimeSupportMap = map[string][]string{
"node": {"pack", "s2i"},
"go": {"pack"},
"rust": {"pack"},
"python": {"pack", "s2i"},
"quarkus": {"pack", "s2i"},
"springboot": {"pack"},
Expand Down
3 changes: 2 additions & 1 deletion test/oncluster/scenario_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (

var runtimeSupportMap = map[string][]string{
"node": {"pack", "s2i"},
"go": {},
"go": {"pack"},
"rust": {"pack"},
"python": {"pack", "s2i"},
"quarkus": {"pack", "s2i"},
"springboot": {"pack"},
Expand Down

0 comments on commit 1256907

Please sign in to comment.