Repository navigation
v0.6.0 - The vngcloud Command
Highlights
- New
vngcloudcommand, installed with
go install danny.vn/vngcloud/cmd/vngcloud@latest. It coversbilling,
pricing,compute,network, anddns, with one subcommand per SDK
operation and flags derived from each operation's Input. --output json|table|text,--query(JMESPath),--cli-input-json, and
--debug, which logs each request's method, path, status, and timing and
never a body, header, token, or credential.- Errors print to stderr as one JSON line with stable exit codes: 1 for API
or network errors and cancellation, 2 for usage and config errors, 3 for
credential and login errors, 4 for not found. - Destructive commands (
billing delete-budget,delete-budget-threshold)
need--yes. Nothing prompts without a terminal. - Read-only profiles:
read_only = true,VNGCLOUD_READ_ONLY=1, or
--read-onlymakes every write command fail before any request. vngcloud configureandconfigure set|get|listedit
~/.vngcloud/configandcredentialssafely: mode 0600 files in a 0700
directory, written through a temp file and rename, symlinks kept, secrets
never taken from the command line.- Generated CLI reference pages in the wiki.
- SDK:
vngcloud.LoginErrorreports a failed login step, its HTTP status,
and a suspected captcha, and never carries a credential.WithLoggernow
logs requests at Debug level.Config.ProfileSettingreads a key from the
resolved profile.
Behavior changes
APIError.Code(andErrorCode) now falls back to a status-derived code
when the API gives none:BadRequest,Unauthorized,Forbidden,
NotFound,Conflict,Throttled,ServerError, orClientError. An
envelope code equal to the HTTP status counts as none, so a billing 400 is
BadRequestrather than"400".- Login failures return
*vngcloud.LoginError. It matchesErrAuth,
except when the login was cancelled or timed out: then it matches
context.Canceledorcontext.DeadlineExceededinstead.
Dependencies
The command adds github.com/spf13/cobra, github.com/spf13/pflag,
github.com/jmespath/go-jmespath, and golang.org/x/term (with
golang.org/x/sys and, on Windows, github.com/inconshreveable/mousetrap).
Only cmd/vngcloud and internal/cli import them; the SDK packages stay
standard-library only, and CI checks it.