Skip to content

Commit

Permalink
Merge branch 'main' into CLC-215
Browse files Browse the repository at this point in the history
  • Loading branch information
kutluhanmetin committed Sep 26, 2023
2 parents 4dc089a + 28cc0fb commit f8e4162
Show file tree
Hide file tree
Showing 255 changed files with 7,399 additions and 5,391 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_release-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: "Set up Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Download Inno Setup installer"
run: "curl -L -o installer.exe http://files.jrsoftware.org/is/6/innosetup-${{ env.INNO_VERSION }}.exe"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: "Set up Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Build the Project"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage_runner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.19'
go-version: '1.21'

- name: Install JDK
uses: actions/setup-java@v2
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/jira.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ jobs:
JIRA_BASE_URL: ${{ secrets.JIRA_BASE_URL }}
JIRA_USER_EMAIL: ${{ secrets.JIRA_USER_EMAIL }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
TARGET_JIRA_PROJECT: API
JIRA_LABEL: CLC
TARGET_JIRA_PROJECT: CLC
ISSUE_TYPE: Bug
7 changes: 1 addition & 6 deletions .github/workflows/nightly_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
- name: "Setup Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Install Go tools"
run: |
Expand All @@ -80,9 +80,4 @@ jobs:
- name: "Run All Tests"
run: |
make test
- name: "Run Coverage"
run: |
make test-cover
make view-cover
2 changes: 1 addition & 1 deletion .github/workflows/test-all-386.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- name: "Setup Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Install Go tools"
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: "Setup Go"
uses: "actions/setup-go@v3"
with:
go-version: "1.19"
go-version: "1.21"

- name: "Install Go Tools"
run: |
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

GIT_COMMIT = $(shell git rev-parse HEAD 2> /dev/null || echo unknown)
CLC_VERSION ?= v0.0.0-CUSTOMBUILD
CLC_SKIP_UPDATE_CHECK ?= 0
LDFLAGS = "-s -w -X 'github.com/hazelcast/hazelcast-commandline-client/internal.GitCommit=$(GIT_COMMIT)' -X 'github.com/hazelcast/hazelcast-commandline-client/internal.Version=$(CLC_VERSION)' -X 'github.com/hazelcast/hazelcast-go-client/internal.ClientType=CLC' -X 'github.com/hazelcast/hazelcast-go-client/internal.ClientVersion=$(CLC_VERSION)' -X 'github.com/hazelcast/hazelcast-commandline-client/internal.SkipUpdateCheck=$(CLC_SKIP_UPDATE_CHECK)'"
MAIN_CMD_HELP ?= Hazelcast CLC
LDFLAGS = -s -w -X 'github.com/hazelcast/hazelcast-commandline-client/clc/cmd.MainCommandShortHelp=$(MAIN_CMD_HELP)' -X 'github.com/hazelcast/hazelcast-commandline-client/internal.GitCommit=$(GIT_COMMIT)' -X 'github.com/hazelcast/hazelcast-commandline-client/internal.Version=$(CLC_VERSION)' -X 'github.com/hazelcast/hazelcast-go-client/internal.ClientType=CLC' -X 'github.com/hazelcast/hazelcast-go-client/internal.ClientVersion=$(CLC_VERSION)'
TEST_FLAGS ?= -v -count 1 -timeout 30m -race
TEST_FLAGS ?= -count 1 -timeout 30m -race
COVERAGE_OUT = coverage.out
PACKAGES = $(shell go list ./... | grep -v internal/it | tr '\n' ',')
BINARY_NAME ?= clc
Expand Down
56 changes: 29 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,40 @@

## Installation

We provide binaries for the popular platforms at our [Releases](https://github.com/hazelcast/hazelcast-commandline-client/releases) page.
In order to install CLC:

* Download the release package for your platform,
* Extract it,
* Optionally move the `clc` binary to somewhere in your *PATH*, so it can be run in any terminal without additional settings.

Currently we provide precompiled binaries of CLC for the following platforms and architectures:

* Linux/amd64
* Windows/amd64
* MacOS/amd64
* MacOS/arm64
* macOS/amd64
* macOS/arm64

Additionally, we provide an installer for Windows 10 and up.
The installer can install CLC for either system-wide or just for the user.
It adds the `clc` binary automatically to the `$PATH`, so it can be run in any terminal without additional settings.
### Linux / macOS

You can run the following command to install the latest stable CLC on a computer running Linux x64 or macOS 10.15 (Catalina) x64/ARM 64 (M1/M2):
```
curl -sL https://raw.githubusercontent.com/hazelcast/hazelcast-commandline-client/main/extras/unix/install.sh | bash
```

On MacOS, you may need to remove the CLC binary from quarantine, if you get a security warning:
On macOS, binaries downloaded outside of AppStore require your intervention to run.
The install script automatically handles this, but if you downloaded a release package you can do it manually:
```
$ xattr -d com.apple.quarantine CLC_FOLDER/clc
```
Use the correct path instead of `CLC_FOLDER` in the command above.

### Windows

We provide an installer for Windows 10 and up.
The installer can install CLC either system-wide or just for the user.
It adds the `clc` binary automatically to the `$PATH`, so it can be run in any terminal without additional settings.

Check out our [Releases](https://github.com/hazelcast/hazelcast-commandline-client/releases/latest) page for the download.

### Building from Source

If your platform is not one of the above, you may want to compile CLC yourself. Our build process is very simple and doesn't have many dependencies.
In most cases just running `make` is sufficient to build CLC if you have the latest [Go](https://go.dev/) compiler installed.
See [Building from source](#building-from-source) section.
In most cases, running `make` is sufficient to build CLC if you have the latest [Go](https://go.dev/) compiler and GNU make installed.
See [Building from source](#building-from-source) section for detailed instructions.

## Usage Summary

Expand All @@ -51,14 +58,6 @@ This file can exist anywhere in the file system, and can be used with the `--con
$ clc -c test/config.yaml
```

If there is a `config.yaml` in the same directory with the CLC binary and the configuration was not explicitly set, CLC tries to load that configuration file:
```
$ ls -lh
total 17M
-rwxrwxr-x 1 yuce yuce 17M Nov 26 23:11 clc*
-rw------- 1 yuce yuce 200 Nov 26 23:12 config.yaml
```

`configs` directory in `$CLC_HOME` is special, it contains all the configurations known to CLC.
Known configurations can be directly specified by their names, instead of the full path.
`clc config list` command lists the configurations known to CLC:
Expand All @@ -73,6 +72,9 @@ $ clc -c pr-3066
```

If no configuration is specified, the `default` configuration is used if it exists.
The name of the default configuration may be overriden using the `CLC_CONFIG` environment variable.

If there's only a single named configuration, then it is used if the configuration is not specified with `-c`/`--config`.

#### Configuration format

Expand Down Expand Up @@ -202,14 +204,14 @@ The following targets are tested and supported.
The prior versions of the given targets would also work, but that's not tested.

* Ubuntu 22.04 or better.
* MacOS 12 or better.
* macOS 15 or better.
* Windows 10 or better.

### Requirements

* Go 1.19 or better
* Go 1.21 or better
* Git
* GNU Make (on Linux and MacOS)
* GNU Make (on Linux and macOS)
* Command Prompt or Powershell (on Windows)
* go-winres: https://github.com/tc-hib/go-winres (on Windows)

Expand All @@ -236,7 +238,7 @@ The `clc` or `clc.exe` binary is created in the `build` directory.

CLC starts the in interactive mode by default.

On Linux and MacOS:
On Linux and macOS:
```
./build/clc
```
Expand Down
54 changes: 9 additions & 45 deletions base/commands/atomic_long/atomic_long.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,30 @@ package atomiclong

import (
"context"
"fmt"

"github.com/hazelcast/hazelcast-go-client"

"github.com/hazelcast/hazelcast-commandline-client/base"
"github.com/hazelcast/hazelcast-commandline-client/clc"
. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

const (
atomicLongFlagName = "name"
atomicLongPropertyName = "atomic-long"
)

type AtomicLongCommand struct {
}
type Command struct{}

func (mc *AtomicLongCommand) Init(cc plug.InitContext) error {
func (Command) Init(cc plug.InitContext) error {
cc.SetCommandUsage("atomic-long")
cc.AddCommandGroup(clc.GroupDDSID, clc.GroupDDSTitle)
cc.SetCommandGroup(clc.GroupDDSID)
cc.AddStringFlag(atomicLongFlagName, "n", defaultAtomicLongName, false, "atomic long name")
cc.SetTopLevel(true)
cc.SetCommandUsage("atomic-long [command] [flags]")
help := "Atomic long operations"
help := "AtomicLong operations"
cc.SetCommandHelp(help, help)
cc.AddStringFlag(base.FlagName, "n", base.DefaultName, false, "AtomicLong name")
return nil
}

func (mc *AtomicLongCommand) Exec(context.Context, plug.ExecContext) error {
return nil
}

func (mc *AtomicLongCommand) Augment(ec plug.ExecContext, props *plug.Properties) error {
ctx := context.TODO()
props.SetBlocking(atomicLongPropertyName, func() (any, error) {
name := ec.Props().GetString(atomicLongFlagName)
// empty atomic long name is allowed
ci, err := ec.ClientInternal(ctx)
if err != nil {
return nil, err
}
mv, stop, err := ec.ExecuteBlocking(ctx, func(ctx context.Context, sp clc.Spinner) (any, error) {
sp.SetText(fmt.Sprintf("Getting atomic long %s", name))
m, err := ci.Client().CPSubsystem().GetAtomicLong(ctx, name)
if err != nil {
return nil, err
}
return m, nil
})
if err != nil {
return nil, err
}
stop()
return mv.(*hazelcast.AtomicLong), nil
})
func (Command) Exec(context.Context, plug.ExecContext) error {
return nil
}

func init() {
cmd := &AtomicLongCommand{}
Must(plug.Registry.RegisterCommand("atomic-long", cmd))
plug.Registry.RegisterAugmentor("20-atomic-long", cmd)
check.Must(plug.Registry.RegisterCommand("atomic-long", &Command{}))
}
15 changes: 7 additions & 8 deletions base/commands/atomic_long/atomic_long_decrement_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@ package atomiclong
import (
"context"

. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

type AtomicLongDecrementGetCommand struct{}
type DecrementGetCommand struct{}

func (mc *AtomicLongDecrementGetCommand) Init(cc plug.InitContext) error {
cc.SetPositionalArgCount(0, 0)
func (DecrementGetCommand) Init(cc plug.InitContext) error {
cc.SetCommandUsage("decrement-get")
help := "Decrement the AtomicLong by the given value"
cc.AddIntFlag(atomicLongFlagBy, "", 1, false, "value to decrement by")
cc.SetCommandHelp(help, help)
cc.SetCommandUsage("decrement-get [flags]")
cc.AddIntFlag(flagBy, "", 1, false, "value to decrement by")
return nil
}

func (mc *AtomicLongDecrementGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
func (DecrementGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
return atomicLongChangeValue(ctx, ec, "Decrement", func(i int64) int64 { return -1 * i })
}

func init() {
Must(plug.Registry.RegisterCommand("atomic-long:decrement-get", &AtomicLongDecrementGetCommand{}))
check.Must(plug.Registry.RegisterCommand("atomic-long:decrement-get", &DecrementGetCommand{}))
}
14 changes: 14 additions & 0 deletions base/commands/atomic_long/atomic_long_destroy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//go:build std || atomiclong

package atomiclong

import (
"github.com/hazelcast/hazelcast-commandline-client/base/commands"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
)

func init() {
c := commands.NewDestroyCommand("AtomicLong", getAtomicLong)
check.Must(plug.Registry.RegisterCommand("atomic-long:destroy", c))
}
46 changes: 21 additions & 25 deletions base/commands/atomic_long/atomic_long_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,50 @@ import (
"context"
"fmt"

"github.com/hazelcast/hazelcast-go-client"

"github.com/hazelcast/hazelcast-commandline-client/clc"
. "github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/clc/cmd"
"github.com/hazelcast/hazelcast-commandline-client/internal/check"
"github.com/hazelcast/hazelcast-commandline-client/internal/output"
"github.com/hazelcast/hazelcast-commandline-client/internal/plug"
"github.com/hazelcast/hazelcast-commandline-client/internal/serialization"
)

type AtomicLongGetCommand struct{}
type GetCommand struct{}

func (mc *AtomicLongGetCommand) Init(cc plug.InitContext) error {
func (GetCommand) Init(cc plug.InitContext) error {
cc.SetCommandUsage("get")
help := "Get the value of the AtomicLong"
cc.SetCommandHelp(help, help)
cc.SetCommandUsage("get")
cc.SetPositionalArgCount(0, 0)
return nil
}

func (mc *AtomicLongGetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
al, err := ec.Props().GetBlocking(atomicLongPropertyName)
if err != nil {
return err
}
ali := al.(*hazelcast.AtomicLong)
vali, stop, err := ec.ExecuteBlocking(ctx, func(ctx context.Context, sp clc.Spinner) (any, error) {
sp.SetText(fmt.Sprintf("Setting value into AtomicLong %s", ali.Name()))
func (GetCommand) Exec(ctx context.Context, ec plug.ExecContext) error {
row, stop, err := cmd.ExecuteBlocking(ctx, ec, func(ctx context.Context, sp clc.Spinner) (output.Row, error) {
ali, err := getAtomicLong(ctx, ec, sp)
if err != nil {
return nil, err
}
sp.SetText(fmt.Sprintf("Getting value of AtomicLong %s", ali.Name()))
val, err := ali.Get(ctx)
if err != nil {
return nil, err
}
return val, nil
row := output.Row{
output.Column{
Name: "Value",
Type: serialization.TypeInt64,
Value: val,
},
}
return row, nil
})
if err != nil {
return err
}
stop()
val := vali.(int64)
row := output.Row{
output.Column{
Name: "Value",
Type: serialization.TypeInt64,
Value: val,
},
}
return ec.AddOutputRows(ctx, row)
}

func init() {
Must(plug.Registry.RegisterCommand("atomic-long:get", &AtomicLongGetCommand{}))
check.Must(plug.Registry.RegisterCommand("atomic-long:get", &GetCommand{}))
}
Loading

0 comments on commit f8e4162

Please sign in to comment.