Skip to content

Commit

Permalink
fix: PaC build
Browse files Browse the repository at this point in the history
* Fixed detection of PaC controller URL for unprivileged users.
* Use fn.Deploy.Image before fn.Image since the fn.Image may not be
  populated.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
  • Loading branch information
matejvasek committed Jun 6, 2024
1 parent 7fe73f8 commit 799ab9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pkg/pipelines/tekton/pac/pac.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const (
func DetectPACInstallation(ctx context.Context, wantedNamespace string) (bool, string, error) {
var installed bool

clientPac, _, err := NewTektonPacClientAndResolvedNamespace("")
clientPac, cns, err := NewTektonPacClientAndResolvedNamespace("")
if err != nil {
return false, "", err
}
Expand All @@ -36,7 +36,7 @@ func DetectPACInstallation(ctx context.Context, wantedNamespace string) (bool, s
return false, "", err
}

_, err = clientPac.Repositories("").List(ctx, metav1.ListOptions{})
_, err = clientPac.Repositories(cns).List(ctx, metav1.ListOptions{})
if err != nil && k8serrors.IsNotFound(err) {
return false, "", nil
}
Expand Down
13 changes: 9 additions & 4 deletions pkg/pipelines/tekton/pipelines_pac_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (pp *PipelinesProvider) createLocalPACResources(ctx context.Context, f fn.F
// also creates PVC for the function source code
func (pp *PipelinesProvider) createClusterPACResources(ctx context.Context, f fn.Function, metadata pipelines.PacMetadata) error {
// figure out pac installation namespace
installed, _, err := pac.DetectPACInstallation(ctx, "")
installed, _, err := pac.DetectPACInstallation(ctx, "openshift-pipelines")
if !installed {
errMsg := ""
if err != nil {
Expand All @@ -154,7 +154,12 @@ func (pp *PipelinesProvider) createClusterPACResources(ctx context.Context, f fn
labels = pp.decorator.UpdateLabels(f, labels)
}

registry, err := docker.GetRegistry(f.Image)
img := f.Deploy.Image
if img == "" {
img = f.Image
}

registry, err := docker.GetRegistry(img)
if err != nil {
return fmt.Errorf("problem in resolving image registry name: %w", err)
}
Expand All @@ -163,7 +168,7 @@ func (pp *PipelinesProvider) createClusterPACResources(ctx context.Context, f fn
registry = authn.DefaultAuthKey
}

creds, err := pp.credentialsProvider(ctx, f.Image)
creds, err := pp.credentialsProvider(ctx, img)
if err != nil {
return err
}
Expand Down Expand Up @@ -199,7 +204,7 @@ func (pp *PipelinesProvider) createClusterPACResources(ctx context.Context, f fn
func (pp *PipelinesProvider) createRemotePACResources(ctx context.Context, f fn.Function, metadata pipelines.PacMetadata) error {

// figure out pac installation namespace
installed, installationNS, err := pac.DetectPACInstallation(ctx, "")
installed, installationNS, err := pac.DetectPACInstallation(ctx, "openshift-pipelines")
if !installed {
errMsg := ""
if err != nil {
Expand Down

0 comments on commit 799ab9d

Please sign in to comment.