Skip to content

Commit

Permalink
Merge pull request #8 from tgermain/input_check
Browse files Browse the repository at this point in the history
  • Loading branch information
mrolla authored Dec 7, 2018
2 parents 8cc7ca2 + d3f2cdb commit e9f2014
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
6 changes: 3 additions & 3 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@
unused-packages = true

[[constraint]]
branch = "dev/tg/getenvvar"
branch = "dev/tg/regex"
name = "github.com/jszwedko/go-circleci"
source = "github.com/tgermain/go-circleci"
# waiting for https://github.com/jszwedko/go-circleci/pull/14 to be merged to be able to use 1.1 API
# waiting for https://github.com/tylux/go-circleci/pull/1 to be merged to fix the tests
# waiting for https://github.com/tylux/go-circleci/pull/2 to be merged to add GetEnvVar
# waiting for https://github.com/tylux/go-circleci/pull/3 to be merged for have access to EnvVarNameValidRE
13 changes: 13 additions & 0 deletions circleci/resource_circleci_environment_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"time"

"github.com/hashicorp/terraform/helper/schema"

circleciapi "github.com/jszwedko/go-circleci"
)

func resourceCircleCIEnvironmentVariable() *schema.Resource {
Expand Down Expand Up @@ -36,6 +38,17 @@ func resourceCircleCIEnvironmentVariable() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: func(i interface{}, keyName string) (warnings []string, errors []error) {
v, ok := i.(string)
if !ok {
return nil, []error{fmt.Errorf("expected type of %s to be string", keyName)}
}
if !circleciapi.ValidateEnvVarName(v) {
return nil, []error{fmt.Errorf("environment variable name %s is not valid. See https://circleci.com/docs/2.0/env-vars/#injecting-environment-variables-with-the-api", v)}
}

return nil, nil
},
},
"value": &schema.Schema{
Description: "The value of the environment variable",
Expand Down
22 changes: 19 additions & 3 deletions vendor/github.com/jszwedko/go-circleci/circleci.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e9f2014

Please sign in to comment.