Giter Club home page Giter Club logo

os-cli's Introduction

OpenSearch Logo Nest Logo

OpenSearch CLI built in Nest,
a progressive Node.js framework for building efficient and scalable server-side applications.

NPM Version Package License Release Status

Installation

The Official opensearch-cli is also available

npm

npm install -g @andreafspeziale/os-cli

yarn

yarn global add @andreafspeziale/os-cli

pnpm

pnpm add -g @andreafspeziale/os-cli

docker

docker pull andreafspeziale/os-cli
docker run --rm --env-file .env andreafspeziale/os-cli

If using a local (docker) OpenSearch image like the one included in the docker-compose file be sure to set correctly the network option and OS_HOST env variable (OS_HOST=http://opensearch:9200) in the above command (docker run --rm --env-file .env --network os-cli_default andreafspeziale/os-cli)

If using the dockerized CLI and you need to use your json payloads as inputs you'll need to mount the folder into the CLI execution context (e.g docker run --rm --env-file .env -v ./recipes:/opt/os-cli/recipes --network os-cli_default andreafspeziale/os-cli d q -i books -f recipes/query.json)

How to use?

Quickstart

To taste the CLI very quickly using npx or after installing it you can spawn OpenSearch locally by using the docker-compose file included in the repository:

  • git clone [email protected]:andreafspeziale/os-cli.git
  • cd os-cli
  • docker compose up -d
  • export OS_CONNECTION_METHOD=local
  • npx @andreafspeziale/os-cli i l or os-cli i l

Like the docker-compose file there are also some recipes included in the repository:

  • npx @andreafspeziale/os-cli i cr -i books -f ./recipes/create-index.json or os-cli i cr -i books -f ./recipes/create-index.json
  • npx @andreafspeziale/os-cli d cr -i books -f ./recipes/create-documents.json or os-cli d cr -i books -f ./recipes/create-documents.json
  • npx @andreafspeziale/os-cli d q -i books -f ./recipes/query.json or os-cli d q -i books -f ./recipes/query.json

Configuration

For proxy mode check aws-sigv4-proxy

The CLI leverages environment variables in order to set connection and logging options just once.

Name Required Default Description Values
OS_HOST when OS_CONNECTION_METHOD is NOT local proxy `http://localhost:(9200 8080)`
OS_CONNECTION_METHOD Yes - How you want to connect to OpenSearch [local, proxy, serviceAccount, credentials]
AWS_REGION only when OS_CONNECTION_METHOD is NOT local proxy - OpenSearch AWS connection region
AWS_ROLE_ARN only when OS_CONNECTION_METHOD is serviceAccount - AWS role ARN for assume role connection -
AWS_WEB_IDENTITY_TOKEN_FILE only when OS_CONNECTION_METHOD is serviceAccount - AWS web identity token file -
AWS_ACCESS_KEY_ID only when OS_CONNECTION_METHOD is credentials - AWS access key id for canonical connection -
AWS_SECRET_ACCESS_KEY only when OS_CONNECTION_METHOD is credentials - AWS secret access key for canonical connection -
LOGGER_LEVEL No info Which logs will be displayed [silent, error, warn, info, http, verbose, debug]
LOGGER_PRETTY No true Boolean to enable/disable logs formatting true, false
LOGGER_REDACT No '' Removed specified words from logs -

For a docker local OpenSearch instance all you need to do is:

export OS_CONNECTION_METHOD=local

Instead for a canonical AWS connection method a receipt along with your values would be:

export OS_HOST=
export OS_CONNECTION_METHOD=credentials
export AWS_REGION=
export AWS_ACCESS_KEY_ID=
export AWS_SECRET_ACCESS_KEY=

Development

After cloning the repository:

  • cd os-cli
  • cp ./env/.env.development ./env
  • docker compose up -d
  • pnpm install

I personally prefer build in a terminal window and run the compiled version in a separate one like so:

  • pnpm build --watch
  • pnpm start:prod or node dist/os-cli.js

Stay in touch

License

os-cli MIT licensed.

os-cli's People

Contributors

andreafspeziale avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

os-cli's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Pending Approval

These branches will be created by Renovate only once you click their checkbox below.

  • chore: update actions/cache action to v4
  • chore: update actions/checkout action to v4
  • chore: update actions/setup-node action to v4
  • chore: update commitlint monorepo to v19 (major) (@commitlint/cli, @commitlint/config-conventional)
  • chore: update dependency @release-it/conventional-changelog to v8
  • chore: update dependency @types/supertest to v6
  • chore: update dependency eslint to v9
  • chore: update dependency eslint-config-prettier to v9
  • chore: update dependency eslint-plugin-prettier to v5
  • chore: update dependency husky to v9
  • chore: update dependency lint-staged to v15
  • chore: update dependency prettier to v3
  • chore: update dependency release-it to v17
  • chore: update dependency supertest to v7
  • chore: update docker/build-push-action action to v5
  • chore: update docker/login-action action to v3
  • chore: update docker/setup-buildx-action action to v3
  • chore: update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • fix: update dependency zod-validation-error to v3
  • ๐Ÿ” Create all pending approval PRs at once ๐Ÿ”

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore: update dependency @types/node to v20.12.10
  • chore: update dependency node to v20.13.0
  • chore: update pnpm to v9.1.0
  • fix: update dependency zod to v3.23.6
  • fix: update dependency zod-validation-error to v1.5.0
  • fix: update nest monorepo to v10.3.8 (@nestjs/common, @nestjs/core, @nestjs/schematics, @nestjs/testing)
  • ๐Ÿ” Create all rate-limited PRs at once ๐Ÿ”

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

docker-compose
docker-compose.yml
dockerfile
Dockerfile
  • node 20.12-alpine3.18
github-actions
.github/workflows/docker-build-and-push.yml
  • actions/checkout v3
  • docker/setup-buildx-action v2
  • docker/login-action v2
  • docker/build-push-action v4
.github/workflows/release.yml
  • actions/checkout v3
  • actions/setup-node v3
  • pnpm/action-setup v2
  • actions/cache v3
npm
package.json
  • @aws-sdk/credential-providers ^3.370.0
  • @nestjs/common ^10.0.0
  • @nestjs/config ^3.0.0
  • @nestjs/core ^10.0.0
  • @opensearch-project/opensearch ^2.3.0
  • nest-commander ^3.11.0
  • reflect-metadata ^0.2.0
  • winston ^3.10.0
  • zod ^3.21.4
  • zod-validation-error ^1.3.1
  • @commitlint/cli ^17.6.6
  • @commitlint/config-conventional ^17.6.6
  • @nestjs/cli ^10.0.0
  • @nestjs/schematics ^10.0.0
  • @nestjs/testing ^10.0.0
  • @release-it/conventional-changelog ^7.0.0
  • @types/jest ^29.5.2
  • @types/node ^20.3.1
  • @types/supertest ^2.0.12
  • @typescript-eslint/eslint-plugin ^5.59.11
  • @typescript-eslint/parser ^5.59.11
  • eslint ^8.42.0
  • eslint-config-prettier ^8.8.0
  • eslint-plugin-prettier ^4.2.1
  • husky ^8.0.3
  • jest ^29.5.0
  • lint-staged ^13.2.3
  • prettier ^2.8.8
  • release-it ^16.1.2
  • source-map-support ^0.5.21
  • supertest ^6.3.3
  • ts-jest ^29.1.0
  • ts-loader ^9.4.3
  • ts-node ^10.9.1
  • tsconfig-paths ^4.2.0
  • typescript ^5.1.3
  • node >=18.16.1
  • pnpm 9.0.6
nvm
.nvmrc
  • node 20.12.2

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.