Skip to content

Commit

Permalink
Fix ReservedDailyGb bug (#103)
Browse files Browse the repository at this point in the history
* reservedDailyGb -> *float32, readme changelog

* update workflow git-secrets
  • Loading branch information
mirii1994 authored Oct 20, 2022
1 parent b4022aa commit c7d8ca4
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 14 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/git-secrets.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<details>
<summary markdown="span">Exapnd to check old versions </summary>

- 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
Expand Down
2 changes: 1 addition & 1 deletion sub_accounts/client_sub_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sub_accounts/client_sub_account_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
2 changes: 1 addition & 1 deletion sub_accounts/client_sub_account_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Expand Down
23 changes: 22 additions & 1 deletion sub_accounts/sub_account_create_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit c7d8ca4

Please sign in to comment.