Repository: knative-sandbox/kn-plugin-func
Pull request #758 (2022-01-13 01:29:08)

ensure build flag binds for run command

<!-- Thanks for sending a pull request! -->

# Changes

<!-- 
Describe your changes here- ideally you can get that description straight from
your descriptive commit message(s)! 

- :gift: Add new feature
- :bug: Fix bug
- :broom: Update or clean up current behavior
- :wastebasket: Remove feature or internal logic
-->

- :bug: Fix the build flag not properly binding to viper

<!--
In addition, categorize the changes you're making using the "/kind" Prow command, example:

/kind <kind>

Supported kinds are: api-change, bug, cleanup, deprecation, removal, documentation, enhancement, performance

-->
/kind bug

<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->


knative-prow-robot: [APPROVALNOTIFIER] This PR is **NOT APPROVED**

This pull-request has been approved by: *<a href="https://github.com/knative-sandbox/kn-plugin-func/pull/758#" title="Author self-approved">shinigambit</a>*
To complete the [pull request process](https://git.k8s.io/community/contributors/guide/owners.md#the-code-review-process), please assign **matejvasek** after the PR has been reviewed.
You can assign the PR to them by writing `/assign @matejvasek` in a comment when ready.

The full list of commands accepted by this bot can be found [here](https://go.k8s.io/bot-commands?repo=knative-sandbox%2Fkn-plugin-func).

<details open>
Needs approval from an approver in each of these files:

- **[OWNERS](https://github.com/knative-sandbox/kn-plugin-func/blob/main/OWNERS)**

Approvers can indicate their approval by writing `/approve` in a comment
Approvers can cancel approval by writing `/approve cancel` in a comment
</details>
<!-- META={"approvers":["matejvasek"]} -->
codecov[bot]: # [Codecov](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox) Report
> Merging [#758](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox) (3ca97bf) into [main](https://codecov.io/gh/knative-sandbox/kn-plugin-func/commit/cb719ff56421352665abbb6902a80dc03c1588a0?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox) (cb719ff) will **not change** coverage.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758/graphs/tree.svg?width=650&height=150&src=pr&token=da1B9bMsQ9&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox)](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox)

```diff
@@           Coverage Diff           @@
##             main     #758   +/-   ##
=======================================
  Coverage   41.25%   41.25%           
=======================================
  Files          44       44           
  Lines        4208     4208           
=======================================
  Hits         1736     1736           
  Misses       2217     2217           
  Partials      255      255           
```


| [Impacted Files](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox) | Coverage Δ | |
|---|---|---|
| [cmd/run.go](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox#diff-Y21kL3J1bi5nbw==) | `61.53% <100.00%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox). Last update [cb719ff...3ca97bf](https://codecov.io/gh/knative-sandbox/kn-plugin-func/pull/758?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=knative-sandbox).


Patch:
diff --git a/.github/workflows/knative-releasability.yaml b/.github/workflows/knative-releasability.yaml
index a9a2955a..df686a89 100644
--- a/.github/workflows/knative-releasability.yaml
+++ b/.github/workflows/knative-releasability.yaml
@@ -38,9 +38,9 @@ jobs:
     env:
       #########################################
       #   Update this section each release.   #
-      RELEASE: 'v1.1'
-      MODULE_RELEASE: 'v0.28'
-      SLACK_CHANNEL: 'release-1dot1'
+      RELEASE: 'v1.2'
+      MODULE_RELEASE: 'v0.29'
+      SLACK_CHANNEL: 'release-1dot2'
       #########################################
 
     steps:
diff --git a/cmd/deploy.go b/cmd/deploy.go
index fca928b9..cdd6da2a 100644
--- a/cmd/deploy.go
+++ b/cmd/deploy.go
@@ -20,7 +20,6 @@ import (
 	"knative.dev/kn-plugin-func/docker"
 	"knative.dev/kn-plugin-func/docker/creds"
 	"knative.dev/kn-plugin-func/knative"
-	"knative.dev/kn-plugin-func/pipelines"
 	"knative.dev/kn-plugin-func/pipelines/tekton"
 	"knative.dev/kn-plugin-func/progress"
 )
@@ -37,11 +36,13 @@ func newDeployClient(cfg deployConfig) (*fn.Client, error) {
 		pusher *docker.Pusher
 		err    error
 	)
+
+	credentialsProvider := creds.NewCredentialsProvider(
+		creds.WithPromptForCredentials(newPromptForCredentials()),
+		creds.WithPromptForCredentialStore(newPromptForCredentialStore()),
+		creds.WithTransport(cfg.Transport))
+
 	if cfg.Push {
-		credentialsProvider := creds.NewCredentialsProvider(
-			creds.WithPromptForCredentials(newPromptForCredentials()),
-			creds.WithPromptForCredentialStore(newPromptForCredentialStore()),
-			creds.WithTransport(cfg.Transport))
 		pusher, err = docker.NewPusher(
 			docker.WithCredentialsProvider(credentialsProvider),
 			docker.WithProgressListener(listener),
@@ -60,7 +61,7 @@ func newDeployClient(cfg deployConfig) (*fn.Client, error) {
 	pipelinesProvider, err := tekton.NewPipelinesProvider(
 		tekton.WithNamespace(cfg.Namespace),
 		tekton.WithProgressListener(listener),
-		tekton.WithPromptForContainerRegistryCredentials(newPromptForPipelineRegistryCredentials()))
+		tekton.WithCredentialsProvider(credentialsProvider))
 	if err != nil {
 		return nil, err
 	}
@@ -287,44 +288,6 @@ func newPromptForCredentials() func(registry string) (docker.Credentials, error)
 	}
 }
 
-func newPromptForPipelineRegistryCredentials() pipelines.ContainerRegistryCredentialsCallback {
-	return func() (pipelines.ContainerRegistryCredentials, error) {
-		var result pipelines.ContainerRegistryCredentials
-		var qs = []*survey.Question{
-			{
-				Name: "server",
-				Prompt: &survey.Input{
-					Message: "Server:",
-					Default: "https://index.docker.io/v1/",
-				},
-				Validate: survey.Required,
-			},
-			{
-				Name: "username",
-				Prompt: &survey.Input{
-					Message: "Username:",
-				},
-				Validate: survey.Required,
-			},
-			{
-				Name: "password",
-				Prompt: &survey.Password{
-					Message: "Password:",
-				},
-				Validate: survey.Required,
-			},
-		}
-
-		fmt.Printf("Please provide credentials for the image registry used by Pipeline.\n")
-
-		err := survey.Ask(qs, &result)
-		if err != nil {
-			return pipelines.ContainerRegistryCredentials{}, err
-		}
-		return result, nil
-	}
-}
-
 func newPromptForCredentialStore() creds.ChooseCredentialHelperCallback {
 	return func(availableHelpers []string) (string, error) {
 		if len(availableHelpers) < 1 {
diff --git a/cmd/run.go b/cmd/run.go
index fcab53c7..2c397f0f 100644
--- a/cmd/run.go
+++ b/cmd/run.go
@@ -55,7 +55,7 @@ kn func build
 kn func run
 `,
 		SuggestFor: []string{"rnu"},
-		PreRunE:    bindEnv("path"),
+		PreRunE:    bindEnv("build", "path"),
 	}
 
 	cmd.Flags().StringArrayP("env", "e", []string{},
diff --git a/docker/pusher.go b/docker/pusher.go
index 5390e08a..571c4781 100644
--- a/docker/pusher.go
+++ b/docker/pusher.go
@@ -12,13 +12,11 @@ import (
 	"net/http"
 	"os"
 	"regexp"
-	"strings"
-
-	"github.com/docker/docker/client"
 
 	fn "knative.dev/kn-plugin-func"
 
 	"github.com/docker/docker/api/types"
+	"github.com/docker/docker/client"
 	"github.com/google/go-containerregistry/pkg/authn"
 	"github.com/google/go-containerregistry/pkg/name"
 	v1 "github.com/google/go-containerregistry/pkg/v1"
@@ -111,18 +109,12 @@ func NewPusher(opts ...Opt) (*Pusher, error) {
 	return result, nil
 }
 
-func GetRegistry(image_url string) (string, error) {
-	var registry string
-	parts := strings.Split(image_url, "/")
-	switch {
-	case len(parts) == 2:
-		registry = fn.DefaultRegistry
-	case len(parts) >= 3:
-		registry = parts[0]
-	default:
-		return "", fmt.Errorf("failed to parse image name: %q", image_url)
+func GetRegistry(img string) (string, error) {
+	ref, err := name.ParseReference(img, name.WeakValidation)
+	if err != nil {
+		return "", err
 	}
-
+	registry := ref.Context().RegistryStr()
 	return registry, nil
 }
 
diff --git a/docs/guides/on-cluster-build.md b/docs/guides/on-cluster-build.md
index 77df6df9..31357043 100644
--- a/docs/guides/on-cluster-build.md
+++ b/docs/guides/on-cluster-build.md
@@ -4,34 +4,23 @@ This guide describes how you can build a Function on Cluster with Tekton Pipelin
 
 > Please note that the following approach requires administrator privileges on the cluster and the build is executed on a privileged container.
 
-## Prerequisites
+## Prerequisite
 1. Install Tekton Pipelines on the cluster. Please refer to [Tekton Pipelines documentation](https://github.com/tektoncd/pipeline/blob/main/docs/install.md) or run the following command:
 ```bash
 kubectl apply -f https://storage.googleapis.com/tekton-releases/pipeline/latest/release.yaml
 ```
-2. Create a Knative Deployer Cluster Role
-```bash
-kubectl apply -f https://raw.githubusercontent.com/knative-sandbox/kn-plugin-func/main/pipelines/resources/knative-deployer-clusterrole.yaml
-```
 
 ## Enabling a namespace to run Function related Tekton Pipelines
 In each namespace that you would like to run Pipelines and deploy a Function you need to create or install the following resources.
-1. Create a Service Account that has permissions to deploy on Knative:
-```bash
-export NAMESPACE=<INSERT_YOUR_NAMESPACE>
-kubectl create serviceaccount knative-deployer-account -n $NAMESPACE
-kubectl create clusterrolebinding $NAMESPACE:knative-deployer-binding \
---clusterrole=kn-deployer --serviceaccount=$NAMESPACE:knative-deployer-account
-```
-2. Install the Git Clone Tekton Task to fetch the Function source code:
+1. Install the Git Clone Tekton Task to fetch the Function source code:
 ```bash
 kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/git-clone/0.4/git-clone.yaml
 ```
-3. Install the Buildpacks Tekton Task to be able to build the Function image:
+2. Install the Buildpacks Tekton Task to be able to build the Function image:
 ```bash
 kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/master/task/buildpacks/0.3/buildpacks.yaml
 ```
-4. Install the `kn func` Deploy Tekton Task to be able to deploy the Function on in the Pipeline:
+3. Install the `kn func` Deploy Tekton Task to be able to deploy the Function on in the Pipeline:
 ```bash
 kubectl apply -f https://raw.githubusercontent.com/knative-sandbox/kn-plugin-func/main/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
 ```
diff --git a/function_git.go b/function_git.go
index b6a5a332..f35a539e 100644
--- a/function_git.go
+++ b/function_git.go
@@ -18,6 +18,9 @@ type Git struct {
 func validateGit(git Git, mandatoryGit bool) (errors []string) {
 	if git.URL != nil {
 		_, err := giturls.ParseTransport(*git.URL)
+		if err != nil {
+			_, err = giturls.ParseScp(*git.URL)
+		}
 		if err != nil {
 			errMsg := fmt.Sprintf("specified option \"git.url=%s\" is not valid", *git.URL)
 
diff --git a/k8s/labels/labels.go b/k8s/labels/labels.go
new file mode 100644
index 00000000..8fd8dee2
--- /dev/null
+++ b/k8s/labels/labels.go
@@ -0,0 +1,13 @@
+package labels
+
+const (
+	FunctionKey        = "function.knative.dev"
+	FunctionValue      = "true"
+	FunctionRuntimeKey = "function.knative.dev/runtime"
+	FunctionNameKey    = "function.knative.dev/name"
+
+	// --- handle usage of deprecated labels
+	DeprecatedFunctionKey        = "boson.dev/function"
+	DeprecatedFunctionRuntimeKey = "boson.dev/runtime"
+	// --- end of handling usage of deprecated runtime labels
+)
diff --git a/k8s/persistent_volumes.go b/k8s/persistent_volumes.go
index 54929968..465d05a7 100644
--- a/k8s/persistent_volumes.go
+++ b/k8s/persistent_volumes.go
@@ -17,7 +17,7 @@ func GetPersistentVolumeClaim(ctx context.Context, name, namespaceOverride strin
 	return client.CoreV1().PersistentVolumeClaims(namespace).Get(ctx, name, metav1.GetOptions{})
 }
 
-func CreatePersistentVolumeClaim(ctx context.Context, name, namespaceOverride string, accessMode corev1.PersistentVolumeAccessMode, resourceRequest resource.Quantity) (err error) {
+func CreatePersistentVolumeClaim(ctx context.Context, name, namespaceOverride string, labels map[string]string, accessMode corev1.PersistentVolumeAccessMode, resourceRequest resource.Quantity) (err error) {
 	client, namespace, err := NewClientAndResolvedNamespace(namespaceOverride)
 	if err != nil {
 		return
@@ -27,6 +27,7 @@ func CreatePersistentVolumeClaim(ctx context.Context, name, namespaceOverride st
 		ObjectMeta: metav1.ObjectMeta{
 			Name:      name,
 			Namespace: namespace,
+			Labels:    labels,
 		},
 		Spec: corev1.PersistentVolumeClaimSpec{
 			AccessModes: []corev1.PersistentVolumeAccessMode{accessMode},
diff --git a/k8s/role_bidings.go b/k8s/role_bidings.go
index ad2d087b..290ddd08 100644
--- a/k8s/role_bidings.go
+++ b/k8s/role_bidings.go
@@ -7,15 +7,16 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
-func CreateClusterRoleBindingForServiceAccount(ctx context.Context, name, namespaceOverride, serviceAccountName, clusterRoleName string) (err error) {
+func CreateRoleBindingForServiceAccount(ctx context.Context, name, namespaceOverride string, labels map[string]string, serviceAccountName, roleKind, roleName string) (err error) {
 	client, namespace, err := NewClientAndResolvedNamespace(namespaceOverride)
 	if err != nil {
 		return
 	}
 
-	crb := &rbacv1.ClusterRoleBinding{
+	rb := &rbacv1.RoleBinding{
 		ObjectMeta: metav1.ObjectMeta{
-			Name: name,
+			Name:   name,
+			Labels: labels,
 		},
 		Subjects: []rbacv1.Subject{
 			{
@@ -26,11 +27,11 @@ func CreateClusterRoleBindingForServiceAccount(ctx context.Context, name, namesp
 		},
 		RoleRef: rbacv1.RoleRef{
 			APIGroup: "rbac.authorization.k8s.io",
-			Kind:     "ClusterRole",
-			Name:     clusterRoleName,
+			Kind:     roleKind,
+			Name:     roleName,
 		},
 	}
 
-	_, err = client.RbacV1().ClusterRoleBindings().Create(ctx, crb, metav1.CreateOptions{})
+	_, err = client.RbacV1().RoleBindings(namespace).Create(ctx, rb, metav1.CreateOptions{})
 	return
 }
diff --git a/k8s/secrets.go b/k8s/secrets.go
index d906713e..04500d5e 100644
--- a/k8s/secrets.go
+++ b/k8s/secrets.go
@@ -36,7 +36,7 @@ func ListSecretsNames(ctx context.Context, namespaceOverride string) (names []st
 	return
 }
 
-func CreateDockerRegistrySecret(ctx context.Context, name, namespaceOverride, username, password, server string) (err error) {
+func CreateDockerRegistrySecret(ctx context.Context, name, namespaceOverride string, labels map[string]string, username, password, server string) (err error) {
 	client, namespace, err := NewClientAndResolvedNamespace(namespaceOverride)
 	if err != nil {
 		return
@@ -46,6 +46,7 @@ func CreateDockerRegistrySecret(ctx context.Context, name, namespaceOverride, us
 		ObjectMeta: metav1.ObjectMeta{
 			Name:      name,
 			Namespace: namespace,
+			Labels:    labels,
 		},
 		Type: corev1.SecretTypeDockerConfigJson,
 		Data: map[string][]byte{},
diff --git a/k8s/service_accounts.go b/k8s/service_accounts.go
index 3312f5fc..5f9a676b 100644
--- a/k8s/service_accounts.go
+++ b/k8s/service_accounts.go
@@ -7,7 +7,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 )
 
-func CreateServiceAccountWithSecret(ctx context.Context, name, namespaceOverride, secretName string) (err error) {
+func CreateServiceAccountWithSecret(ctx context.Context, name, namespaceOverride string, labels map[string]string, secretName string) (err error) {
 	client, namespace, err := NewClientAndResolvedNamespace(namespaceOverride)
 	if err != nil {
 		return
@@ -17,6 +17,7 @@ func CreateServiceAccountWithSecret(ctx context.Context, name, namespaceOverride
 		ObjectMeta: metav1.ObjectMeta{
 			Name:      name,
 			Namespace: namespace,
+			Labels:    labels,
 		},
 		Secrets: []corev1.ObjectReference{
 			{
diff --git a/knative/deployer.go b/knative/deployer.go
index cefc6795..77118747 100644
--- a/knative/deployer.go
+++ b/knative/deployer.go
@@ -22,6 +22,7 @@ import (
 
 	fn "knative.dev/kn-plugin-func"
 	"knative.dev/kn-plugin-func/k8s"
+	"knative.dev/kn-plugin-func/k8s/labels"
 )
 
 const LIVENESS_ENDPOINT = "/health/liveness"
@@ -349,10 +350,14 @@ func updateService(f fn.Function, newEnv []corev1.EnvVar, newEnvFrom []corev1.En
 //     value: {{ env:MY_ENV }}
 func processLabels(f fn.Function) (map[string]string, error) {
 	labels := map[string]string{
-		"boson.dev/function":           "true",
-		"boson.dev/runtime":            f.Runtime,
-		"function.knative.dev":         "true",
-		"function.knative.dev/runtime": f.Runtime,
+		labels.FunctionKey:        labels.FunctionValue,
+		labels.FunctionNameKey:    f.Name,
+		labels.FunctionRuntimeKey: f.Runtime,
+
+		// --- handle usage of deprecated labels (`boson.dev/function`, `boson.dev/runtime`)
+		labels.DeprecatedFunctionKey:        labels.FunctionValue,
+		labels.DeprecatedFunctionRuntimeKey: f.Runtime,
+		// --- end of handling usage of deprecated runtime labels
 	}
 	for _, label := range f.Labels {
 		if label.Key != nil && label.Value != nil {
diff --git a/knative/lister.go b/knative/lister.go
index 433bff7e..da8ad8aa 100644
--- a/knative/lister.go
+++ b/knative/lister.go
@@ -9,14 +9,7 @@ import (
 
 	fn "knative.dev/kn-plugin-func"
 	"knative.dev/kn-plugin-func/k8s"
-)
-
-const (
-	labelFunctionKey           = "function.knative.dev"
-	deprecatedLabelFunctionKey = "boson.dev/function"
-	labelFunctionValue         = "true"
-	labelRuntimeKey            = "function.knative.dev/runtime"
-	deprecatedLabelRuntimeKey  = "boson.dev/runtime"
+	"knative.dev/kn-plugin-func/k8s/labels"
 )
 
 type Lister struct {
@@ -43,13 +36,13 @@ func (l *Lister) List(ctx context.Context) (items []fn.ListItem, err error) {
 		return
 	}
 
-	lst, err := client.ListServices(ctx, clientservingv1.WithLabel(labelFunctionKey, labelFunctionValue))
+	lst, err := client.ListServices(ctx, clientservingv1.WithLabel(labels.FunctionKey, labels.FunctionValue))
 	if err != nil {
 		return
 	}
 
 	// --- handle usage of deprecated function labels (`boson.dev/function`)
-	lstDeprecated, err := client.ListServices(ctx, clientservingv1.WithLabel(deprecatedLabelFunctionKey, labelFunctionValue))
+	lstDeprecated, err := client.ListServices(ctx, clientservingv1.WithLabel(labels.DeprecatedFunctionKey, labels.FunctionValue))
 	if err != nil {
 		return
 	}
@@ -82,10 +75,10 @@ func (l *Lister) List(ctx context.Context) (items []fn.ListItem, err error) {
 
 		// --- handle usage of deprecated runtime labels (`boson.dev/runtime`)
 		runtimeLabel := ""
-		if val, ok := f.Labels[labelRuntimeKey]; ok {
+		if val, ok := f.Labels[labels.FunctionRuntimeKey]; ok {
 			runtimeLabel = val
 		} else {
-			runtimeLabel = f.Labels[deprecatedLabelRuntimeKey]
+			runtimeLabel = f.Labels[labels.DeprecatedFunctionRuntimeKey]
 		}
 		// --- end of handling usage of deprecated runtime labels
 
diff --git a/pipelines/init.go b/pipelines/init.go
new file mode 100644
index 00000000..6af4c599
--- /dev/null
+++ b/pipelines/init.go
@@ -0,0 +1,1 @@
+package pipelines
diff --git a/pipelines/registry_credentials.go b/pipelines/registry_credentials.go
deleted file mode 100644
index 95ab20da..00000000
--- a/pipelines/registry_credentials.go
+++ /dev/null
@@ -1,9 +0,0 @@
-package pipelines
-
-type ContainerRegistryCredentialsCallback func() (ContainerRegistryCredentials, error)
-
-type ContainerRegistryCredentials struct {
-	Username string
-	Password string
-	Server   string
-}
diff --git a/pipelines/resources/knative-deployer-account.yaml b/pipelines/resources/knative-deployer-account.yaml
deleted file mode 100644
index bc83ce00..00000000
--- a/pipelines/resources/knative-deployer-account.yaml
+++ /dev/null
@@ -1,18 +0,0 @@
-apiVersion: v1
-kind: ServiceAccount
-metadata:
-  name: knative-deployer-account
-  namespace: default
----
-
-apiVersion: rbac.authorization.k8s.io/v1
-kind: ClusterRoleBinding
-metadata:
-  name: default:knative-deployer-binding
-subjects:
-- kind: ServiceAccount
-  name: knative-deployer-account
-roleRef:
-  kind: ClusterRole
-  name: kn-deployer
-  apiGroup: rbac.authorization.k8s.io
diff --git a/pipelines/resources/knative-deployer-clusterrole.yaml b/pipelines/resources/knative-deployer-clusterrole.yaml
deleted file mode 100644
index aa4d06e2..00000000
--- a/pipelines/resources/knative-deployer-clusterrole.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-kind: ClusterRole
-apiVersion: rbac.authorization.k8s.io/v1
-metadata:
-  name: kn-deployer
-rules:
-  - apiGroups: ["serving.knative.dev"]
-    resources: ["services", "revisions", "routes"]
-    verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
diff --git a/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml b/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
index 4af24c14..a7aeee5c 100644
--- a/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
+++ b/pipelines/resources/tekton/task/func-deploy/0.1/func-deploy.yaml
@@ -26,7 +26,7 @@ spec:
     args:
       - "deploy"
       - "--verbose"
-      - "--build=false"
+      - "--build=disabled"
       - "--push=false"
       - "--path"
       - "$(params.path)"
diff --git a/pipelines/tekton/pipeplines_provider.go b/pipelines/tekton/pipeplines_provider.go
index dc472f30..b8a4969d 100644
--- a/pipelines/tekton/pipeplines_provider.go
+++ b/pipelines/tekton/pipeplines_provider.go
@@ -5,6 +5,9 @@ import (
 	"fmt"
 	"sync"
 
+	"github.com/google/go-containerregistry/pkg/authn"
+	"github.com/google/go-containerregistry/pkg/name"
+
 	"github.com/tektoncd/cli/pkg/pipelinerun"
 	"github.com/tektoncd/cli/pkg/taskrun"
 	"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
@@ -14,9 +17,10 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	fn "knative.dev/kn-plugin-func"
+	"knative.dev/kn-plugin-func/docker"
 	"knative.dev/kn-plugin-func/k8s"
+	"knative.dev/kn-plugin-func/k8s/labels"
 	"knative.dev/kn-plugin-func/knative"
-	"knative.dev/kn-plugin-func/pipelines"
 	"knative.dev/pkg/apis"
 )
 
@@ -25,10 +29,10 @@ type Opt func(*PipelinesProvider) error
 type PipelinesProvider struct {
 	// namespace with which to override that set on the default configuration (such as the ~/.kube/config).
 	// If left blank, pipeline creation/run will commence to the configured namespace.
-	namespace                            string
-	Verbose                              bool
-	progressListener                     fn.ProgressListener
-	containerRegistryCredentialsCallback pipelines.ContainerRegistryCredentialsCallback
+	namespace           string
+	Verbose             bool
+	progressListener    fn.ProgressListener
+	credentialsProvider docker.CredentialsProvider
 }
 
 func WithNamespace(namespace string) Opt {
@@ -49,9 +53,9 @@ func WithProgressListener(pl fn.ProgressListener) Opt {
 	}
 }
 
-func WithPromptForContainerRegistryCredentials(cbk pipelines.ContainerRegistryCredentialsCallback) Opt {
+func WithCredentialsProvider(credentialsProvider docker.CredentialsProvider) Opt {
 	return func(pp *PipelinesProvider) error {
-		pp.containerRegistryCredentialsCallback = cbk
+		pp.credentialsProvider = credentialsProvider
 		return nil
 	}
 }
@@ -80,14 +84,17 @@ func (pp *PipelinesProvider) Run(ctx context.Context, f fn.Function) error {
 		return err
 	}
 
-	err = k8s.CreatePersistentVolumeClaim(ctx, getPipelinePvcName(f), pp.namespace, corev1.ReadWriteOnce, *resource.NewQuantity(DefaultPersistentVolumeClaimSize, resource.DecimalSI))
+	// let's specify labels that will be applied to every resouce that is created for a Pipeline
+	labels := map[string]string{labels.FunctionNameKey: f.Name}
+
+	err = k8s.CreatePersistentVolumeClaim(ctx, getPipelinePvcName(f), pp.namespace, labels, corev1.ReadWriteOnce, *resource.NewQuantity(DefaultPersistentVolumeClaimSize, resource.DecimalSI))
 	if err != nil {
 		if !errors.IsAlreadyExists(err) {
 			return fmt.Errorf("problem creating persistent volume claim: %v", err)
 		}
 	}
 
-	_, err = client.Pipelines(pp.namespace).Create(ctx, generatePipeline(f), metav1.CreateOptions{})
+	_, err = client.Pipelines(pp.namespace).Create(ctx, generatePipeline(f, labels), metav1.CreateOptions{})
 	if err != nil {
 		if !errors.IsAlreadyExists(err) {
 			if errors.IsNotFound(err) {
@@ -97,16 +104,25 @@ func (pp *PipelinesProvider) Run(ctx context.Context, f fn.Function) error {
 		}
 	}
 
+	registry, err := docker.GetRegistry(f.Image)
+	if err != nil {
+		return err
+	}
+
 	_, err = k8s.GetSecret(ctx, getPipelineSecretName(f), pp.namespace)
 	if errors.IsNotFound(err) {
 		pp.progressListener.Stopping()
-		creds, err := pp.containerRegistryCredentialsCallback()
+		creds, err := pp.credentialsProvider(ctx, registry)
 		if err != nil {
 			return err
 		}
 		pp.progressListener.Increment("Creating Pipeline resources")
 
-		err = k8s.CreateDockerRegistrySecret(ctx, getPipelineSecretName(f), pp.namespace, creds.Username, creds.Password, creds.Server)
+		if registry == name.DefaultRegistry {
+			registry = authn.DefaultAuthKey
+		}
+
+		err = k8s.CreateDockerRegistrySecret(ctx, getPipelineSecretName(f), pp.namespace, labels, creds.Username, creds.Password, registry)
 		if err != nil {
 			return err
 		}
@@ -114,22 +130,23 @@ func (pp *PipelinesProvider) Run(ctx context.Context, f fn.Function) error {
 		return fmt.Errorf("problem in creating secret: %v", err)
 	}
 
-	err = k8s.CreateServiceAccountWithSecret(ctx, getPipelineBuilderServiceAccountName(f), pp.namespace, getPipelineSecretName(f))
+	err = k8s.CreateServiceAccountWithSecret(ctx, getPipelineBuilderServiceAccountName(f), pp.namespace, labels, getPipelineSecretName(f))
 	if err != nil {
 		if !errors.IsAlreadyExists(err) {
 			return fmt.Errorf("problem in creating service account: %v", err)
 		}
 	}
 
-	err = k8s.CreateClusterRoleBindingForServiceAccount(ctx, getPipelineDeployerClusterRoleBindingName(f, pp.namespace), pp.namespace, getPipelineBuilderServiceAccountName(f), "knative-serving-namespaced-edit")
+	// using ClusterRole `knative-serving-namespaced-admin` that should be present on the cluster after the installation of Knative Serving
+	err = k8s.CreateRoleBindingForServiceAccount(ctx, getPipelineDeployerRoleBindingName(f), pp.namespace, labels, getPipelineBuilderServiceAccountName(f), "ClusterRole", "knative-serving-namespaced-admin")
 	if err != nil {
 		if !errors.IsAlreadyExists(err) {
-			return fmt.Errorf("problem in creating cluster role biding: %v", err)
+			return fmt.Errorf("problem in creating role biding: %v", err)
 		}
 	}
 
 	pp.progressListener.Increment("Running Pipeline with the Function")
-	pr, err := client.PipelineRuns(pp.namespace).Create(ctx, generatePipelineRun(f), metav1.CreateOptions{})
+	pr, err := client.PipelineRuns(pp.namespace).Create(ctx, generatePipelineRun(f, labels), metav1.CreateOptions{})
 	if err != nil {
 		return fmt.Errorf("problem in creating pipeline run: %v", err)
 	}
diff --git a/pipelines/tekton/resources.go b/pipelines/tekton/resources.go
index 1ddbe8a5..ad41184a 100644
--- a/pipelines/tekton/resources.go
+++ b/pipelines/tekton/resources.go
@@ -10,7 +10,7 @@ import (
 	fn "knative.dev/kn-plugin-func"
 )
 
-func generatePipeline(f fn.Function) *pplnv1beta1.Pipeline {
+func generatePipeline(f fn.Function, labels map[string]string) *pplnv1beta1.Pipeline {
 	pipelineName := getPipelineName(f)
 
 	params := []pplnv1beta1.ParamSpec{
@@ -52,7 +52,8 @@ func generatePipeline(f fn.Function) *pplnv1beta1.Pipeline {
 
 	return &pplnv1beta1.Pipeline{
 		ObjectMeta: v1.ObjectMeta{
-			Name: pipelineName,
+			Name:   pipelineName,
+			Labels: labels,
 		},
 		Spec: pplnv1beta1.PipelineSpec{
 			Params:     params,
@@ -62,7 +63,7 @@ func generatePipeline(f fn.Function) *pplnv1beta1.Pipeline {
 	}
 }
 
-func generatePipelineRun(f fn.Function) *pplnv1beta1.PipelineRun {
+func generatePipelineRun(f fn.Function, labels map[string]string) *pplnv1beta1.PipelineRun {
 
 	revision := ""
 	if f.Git.Revision != nil {
@@ -76,6 +77,7 @@ func generatePipelineRun(f fn.Function) *pplnv1beta1.PipelineRun {
 	return &pplnv1beta1.PipelineRun{
 		ObjectMeta: v1.ObjectMeta{
 			GenerateName: fmt.Sprintf("%s-run-", getPipelineName(f)),
+			Labels:       labels,
 		},
 
 		Spec: pplnv1beta1.PipelineRunSpec{
@@ -85,13 +87,6 @@ func generatePipelineRun(f fn.Function) *pplnv1beta1.PipelineRun {
 
 			ServiceAccountName: getPipelineBuilderServiceAccountName(f),
 
-			TaskRunSpecs: []pplnv1beta1.PipelineTaskRunSpec{
-				{
-					PipelineTaskName:       "deploy",
-					TaskServiceAccountName: "knative-deployer-account",
-				},
-			},
-
 			Params: []pplnv1beta1.Param{
 				{
 					Name:  "gitRepository",
@@ -151,6 +146,6 @@ func getPipelineBuilderServiceAccountName(f fn.Function) string {
 	return fmt.Sprintf("%s-builder-secret", getPipelineName(f))
 }
 
-func getPipelineDeployerClusterRoleBindingName(f fn.Function, namespace string) string {
-	return fmt.Sprintf("%s-%s-deployer-binding", getPipelineName(f), namespace)
+func getPipelineDeployerRoleBindingName(f fn.Function) string {
+	return fmt.Sprintf("%s-deployer-binding", getPipelineName(f))
 }


Test patch:
diff --git a/docker/pusher_test.go b/docker/pusher_test.go
index 6895b58f..be7f052d 100644
--- a/docker/pusher_test.go
+++ b/docker/pusher_test.go
@@ -45,18 +45,13 @@ func TestGetRegistry(t *testing.T) {
 		{
 			name: "default registry",
 			arg:  "docker.io/mysamplefunc:latest",
-			want: "docker.io",
+			want: "index.docker.io",
 		},
 		{
 			name: "long-form nested url",
 			arg:  "myregistry.io/myorg/myuser/myfunctions/mysamplefunc:latest",
 			want: "myregistry.io",
 		},
-		{
-			name: "invalid url",
-			arg:  "myregistry.io-mysamplefunc:latest",
-			want: "",
-		},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {
diff --git a/function_git_unit_test.go b/function_git_unit_test.go
index 0f155523..4ac34414 100644
--- a/function_git_unit_test.go
+++ b/function_git_unit_test.go
@@ -15,13 +15,21 @@ func Test_validateGit(t *testing.T) {
 		errs         int
 	}{
 		{
-			"correct 'Git - only URL",
+			"correct 'Git - only URL https",
 			Git{
 				URL: ptr.String("https://myrepo/foo.git"),
 			},
 			true,
 			0,
 		},
+		{
+			"correct 'Git - only URL scp",
+			Git{
+				URL: ptr.String("git@myrepo:foo.git"),
+			},
+			true,
+			0,
+		},
 		{
 			"correct 'Git - URL + revision",
 			Git{