jx: github.com/jenkins-x/jx/pkg/surveyutils Index | Files

package surveyutils

import "github.com/jenkins-x/jx/pkg/surveyutils"

Index

Package Files

jsonschema.go schema_template.go validators.go

func BoolValidator Uses

func BoolValidator() survey.Validator

BoolValidator validates that val is a bool

func DateTimeValidator Uses

func DateTimeValidator() survey.Validator

DateTimeValidator validates that a string is a RFC 3339 date-time format

func DateValidator Uses

func DateValidator() survey.Validator

DateValidator validates that a string is a RFC 3339 full-date format

func EmailValidator Uses

func EmailValidator() survey.Validator

EmailValidator validates that a string is a RFC 5322 email

func EnumValidator Uses

func EnumValidator(enum []interface{}) survey.Validator

EnumValidator validates that val appears in the enum

func FloatValidator Uses

func FloatValidator() survey.Validator

FloatValidator validates that val is a float

func HostnameValidator Uses

func HostnameValidator() survey.Validator

HostnameValidator validates that a string is a RFC 1034 hostname

func IntegerValidator Uses

func IntegerValidator() survey.Validator

IntegerValidator validates that val is an int

func Ipv4Validator Uses

func Ipv4Validator() survey.Validator

Ipv4Validator validates that a string is a RFC 2673 IPv4 address

func Ipv6Validator Uses

func Ipv6Validator() survey.Validator

Ipv6Validator validates that a string is a RFC 4291 IPv6 address

func JSONPointerValidator Uses

func JSONPointerValidator() survey.Validator

JSONPointerValidator validates that a string is a JSON Pointer

func MaxItemsValidator Uses

func MaxItemsValidator(maxItems *int, value []interface{}) survey.Validator

MaxItemsValidator validates that at most the maxItems number of items exist in a slice

func MaxLengthValidator Uses

func MaxLengthValidator(maxLength *int) survey.Validator

MaxLengthValidator validates that val is shorter in length than maxLength

func MaxPropertiesValidator Uses

func MaxPropertiesValidator(maxItems *int, value *orderedmap.OrderedMap, key string) survey.Validator

MaxPropertiesValidator validates that at most the maxItems number of key-value pairs exist in a map

func MaxValidator Uses

func MaxValidator(max *float64, exclusive bool) survey.Validator

MaxValidator validates that the val is less than the max, if exclusive, then less than or equal to

func MinItemsValidator Uses

func MinItemsValidator(minItems *int, value []interface{}) survey.Validator

MinItemsValidator validates that at least the minItems number of items exist in a slice

func MinLengthValidator Uses

func MinLengthValidator(minLength *int) survey.Validator

MinLengthValidator validates that val is longer in length than minLength

func MinPropertiesValidator Uses

func MinPropertiesValidator(minItems *int, value *orderedmap.OrderedMap, key string) survey.Validator

MinPropertiesValidator validates that at least the minItems number of key-value pairs exist in a map

func MinValidator Uses

func MinValidator(min *float64, exclusive bool) survey.Validator

MinValidator validates that the val is more than the min, if exclusive then more than or equal to

func MultipleOfValidator Uses

func MultipleOfValidator(multipleOf *float64) survey.Validator

MultipleOfValidator validates that the val is a multiple of multipleOf

func NoWhiteSpaceValidator Uses

func NoWhiteSpaceValidator() survey.Validator

NoWhiteSpaceValidator is an input validator for the survey package that disallows any whitespace in the val

func NoopValidator Uses

func NoopValidator() survey.Validator

NoopValidator always passes (use instead of nil in a slice of validators)

func OverrideAnswerValidator Uses

func OverrideAnswerValidator(ans interface{}, validator survey.Validator) survey.Validator

OverrideAnswerValidator will validate the answer supplied as an argument, rather the answer the user provides this is useful when you want to validate the value a confirm dialog is confirming, rather than the Y/n

func PatternValidator Uses

func PatternValidator(pattern *string) survey.Validator

PatternValidator validates that the val matches the regex pattern

func ReadSchemaTemplate Uses

func ReadSchemaTemplate(templateFile string, requirements *config.RequirementsConfig) ([]byte, error)

readSchemaTemplate evaluates the given go template file and returns the output data

func RequiredValidator Uses

func RequiredValidator(required bool) survey.Validator

RequiredValidator applies the RequiredValidator if required is true

func TemplateSchemaFile Uses

func TemplateSchemaFile(schemaFileName string, requirements *config.RequirementsConfig) error

TemplateSchemaFile if there is a template for the schema file then evaluate it and write the schema file

func TimeValidator Uses

func TimeValidator() survey.Validator

TimeValidator validates that a string is a RFC3339 full-time format

func URIReferenceValidator Uses

func URIReferenceValidator() survey.Validator

URIReferenceValidator validates that a string is a valid RFC 3986 URI Reference

func URIValidator Uses

func URIValidator() survey.Validator

URIValidator validates that a string is a valid RFC 3986 URI

func UniqueItemsValidator Uses

func UniqueItemsValidator(value []interface{}) survey.Validator

UniqueItemsValidator validates that the val is unique in a slice

type Definitions Uses

type Definitions map[string]*Type

Definitions hold schema definitions.

type Dependency Uses

type Dependency struct {
    Type  *Type    `json:-`
    Array []string `json:-`
}

Dependency is either a Type or an array of strings, and so requires special unmarshaling from JSON

func (*Dependency) UnmarshalJSON Uses

func (d *Dependency) UnmarshalJSON(b []byte) error

UnmarshalJSON performs unmarshals Dependency from JSON, required as the json field can be one of two types

type Items Uses

type Items struct {
    Types []*Type `json:-`
    Type  *Type   `json:-`
}

Items is a either a Type or a array of types, and so requires special unmarshaling from JSON

func (*Items) UnmarshalJSON Uses

func (t *Items) UnmarshalJSON(b []byte) error

UnmarshalJSON performs unmarshals Items from JSON, required as the json field can be one of two types

type JSONSchemaOptions Uses

type JSONSchemaOptions struct {
    VaultClient         secreturl.Client
    VaultBasePath       string
    VaultScheme         string
    AskExisting         bool
    AutoAcceptDefaults  bool
    NoAsk               bool
    IgnoreMissingValues bool
    In                  terminal.FileReader
    Out                 terminal.FileWriter
    OutErr              io.Writer
}

JSONSchemaOptions are options for generating values from a schema

func (*JSONSchemaOptions) GenerateValues Uses

func (o *JSONSchemaOptions) GenerateValues(schemaBytes []byte, existingValues map[string]interface{}) ([]byte, error)

GenerateValues examines the schema in schemaBytes, asks a series of questions using in, out and outErr, applying validators, returning a generated json file. If there are existingValues then those questions will be ignored and the existing value used unless askExisting is true. If autoAcceptDefaults is true, then default values will be used automatically. If ignoreMissingValues is false then any values which don't have an existing value ( or a default value if autoAcceptDefaults is true) will cause an error

type Properties Uses

type Properties struct {
    *orderedmap.OrderedMap
}

Properties is a set of ordered key-value pairs, as it is ordered it requires special marshaling to/from JSON

func (*Properties) UnmarshalJSON Uses

func (p *Properties) UnmarshalJSON(b []byte) error

UnmarshalJSON performs custom Unmarshaling for Properties allowing us to preserve order, which is not a standard JSON feature

type Type Uses

type Type struct {
    Version          string      `json:"$schema,omitempty"`
    Ref              string      `json:"$ref,omitempty"`
    MultipleOf       *float64    `json:"multipleOf,omitempty"`
    Maximum          *float64    `json:"maximum,omitempty"`
    ExclusiveMaximum *float64    `json:"exclusiveMaximum,omitempty"`
    Minimum          *float64    `json:"minimum,omitempty"`
    ExclusiveMinimum *float64    `json:"exclusiveMinimum,omitempty"`
    MaxLength        *int        `json:"maxLength,omitempty"`
    MinLength        *int        `json:"minLength,omitempty"`
    Pattern          *string     `json:"pattern,omitempty"`
    AdditionalItems  *Type       `json:"additionalItems,omitempty"`
    Items            Items       `json:"items,omitempty"`
    MaxItems         *int        `json:"maxItems,omitempty"`
    MinItems         *int        `json:"minItems,omitempty"`
    UniqueItems      bool        `json:"uniqueItems,omitempty"`
    MaxProperties    *int        `json:"maxProperties,omitempty"`
    MinProperties    *int        `json:"minProperties,omitempty"`
    Required         []string    `json:"required,omitempty"`
    Properties       *Properties `json:"properties,omitempty"`
    // TODO Implement support & tests for PatternProperties
    PatternProperties map[string]*Type `json:"patternProperties,omitempty"`
    // TODO Implement support & tests for AdditionalProperties
    AdditionalProperties *Type `json:"additionalProperties,omitempty"`
    // TODO Implement support & tests for Dependencies
    Dependencies map[string]Dependency `json:"dependencies,omitempty"`
    // TODO Implement support & tests for PropertyNames
    PropertyNames *Type         `json:"propertyNames,omitempty"`
    Enum          []interface{} `json:"enum,omitempty"`
    Type          string        `json:"type,omitempty"`
    If            *Type         `json:"if,omitempty"`
    Then          *Type         `json:"then,omitempty"`
    Else          *Type         `json:"else,omitempty"`
    // TODO Implement support & tests for All
    AllOf []*Type `json:"allOf,omitempty"`
    AnyOf []*Type `json:"anyOf,omitempty"`
    // TODO Implement support & tests for OneOf
    OneOf []*Type `json:"oneOf,omitempty"`
    // TODO Implement support & tests for Not
    Not *Type `json:"not,omitempty"`
    // TODO Implement support & tests for Definitions
    Definitions Definitions `json:"definitions,omitempty"`
    // TODO Implement support & tests for Contains
    Contains         *Type        `json:"contains,omitempty"`
    Const            *interface{} `json:"const,omitempty"`
    Title            string       `json:"title,omitempty"`
    Description      string       `json:"description,omitempty"`
    Default          interface{}  `json:"default,omitempty"`
    Format           *string      `json:"format,omitempty"`
    ContentMediaType *string      `json:"contentMediaType,omitempty"`
    ContentEncoding  *string      `json:"contentEncoding,omitempty"`
}

Type represents a JSON Schema object type current to https://www.ietf.org/archive/id/draft-handrews-json-schema-validation-01.txt

Package surveyutils imports 27 packages (graph) and is imported by 4 packages. Updated 2019-11-14. Refresh now. Tools for package owners.