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

Add Storage Region Validation #94

Conversation

RoseSecurity
Copy link

What and Why

  • Formatting update
  • Adds storage_region validation for available regions obtained via:
package main

import (
    "context"
    "fmt"
    "os"
    openapiclient "github.com/cloudsmith-io/cloudsmith-api-go"
)

func main() {

    configuration := openapiclient.NewConfiguration()
    apiClient := openapiclient.NewAPIClient(configuration)
    resp, r, err := apiClient.StorageRegionsApi.StorageRegionsList(context.Background()).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `StorageRegionsApi.StorageRegionsList``: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `StorageRegionsList`: []StorageRegion
    fmt.Fprintf(os.Stdout, "Response from `StorageRegionsApi.StorageRegionsList`: %v\n", resp)
}

Output:

Response from `StorageRegionsApi.StorageRegionsList`: [{Default Region default} {Northern California, United States us-norcal} {Sydney, Australia au-sydney} {Singapore sg-singapore} {Montreal, Canada ca-montreal} {Frankfurt, Germany de-frankfurt} {Oregon, United States us-oregon} {Ohio, United States us-ohio} {Dublin, Ireland ie-dublin}]

Adds validation using:

"storage_region": {
Type: schema.TypeString,
Description: "The Cloudsmith region in which package files are stored." +
	"Supported regions include: Northern California, United States (us-norcal), Sydney, Australia (au-sydney)," +
	"Singapore (sg-singapore), Montreal, Canada (ca-montreal), Frankfurt, Germany (de-frankfurt), Oregon," +
	"United States (us-oregon), Ohio, United States (us-ohio), Dublin, Ireland (ie-dublin)",
Optional:     true,
Computed:     true,
ForceNew:     true,
ValidateFunc: validation.StringInSlice([]string{"us-norcal", "au-sydney", "sg-singapore", "ca-montreal", "de-frankfurt", "us-oregon", "us-ohio", "ie-dublin"}, false),
},

@RoseSecurity RoseSecurity requested a review from a team as a code owner June 6, 2024 04:08
@BartoszBlizniak
Copy link
Contributor

Thank you for your contribution! Unfortunately forked PR's won't work with our acceptance testing therefore, I have to create an internal branch and merge those in, your contribution has been noted and it will be part of Pull 107!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants