Skip to content

Conversation

@zacharyblasczyk
Copy link
Member

@zacharyblasczyk zacharyblasczyk commented Jan 13, 2026

This fixes the azure endpoint to reflect what is returned by kubectl cluster-info.

Summary by CodeRabbit

Bug Fixes

  • Enhanced Azure AKS cluster endpoint extraction and normalization to ensure consistent and reliable cluster synchronization.

Refactor

  • Consolidated endpoint processing logic for improved consistency across cluster configuration operations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

📝 Walkthrough

Walkthrough

A refactoring that extracts endpoint derivation logic from the processCluster function into a dedicated getEndpoint helper function. This centralizes endpoint formatting logic for handling PrivateFQDN/Fqdn resolution, scheme normalization, and port appending across the codebase.

Changes

Cohort / File(s) Summary
Endpoint extraction refactoring
cmd/ctrlc/root/sync/azure/aks/aks.go
Introduces getEndpoint() helper function to centralize endpoint derivation logic. Removes inlined endpoint extraction from processCluster, consolidating PrivateFQDN/Fqdn resolution, scheme normalization (https://), and port handling (:443) into a single reusable function.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A helper hops in with grace so fine,
Tangled endpoints now in line,
PrivateFQDN or Fqdn, it finds the way,
Port and scheme in perfect play! 🔗

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(aks): correct the endpoint' directly relates to the main change: extracting and centralizing endpoint derivation logic in the AKS integration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
cmd/ctrlc/root/sync/azure/aks/aks.go (1)

384-406: Port detection logic is fragile.

The check !strings.Contains(endpoint, ":443") would produce an invalid URL if the endpoint already contains a different port (e.g., https://example.com:8443 would become https://example.com:8443:443).

While AKS API servers typically use port 443, a more robust approach would parse the URL to check for any existing port:

♻️ Suggested improvement using URL parsing
+import "net/url"
+
 func getEndpoint(cluster *armcontainerservice.ManagedCluster) string {
 	endpoint := ""
 	if cluster.Properties.PrivateFQDN != nil {
 		endpoint = *cluster.Properties.PrivateFQDN
 	} else if cluster.Properties.Fqdn != nil {
 		endpoint = *cluster.Properties.Fqdn
 	}
 
 	if endpoint == "" {
 		return ""
 	}
 
 	if !strings.HasPrefix(endpoint, "http://") && !strings.HasPrefix(endpoint, "https://") {
 		endpoint = fmt.Sprintf("https://%s", endpoint)
 	}
 
 	// AKS kubeconfig includes :443, and ArgoCD uses the exact server URL as identifier
-	if !strings.Contains(endpoint, ":443") {
-		endpoint = fmt.Sprintf("%s:443", endpoint)
+	u, err := url.Parse(endpoint)
+	if err != nil {
+		return endpoint
+	}
+	if u.Port() == "" {
+		u.Host = u.Host + ":443"
 	}
 
-	return endpoint
+	return u.String()
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ad56622 and f51ad57.

📒 Files selected for processing (1)
  • cmd/ctrlc/root/sync/azure/aks/aks.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: docker (linux/amd64)
🔇 Additional comments (1)
cmd/ctrlc/root/sync/azure/aks/aks.go (1)

234-237: LGTM - Endpoint extraction centralized.

The refactoring to use getEndpoint(cluster) here correctly centralizes the endpoint derivation logic, ensuring consistency with the metadata at line 287.

@zacharyblasczyk zacharyblasczyk merged commit 75fd3dd into main Jan 13, 2026
2 checks passed
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.

3 participants