Skip to content

Conversation

@dennisvankekem
Copy link
Contributor

@dennisvankekem dennisvankekem commented Jan 6, 2026

@dennisvankekem
Copy link
Contributor Author

based on the assumption that clusterDomainSuffix is always present in settings

Copy link
Collaborator

@ferruhcihan ferruhcihan left a comment

Choose a reason for hiding this comment

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

Overall, the approach looks good 👍 I just noticed that some tests are failing in workloadUtils.test.ts, and there’s a small improvement needed in the URL checks instead of exact match.

: normalizeRepoUrl(repositoryUrl, isPrivate, isSSH)

const repoUrl =
repositoryUrl === `https://gitea.${cluster?.domainSuffix}`
Copy link
Collaborator

Choose a reason for hiding this comment

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

This check would never match any actual repository URL and will cause all internal Gitea repositories to fail the equality check. For the URL check, we could use something like the following:

  const isInternalGitea = (() => {
    try {
      const url = new URL(repositoryUrl)
      return url.hostname === `gitea.${cluster?.domainSuffix}`
    } catch {
      return false
    }
  })()

  const repoUrl = isInternalGitea
    ? repositoryUrl
    : normalizeRepoUrl(repositoryUrl, isPrivate, isSSH)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add an isInternalGiteaURL function and replace the duplicated checks with this function call. I wil also make a test for it

post:
operationId: getWorkloadCatalog
x-eov-operation-handler: v1/workloadCatalog
x-aclSchema: Workload
Copy link
Contributor

Choose a reason for hiding this comment

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

Why schema is called workload if the resource is tWorkloadCatalog?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

WorkloadCatalog is part of the Workload workflow

if (!existsSync(localHelmChartsDir)) mkdirSync(localHelmChartsDir, { recursive: true })
let gitUrl = helmChartCatalogUrl
if (isGiteaURL(helmChartCatalogUrl)) {
if (helmChartCatalogUrl === `https://gitea.${clusterDomainSuffix}`) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you could also rely on HELM_CHART_CATALOG env

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good tip! I will take it into account

@dennisvankekem dennisvankekem requested a review from Copilot January 9, 2026 09:15
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses bug APL-1412 by adding missing ACL schema declarations and replacing the isGiteaURL helper function with a direct string comparison against the cluster domain suffix.

  • Adds x-aclSchema: Workload to three API endpoints that were missing ACL schema declarations
  • Replaces isGiteaURL() function calls with explicit URL comparison using clusterDomainSuffix parameter
  • Threads the clusterDomainSuffix parameter through the workload utility functions

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/openapi/api.yaml Adds missing x-aclSchema: Workload declarations to workload catalog endpoints
src/utils/workloadUtils.ts Updates URL validation from isGiteaURL() to explicit domain suffix comparison
src/otomi-stack.ts Passes cluster?.domainSuffix to workload functions and normalizes import ordering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!existsSync(localHelmChartsDir)) mkdirSync(localHelmChartsDir, { recursive: true })
let gitUrl = helmChartCatalogUrl
if (isGiteaURL(helmChartCatalogUrl)) {
if (helmChartCatalogUrl === `https://gitea.${clusterDomainSuffix}`) {
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The URL comparison will fail when clusterDomainSuffix is undefined. The condition should check if clusterDomainSuffix exists before comparing, or use startsWith to match the URL pattern more robustly.

Suggested change
if (helmChartCatalogUrl === `https://gitea.${clusterDomainSuffix}`) {
if (clusterDomainSuffix && helmChartCatalogUrl.startsWith(`https://gitea.${clusterDomainSuffix}`)) {

Copilot uses AI. Check for mistakes.
if (!existsSync(helmChartsDir)) mkdirSync(helmChartsDir, { recursive: true })
let gitUrl = url
if (isGiteaURL(url)) {
if (url === `https://gitea.${clusterDomainSuffix}`) {
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

The URL comparison will fail when clusterDomainSuffix is undefined. The condition should check if clusterDomainSuffix exists before comparing, or use startsWith to match the URL pattern more robustly.

Suggested change
if (url === `https://gitea.${clusterDomainSuffix}`) {
if (clusterDomainSuffix && url.startsWith(`https://gitea.${clusterDomainSuffix}`)) {

Copilot uses AI. Check for mistakes.
Comment on lines +1229 to +1230
const repoUrl =
repositoryUrl === `https://gitea.${cluster?.domainSuffix}`
Copy link

Copilot AI Jan 9, 2026

Choose a reason for hiding this comment

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

When cluster?.domainSuffix is undefined, this creates the string 'https://gitea.undefined' which will cause incorrect URL matching. Add a guard to check cluster?.domainSuffix exists before string interpolation.

Suggested change
const repoUrl =
repositoryUrl === `https://gitea.${cluster?.domainSuffix}`
const giteaUrl = cluster?.domainSuffix ? `https://gitea.${cluster.domainSuffix}` : undefined
const repoUrl =
giteaUrl && repositoryUrl === giteaUrl

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants