config

package
v0.0.0-...-305df0d Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApplyResourceRule

type ApplyResourceRule string

ApplyResourceRule lists a resource to create

func (ApplyResourceRule) Describe

func (r ApplyResourceRule) Describe() string

Describe returns a user-friendly representation of a ApplyResourceRule

func (ApplyResourceRule) Parse

Parse parses the rule as a YAML object

func (ApplyResourceRule) ParseTemplated

func (r ApplyResourceRule) ParseTemplated(args templating.Args) (KubernetesResource, error)

ParseTemplated templates the rule and then parses it as a YAML object

func (ApplyResourceRule) String

func (r ApplyResourceRule) String() string

String returns the rule as a string

func (ApplyResourceRule) Validate

func (r ApplyResourceRule) Validate() ([]string, error)

Validate a Delete Kubernetes Resouce rule definition. This function returns a slice of warnings and an error.

type DeleteResourceRule

type DeleteResourceRule struct {
	// The Kubernetes API version of the resource(s) to delete
	APIVersion string `yaml:"apiVersion"`

	// The resource kind
	Kind string `yaml:"kind"`

	// The resource namespace
	Namespace string `yaml:"namespace,omitempty"`

	// The label selector
	Selector LabelSelector `yaml:"selector"`

	// The maximum resources to delete. If the number of returned resources is < limit, then fail
	Limit *int `yaml:"limit"`
}

DeleteResourceRule lists a resource to delete

func (DeleteResourceRule) Describe

func (r DeleteResourceRule) Describe() string

Describe returns a user-friendly representation of a DeleteResourceRule

func (DeleteResourceRule) ToGroupVersion

func (r DeleteResourceRule) ToGroupVersion() schema.GroupVersion

ToGroupVersion maps a DeleteResourceRule to a GroupVersion

func (DeleteResourceRule) ToTypeMeta

func (r DeleteResourceRule) ToTypeMeta() metav1.TypeMeta

ToTypeMeta maps a DeleteResourceRule to a Kubernetes meta/v1 TypeMeta

func (DeleteResourceRule) Validate

func (r DeleteResourceRule) Validate() ([]string, error)

Validate a Delete Kubernetes Resouce rule definition. This function returns a slice of warnings and an error.

type File

type File struct {
	// Service hook rules
	ServiceHooks []ServiceHook `yaml:"serviceHooks"`
}

File is the root struct representing the config file

func NewConfigFile

func NewConfigFile(configFileYaml []byte) (File, error)

NewConfigFile creates a ConfigFile from YAML

func (File) Describe

func (c File) Describe() string

Describe returns a user-friendly representation of a ConfigFile

func (File) Validate

func (c File) Validate() ([]string, error)

Validate a Config File. This function returns a slice of warnings and an error.

type FileSection

type FileSection interface {
	Describe() string
	Validate() ([]string, error)
}

FileSection is an interface for the common methods in all File structs

type KubernetesResource

type KubernetesResource struct {
	//
	// TypeMeta
	//
	Kind       string                     `yaml:"kind"`
	APIVersion string                     `yaml:"apiVersion"`
	Metadata   KubernetesResourceMetadata `yaml:"metadata"`
}

KubernetesResource represents a Kubernetes resource, which has both Type and metadata information

func (KubernetesResource) ToGroupVersion

func (r KubernetesResource) ToGroupVersion() schema.GroupVersion

ToGroupVersion maps a KubernetesResource to a GroupVersion

func (KubernetesResource) ToTypeMeta

func (r KubernetesResource) ToTypeMeta() metav1.TypeMeta

ToTypeMeta maps a KubernetesResource to a meta/v1 Type

type KubernetesResourceMetadata

type KubernetesResourceMetadata struct {
	//
	// ObjectMeta
	//
	Name         string            `yaml:"name"`
	GenerateName string            `yaml:"generateName"`
	Namespace    string            `yaml:"namespace"`
	Labels       map[string]string `yaml:"labels"`
	Annotations  map[string]string `yaml:"annotations"`
}

KubernetesResourceMetadata represents a Kubernetes resource metadata

func (KubernetesResourceMetadata) ToObjectMeta

func (r KubernetesResourceMetadata) ToObjectMeta() metav1.ObjectMeta

ToObjectMeta maps a KubernetesResourceMetadata to a meta/v1 Object

type LabelSelector

type LabelSelector struct {
	MatchLabels map[string]string `yaml:"matchLabels"`

	MatchExpressions []LabelSelectorRequirement `yaml:"matchExpressions"`
}

LabelSelector represents a k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector, because it doesn't have YAML tags

func (LabelSelector) Describe

func (ls LabelSelector) Describe() string

Describe returns a user-friendly representation of a LabelSelector

func (LabelSelector) ToKubernetesLabelSelector

func (ls LabelSelector) ToKubernetesLabelSelector() metav1.LabelSelector

ToKubernetesLabelSelector maps a LabelSelector to a k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector

func (LabelSelector) ToTemplatedKubernetesLabelSelector

func (ls LabelSelector) ToTemplatedKubernetesLabelSelector(args templating.Args) (metav1.LabelSelector, error)

ToTemplatedKubernetesLabelSelector templates a LabelSelector and then maps it to a k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelector

func (LabelSelector) Validate

func (ls LabelSelector) Validate() ([]string, error)

Validate a LabelSelector. This function returns a slice of warnings and an error.

type LabelSelectorRequirement

type LabelSelectorRequirement struct {
	Key      string                       `yaml:"key"`
	Operator metav1.LabelSelectorOperator `yaml:"operator"`
	Values   []string                     `yaml:"values"`
}

LabelSelectorRequirement represents a k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement, because it doesn't have YAML tags

func (LabelSelectorRequirement) Describe

func (lsr LabelSelectorRequirement) Describe() string

Describe returns a user-friendly representation of a LabelSelectorRequirement

func (LabelSelectorRequirement) ToKubernetesLabelSelectorRequirement

func (lsr LabelSelectorRequirement) ToKubernetesLabelSelectorRequirement() metav1.LabelSelectorRequirement

ToKubernetesLabelSelectorRequirement maps a LabelSelectorRequirement to a k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement

func (LabelSelectorRequirement) ToTemplatedKubernetesLabelSelectorRequirement

func (lsr LabelSelectorRequirement) ToTemplatedKubernetesLabelSelectorRequirement(args templating.Args) (metav1.LabelSelectorRequirement, error)

ToTemplatedKubernetesLabelSelectorRequirement templates a LabelSelectorRequirement and maps it to a k8s.io/apimachinery/pkg/apis/meta/v1.LabelSelectorRequirement

func (LabelSelectorRequirement) Validate

func (lsr LabelSelectorRequirement) Validate() ([]string, error)

Validate a LabelSelectorRequirement. This function returns a slice of warnings and an error.

type Rules

type Rules struct {
	// The resources to apply
	Apply []ApplyResourceRule `yaml:"apply"`

	// The resources to delete
	Delete []DeleteResourceRule `yaml:"delete"`
}

Rules lists all of the rules to perform upon an event

func (Rules) Describe

func (r Rules) Describe() string

Describe returns a user-friendly representation of a Rules

func (Rules) IsEmpty

func (r Rules) IsEmpty() bool

IsEmpty returns true if the Rules has doesn't contain any rules

func (Rules) Validate

func (r Rules) Validate() ([]string, error)

Validate a Rules definition. This function returns a slice of warnings and an error.

type ServiceHook

type ServiceHook struct {
	// The EventType
	// See https://docs.microsoft.com/en-us/azure/devops/service-hooks/events?toc=%2Fazure%2Fdevops%2Fintegrate%2Ftothis.json&bc=%2Fazure%2Fdevops%2Fintegrate%2Fbreadcrumb%2Ftothis.json&view=azure-devops
	// for the event type
	Event ServiceHookEventType `yaml:"event"`

	// Resource filters
	ResourceFilters ServiceHookResourceFilters `yaml:"resourceFilters"`

	// If Continue is true, process any other service hooks that match the Service Hook
	Continue bool `yaml:"continue"`

	// The rules to perform on the Service Hook
	Rules Rules `yaml:"rules"`
}

ServiceHook holds rules for a Service Hook

func (ServiceHook) Describe

func (sh ServiceHook) Describe() string

Describe returns a user-friendly representation of a ServiceHook

func (ServiceHook) Matches

func (sh ServiceHook) Matches(serviceHook *azuredevops.ServiceHook) (bool, error)

Matches determines if a rule should be applied for a Service Hook

func (ServiceHook) Validate

func (sh ServiceHook) Validate() ([]string, error)

Validate a Service Hook rule definition. This function returns a slice of warnings and an error.

type ServiceHookEventType

type ServiceHookEventType string

ServiceHookEventType represents all possible Event Type values for a Service Hook configuration

const (
	// ServiceHookEventTypeBuildComplete represents the Build Completed event
	ServiceHookEventTypeBuildComplete ServiceHookEventType = "build.complete"
	// ServiceHookEventTypeBuilds is a sum type for:
	// - build.complete
	ServiceHookEventTypeBuilds ServiceHookEventType = "Builds"

	// ServiceHookEventTypeReleaseAbandoned represents the Release Abandoned event
	ServiceHookEventTypeReleaseAbandoned ServiceHookEventType = "ms.vss-release.release-abandoned-event"
	// ServiceHookEventTypeReleaseCreated represents the Release Created event
	ServiceHookEventTypeReleaseCreated ServiceHookEventType = "ms.vss-release.release-created-event"
	// ServiceHookEventTypeReleases is a sum type for:
	// - ms.vss-release.release-abandoned-event
	// - ms.vss-release.release-created-event
	ServiceHookEventTypeReleases ServiceHookEventType = "Releases"

	// ServiceHookEventTypeReleaseDeploymentApprovalCompleted represents the Release Deployment Approval Completed event
	ServiceHookEventTypeReleaseDeploymentApprovalCompleted ServiceHookEventType = "ms.vss-release.deployment-approval-completed-event"
	// ServiceHookEventTypeReleaseDeploymentApprovalPending represents the Release Deployment Approval Pending event
	ServiceHookEventTypeReleaseDeploymentApprovalPending ServiceHookEventType = "ms.vss-release.deployment-approval-pending-event"
	// ServiceHookEventTypeReleaseDeploymentApprovals is a sum type for:
	// - ms.vss-release.deployment-approval-completed-event
	// - ms.vss-release.deployment-approval-pending-event
	ServiceHookEventTypeReleaseDeploymentApprovals ServiceHookEventType = "Release Deployment Approals"

	// ServiceHookEventTypeReleaseDeploymentCompleted represents the Release Deployment Completed event
	ServiceHookEventTypeReleaseDeploymentCompleted ServiceHookEventType = "ms.vss-release.deployment-completed-event"
	// ServiceHookEventTypeReleaseDeploymentStarted represents the Release Deployment Started event
	ServiceHookEventTypeReleaseDeploymentStarted ServiceHookEventType = "ms.vss-release.deployment-started-event"
	// ServiceHookEventTypeReleaseDeployments is a sum type for:
	// - ms.vss-release.deployment-completed-event
	// - ms.vss-release.deployment-started-event
	ServiceHookEventTypeReleaseDeployments ServiceHookEventType = "Release Deployments"

	// ServiceHookEventTypeCodeCheckedIn represents the Code Checked In event
	ServiceHookEventTypeCodeCheckedIn ServiceHookEventType = "tfvc.checkin"
	// ServiceHookEventTypeCodePushed represents the Code Pushed event
	ServiceHookEventTypeCodePushed ServiceHookEventType = "git.push"
	// ServiceHookEventTypeCode is a sum type for:
	// - tfvc.checkin
	// - git.push
	ServiceHookEventTypeCode ServiceHookEventType = "Code"

	// ServiceHookEventTypePullRequestCreated represents the Pull Request Created event
	ServiceHookEventTypePullRequestCreated ServiceHookEventType = "git.pullrequest.created"
	// ServiceHookEventTypePullRequestMerged represents the Pull Request Merged event
	ServiceHookEventTypePullRequestMerged ServiceHookEventType = "git.pullrequest.merged"
	// ServiceHookEventTypePullRequestUpdated represents the Pull Request Updated event
	ServiceHookEventTypePullRequestUpdated ServiceHookEventType = "git.pullrequest.updated"
	// ServiceHookEventTypePullRequests is a sum type for:
	// - git.pullrequest.created
	// - git.pullrequest.merged
	// - git.pullrequest.updated
	ServiceHookEventTypePullRequests ServiceHookEventType = "Pull Requests"

	// ServiceHookEventTypeWorkItemCreated represents the Work Item Created event
	ServiceHookEventTypeWorkItemCreated ServiceHookEventType = "workitem.created"
	// ServiceHookEventTypeWorkItemDeleted represents the Work Item Deleted event
	ServiceHookEventTypeWorkItemDeleted ServiceHookEventType = "workitem.deleted"
	// ServiceHookEventTypeWorkItemRestored represents the Work Item Restored event
	ServiceHookEventTypeWorkItemRestored ServiceHookEventType = "workitem.restored"
	// ServiceHookEventTypeWorkItemUpdated represents the Work Item Updated event
	ServiceHookEventTypeWorkItemUpdated ServiceHookEventType = "workitem.updated"
	// ServiceHookEventTypeWorkItemCommented represents the Work Item Commented event
	ServiceHookEventTypeWorkItemCommented ServiceHookEventType = "workitem.commented"
	// ServiceHookEventTypeWorkItems is a sum type for:
	// - workitem.created
	// - workitem.deleted
	// - workitem.restored
	// - workitem.updated
	// - workitem.commented
	ServiceHookEventTypeWorkItems ServiceHookEventType = "Work Items"
)

func (ServiceHookEventType) GetEventTypes

func (et ServiceHookEventType) GetEventTypes() []string

GetEventTypes returns all of the Service Hook event types that this value represents

type ServiceHookResourceFilters

type ServiceHookResourceFilters struct {
	// Only execute the rules if {resource.status ∈ this.Statuses}
	Statuses []string `yaml:"statuses"`

	// Only execute the rules if {resource.reason ∈ this.Reasons}
	Reasons []string `yaml:"reasons"`

	// Only execute the rules if {resource.project.name ∈ this.Projects} || {resource.release.project.name ∈ this.Projects}
	Projects []string `yaml:"projects"`

	// Only execute the rules if {resource.release.releaseDefinition.name ∈ this.Releases}
	Releases []string `yaml:"releases"`

	// Only execute the rules if {resource.release.environments[].name ∈ this.Environment}
	Environments []string `yaml:"environments"`

	// Only execute the rules if {resource.approval.type ∈ this.ApprovalTypes}
	ApprovalTypes []azuredevops.ApprovalType `yaml:"approvalTypes"`

	// Only execute the rules if {resource.repository.name ∈ this.Repositories}
	Repositories []string `yaml:"repositories"`

	// Only execute the rules {resource.SourceRefName ∈ this.SourceRefs}
	SourceRefs []string `yaml:"sourceRefs"`

	// Only execute the rules {resource.TargetRefName ∈ this.TargetRefs}
	TargetRefs []string `yaml:"targetRefs"`

	// Filters that are Go templated with the ServiceHook Resource and must return true
	Templates []string `yaml:"templates"`
}

ServiceHookResourceFilters holds filters for a Service Hook Resource

func (ServiceHookResourceFilters) Describe

func (shrf ServiceHookResourceFilters) Describe() string

Describe returns a user-friendly representation of a ServiceHook

func (ServiceHookResourceFilters) Validate

func (shrf ServiceHookResourceFilters) Validate() ([]string, error)

Validate a Service Hook filters definition. This function returns a slice of warnings and an error.

Jump to

Keyboard shortcuts

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