Skip to content
Merged
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,6 @@ require (
replace (
k8s.io/client-go => k8s.io/client-go v0.30.10

knative.dev/func => github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250820114648-23f4490237ad
knative.dev/func => github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250902202941-96eed712cf14
knative.dev/kn-plugin-event => github.com/openshift-knative/kn-plugin-event v0.43.1-0.20250505073738-1d80299d87eb
)
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1497,8 +1497,8 @@ github.com/opencontainers/selinux v1.11.0 h1:+5Zbo97w3Lbmb3PeqQtpmTkMwsW5nRI3YaL
github.com/opencontainers/selinux v1.11.0/go.mod h1:E5dMC3VPuVvVHDYmi78qvhJp8+M586T4DlDRYpFkyec=
github.com/openshift-knative/kn-plugin-event v0.43.1-0.20250505073738-1d80299d87eb h1:pnk1Mw27NO/gntKymU4DDaRRbrGMY1a9Wu8hI2d/CK8=
github.com/openshift-knative/kn-plugin-event v0.43.1-0.20250505073738-1d80299d87eb/go.mod h1:AB3tJ9HfekmLRSMPgcevg5oxO6WwKVrYqchBajXZ1xc=
github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250820114648-23f4490237ad h1:R727qHXX54tR4ALaJfEMRxn8xleX6B3XL6a9ELg5NuU=
github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250820114648-23f4490237ad/go.mod h1:9FVSpi1LvVlZ/JoNf5Z+sBCgLObzkVIHHvx9fSo5/mA=
github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250902202941-96eed712cf14 h1:X8Xv+QSU3k2glAznik2h2GiJFXIsGSARmpq9wnFGALY=
github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250902202941-96eed712cf14/go.mod h1:9FVSpi1LvVlZ/JoNf5Z+sBCgLObzkVIHHvx9fSo5/mA=
github.com/openshift-pipelines/pipelines-as-code v0.27.0 h1:uxpva7/Ad/QEvc40BCBFEWrmYlAjCZ9dZCFYPYWW61c=
github.com/openshift-pipelines/pipelines-as-code v0.27.0/go.mod h1:rzfXtaqbUrsAock3f948p9ekXWc3DFFk9acz5BsEwA4=
github.com/openshift/source-to-image v1.4.1-0.20240605122348-f94ff357628b h1:FGmtvZdOUj8+oEmL773UwU348D1mx42KHSqFoEAXwtw=
Expand Down
51 changes: 51 additions & 0 deletions vendor/knative.dev/func/pkg/pipelines/tekton/tasks.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package tekton

import (
"context"
"fmt"
"strings"

"gopkg.in/yaml.v3"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"knative.dev/func/pkg/k8s"
)

var DeployerImage = "ghcr.io/knative/func-utils:latest"
Expand Down Expand Up @@ -454,6 +460,51 @@ spec:
`, DeployerImage)
}

func getGitCloneTask() (string, error) {
c, err := k8s.NewDynamicClient()
if err != nil {
return "", fmt.Errorf("cannot create k8s client: %v", err)
}
taskGVR := schema.GroupVersionResource{
Group: "tekton.dev",
Version: "v1",
Resource: "tasks",
}
o, err := c.Resource(taskGVR).Namespace("openshift-pipelines").Get(context.Background(), "git-clone", metav1.GetOptions{})
if err != nil {
return "", fmt.Errorf("cannot get git-clone task: %v", err)
}

/* BEGIN fixup workspaces */
spec := o.Object["spec"].(map[string]any)
workspaces := spec["workspaces"].([]any)
type ws struct {
Name string
Optional bool
}
spec["workspaces"] = append(workspaces,
ws{Name: "dockerconfig", Optional: true},
ws{Name: "cache", Optional: true},
)
/* END fixup workspaces */

/* BEGIN delete unnecessary fields */
delete(o.Object["metadata"].(map[string]any), "managedFields")
stepTemplate := spec["stepTemplate"].(map[string]any)
delete(stepTemplate, "computeResources")
steps := spec["steps"].([]any)
for idx := range steps {
delete(steps[idx].(map[string]any), "computeResources")
}
/* END delete unnecessary fields */

bs, err := yaml.Marshal(o.Object)
if err != nil {
return "", fmt.Errorf("cannot marshal object to yaml: %v", err)
}
return string(bs), nil
}

// GetClusterTasks returns multi-document yaml containing tekton tasks used by func.
func GetClusterTasks() string {
tasks := getBuildpackTask() + "\n---\n" + getS2ITask() + "\n---\n" + getDeployTask() + "\n---\n" + getScaffoldTask()
Expand Down
40 changes: 26 additions & 14 deletions vendor/knative.dev/func/pkg/pipelines/tekton/templates.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ const (
name: git-clone
workspaces:
- name: output
workspace: source-workspace`
// TODO fix Tekton Hub reference
workspace: source-workspace
- name: cache
workspace: cache-workspace
- name: dockerconfig
workspace: dockerconfig-workspace`

taskGitCloneTaskRef = `- name: fetch-sources
params:
- name: url
- name: URL
value: $(params.gitRepository)
- name: revision
- name: REVISION
value: $(params.gitRevision)
taskRef:
resolver: hub
params:
- name: kind
value: task
- name: name
value: git-clone
- name: version
value: "0.4"
workspaces:
- name: output
workspace: source-workspace`
workspace: source-workspace
- name: cache
workspace: cache-workspace
- name: dockerconfig
workspace: dockerconfig-workspace`

runAfterFetchSourcesRef = `runAfter:
- fetch-sources`

Expand Down Expand Up @@ -96,6 +96,7 @@ type templateData struct {

// Task references
GitCloneTaskRef string
GitCloneTaskSpec string
FuncBuildpacksTaskRef string
FuncS2iTaskRef string
FuncDeployTaskRef string
Expand Down Expand Up @@ -307,10 +308,20 @@ func createAndApplyPipelineTemplate(f fn.Function, namespace string, labels map[
// If Git is set up create fetch task and reference it from build task,
// otherwise sources have been already uploaded to workspace PVC.
gitCloneTaskRef := ""
gitCloneTaskSpec := ""
runAfterFetchSources := ""
if f.Build.Git.URL != "" {
runAfterFetchSources = runAfterFetchSourcesRef
gitCloneTaskRef = taskGitCloneTaskRef
gct, err := getGitCloneTask()
if err != nil {
return fmt.Errorf("error getting git clone task: %v", err)
}
ts, err := getTaskSpec(gct)
if err != nil {
return err
}
gitCloneTaskSpec = ts
}

data := templateData{
Expand All @@ -320,6 +331,7 @@ func createAndApplyPipelineTemplate(f fn.Function, namespace string, labels map[
PipelineName: getPipelineName(f),
RunAfterFetchSources: runAfterFetchSources,
GitCloneTaskRef: gitCloneTaskRef,
GitCloneTaskSpec: gitCloneTaskSpec,
}

for _, val := range []struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ spec:
type: array
tasks:
{{.GitCloneTaskRef}}
{{.GitCloneTaskSpec}}
- name: scaffold
params:
- name: path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ spec:
default: 'image:///usr/libexec/s2i'
tasks:
{{.GitCloneTaskRef}}
{{.GitCloneTaskSpec}}
- name: scaffold
params:
- name: path
Expand Down
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2174,7 +2174,7 @@ knative.dev/eventing-kafka-broker/control-plane/pkg/apis/sources/v1beta1
knative.dev/eventing-kafka-broker/control-plane/pkg/client/clientset/versioned/scheme
knative.dev/eventing-kafka-broker/control-plane/pkg/client/clientset/versioned/typed/sources/v1beta1
knative.dev/eventing-kafka-broker/control-plane/pkg/client/clientset/versioned/typed/sources/v1beta1/fake
# knative.dev/func v0.43.2 => github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250820114648-23f4490237ad
# knative.dev/func v0.43.2 => github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250902202941-96eed712cf14
## explicit; go 1.23.0
knative.dev/func/cmd
knative.dev/func/cmd/prompt
Expand Down Expand Up @@ -2433,5 +2433,5 @@ sigs.k8s.io/structured-merge-diff/v4/value
sigs.k8s.io/yaml
sigs.k8s.io/yaml/goyaml.v2
# k8s.io/client-go => k8s.io/client-go v0.30.10
# knative.dev/func => github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250820114648-23f4490237ad
# knative.dev/func => github.com/openshift-knative/kn-plugin-func v1.1.3-0.20250902202941-96eed712cf14
# knative.dev/kn-plugin-event => github.com/openshift-knative/kn-plugin-event v0.43.1-0.20250505073738-1d80299d87eb