ic

command module
v0.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2024 License: MIT Imports: 2 Imported by: 0

README

Inventory CLI (ic)

ci tag

This is the CLI used to interact with k8s-inventory-server.

Installation

From Release Distribution on GitHub

This only works on MacOS and Linux:

tag=$(
    curl --silent -H "Accept: application/vnd.github.v3+json" \
    https://api.github.com/repos/neticdk-k8s/ic/releases/latest \
    | jq -r .tag_name
)

curl -L https://github.com/neticdk-k8s/ic/releases/download/${tag}/ic-${tag}-$(uname -s|tr A-Z a-z)-$(uname -m).tar.gz \
    | tar xzf - /usr/local/bin/ic

For Windows, go to the release page and download the zip archive.

From Source
Using go install

You will need:

  • go

Run:

GOPRIVATE=github.com/neticdk/go-common go install github.com/neticdk-k8s/ic@latest

The executable will be installed in $GOPATH/bin Add it to your PATH if you haven't already.

Using make install

You will need:

  • go
  • golangci-lint

Checkout this repository and run:

make install

The executable will be installed in $GOPATH/bin Add it to your PATH if you haven't already.

Introduction

Basic usage:

ic COMMAND [flags]
Authentication

Most commands require authentication. By default, browser based OICD authentication will be used.

If you want to use keyboard based OICD authentication you can use the --oidc-grant-type authcode-keyboard flag.

ic will try to refresh the token on every run.

Tokens are cached in the default user cache directory for the Operating System ic is running on:

  • ~/Library/Caches/ic/oidc-login/ on MacOS
  • $XDG_CACHE_HOME (typically $HOME/.cache) on Linux
  • %LocalAppData% on Windows
Output

Commands will output log messages and errors to stderr and normal output to stdout.

The default format is text which in usually means tables. In most cases commands will support json output via the --output-format json flag.

Colors and other flashy things are disabled while running in a non-interactive environment (e.g. when redirecting output to a log file). This can be controlled via the --interactive flag.

If you don't want headers printed you can use the --no-headers flag. This can be useful for piping output to other commands.

Commands and Usage

See docs/ic.md for more documentation on the commands.

You may also run ic help.

Development

Configuration for Local Development

You might want to create a configuration file named ic.toml in the root directory that looks something like this:

log-level="debug"
oidc-issuer-url="http://localhost:8080/realms/test"
api-server="http://localhost:8087"
Code Generation
Mocks

Interface mocks are generated using mockery

The command used is:

mockery --with-expecter --inpackage --name <interface name>
OpenAPI Client Code

The inventory server provides an OpenAPI 2.0 spec.

We use oapi-codegen to generate the client code. See docs/openapi.md.

Make Targets
  • make build builds bin/ic
  • make test runs tests
  • make install builds and install the ic command
  • make docker-build builds a docker image
  • make gen runs code generation
  • make doc generates command line documentation in docs/
  • make release-patch tags and pushes the next patch release
  • make release-minor tags and pushes a new minor release

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
apiclient
Package apiclient provides primitives to interact with the openapi HTTP API.
Package apiclient provides primitives to interact with the openapi HTTP API.
jwt
ui

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL