Git Product home page Git Product logo

axon-server-cli's Introduction

Axon Server Command line interface

Release Software License Go Doc Go Report Card Powered By: GoReleaser

The intention of this repo is to have a similar cli as in axon-server-cli but written in go instead of java. This is more of a learning exercise of go language but should be as much usable as the official cli.

The Axon Server command line interface allows updating the Axon Server configuration through scripts or from a command line.

For the Axon Server Standard edition the only supported commands are:

  • metrics
  • users
  • register-user
  • delete-user

Axon Server Enterprise edition supports these additional commands:โ€Œ

  • applications
  • register-application
  • delete-application
  • init-cluster
  • cluster
  • update-license
  • register-node
  • unregister-node
  • contexts
  • register-context
  • delete-context
  • add-node-to-context
  • delete-node-from-context

The option -S with the url to the Axon Server is optional, if it is omitted it defaults to http://localhost:8024.

Access control

When running Axon Server with access control enabled, executing commands remotely requires an access token. This has to provided with the -t option. When you run a command on the Axon Server node itself, you don't have to provide a token.

For Axon Server Standard Edition, the token is specified in the axonserver.properties file (property name = axoniq.axonserver.token). The token needs to be supplied using the -t option in any of the commands.

Config

This specific cli accept a configuration file named axonserver-cli.yaml on the same directory or using -config flag to override it. In this file you can set default values for flags such as server and token.

Commands

This section describes some commands with examples supported by the command line interface. Mind that the list above is marking the ones which are already done. All commands have the -h option, which will show all the info you need to know including all the flags you can set.

For example:

axon-server-cli -h

This CLI is used to perform actions on AxonServer

Usage:
  axon-server-cli [command]

Available Commands:
  application commands related to applications
  context     commands related to contexts
  help        Help about any command
  user        Commands related to users

Flags:
      --config string   config file (default is axonserver-cli.yaml)
  -h, --help            help for axon-server-cli
  -S, --server string   URL of AxonServer (default "http://localhost:8024")
  -t, --token string    Authentication Token
  -v, --version         version for axon-server-cli

Use "axon-server-cli [command] --help" for more information about a command.

or axon-server-cli user -h

This is the command related to users

Usage:
  axon-server-cli user [command]

Aliases:
  user, u

Available Commands:
  delete      Remove a user
  list        list all the users
  register    Register a user

Flags:
  -h, --help   help for user

Global Flags:
      --config string   config file (default is axonserver-cli.yaml)
  -S, --server string   URL of AxonServer (default "http://localhost:8024")
  -t, --token string    Authentication Token

Use "axon-server-cli user [command] --help" for more information about a command.

or even deeper axon-server-cli user register -h

register a user to be used on axonserver

Usage:
  axon-server-cli user register [flags]

Aliases:
  register, r

Flags:
  -h, --help              help for register
  -p, --password string   user password
  -r, --roles strings     user roles
  -u, --username string   user username

Global Flags:
      --config string   config file (default is axonserver-cli.yaml)
  -S, --server string   URL of AxonServer (default "http://localhost:8024")
  -t, --token string    Authentication Token

Release process

Release is automatic triggered by a git tag using goreleaser. For do that, you have to create a new tag using git tag -a vx.y.z -m "my release message" and push it to the repo using git push origin master --tags.

axon-server-cli's People

Contributors

bert-laverman avatar dependabot-preview[bot] avatar dependabot[bot] avatar lfgcampos avatar noblica avatar

Stargazers

 avatar  avatar

axon-server-cli's Issues

Introduce a verbose flag

For all operations we print things related to config, to the command, URLs, etc.
We should only print all that when the verbose flag is active.

"application register" is missing settoken option

From axonserver-cli:

/**
     * Defines the token for a new application. If this is omitted Axon Server will generate a token.
     */
    public static final Option SET_TOKEN = Option
            .builder("T")
            .longOpt("token")
            .hasArg()
            .desc("use this token for the app")
            .build();

[Refactor]: Use local command variables wherever possible.

Currently we have a lot of commands which use global package variables (declared at the top of the file).
Instead of doing that, we should get them via the cmd pointer, that's passed in to the Run function of the command, like so:

func deleteApplication(cmd *cobra.Command, args []string) {
  applicationName, _ := cmd.Flags().GetString("application")
  ...
}

Where, in the example, application is a flag command.

Overload our httpwrapper to work without token

As it current is, out httpwrapper.go only works when we have a token.
We need to overload the methods to work without a token as well since this is not a hard requirement on AxonServer.

Check which flags are required and mark them

Some of the flags are required but we are not marking tham as such.

We should revisit all the commands and check which flags are required and add the following to them:
ex: clusterRegisterNodeCmd.MarkFlagRequired("internal-host")

Introduce a global flag for pretty json

In axonserver-cli, we have a flag called json for it.

ex: JSON, err := json.MarshalIndent(input, "", " ")

The JSON input (or output) would be:

$ ./axon-server-cli.exe application register -a myapp -d "My app from go cli" -r USE_CONTEXT@default
Using config file: C:\Users\Domin\IdeaProjects\axon-server-cli\axonserver-cli.yaml
2020/06/22 14:59:47 calling: http://localhost:8024/v1/applications
applicationJson:
{
  "name": "myapp",
  "description": "My app from go cli",
  "roles": [
    {
      "context": "default",
      "roles": [
        "USE_CONTEXT"
      ]
    }
  ]
}

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.