From c7d8ca41cd3a45688949c065f7fe64e328ce35ae Mon Sep 17 00:00:00 2001 From: Miri Bar <37478344+mirii1994@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:57:49 +0300 Subject: [PATCH] Fix ReservedDailyGb bug (#103) * reservedDailyGb -> *float32, readme changelog * update workflow git-secrets --- .github/workflows/git-secrets.yml | 14 +++++------ README.md | 6 +++-- sub_accounts/client_sub_account.go | 2 +- sub_accounts/client_sub_account_create.go | 2 +- sub_accounts/client_sub_account_update.go | 2 +- .../sub_account_create_integration_test.go | 23 ++++++++++++++++++- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/.github/workflows/git-secrets.yml b/.github/workflows/git-secrets.yml index a3dce06..b83827e 100644 --- a/.github/workflows/git-secrets.yml +++ b/.github/workflows/git-secrets.yml @@ -1,33 +1,31 @@ name: git-secrets - # Controls when the workflow will run # Triggers the workflow on push or pull request events but only for the main branch on: [push] - # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: # This workflow contains a single job called "main" git-secrets: # The type of runner that the job will run on - runs-on: ubuntu-18.04 - + runs-on: ubuntu-22.04 # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Check Out Source Code uses: actions/checkout@v2 - - name: Set up Python 3.8 uses: actions/setup-python@v2 with: python-version: 3.8 - name: Installing dependencies run: - sudo apt-get install git less openssh-server + sudo apt-get install less openssh-server - name: Installing scanning tool run: | + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" brew install git-secrets git secrets --install - git secrets --register-aws + git secrets --register-aws - name: Running scanning tool run: - git secrets --scan + eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + git secrets --scan \ No newline at end of file diff --git a/README.md b/README.md index 9dac06a..4f4512c 100644 --- a/README.md +++ b/README.md @@ -30,18 +30,20 @@ The library currently supports the following API endpoints: ### Changelog +- v1.13.0 + - Bug fix - **sub_accounts**: field `ReservedDailyGB` in requests can be 0. - v1.12.0 - Upgrade to Go 1.18. - Refactor `users`, adjust to the recent API fields. - Add field `UserName` to `restore` initiate request, to match recent API fields. - v1.11.0 - Add [Kibana Objects](https://docs.logz.io/api/#tag/Import-or-export-Kibana-objects). -- v1.10.3 - - Bug fix - **sub_accounts**: omit maxDailyGb if needed.
Exapnd to check old versions +- v1.10.3 + - Bug fix - **sub_accounts**: omit maxDailyGb if needed. - v1.10.2 - Bug fix - **alerts_v2**: allow sending with columns without sort. - v1.10.1 diff --git a/sub_accounts/client_sub_account.go b/sub_accounts/client_sub_account.go index cb79937..bd1c430 100644 --- a/sub_accounts/client_sub_account.go +++ b/sub_accounts/client_sub_account.go @@ -29,7 +29,7 @@ type CreateOrUpdateSubAccount struct { Email string `json:"email,omitempty"` AccountName string `json:"accountName"` Flexible string `json:"isFlexible,omitempty"` // boolean - ReservedDailyGB float32 `json:"reservedDailyGB,omitempty"` + ReservedDailyGB *float32 `json:"reservedDailyGB,omitempty"` MaxDailyGB *float32 `json:"maxDailyGB,omitempty"` RetentionDays int32 `json:"retentionDays"` Searchable string `json:"searchable,omitempty"` // boolean diff --git a/sub_accounts/client_sub_account_create.go b/sub_accounts/client_sub_account_create.go index cb60021..80f4714 100644 --- a/sub_accounts/client_sub_account_create.go +++ b/sub_accounts/client_sub_account_create.go @@ -84,7 +84,7 @@ func validateCreateSubAccount(createSubAccount CreateOrUpdateSubAccount) error { return fmt.Errorf("flexible field is not set to boolean value") } } else { - if createSubAccount.ReservedDailyGB != 0 { + if createSubAccount.ReservedDailyGB != nil { return fmt.Errorf("when isFlexible=false reservedDailyGB should be 0, empty, or emitted") } } diff --git a/sub_accounts/client_sub_account_update.go b/sub_accounts/client_sub_account_update.go index bd0c52a..7df88e3 100644 --- a/sub_accounts/client_sub_account_update.go +++ b/sub_accounts/client_sub_account_update.go @@ -52,7 +52,7 @@ func validateUpdateSubAccount(updateSubAccount CreateOrUpdateSubAccount) error { return fmt.Errorf("flexible field is not set to boolean value") } } else { - if updateSubAccount.ReservedDailyGB != 0 { + if updateSubAccount.ReservedDailyGB != nil { return fmt.Errorf("when isFlexible=false reservedDailyGB should be 0, empty, or emitted") } } diff --git a/sub_accounts/sub_account_create_integration_test.go b/sub_accounts/sub_account_create_integration_test.go index c151efc..f54a98c 100644 --- a/sub_accounts/sub_account_create_integration_test.go +++ b/sub_accounts/sub_account_create_integration_test.go @@ -77,7 +77,28 @@ this test will be tested locally by uncommenting it, and not as part of the auto // createSubAccount := getCreatrOrUpdateSubAccount(email) // createSubAccount.AccountName = createSubAccount.AccountName + "_create_flexible" // createSubAccount.Flexible = strconv.FormatBool(true) -// createSubAccount.ReservedDailyGB = 1 +// createSubAccount.ReservedDailyGB = new(float32) +// *createSubAccount.ReservedDailyGB = 1 +// subAccount, err := underTest.CreateSubAccount(createSubAccount) +// +// if assert.NoError(t, err) && assert.NotNil(t, subAccount) { +// time.Sleep(4 * time.Second) +// defer underTest.DeleteSubAccount(int64(subAccount.AccountId)) +// assert.NotEmpty(t, subAccount.AccountToken) +// assert.NotEmpty(t, subAccount.AccountId) +// } +// } +//} +// +//func TestIntegrationSubAccount_CreateSubAccountFlexibleReservedZero(t *testing.T) { +// underTest, email, err := setupSubAccountsIntegrationTest() +// +// if assert.NoError(t, err) { +// createSubAccount := getCreatrOrUpdateSubAccount(email) +// createSubAccount.AccountName = createSubAccount.AccountName + "_create_flexible" +// createSubAccount.Flexible = strconv.FormatBool(true) +// createSubAccount.ReservedDailyGB = new(float32) +// *createSubAccount.ReservedDailyGB = 0 // subAccount, err := underTest.CreateSubAccount(createSubAccount) // // if assert.NoError(t, err) && assert.NotNil(t, subAccount) {