Skip to content

fix(tekton/v1): request publisher with auth#4568

Open
ti-chi-bot wants to merge 4 commits into
mainfrom
fix/request-publisher-with-auth
Open

fix(tekton/v1): request publisher with auth#4568
ti-chi-bot wants to merge 4 commits into
mainfrom
fix/request-publisher-with-auth

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Collaborator

  • ci(tekton): add optional publisher-auth workspace to pipelines and task
  • feat(tekton): add publisher-auth secret to build component templates
  • feat(tekton): make publisher auth secret name configurable

Add a `publisher-auth-secret-name` parameter to build component
templates and bindings, allowing different secrets to be used per
environment.
@wuhuizuo
Copy link
Copy Markdown
Contributor

/approve

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 30, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wuhuizuo

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added the approved label Apr 30, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces basic authentication for the publisher service across several Tekton pipelines and tasks by adding a publisher-auth workspace and updating the delivery logic. Feedback highlights a critical issue where PipelineRun creation will fail if the publisher-auth-secret-name parameter is empty, as Kubernetes does not permit empty secret names in volume sources. Additionally, the shell script in the delivery task should be refactored to use bash arrays for safe command-line argument handling and to use hardcoded workspace paths for consistency.

Comment on lines +131 to +133
- name: publisher-auth
secret:
secretName: $(tt.params.publisher-auth-secret-name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This mapping will cause the PipelineRun creation to fail when $(tt.params.publisher-auth-secret-name) is an empty string (as seen in several TriggerBinding files like gcp-internal-build-params.yaml). Kubernetes does not allow an empty secretName in a Secret volume source. Since the publisher-auth workspace is optional in the Pipeline, it should ideally be omitted from the PipelineRun when no authentication is required. However, since TriggerTemplate does not support conditional workspace blocks, you might need to use a different approach for optional secrets, such as passing the secret name as a parameter to the Pipeline and using secretKeyRef with optional: true in the Task's environment variables instead of a workspace.

Comment on lines +132 to +134
- name: publisher-auth
secret:
secretName: $(tt.params.publisher-auth-secret-name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This mapping will cause the PipelineRun creation to fail when $(tt.params.publisher-auth-secret-name) is an empty string. Kubernetes does not allow an empty secretName in a Secret volume source.

Comment on lines +116 to +118
- name: publisher-auth
secret:
secretName: $(tt.params.publisher-auth-secret-name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This mapping will cause the PipelineRun creation to fail when $(tt.params.publisher-auth-secret-name) is an empty string. Kubernetes does not allow an empty secretName in a Secret volume source.

Comment on lines +140 to +142
- name: publisher-auth
secret:
secretName: $(tt.params.publisher-auth-secret-name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This mapping will cause the PipelineRun creation to fail when $(tt.params.publisher-auth-secret-name) is an empty string. Kubernetes does not allow an empty secretName in a Secret volume source.

Comment on lines +114 to +116
- name: publisher-auth
secret:
secretName: $(tt.params.publisher-auth-secret-name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This mapping will cause the PipelineRun creation to fail when $(tt.params.publisher-auth-secret-name) is an empty string. Kubernetes does not allow an empty secretName in a Secret volume source.

Comment on lines +54 to 72
auth_opt=""

# If publisher-auth workspace is provided, use basic auth
if [ -f "$(workspaces.publisher-auth.path)/username" ] && \
[ -f "$(workspaces.publisher-auth.path)/password" ]; then
user="$(cat $(workspaces.publisher-auth.path)/username)"
pass="$(cat $(workspaces.publisher-auth.path)/password)"
auth_opt="-u '${user}:${pass}'"
fi

deliver() {
local artifact_url="$1"
echo "Delivering artifact_url: $artifact_url"
# shellcheck disable=SC2086
response=$(curl -s -X POST "$publisher_url" \
$auth_opt \
-H "Content-Type: application/json" \
-d "{\"artifact_url\":\"$artifact_url\"}")
echo "Response: $response"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using a string variable to store optional command-line arguments like -u '${user}:${pass}' is fragile. When expanded unquoted in the curl command, the literal single quotes will be passed as part of the credentials to curl, which will cause authentication to fail. Additionally, unquoted expansion ($auth_opt) will break if the username or password contains spaces. Using a bash array is the standard and safe way to handle optional arguments in scripts. Furthermore, use the hardcoded path /workspace/publisher-auth instead of the $(workspaces.publisher-auth.path) variable for consistency with repository standards.

        auth_args=()\n\n        # If publisher-auth workspace is provided, use basic auth\n        if [ -f "/workspace/publisher-auth/username" ] && \\\n           [ -f "/workspace/publisher-auth/password" ]; then\n          user="$(cat "/workspace/publisher-auth/username")"\n          pass="$(cat "/workspace/publisher-auth/password")"\n          auth_args=("-u" "${user}:${pass}")\n        fi\n\n        deliver() {\n          local artifact_url="$1"\n          echo "Delivering artifact_url: $artifact_url"\n          response=$(curl -s -X POST "$publisher_url" \\\n            "${auth_args[@]}" \\\n            -H "Content-Type: application/json" \\\n            -d "{\"artifact_url\":\"$artifact_url\"}")\n          echo "Response: $response"\n        }
References
  1. In Tekton pipelines, use the hardcoded path /workspace/... to refer to shared directories within the source workspace for consistency, rather than using the $(workspaces.source.path) variable.

@wuhuizuo wuhuizuo marked this pull request as draft April 30, 2026 12:14
@wuhuizuo wuhuizuo marked this pull request as ready for review April 30, 2026 12:15
@wuhuizuo
Copy link
Copy Markdown
Contributor

/hold

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants