context

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package context classifies governance inputs such as environments and owners.

Index

Constants

View Source
const (
	APIVersion          = "openmeshguard.io/v1alpha1"
	ScanConfigKind      = "ScanConfig"
	OwnershipImportKind = "OwnershipImport"
	ExceptionKind       = "Exception"
)
View Source
const (
	EnvironmentUnclassified = "unclassified"
	ConfidenceObserved      = "observed"
	ConfidenceResolved      = "resolved"
	ConfidenceInferred      = "inferred"
	ConfidenceUserSupplied  = "user-supplied"
	ConfidenceUnavailable   = "unavailable"
)

Variables

This section is empty.

Functions

func ClassificationCounts

func ClassificationCounts(classifications map[string]Classification) (classified, unclassified int, byEnvironment map[string]int)

Types

type Application

type Application struct {
	AppID string `yaml:"appId"`
	Owner string `yaml:"owner"`
}

type Classification

type Classification struct {
	Environment string
	Confidence  string
	Known       bool
	Reason      string
	Source      string
}

type ClassificationConfig

type ClassificationConfig struct {
	Sources []ClassificationSource `yaml:"sources,omitempty"`
}

type ClassificationSource

type ClassificationSource struct {
	Type        string            `yaml:"type"`
	Mappings    map[string]string `yaml:"mappings,omitempty"`
	Keys        []string          `yaml:"keys,omitempty"`
	Rules       []NameRule        `yaml:"rules,omitempty"`
	Environment string            `yaml:"environment,omitempty"`
}

type ContextInputs

type ContextInputs struct {
	OwnershipImport string   `yaml:"ownershipImport,omitempty"`
	Exceptions      []string `yaml:"exceptions,omitempty"`
}

type ControlOverride

type ControlOverride struct {
	ControlID             string            `yaml:"controlId"`
	Environments          *[]string         `yaml:"environments,omitempty"`
	SeverityByEnvironment map[string]string `yaml:"severityByEnvironment,omitempty"`
}

type ControlParameters

type ControlParameters struct {
	Defaults     map[string]any            `yaml:"defaults,omitempty"`
	Environments map[string]map[string]any `yaml:"environments,omitempty"`
}

type ControlsConfig

type ControlsConfig struct {
	Parameters ControlParameters `yaml:"parameters,omitempty"`
	Overrides  []ControlOverride `yaml:"overrides,omitempty"`
}

type ExceptionRecord

type ExceptionRecord struct {
	APIVersion       string        `yaml:"apiVersion"`
	Kind             string        `yaml:"kind"`
	Metadata         Metadata      `yaml:"metadata"`
	Spec             ExceptionSpec `yaml:"spec"`
	File             string        `yaml:"-"`
	ValidationErrors []string      `yaml:"-"`
	ExpiresAt        time.Time     `yaml:"-"`
}

func LoadExceptions

func LoadExceptions(paths []string) ([]ExceptionRecord, error)

type ExceptionSpec

type ExceptionSpec struct {
	ControlIDs    []string `yaml:"controlIds"`
	Owner         string   `yaml:"owner"`
	Approver      string   `yaml:"approver"`
	Justification string   `yaml:"justification"`
	Ticket        string   `yaml:"ticket"`
	ExpiresAt     string   `yaml:"expiresAt"`
}

type Metadata

type Metadata struct {
	Name    string `yaml:"name"`
	Version string `yaml:"version"`
}

type NameRule

type NameRule struct {
	Pattern     string `yaml:"pattern"`
	Environment string `yaml:"environment"`
}

type NamespaceInput

type NamespaceInput struct {
	Name        string
	Labels      map[string]string
	Annotations map[string]string
	LabelsKnown bool
}

type Ownership

type Ownership struct {
	AppID       string
	Owner       string
	AppIDKnown  bool
	OwnerKnown  bool
	AppIDSource string
	OwnerSource string
	AppIDReason string
	OwnerReason string
}

type OwnershipConfig

type OwnershipConfig struct {
	Labels       OwnershipLabels `yaml:"labels,omitempty"`
	Applications []Application   `yaml:"applications,omitempty"`
}

type OwnershipImport

type OwnershipImport struct {
	APIVersion   string        `yaml:"apiVersion"`
	Kind         string        `yaml:"kind"`
	Metadata     Metadata      `yaml:"metadata"`
	Applications []Application `yaml:"applications"`
	File         string        `yaml:"-"`
}

func LoadOwnershipImport

func LoadOwnershipImport(path string) (OwnershipImport, error)

type OwnershipLabels

type OwnershipLabels struct {
	AppID []string `yaml:"appId,omitempty"`
	Owner []string `yaml:"owner,omitempty"`
}

type ResolveInput

type ResolveInput struct {
	ClusterContext    string
	InferEnvironments bool
	Config            ScanConfig
	OwnershipImport   OwnershipImport
	Namespaces        []NamespaceInput
	Workloads         []WorkloadInput
}

type Result

type Result struct {
	Namespaces map[string]Classification
	Workloads  []WorkloadContext
}

func Resolve

func Resolve(input ResolveInput) Result

type ScanConfig

type ScanConfig struct {
	APIVersion     string               `yaml:"apiVersion"`
	Kind           string               `yaml:"kind"`
	Metadata       Metadata             `yaml:"metadata"`
	Inputs         ContextInputs        `yaml:"inputs,omitempty"`
	Classification ClassificationConfig `yaml:"classification,omitempty"`
	Ownership      OwnershipConfig      `yaml:"ownership,omitempty"`
	Controls       ControlsConfig       `yaml:"controls,omitempty"`
	File           string               `yaml:"-"`
}

func LoadScanConfig

func LoadScanConfig(path string) (ScanConfig, error)

type WorkloadContext

type WorkloadContext struct {
	Ref            resolver.WorkloadRef
	Classification Classification
	Ownership      Ownership
	ExceptionID    string
}

type WorkloadInput

type WorkloadInput struct {
	Ref         resolver.WorkloadRef
	Labels      map[string]string
	Annotations map[string]string
	Namespace   NamespaceInput
}

Jump to

Keyboard shortcuts

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