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

Prevent panic on random_string and random_password when character set is empty #551

Merged
merged 4 commits into from
Apr 15, 2024

Commits on Apr 10, 2024

  1. resource/random_password+random_string: Prevent panic when special, u…

    …pper, lower, numeric/number are set to false (#549)
    
    Previously, a panic would be generated if the following configuration was used:
    
    ```
    resource "random_string" "random" {
      length  = 16
      special = false
      upper   = false
      lower   = false
      numeric = false
    }
    ```
    
    ```
    ╷
    │ Error: Plugin did not respond
    │
    │   with random_string.random,
    │   on resource.tf line 1, in resource "random_string" "random":
    │    1: resource "random_string" "random" {
    │
    │ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
    ╵
    
    Stack trace from the terraform-provider-random plugin:
    
    panic: crypto/rand: argument to Int is <= 0
    ```
    
    This change will cause validation to fail if special, upper, lower, and numeric/number are all set to false
    
    Output from acceptance testing:
    
    ```console
    TF_ACC=1 go test -count=1 -run='TestAccResourceString_NumericFalse' -timeout=10m -v ./internal/provider
    === RUN   TestAccResourceString_NumericFalse
    === PAUSE TestAccResourceString_NumericFalse
    === CONT  TestAccResourceString_NumericFalse
    --- PASS: TestAccResourceString_NumericFalse (0.15s)
    ```
    bendbennett committed Apr 10, 2024
    Configuration menu
    Copy the full SHA
    be5e90d View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e847d2d View commit details
    Browse the repository at this point in the history
  3. Linting

    bendbennett committed Apr 10, 2024
    Configuration menu
    Copy the full SHA
    99e5112 View commit details
    Browse the repository at this point in the history

Commits on Apr 11, 2024

  1. Updating description for number and numeric attributes on resource_pa…

    …ssword and resource_string
    bendbennett committed Apr 11, 2024
    Configuration menu
    Copy the full SHA
    64ce4ae View commit details
    Browse the repository at this point in the history