Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/integration-test-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
java: [ 11 ]
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: ${{ matrix.java }}

- name: Checkout OpenSearch
uses: actions/checkout@v3
uses: actions/checkout@v6
with:
repository: opensearch-project/opensearch
ref: ${{ env.OPENSEARCH_VERSION }}
Expand All @@ -43,12 +43,12 @@ jobs:
sleep 90

- name: Set up Go ubuntu-latest
uses: actions/setup-go@v2
uses: actions/setup-go@v6
with:
go-version: 1.18.2
go-version: '1.26'

- name: Check out source code
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Run Integration Tests
env:
Expand Down
29 changes: 7 additions & 22 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,21 @@ jobs:
strategy:
matrix:
entry:
- { opensearch_version: 1.0.1 }
- { opensearch_version: 1.1.0 }
- { opensearch_version: 1.2.4 }
- { opensearch_version: 1.3.8 }
- { opensearch_version: 2.0.1 }
- { opensearch_version: 2.1.0 }
- { opensearch_version: 2.2.1 }
- { opensearch_version: 2.3.0 }
- { opensearch_version: 2.4.1 }
- { opensearch_version: 2.5.0 }
- { opensearch_version: 2.6.0 }
- { opensearch_version: 2.7.0 }
- { opensearch_version: 2.8.0 }
- { opensearch_version: 2.9.0 }
- { opensearch_version: 2.10.0 }
- { opensearch_version: 2.11.0 }
go-version: [ 1.18.2 ]
- { opensearch_version: 2.19.4 }
- { opensearch_version: 3.6.0 }
runs-on: ubuntu-latest
steps:
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v2
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
go-version: '1.26'

- name: Check out source code
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Run Docker Image
env:
OPENSEARCH_VERSION: ${{ matrix.opensearch-version }}
OPENSEARCH_VERSION: ${{ matrix.entry.opensearch_version }}
run: |
make docker.start.components
sleep 60
Expand Down
26 changes: 12 additions & 14 deletions .github/workflows/test-build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Set up Go ubuntu-latest
uses: actions/setup-go@v2
uses: actions/setup-go@v6
with:
go-version: 1.18.2
go-version: '1.26'

- name: Install goimports
run: go install golang.org/x/tools/cmd/goimports@latest

- name: Check out source code
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Format check
run: goimports -w .

- name: Check for modified files
id: git-check
run: |
echo ::set-output name=modified::$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)
echo "modified=$(if git diff-index --quiet HEAD --; then echo "false"; else echo "true"; fi)" >> "$GITHUB_OUTPUT"

- name: Display unformated changes and fail if any
if: steps.git-check.outputs.modified == 'true'
Expand All @@ -40,10 +40,9 @@ jobs:
exit 1

- name: Lint check
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v9
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.50.1
version: v2.11

- name: Run Unit Tests
env:
Expand All @@ -53,7 +52,7 @@ jobs:
go tool cover -func=coverage.out

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v5
with:
token: ${{secrets.CODECOV_TOKEN}}
file: coverage.out
Expand All @@ -65,18 +64,17 @@ jobs:
strategy:
matrix:
platform: [ ubuntu-latest, macos-latest, windows-latest ]
go-version: [ 1.18.2 ]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Go ${{ matrix.platform }}
uses: actions/setup-go@v2
uses: actions/setup-go@v6
with:
go-version: ${{ matrix.go-version }}
go-version: '1.26'

- name: Check out source code
uses: actions/checkout@v3
uses: actions/checkout@v6

- name: Build for ${{ matrix.platform }}-${{ matrix.go-version }}
- name: Build for ${{ matrix.platform }}
env:
GOPROXY: "https://proxy.golang.org"
run: go build .
run: go build .
11 changes: 6 additions & 5 deletions COMPATIBILITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

The below matrix shows the compatibility of the [`opensearch-cli`](https://github.com/opensearch-project/opensearch-cli/releases) with versions of [`OpenSearch`](https://opensearch.org/downloads.html#opensearch).

| OpenSearch CLI | OpenSearch |
| ------------- | --------------- |
| 1.0.0 | 1.0.0 |
| 1.1.0 | 1.x |
| 1.1.0 | 2.x |
| OpenSearch CLI | OpenSearch |
|----------------|------------|
| 1.0.0 | 1.0.0 |
| 1.1.0 | 1.x, 2.x |
| 1.2.0 | 2.x |
| 1.3.0 | 2.x, 3.x |
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ INTEGRATION_TEST_PATH=./it/...
ENV_LOCAL_TEST=\
OPENSEARCH_ENDPOINT="https://localhost:9200" \
OPENSEARCH_USER="admin" \
OPENSEARCH_PASSWORD="admin"
OPENSEARCH_PASSWORD="MyStr0ngP@ssw0rd!"

# this command will start a docker components that we set in docker-compose.yml
docker.start.components:
docker-compose up -d;
docker compose up -d;

# shutting down docker components
docker.stop:
docker-compose down;
docker compose down;

# clean up docker
docker.clean:
Expand Down
6 changes: 3 additions & 3 deletions client/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import (

const defaultTimeout = 10

//Client is an Abstraction for actual client
// Client is an Abstraction for actual client
type Client struct {
HTTPClient *retryablehttp.Client
}

//NewDefaultClient return new instance of client
// NewDefaultClient return new instance of client
func NewDefaultClient(tripper http.RoundTripper) (*Client, error) {

client := retryablehttp.NewClient()
Expand All @@ -38,7 +38,7 @@ func NewDefaultClient(tripper http.RoundTripper) (*Client, error) {
}, nil
}

//New takes transport and uses accordingly
// New takes transport and uses accordingly
func New(tripper http.RoundTripper) (*Client, error) {
if tripper == nil {
tripper = &http.Transport{
Expand Down
2 changes: 1 addition & 1 deletion client/mocks/mock_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (f RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error) {
return f(req), nil
}

//NewTestClient returns *http.Client with Transport replaced to avoid making real calls
// NewTestClient returns *http.Client with Transport replaced to avoid making real calls
func NewTestClient(fn RoundTripFunc) *client.Client {
c, err := client.New(fn)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions commands/ad.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const (
adCommandName = "ad"
)

//adCommand is base command for Anomaly Detection plugin.
// adCommand is base command for Anomaly Detection plugin.
var adCommand = &cobra.Command{
Use: adCommandName,
Short: "Manage the Anomaly Detection plugin",
Expand All @@ -39,13 +39,13 @@ func init() {
GetRoot().AddCommand(adCommand)
}

//GetADCommand returns AD base command, since this will be needed for subcommands
//to add as parent later
// GetADCommand returns AD base command, since this will be needed for subcommands
// to add as parent later
func GetADCommand() *cobra.Command {
return adCommand
}

//GetADHandler returns handler by wiring the dependency manually
// GetADHandler returns handler by wiring the dependency manually
func GetADHandler() (*handler.Handler, error) {
c, err := client.New(nil)
if err != nil {
Expand Down
8 changes: 4 additions & 4 deletions commands/ad_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (
generate = "generate-template"
)

//createCmd creates detectors with configuration from input file, if interactive mode is on,
//this command will prompt for confirmation on number of detectors will be created on executions.
// createCmd creates detectors with configuration from input file, if interactive mode is on,
// this command will prompt for confirmation on number of detectors will be created on executions.
var createCmd = &cobra.Command{
Use: createDetectorsCommandName + " json-file-path ...",
Short: "Create detectors based on JSON files",
Expand All @@ -46,7 +46,7 @@ var createCmd = &cobra.Command{
},
}

//generateTemplate prints sample detector configuration
// generateTemplate prints sample detector configuration
func generateTemplate() {
detector, _ := handler.GenerateAnomalyDetector()
fmt.Println(string(detector))
Expand All @@ -59,7 +59,7 @@ func init() {

}

//createDetectors create detectors based on configurations from fileNames
// createDetectors create detectors based on configurations from fileNames
func createDetectors(fileNames []string) error {

commandHandler, err := GetADHandler()
Expand Down
6 changes: 3 additions & 3 deletions commands/ad_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ const (
detectorForceDeletionFlagName = "force"
)

//deleteDetectorsCmd deletes detectors based on id, name or name regex pattern.
//default input is name pattern, one can change this format to be id by passing --id flag
// deleteDetectorsCmd deletes detectors based on id, name or name regex pattern.
// default input is name pattern, one can change this format to be id by passing --id flag
var deleteDetectorsCmd = &cobra.Command{
Use: deleteDetectorsCommandName + " detector_name ..." + " [flags] ",
Short: "Delete detectors based on a list of IDs, names, or name regex patterns",
Expand All @@ -51,7 +51,7 @@ func init() {
deleteDetectorsCmd.Flags().BoolP("help", "h", false, "Help for "+deleteDetectorsCommandName)
}

//deleteDetectors deletes detectors with force by calling delete method provided
// deleteDetectors deletes detectors with force by calling delete method provided
func deleteDetectors(detectors []string, force bool, f func(*handler.Handler, string, bool) error) error {
commandHandler, err := GetADHandler()
if err != nil {
Expand Down
18 changes: 9 additions & 9 deletions commands/ad_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ const (
getDetectorIDFlagName = "id"
)

//getDetectorsCmd prints detectors configuration based on id, name or name regex pattern.
//default input is name pattern, one can change this format to be id by passing --id flag
// getDetectorsCmd prints detectors configuration based on id, name or name regex pattern.
// default input is name pattern, one can change this format to be id by passing --id flag
var getDetectorsCmd = &cobra.Command{
Use: getDetectorsCommandName + " detector_name ..." + " [flags] ",
Short: "Get detectors based on a list of IDs, names, or name regex patterns",
Expand All @@ -45,7 +45,7 @@ var getDetectorsCmd = &cobra.Command{

type Display func(*cobra.Command, *entity.DetectorOutput) error

//printDetectors print detectors
// printDetectors print detectors
func printDetectors(display Display, cmd *cobra.Command, detectors []string) error {
idStatus, _ := cmd.Flags().GetBool(getDetectorIDFlagName)
commandHandler, err := GetADHandler()
Expand All @@ -64,7 +64,7 @@ func printDetectors(display Display, cmd *cobra.Command, detectors []string) err
return fprint(cmd, display, results)
}

//getDetectors fetch detector from controller
// getDetectors fetch detector from controller
func getDetectors(
commandHandler *ad.Handler, args []string, get func(*ad.Handler, string) (
[]*entity.DetectorOutput, error)) ([]*entity.DetectorOutput, error) {
Expand All @@ -79,7 +79,7 @@ func getDetectors(
return results, nil
}

//getDetectorsByID gets detector output based on ID as argument
// getDetectorsByID gets detector output based on ID as argument
func getDetectorsByID(commandHandler *ad.Handler, ID string) ([]*entity.DetectorOutput, error) {

output, err := ad.GetAnomalyDetectorByID(commandHandler, ID)
Expand All @@ -89,7 +89,7 @@ func getDetectorsByID(commandHandler *ad.Handler, ID string) ([]*entity.Detector
return []*entity.DetectorOutput{output}, nil
}

//fprint displays the list of detectors.
// fprint displays the list of detectors.
func fprint(cmd *cobra.Command, display Display, results []*entity.DetectorOutput) error {
if results == nil {
return nil
Expand All @@ -102,8 +102,8 @@ func fprint(cmd *cobra.Command, display Display, results []*entity.DetectorOutpu
return nil
}

//FPrint prints detector configuration on writer
//Since this is json format, use indent function to pretty print before printing on writer
// FPrint prints detector configuration on writer
// Since this is json format, use indent function to pretty print before printing on writer
func FPrint(writer io.Writer, d *entity.DetectorOutput) error {
formattedOutput, err := json.MarshalIndent(d, "", " ")
if err != nil {
Expand All @@ -113,7 +113,7 @@ func FPrint(writer io.Writer, d *entity.DetectorOutput) error {
return err
}

//Println prints detector configuration on stdout
// Println prints detector configuration on stdout
func Println(cmd *cobra.Command, d *entity.DetectorOutput) error {
return FPrint(os.Stdout, d)
}
Expand Down
8 changes: 4 additions & 4 deletions commands/ad_start_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const (
idFlagName = "id"
)

//startDetectorsCmd start detectors based on id, name or name regex pattern.
//default input is name pattern, one can change this format to be id by passing --id flag
// startDetectorsCmd start detectors based on id, name or name regex pattern.
// default input is name pattern, one can change this format to be id by passing --id flag
var startDetectorsCmd = &cobra.Command{
Use: startDetectorsCommandName + " detector_name ..." + " [flags] ",
Short: "Start detectors based on a list of IDs, names, or name regex patterns",
Expand All @@ -44,8 +44,8 @@ var startDetectorsCmd = &cobra.Command{
},
}

//stopDetectorsCmd stops detectors based on id and name pattern.
//default input is name pattern, one can change this format to be id by passing --id flag
// stopDetectorsCmd stops detectors based on id and name pattern.
// default input is name pattern, one can change this format to be id by passing --id flag
var stopDetectorsCmd = &cobra.Command{
Use: stopDetectorsCommandName + " detector_name ..." + " [flags] ",
Short: "Stop detectors based on a list of IDs, names, or name regex patterns",
Expand Down
2 changes: 1 addition & 1 deletion commands/ad_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
startFlagName = "start"
)

//updateDetectorsCmd updates detectors with configuration from input file
// updateDetectorsCmd updates detectors with configuration from input file
var updateDetectorsCmd = &cobra.Command{
Use: updateDetectorsCommandName + " json-file-path ... [flags]",
Short: "Update detectors based on JSON files",
Expand Down
2 changes: 1 addition & 1 deletion commands/completion.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ var completionCmd = &cobra.Command{
Long: longText,
DisableFlagsInUseLine: true,
ValidArgs: []string{BashShell, ZshShell, FishShell, PowerShell},
Args: cobra.ExactValidArgs(1),
Args: cobra.MatchAll(cobra.ExactArgs(1), cobra.OnlyValidArgs),
Run: func(cmd *cobra.Command, args []string) {
var err error
switch args[0] {
Expand Down
Loading