config

package
v1.0.0-beta.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const VersionKey = "configVersion"

Variables

View Source
var Schemas = map[string]string{
	"v1": `
definitions:
  nameSelector:
    type: object
    additionalProperties: false
    required:
    - matchNames
    properties:
      matchNames:
        type: array
        additionalItems: false
        items:
          type: string
  labelSelector:
    type: object
    additionalProperties: false
    minProperties: 1
    maxProperties: 2
    properties:
      matchLabels:
        type: object
        additionalProperties:
          type: string
      matchExpressions:
        type: array
        items:
          type: object
          additionalProperties: false
          required:
          - key
          - operator
          properties:
            key:
              type: string
            operator:
              type: string
              enum:
              - In
              - NotIn
              - Exists
              - DoesNotExist
            values:
              type: array
              items:
                type: string

type: object
additionalProperties: false
required:
- configVersion
minProperties: 2
properties:
  configVersion:
    type: string
    enum:
    - v1
  onStartup:
    title: onStartup binding
    description: |
      the value is the order to sort onStartup hooks
    type: integer
    example: 10
  schedule:
    title: schedule bindings
    description: |
      configuration of hooks that should run on schedule
    type: array
    additionalItems: false
    minItems: 1
    items:
      type: object
      additionalProperties: false
      required:
      - crontab
      properties:
        name:
          type: string
        crontab:
          type: string
        allowFailure:
          type: boolean
          default: false
        includeSnapshotsFrom:
          type: array
          additionalItems: false
          minItems: 1
          items:
            type: string
        queue:
          type: string
        group:
          type: string
  kubernetes:
    title: kubernetes event bindings
    type: array
    additionalItems: false
    minItems: 1
    items:
      type: object
      additionalProperties: false
      required:
      - kind
      patternProperties:
        "^(watchEvent|executeHookOnEvent)$":
          type: array
          additionalItems: false
          minItems: 0
          items:
            type: string
            enum:
            - Added
            - Modified
            - Deleted
      properties:
        name:
          type: string
        apiVersion:
          type: string
        kind:
          type: string
        includeSnapshotsFrom:
          type: array
          additionalItems: false
          minItems: 1
          items:
            type: string
        queue:
          type: string
        jqFilter:
          type: string
          example: ".metadata.labels"
        allowFailure:
          type: boolean
        executeHookOnSynchronization:
          type: boolean
        waitForSynchronization:
          type: boolean
        resynchronizationPeriod:
          type: string
        nameSelector:
          "$ref": "#/definitions/nameSelector"
        labelSelector:
          "$ref": "#/definitions/labelSelector"
        fieldSelector:
          type: object
          additionalProperties: false
          required:
          - matchExpressions
          properties:
            matchExpressions:
              type: array
              items:
                type: object
                additionalProperties: false
                minProperties: 3
                maxProperties: 3
                properties:
                  field:
                    type: string
                  operator:
                    type: string
                    enum: ["=", "==", "Equals", "!=", "NotEquals"]
                  value:
                    type: string
        group:
          type: string
        namespace:
          type: object
          additionalProperties: false
          minProperties: 1
          maxProperties: 2
          properties:
            nameSelector:
              "$ref": "#/definitions/nameSelector"
            labelSelector:
              "$ref": "#/definitions/labelSelector"
`,
	"v0": `
type: object
additionalProperties: false
minProperties: 1
properties:
  onStartup:
    title: onStartup binding
    description: |
      the value is the order to sort onStartup hooks
    type: integer
  schedule:
    type: array
    items:
      type: object
  onKubernetesEvent:
    type: array
    items:
      type: object
`,
}
View Source
var SchemasCache = map[string]*spec.Schema{}

Functions

func GetSchema

func GetSchema(name string) *spec.Schema

GetSchema returns loaded schema.

func LoadSchema

func LoadSchema(name string) (*spec.Schema, error)

LoadSchema returns spec.Schema object loaded from yaml in Schemas map.

Types

type VersionedUntyped

type VersionedUntyped struct {
	Obj     map[string]interface{}
	Version string

	VersionKey       string
	VersionValidator func(string, bool) (string, error)
}

func NewDefaultVersionedUntyped

func NewDefaultVersionedUntyped() *VersionedUntyped

NewDefaultVersionedUntyped is a VersionedUntyper object with default version key and version validator against Schemas map

func (*VersionedUntyped) GetString

func (u *VersionedUntyped) GetString(key string) (value string, found bool, err error)

GetString returns string value by key

func (*VersionedUntyped) Load

func (u *VersionedUntyped) Load(data []byte) error

func (*VersionedUntyped) LoadConfigVersion

func (u *VersionedUntyped) LoadConfigVersion() (string, error)

LoadConfigVersion

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL