Skip to content

Commit

Permalink
Issues #258 - Stubbed validateDockerImage
Browse files Browse the repository at this point in the history
Was validating pipeline environment image as an AMI when it
is actually a docker image. The registry/image:tag regex
is fairly complicated and varies between v1 and v2
of the registries. For now just adding an empty method where
validation may occur later if we want.
  • Loading branch information
mneil committed Sep 10, 2018
1 parent cbd1332 commit 9da9534
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type Pipeline struct {
Disabled bool `yaml:"disabled,omitempty"`
Type EnvironmentType `yaml:"type,omitempty"`
ComputeType ComputeType `yaml:"computeType,omitempty"`
Image string `yaml:"image,omitempty" validate:"validateResourceID=ami"`
Image string `yaml:"image,omitempty" validate:"validateDockerImage"`
Bucket string `yaml:"bucket,omitempty"`
BuildTimeout string `yaml:"timeout,omitempty" validate:"max=480"`
} `yaml:"build,omitempty"`
Expand All @@ -183,7 +183,7 @@ type Pipeline struct {
Environment string `yaml:"environment,omitempty"`
Type EnvironmentType `yaml:"type,omitempty"`
ComputeType ComputeType `yaml:"computeType,omitempty"`
Image string `yaml:"image,omitempty" validate:"validateResourceID=ami"`
Image string `yaml:"image,omitempty" validate:"validateDockerImage"`
Roles struct {
CodeBuild string `yaml:"codeBuild,omitempty" validate:"validateRoleARN"`
Mu string `yaml:"mu,omitempty" validate:"validateRoleARN"`
Expand Down
6 changes: 6 additions & 0 deletions common/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ func validators() {
validator.SetValidationFunc("validateURL", validateURL)
validator.SetValidationFunc("validateInstanceType", validateInstanceType)
validator.SetValidationFunc("validateCIDR", validateCIDR)
validator.SetValidationFunc("validateDockerImage", validateDockerImage)
}

func validateResourceID(v interface{}, param string) error {
Expand Down Expand Up @@ -60,6 +61,11 @@ func validateCIDR(v interface{}, param string) error {
return regexpLength(reflect.ValueOf(v).String(), pattern, 18)
}

func validateDockerImage(v interface{}, param string) error {
// TODO: Validate Docker Image registry/image:tag
return nil
}

// validateRoleARN validates that the value is an valid role ARN
func validateRoleARN(v interface{}, param string) error {
value := reflect.ValueOf(v).String()
Expand Down

0 comments on commit 9da9534

Please sign in to comment.