Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When a command returns an empty array in JSON it should not be null #869

Closed
jerome-quere opened this issue Apr 15, 2020 · 3 comments · Fixed by #1034
Closed

When a command returns an empty array in JSON it should not be null #869

jerome-quere opened this issue Apr 15, 2020 · 3 comments · Fixed by #1034
Assignees
Labels
Milestone

Comments

@jerome-quere
Copy link
Contributor

When using JSON output with a command that returns an empty list we should have [] not null
example

$> scw instance volume list volume-type=b_ssd
null
@Sh4d1
Copy link
Contributor

Sh4d1 commented Apr 24, 2020

Blocked by golang/go#37711
It may be possible with some dirty hacks though

@Sh4d1
Copy link
Contributor

Sh4d1 commented Apr 24, 2020

Something like:

    var output string
    buff := bytes.NewBufferString(output)
    err = json.NewEncoder(buff).Encode(data)
    if err != nil {
        return err
    }
    if buff.String() == "null\n" {
        _, err = o.Writer.Write([]byte("{}\n"))
        return err
    }
    _, err = o.Writer.Write([]byte(buff.String()))
    return err

But it's ugly 😅

@remyleone
Copy link
Member

We can use an if before calling JSONEncode.

@remyleone remyleone self-assigned this May 28, 2020
@remyleone remyleone linked a pull request May 28, 2020 that will close this issue
clement-gilbert pushed a commit to clement-gilbert/scaleway-cli that referenced this issue Mar 3, 2022
Replace "scaleway_iot_hub_device" with "scaleway_iot_device"

Co-authored-by: Rémy Léone <rleone@scaleway.com>
clement-gilbert pushed a commit to clement-gilbert/scaleway-cli that referenced this issue Mar 3, 2022
* feat(lb): Add LB Private Network support

* feat(lb): Add LB Route support

* fixup! feat(lb): Add LB Private Network support

* fix: increase rdb instance creation timeout to 15m (scaleway#868)

Co-authored-by: Antoine Barbare <abarbare@online.net>

* doc: fix broken links following the release of the LB Zoned API (scaleway#871)

* fix(docs) wrong name for resource iot_device (scaleway#869)

Replace "scaleway_iot_hub_device" with "scaleway_iot_device"

Co-authored-by: Rémy Léone <rleone@scaleway.com>

* chore: add a SECURITY.md (scaleway#872)

* feat(domain): add record resource (scaleway#854)

Co-authored-by: Jeremy JACQUEMIN <jjacquemin@scaleway.com>

* doc: fix default runtime on k8s_pool (scaleway#873)

* feat(iot): Add ability to set user device certificate (scaleway#859)

* feat(iot): add ability to set user device certificate

* test(iot): add test for user device certificate

* test(iot): use unique resource names in tests to prevent conflict between tests set

* test(iot): update cassettes for iot-device-minimal

* chore: add a SECURITY.md (scaleway#872)

* feat(domain): add record resource (scaleway#854)

Co-authored-by: Jeremy JACQUEMIN <jjacquemin@scaleway.com>

* doc: fix default runtime on k8s_pool (scaleway#873)

Co-authored-by: Jerome Malinge <jmalinge@online.net>
Co-authored-by: Rémy Léone <rleone@scaleway.com>
Co-authored-by: jerjako <contact@jerjako.com>
Co-authored-by: Jeremy JACQUEMIN <jjacquemin@scaleway.com>
Co-authored-by: Jérémy THERIN <jtherin@users.noreply.github.com>
Co-authored-by: jaime Bernabe <jbernabe@student.42.fr>

* feat(instance): Adding the datasource for instance ip (scaleway#870)

* feat(instance): Adding the datasource for instance ip

* refactoring: using ParseIP to validate the IP

* fix: use proper validation

* minor fixes

* style(tfproviderlint): S019: schema should omit Computed, Optional, or Required set to false

* fix: avoiding one api call if the ID is passed

Co-authored-by: Rémy Léone <rleone@scaleway.com>
Co-authored-by: jaime Bernabe <jbernabe@student.42.fr>

* feat(lb): add data source for lb (scaleway#760)

* feat(lb): add data source for lb

* Fix

* Update scaleway/data_source_lb.go

Co-authored-by: Jerome Quere <pub@jeromequere.fr>

* Update scaleway/data_source_lb.go

Co-authored-by: Jerome Quere <pub@jeromequere.fr>

* Update docs/data-sources/lb.md

Co-authored-by: Quentin Brosse <quentin.brosse@icloud.com>

* Fix

* Fix

* Fix

* feat(lb): remove repeated explanation

* feat(lb): update lb datasource reader with zone

* feat(lb): update lb datasource reader with zone and test

Co-authored-by: Jerome Quere <pub@jeromequere.fr>
Co-authored-by: Quentin Brosse <quentin.brosse@icloud.com>
Co-authored-by: jaime Bernabe <jbernabe@student.42.fr>
Co-authored-by: Jaime BERNABE <jbernabe@scaleway.com>

* feat(vpcgw): add support for DHCP (scaleway#865)

* feat(vpcgw): add support for DHCP

* Fix

* Fix

* Fix

* Fix

* feat(lb): update vpc gw dhcp and small corrections

* feat(vpc_public_gateway_dhcp): fix doc and test

Co-authored-by: jaime Bernabe <6184069+Monitob@users.noreply.github.com>
Co-authored-by: Jaime BERNABE <jbernabe@scaleway.com>

* feat(domain): Add domain record data source (scaleway#874)

* feat(domain): Add domain record data source

* fix tests

Co-authored-by: Jeremy JACQUEMIN <jjacquemin@scaleway.com>
Co-authored-by: jaime Bernabe <6184069+Monitob@users.noreply.github.com>

* chore: add support for dependabot (scaleway#877)

* chore(deps): bump github.com/aws/aws-sdk-go from 1.39.3 to 1.40.53 (scaleway#878)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.39.3 to 1.40.53.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.39.3...v1.40.53)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/hashicorp/terraform-plugin-sdk/v2 (scaleway#880)

Bumps [github.com/hashicorp/terraform-plugin-sdk/v2](https://github.com/hashicorp/terraform-plugin-sdk) from 2.7.0 to 2.8.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-sdk/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-sdk/blob/main/CHANGELOG.md)
- [Commits](hashicorp/terraform-plugin-sdk@v2.7.0...v2.8.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-sdk/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rémy Léone <rleone@scaleway.com>

* chore(deps): bump github.com/dnaeon/go-vcr from 1.1.0 to 1.2.0 (scaleway#879)

Bumps [github.com/dnaeon/go-vcr](https://github.com/dnaeon/go-vcr) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/dnaeon/go-vcr/releases)
- [Commits](dnaeon/go-vcr@v1.1.0...v1.2.0)

---
updated-dependencies:
- dependency-name: github.com/dnaeon/go-vcr
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Rémy Léone <rleone@scaleway.com>

* chore(deps): bump github.com/aws/aws-sdk-go from 1.40.53 to 1.40.54 (scaleway#881)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.40.53 to 1.40.54.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.40.53...v1.40.54)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(provider): add profile name from configuration file support (scaleway#875)

* feat(provider): add profile name from configuration file support

* feat(provider): enhance error handling

* chore(provider): add section about new profile feature usage

* fix(provider): fix condition

* Apply suggestions from code review

Co-authored-by: jaime Bernabe <6184069+Monitob@users.noreply.github.com>

* feat(lb): test for private network

* fix(lb): linter correction

* fix(lb): lint correction

* fix(lb): lint correction

* chore(deps): bump github.com/aws/aws-sdk-go from 1.40.54 to 1.40.55 (scaleway#883)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.40.54 to 1.40.55.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.40.54...v1.40.55)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore: bump go version (scaleway#882)

* k8s: add type on cluster (scaleway#886)

* fix(vpc): reverse issue (scaleway#887)

* fix(vpc): reverse issue

* fix(vpc): add test to check reverse and address

* fix(vpc): double retry interval

Co-authored-by: scaleway-bot <github@scaleway.com>

* chore(deps): bump github.com/aws/aws-sdk-go from 1.40.55 to 1.40.56 (scaleway#888)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.40.55 to 1.40.56.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.40.55...v1.40.56)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jaime Bernabe <6184069+Monitob@users.noreply.github.com>

* fix(instance): security group rule read from api and acl database not statefull (scaleway#892)

* Convert acl_rules from list to set

* Fix read security group rules, removed from api

* fix update typeSet for acl_rules

* change order

Co-authored-by: Rémy Léone <rleone@scaleway.com>

* chore(deps): bump github.com/aws/aws-sdk-go from 1.40.56 to 1.40.59 (scaleway#893)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.40.56 to 1.40.59.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.40.56...v1.40.59)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: jaime Bernabe <6184069+Monitob@users.noreply.github.com>

* feat(vpcgw): add gateway network resource (scaleway#891)

Co-authored-by: scaleway-bot <github@scaleway.com>

* chore(deps): bump github.com/aws/aws-sdk-go from 1.40.59 to 1.41.0 (scaleway#894)

Bumps [github.com/aws/aws-sdk-go](https://github.com/aws/aws-sdk-go) from 1.40.59 to 1.41.0.
- [Release notes](https://github.com/aws/aws-sdk-go/releases)
- [Changelog](https://github.com/aws/aws-sdk-go/blob/main/CHANGELOG.md)
- [Commits](aws/aws-sdk-go@v1.40.59...v1.41.0)

---
updated-dependencies:
- dependency-name: github.com/aws/aws-sdk-go
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat(lb): add wait lb in every resource

* fix(lb): add test steps

* feat(lb): add test and change schema

* feat(lb): add test for dhcp

* feat(lb): add cassette

* feat(lb): add cassette basic and dhcp. add doc. add test dhcp

* fix(lb_pn): lint

* Remove trailing spaces

* fix(lb_certificate): remove wait on lb_certificate

* feat(lb): add release_ip to data_source

* fix(lbacl): fix test lb acl

* fix(lb-acl): update cassettes lb acl

* fix(lb-pn): fix cassette

* fix(lb-route): cassette

Co-authored-by: abarbare <antoinebarbare@gmail.com>
Co-authored-by: Antoine Barbare <abarbare@online.net>
Co-authored-by: Jean-Sébastien Hedde <jshedde@scaleway.com>
Co-authored-by: jerousseau <rousseau.jean.eudes@gmail.com>
Co-authored-by: Rémy Léone <rleone@scaleway.com>
Co-authored-by: jerjako <contact@jerjako.com>
Co-authored-by: Jeremy JACQUEMIN <jjacquemin@scaleway.com>
Co-authored-by: Jérémy THERIN <jtherin@users.noreply.github.com>
Co-authored-by: grom-42 <56079173+grom-42@users.noreply.github.com>
Co-authored-by: Jerome Malinge <jmalinge@online.net>
Co-authored-by: jaime Bernabe <jbernabe@student.42.fr>
Co-authored-by: Jerome Quere <pub@jeromequere.fr>
Co-authored-by: Quentin Brosse <quentin.brosse@icloud.com>
Co-authored-by: Jaime BERNABE <jbernabe@scaleway.com>
Co-authored-by: jaime Bernabe <6184069+Monitob@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Alexandre Bouthinon <bouthinon.alexandre@gmail.com>
Co-authored-by: scaleway-bot <github@scaleway.com>
Co-authored-by: LucasBoisserie <LucasBoisserie@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants