Skip to content

Enhance keychain configuration and add version check feature - #44

Closed
evgenyk wants to merge 6 commits into
mainfrom
ev/semver_check
Closed

Enhance keychain configuration and add version check feature#44
evgenyk wants to merge 6 commits into
mainfrom
ev/semver_check

Conversation

@evgenyk

@evgenyk evgenyk commented Sep 8, 2025

Copy link
Copy Markdown
Contributor

Update the README to include enhancements for keychain configuration and structured logging. Introduce a version check feature for the Kinde CLI, improving automation support. Update dependencies for version comparison and enhance version command output formatting. Upgrade installation commands for better clarity.

evgenyk added 3 commits September 8, 2025 16:35
…structured logging option for improved automation support
…ison and enhance version command output formatting
@coderabbitai

coderabbitai Bot commented Sep 8, 2025

Copy link
Copy Markdown

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (2)
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ev/semver_check

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (6)
pkg/release/release.go (4)

39-45: Emit structured output for dev builds when KINDE_STRUCTURED_LOG=true.

Helps CI consume machine-readable results.

-	currentVersion, err := semver.NewVersion(strings.TrimPrefix(Version, "v"))
+	currentVersion, err := semver.NewVersion(strings.TrimPrefix(Version, "v"))
 	if err != nil {
-		// Handle development versions or invalid semver
-		fmt.Printf("Current version '%s' is not a semantic version (development build)\n", Version)
-		fmt.Printf("Latest release: %v\n", latest)
+		if structured {
+			fmt.Printf("{\"status\":\"dev_build\",\"current\":\"%s\",\"latest\":\"%s\"}\n", Version, latest)
+		} else {
+			fmt.Printf("Current version '%s' is not a semantic version (development build)\n", Version)
+			fmt.Printf("Latest release: %v\n", latest)
+		}
 		return
 	}

Add once at function start:

structured := os.Getenv("KINDE_STRUCTURED_LOG") == "true"

47-51: Return structured error on parse failure of latest tag.

Keeps CLI usable in automation.

-	latestVersion, err := semver.NewVersion(strings.TrimPrefix(latest, "v"))
+	latestVersion, err := semver.NewVersion(strings.TrimPrefix(latest, "v"))
 	if err != nil {
-		fmt.Printf("Error parsing latest version '%s': %v\n", latest, err)
+		if structured {
+			fmt.Printf("{\"status\":\"error\",\"error\":\"parse_latest\",\"current\":\"%s\",\"latest_raw\":\"%s\"}\n", Version, latest)
+		} else {
+			fmt.Printf("Error parsing latest version '%s': %v\n", latest, err)
+		}
 		return
 	}

10-10: Prepare imports for structured mode.

You’ll need os for env reads.

 	"strings"
 	"time"
 
 	"github.com/Masterminds/semver/v3"
 	"github.com/briandowns/spinner"
 	"github.com/google/go-github/v28/github"
+	"os"

53-61: Gate release output by KINDE_STRUCTURED_LOG

  • In pkg/release/release.go, parse KINDE_STRUCTURED_LOG into a structured boolean at the top of IsNeedingUpdate().
  • Wrap the spinner (and “Checking for updates…”) and the human‐readable fmt.Printf calls in if !structured { … } else { … }, emitting JSON in each branch (e.g. {"status":"update_available","current":…,"latest":…}, {"status":"latest","current":…}, {"status":"ahead","current":…,"latest":…}) when structured is true.
  • Add unit tests in pkg/release to verify both structured (JSON) and human outputs.
pkg/cmd/versionCommand.go (1)

30-31: Show a sensible version for dev builds and support quiet mode.

Print “dev” (or commit) when Version is empty; suppress ASCII art when KINDE_STRUCTURED_LOG=true.

-				fmt.Printf("Version %v\n", release.Version)
+				v := release.Version
+				if v == "" {
+					v = "dev"
+				}
+				fmt.Printf("Version %s\n", v)

Additionally (outside selected lines):

// import "os"
if os.Getenv("KINDE_STRUCTURED_LOG") == "true" {
  // skip ASCII art
} else {
  fmt.Print(`...ASCII...`)
}
README.md (1)

243-246: Add a security caution for KINDE_KEYCHAIN_PASS and clarify structured logs.

Environment-stored secrets can leak via process lists, shell history, or CI logs. Recommend a caution and note JSON-only output disables ASCII art/spinners.

-  - `KINDE_KEYCHAIN_PASS` - Override the default keychain password when user interaction is not possible
+  - `KINDE_KEYCHAIN_PASS` - Override the default keychain password when user interaction is not possible (Use with care: treat as a secret; prefer CI secret managers and ephemeral env vars.)
   - `KINDE_LOG_LEVEL` - Set the logging level for the CLI
-  - `KINDE_STRUCTURED_LOG` - Enable JSON-only output for CI/CD or automated processing (default: `false`, set to `true` to enable)
+  - `KINDE_STRUCTURED_LOG` - Enable JSON-only output for CI/CD or automated processing (default: `false`, set to `true` to enable). Disables ASCII art and spinners.
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5d62028 and f00ed8b.

⛔ Files ignored due to path filters (3)
  • .vscode/launch.json is excluded by !**/*.json
  • go.mod is excluded by !**/*.mod
  • go.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (3)
  • README.md (4 hunks)
  • pkg/cmd/versionCommand.go (1 hunks)
  • pkg/release/release.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/cmd/versionCommand.go (1)
pkg/release/release.go (1)
  • Version (16-16)
🔇 Additional comments (4)
README.md (4)

34-38: Brew upgrade snippet LGTM.

Clear and correct.


45-49: Scoop upgrade snippet LGTM.

Works as intended.


142-143: Usage entry for version is clear.

Matches the command behavior.


146-160: Document structured/quiet behavior of version or align code.

If the CLI supports KINDE_STRUCTURED_LOG, note that version disables ASCII art/spinner and emits JSON. If not yet implemented, please align code or adjust docs.

Comment thread pkg/release/release.go
Comment thread README.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (1)
pkg/release/release.go (1)

36-40: Nil-safe tag access implemented; resolves prior concern.

Using rep.GetTagName() with an empty guard avoids the nil deref reported earlier. LGTM.

🧹 Nitpick comments (3)
pkg/release/release.go (3)

42-49: Nit: normalize whitespace before parsing current version.

This makes parsing resilient to accidental spaces from build-time injection.

-	currentVersion, err := semver.NewVersion(strings.TrimPrefix(Version, "v"))
+	normalizedCurrent := strings.TrimSpace(strings.TrimPrefix(Version, "v"))
+	currentVersion, err := semver.NewVersion(normalizedCurrent)

51-55: Apply the same normalization to the latest tag.

Keeps behavior consistent and robust.

-	latestVersion, err := semver.NewVersion(strings.TrimPrefix(latest, "v"))
+	normalizedLatest := strings.TrimSpace(strings.TrimPrefix(latest, "v"))
+	latestVersion, err := semver.NewVersion(normalizedLatest)

57-65: Optional: expose a machine-readable status for automation.

To better support CI, consider returning a status (or emitting a single structured line) in addition to human text.

-func IsNeedingUpdate() {
+// UpdateStatus indicates comparison outcome for automation.
+type UpdateStatus int
+const (
+	UpdateUnknown UpdateStatus = iota
+	UpdateAvailable
+	UpdateUpToDate
+	UpdateAhead
+)
+func IsNeedingUpdate() UpdateStatus {
@@
-		fmt.Printf("An update is available: %v (current: %v)\n", latest, Version)
+		fmt.Printf("An update is available: %v (current: %v)\n", latest, Version)
+		return UpdateAvailable
 	} else if currentVersion.Equal(latestVersion) {
-		fmt.Printf("You are using the latest version: %v\n", Version)
+		fmt.Printf("You are using the latest version: %v\n", Version)
+		return UpdateUpToDate
 	} else {
-		fmt.Printf("You are using a newer version than the latest release: %v (latest: %v)\n", Version, latest)
+		fmt.Printf("You are using a newer version than the latest release: %v (latest: %v)\n", Version, latest)
+		return UpdateAhead
 	}
+	return UpdateUnknown

Alternatively, emit one line like: update_status=available|up_to_date|ahead for easy grepping.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f00ed8b and e63f204.

📒 Files selected for processing (2)
  • README.md (4 hunks)
  • pkg/release/release.go (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • README.md

Comment thread pkg/release/release.go
coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 8, 2025
@evgenyk
evgenyk dismissed coderabbitai[bot]’s stale review September 8, 2025 08:22

The merge-base changed after approval.

@evgenyk

evgenyk commented Sep 8, 2025

Copy link
Copy Markdown
Contributor Author

@CodeRabbit re-review please

@coderabbitai

coderabbitai Bot commented Sep 8, 2025

Copy link
Copy Markdown

@evgenyk I'll conduct a fresh review of your PR that enhances keychain configuration and adds the version check feature.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 8, 2025
@evgenyk
evgenyk dismissed coderabbitai[bot]’s stale review September 8, 2025 08:57

The merge-base changed after approval.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Sep 8, 2025
@evgenyk
evgenyk dismissed coderabbitai[bot]’s stale review September 8, 2025 09:02

The merge-base changed after approval.

@evgenyk
evgenyk requested a review from rairaman September 8, 2025 09:04
rairaman
rairaman previously approved these changes Sep 8, 2025
@evgenyk
evgenyk dismissed rairaman’s stale review September 8, 2025 09:08

The merge-base changed after approval.

@rairaman
rairaman self-requested a review September 8, 2025 09:25
rairaman
rairaman previously approved these changes Sep 8, 2025
@evgenyk
evgenyk dismissed rairaman’s stale review September 8, 2025 09:25

The merge-base changed after approval.

@rairaman
rairaman self-requested a review September 8, 2025 09:29
rairaman
rairaman previously approved these changes Sep 8, 2025
@evgenyk
evgenyk dismissed rairaman’s stale review September 8, 2025 09:30

The merge-base changed after approval.

@evgenyk evgenyk closed this Sep 8, 2025
@evgenyk
evgenyk deleted the ev/semver_check branch September 8, 2025 10:19
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.

2 participants