Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ builds:
flags:
- -trimpath
ldflags:
- -s -w -X main.version={{.Version}}
- -s -w
- -X main.version={{.Version}}
- -X main.commit={{.ShortCommit}}
- -X main.buildDate={{.Date}}
goos:
- linux
- darwin
Expand Down
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
.DEFAULT_GOAL := help

GO ?= go
LDFLAGS ?= -s -w -X main.version=$(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo none)
BUILD_DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")

LDFLAGS ?= \
-s -w \
-X main.version=$(VERSION) \
-X main.commit=$(COMMIT) \
-X main.buildDate=$(BUILD_DATE)

BIN_DIR := bin

.PHONY: help
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<p align="center">
<img src="docs/commands/optiqor-hori.jpg" alt="Optiqor" width="520">

Check warning on line 2 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (Optiqor)

Check warning on line 2 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (hori)

Check warning on line 2 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (optiqor)
</p>

<p align="center"><b>Detect. Fix. Prove.</b></p>
Expand All @@ -13,7 +13,7 @@
[![Downloads](https://img.shields.io/npm/dm/@optiqor/cli.svg)](https://www.npmjs.com/package/@optiqor/cli)

```sh
npx @optiqor/cli analyze ./my-helm-chart

Check warning on line 16 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (optiqor)
```

That is it. One command. No setup. No account. Cost findings for your Kubernetes workloads in under three seconds.
Expand All @@ -22,7 +22,7 @@

## Table of Contents

- [Why Optiqor CLI](#why-optiqor-cli)

Check warning on line 25 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (Optiqor)
- [Install](#install)
- [Quick Start](#quick-start)
- [How It Works](#how-it-works)
Expand All @@ -32,20 +32,20 @@
- [CLI vs Agent vs Sandbox](#cli-vs-agent-vs-sandbox)
- [Configuration](#configuration)
- [Privacy and Accuracy](#privacy-and-accuracy)
- [The Full Optiqor Platform](#the-full-optiqor-platform)

Check warning on line 35 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (Optiqor)
- [FAQ](#faq)
- [Contributing](#contributing)
- [License](#license)

---

## Why Optiqor CLI

Check warning on line 42 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (Optiqor)

Most Kubernetes cost tools require you to install an agent in your cluster, expose Prometheus, and wait 30 days for data. That is the right call for production teams who need exact numbers.

But sometimes you just want a directional answer **right now** about a chart you are reviewing.

The Optiqor CLI is a deterministic rule engine that reads your Helm chart files (or `values.yaml`) and reports cost inefficiencies in seconds. It runs fully offline. It does not phone home. It is honest about what it can and cannot tell from static files alone.

Check warning on line 48 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (Optiqor)

> [!TIP]
> **Bonus:** while it is parsing your chart for cost waste, it also flags the obvious Kubernetes security misconfigurations it sees (`runAsRoot`, `:latest` tags, missing `securityContext`, host namespaces, etc.). This is a side-effect of the parser — not the headline feature. If you need a real security posture tool, use one. If you happen to also catch them for free during a cost review, even better.
Expand All @@ -60,13 +60,13 @@
### Option 1: npx (zero-install, recommended for one-off use)

```sh
npx @optiqor/cli analyze ./chart

Check warning on line 63 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (optiqor)
```

### Option 2: Global npm install

```sh
npm install -g @optiqor/cli

Check warning on line 69 in README.md

View workflow job for this annotation

GitHub Actions / Spell check

Unknown word (optiqor)
optiqor analyze ./chart
```

Expand Down Expand Up @@ -185,6 +185,7 @@
| `compare <a> <b>` | Currently an alias for `diff` (richer output ships in Phase 7) | Beta |
| `watch [chart]` | Re-analyze on file change | Coming soon |
| `--version` | Print version and exit | Stable |
| `--version --verbose` | Print full version and exit | Stable |
| `--help` | Help for any command | Stable |

### Filter and exit-code flags
Expand Down Expand Up @@ -439,6 +440,8 @@

| Flag | Default | Description |
| --- | --- | --- |
| `--version` | true | Print version and exit |
| `--version --verbose` | true | Print full version and exit |
| `--json` | false | Emit machine-readable JSON |
| `--offline` | true | Do not perform any network calls |
| `--share` | false | Upload sanitized analysis to optiqor.dev (opt-in) |
Expand Down
43 changes: 38 additions & 5 deletions cmd/optiqor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"io"
"os"
"path/filepath"
"runtime"

"github.com/spf13/cobra"

Expand All @@ -34,13 +35,38 @@ const (
// errFindings is a sentinel returned from RunE so main can map it to exitFindings.
var errFindings = errors.New("optiqor: findings exceed threshold")

var version = "dev"
var (
version = "dev"
commit = "none"
buildDate = "unknown"
)

// accuracyDisclosure is the mandatory line every command's help and
// output must contain (hard rule per CLAUDE.md).
const accuracyDisclosure = "Sandbox accuracy: ±40%. Install the Optiqor agent for exact numbers (optiqor.dev/get)."

func main() {
var showVersion bool
var verbose bool

for _, arg := range os.Args[1:] {
switch arg {
case "--version", "-v":
showVersion = true
case "--verbose":
verbose = true
}
}

if showVersion {
if verbose {
fmt.Println(versionTemplate())
} else {
fmt.Printf("optiqor %s\n", version)
}
os.Exit(0)
}

err := newRootCmd().Execute()
switch {
case err == nil:
Expand All @@ -59,6 +85,7 @@ func newRootCmd() *cobra.Command {
noColor bool
configPath string
)
var verboseVersion bool

root := &cobra.Command{
Use: "optiqor",
Expand Down Expand Up @@ -90,7 +117,7 @@ namespaces, etc.). Cost is the headline; security is a side-effect.

root.PersistentFlags().BoolVar(&noColor, "no-color", false, "disable colored output (also: NO_COLOR env)")
root.PersistentFlags().StringVar(&configPath, "config", "", "path to .optiqor.yaml (default: ./.optiqor.yaml or $OPTIQOR_CONFIG)")

root.PersistentFlags().BoolVar(&verboseVersion, "verbose", false, "show detailed version information")
root.PersistentPreRunE = func(cmd *cobra.Command, _ []string) error {
cfg, err := config.Load(configPath)
if err != nil {
Expand All @@ -105,8 +132,6 @@ namespaces, etc.). Cost is the headline; security is a side-effect.
return nil
}

root.SetVersionTemplate(versionTemplate())

root.AddCommand(
newAnalyzeCmd(),
newDemoCmd(),
Expand All @@ -121,7 +146,15 @@ namespaces, etc.). Cost is the headline; security is a side-effect.
}

func versionTemplate() string {
return fmt.Sprintf("optiqor %s — %s\n", version, "Helm chart cost analysis (security bonus)")
return fmt.Sprintf(
"optiqor %s\ncommit: %s\nbuilt: %s\ngo version: %s\nos/arch: %s/%s",
version,
commit,
buildDate,
runtime.Version(),
runtime.GOOS,
runtime.GOARCH,
)
}

func newAnalyzeCmd() *cobra.Command {
Expand Down
Loading