Skip to content

Add first few commands - #2

Merged
josefkarasek merged 11 commits into
kedify:mainfrom
josefkarasek:list-clusters-2
Jun 16, 2026
Merged

josefkarasek merged 11 commits into
kedify:mainfrom
josefkarasek:list-clusters-2

Conversation

@josefkarasek

@josefkarasek josefkarasek commented Jun 16, 2026 •

Copy link
Copy Markdown
Contributor

This PR introduces the first working version of the kedify CLI with a small but solid command surface, reusable internal structure, interactive terminal UX where it helps, and CI/release scaffolding.

The CLI now supports:

  • kedify login
  • kedify list clusters
  • kedify get cluster

It uses:

  • kong for command parsing, flags, and help text
  • bubbletea for interactive flows
  • lipgloss for styling
  • OS keyring for credential storage when available, with file fallback

Command Overview

kedify login

  • Stores the Kedify API token for later commands.
  • Token can come from:
    • positional arg
    • env/flag-provided token
    • interactive prompt / stdin
  • Interactive input hides the token as it is typed.
  • Prompts are written to stderr so stdout stays clean for shell usage.
  • Users are instructed to generate a token at https://dashboard.dev.kedify.io/api-keys.
  • Credentials are stored in the OS credential store when available.
  • If no system credential store is available, it falls back to ~/.config/kedify/credentials.json.

kedify list clusters

  • Calls the Kedify clusters API and transparently follows pagination until all pages are loaded.
  • Supports --output / -o with:
    • text (default)
    • json
    • yaml
  • The default text output is human-readable and kubectl-inspired.
  • The text table includes key cluster fields such as:
    • name
    • id
    • agent version
    • keda version
    • statuses
    • age

kedify get cluster [name-or-id]

  • Fetches one cluster.
  • If no argument is provided, it opens an interactive cluster picker.
  • If a cluster name is provided, it resolves from the cluster list.
  • If a UUID is provided, it uses the dedicated cluster detail endpoint directly.

UUID Behavior in get cluster

This PR adds explicit UUID-aware behavior to kedify get cluster.

How it works:

  • If the argument is a valid UUID, kedify get cluster calls:
    • GET /v1/clusters/<uuid>
  • If the argument is not a UUID, it treats it as a cluster name and searches the cluster list response.
  • If no argument is provided:
    • the CLI first shows an interactive picker
    • once a cluster is selected, if that cluster has a valid UUID, the CLI uses the dedicated UUID endpoint for the final fetch

That gives us:

  • better API semantics
  • a cleaner path for exact cluster lookup
  • future flexibility if names are non-unique or mutable

Output Behavior

All resource commands support:

  • --output
  • -o

Formats:

  • text
  • json
  • yaml

Design intent:

  • text is for humans
  • json/yaml are for scripts and automation
  • interactive prompts and helper text go to stderr, keeping stdout safe for piping

Internal Structure

The repo was organized to keep CLI concerns separated:

  • command parsing and command handlers in internal/cli
  • HTTP/API client logic in internal/api
  • credential/config handling in internal/config
  • renderers in internal/output
  • interactive terminal flows in internal/tui
  • entrypoint in cmd/kedify

This keeps the command layer testable and makes it easier to grow from kedify <verb> <noun> over time.

Testing

The layout was made unit-test friendly, and tests were added around:

  • command behavior
  • API client behavior
  • config/credential handling
  • output formatting
  • TUI helper behavior

CI and Release Work

This PR also adds supporting project automation:

  • PR check workflow
  • Make targets for build/test/lint
  • pinned local golangci-lint behavior for better CI reproduction
  • starter GoReleaser-based release setup
  • multi-arch release targeting
  • Cosign integration scaffolding

Copilot AI review requested due to automatic review settings June 16, 2026 08:33

Copilot AI 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.

Pull request overview

Introduces an experimental kedify Go CLI with local credential storage, an interactive Bubble Tea-based login prompt, and a list clusters command that fetches clusters from the Kedify API and outputs JSON/YAML.

Changes:

  • Add CLI entrypoint and command routing for login and list clusters, including global --apiurl override and -o/--output formatting.
  • Implement credential read/write to ~/.config/kedify/credentials.json and a Bubble Tea + Lip Gloss interactive (hidden) token prompt.
  • Add a simple HTTP API client that paginates through /clusters and aggregates results.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
README.md Documents CLI features, authentication, build, and usage examples.
Makefile Adds a make build target to compile ./cmd/kedify into ./bin/kedify.
internal/tui/login.go Implements Bubble Tea login prompt + stdin fallback for token entry.
internal/output/output.go Adds JSON/YAML encoding helper for command output.
internal/config/config.go Implements credential persistence and env-based API URL override helper.
internal/cli/run.go Adds core CLI routing, global flags parsing, and list clusters flag parsing/help.
internal/cli/output.go Thin wrapper to centralize output writing.
internal/cli/login.go Implements kedify login command and help text.
internal/api/client.go Implements HTTP client + pagination logic for listing clusters.
go.mod Defines module and dependencies (Bubble Tea, Lip Gloss, YAML).
go.sum Adds dependency checksums.
cmd/kedify/main.go Adds program entrypoint wiring stdin/stdout/stderr into the CLI runner.
.gitignore Ignores .agents.

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

Comment thread internal/api/client.go Outdated
Comment thread internal/output/output.go Outdated
Comment thread internal/tui/login.go Outdated
Comment thread README.md Outdated
Copilot AI review requested due to automatic review settings June 16, 2026 11:13

Copilot AI 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.

Pull request overview

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

Comment thread internal/cli/login.go
Comment thread internal/cli/auth.go
Comment thread internal/cli/list.go
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 16, 2026 13:30

Copilot AI 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.

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 4 comments.

Comment thread internal/cli/login.go Outdated
Comment thread internal/cli/auth.go
Comment thread internal/api/client.go Outdated
Comment thread README.md
@github-advanced-security

Copy link
Copy Markdown

You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool.

What Enabling Code Scanning Means:

  • The 'Security' tab will display more code scanning analysis results (e.g., for the default branch).
  • Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results.
  • You will be able to see the analysis results for the pull request's branch on this overview once the scans have completed and the checks have passed.

For more information about GitHub Code Scanning, check out the documentation.

Comment thread internal/config/config.go Fixed
Comment thread internal/config/config.go Fixed
Comment thread internal/tui/login.go Fixed
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
@josefkarasek josefkarasek changed the title Use libraries bubbletea + lipgloss for list clusters Add first few commands Jun 16, 2026
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 16, 2026 13:56

Copilot AI 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.

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 2 comments.

Comment thread internal/cli/get.go Outdated
Comment thread README.md Outdated
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>
Copilot AI review requested due to automatic review settings June 16, 2026 14:20

Copilot AI 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.

Pull request overview

Copilot reviewed 23 out of 25 changed files in this pull request and generated 1 comment.

Comment thread internal/tui/cluster_picker.go Outdated
Signed-off-by: Josef Karasek <karasek.jose@gmail.com>

@zroubalik zroubalik left a comment

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.

@josefkarasek
josefkarasek merged commit 007b1a3 into kedify:main Jun 16, 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.

4 participants