importer

package
v0.0.0-...-2170ac4 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyClusterWritePlan

func ApplyClusterWritePlan(plan *ClusterWritePlan) error

func IsProtectedField

func IsProtectedField(path string) bool

func RenderScanResult

func RenderScanResult(result *ImportScanResult, format string) ([]byte, error)

func RepoHash

func RepoHash(repoPath string) string

func SelectApprovedFields

func SelectApprovedFields(cluster ClusterImportResult) ([]FieldInferenceResult, []SkippedField)

Types

type ArtifactStore

type ArtifactStore struct {
	// contains filtered or unexported fields
}

func NewArtifactStore

func NewArtifactStore() (*ArtifactStore, error)

func (*ArtifactStore) LoadLatest

func (s *ArtifactStore) LoadLatest(repoPath string) (*SavedArtifact, error)

func (*ArtifactStore) Save

func (s *ArtifactStore) Save(repoPath string, result *ImportScanResult, savedAt time.Time) (*SavedArtifact, error)

type ClusterImportResult

type ClusterImportResult struct {
	ClusterName    string                   `json:"cluster_name"`
	Organization   string                   `json:"organization,omitempty"`
	Sources        ClusterSources           `json:"sources"`
	ProposedConfig *v2.Config               `json:"proposed_config,omitempty"`
	FieldResults   []FieldInferenceResult   `json:"field_results,omitempty"`
	ServiceResults []ServiceInferenceResult `json:"service_results,omitempty"`
	Conflicts      []FieldConflict          `json:"conflicts,omitempty"`
	SkippedFields  []SkippedField           `json:"skipped_fields,omitempty"`
	ExistingConfig string                   `json:"existing_config,omitempty"`
	ProposedPatch  string                   `json:"proposed_patch,omitempty"`
	Warnings       []string                 `json:"warnings,omitempty"`
	Errors         []string                 `json:"errors,omitempty"`
}

func BuildLiveImportResult

func BuildLiveImportResult(ctx context.Context, cfg *v2.Config, kubeconfigPath string) (ClusterImportResult, error)

type ClusterSources

type ClusterSources struct {
	RepoPath         string   `json:"repo_path"`
	ClusterName      string   `json:"cluster_name"`
	ClusterDir       string   `json:"cluster_dir,omitempty"`
	OverlayDir       string   `json:"overlay_dir,omitempty"`
	LegacyConfigPath string   `json:"legacy_config_path,omitempty"`
	ReadmePath       string   `json:"readme_path,omitempty"`
	KubeconfigPaths  []string `json:"kubeconfig_paths,omitempty"`
}

type ClusterWritePlan

type ClusterWritePlan struct {
	ClusterName     string
	Organization    string
	ConfigPath      string
	Create          bool
	ApprovedFields  []FieldInferenceResult
	SkippedFields   []SkippedField
	RenderedContent []byte
	Diff            string
}

func PrepareClusterWritePlan

func PrepareClusterWritePlan(ctx context.Context, cluster ClusterImportResult) (*ClusterWritePlan, error)

type ConfidenceLevel

type ConfidenceLevel string
const (
	ConfidenceHigh     ConfidenceLevel = "high"
	ConfidenceMedium   ConfidenceLevel = "medium"
	ConfidenceLow      ConfidenceLevel = "low"
	ConfidenceConflict ConfidenceLevel = "conflict"
)

type DetectorRegistry

type DetectorRegistry struct {
	// contains filtered or unexported fields
}

func NewDetectorRegistry

func NewDetectorRegistry() *DetectorRegistry

func (*DetectorRegistry) Detector

func (r *DetectorRegistry) Detector(name string) ServiceDetector

func (*DetectorRegistry) Names

func (r *DetectorRegistry) Names() []string

type EvidenceRef

type EvidenceRef struct {
	Source string `json:"source,omitempty"`
	Path   string `json:"path,omitempty"`
	Detail string `json:"detail,omitempty"`
}

type FieldConflict

type FieldConflict struct {
	Path           string        `json:"path"`
	GitOpsValue    any           `json:"gitops_value,omitempty"`
	LiveValue      any           `json:"live_value,omitempty"`
	Recommended    string        `json:"recommended,omitempty"`
	Evidence       []EvidenceRef `json:"evidence,omitempty"`
	ProtectedField bool          `json:"protected_field,omitempty"`
}

type FieldInferenceResult

type FieldInferenceResult struct {
	Path       string          `json:"path"`
	Value      any             `json:"value,omitempty"`
	Confidence ConfidenceLevel `json:"confidence"`
	Origin     FieldOrigin     `json:"origin"`
	Evidence   []EvidenceRef   `json:"evidence,omitempty"`
}

type FieldOrigin

type FieldOrigin string
const (
	FieldOriginGitOps  FieldOrigin = "gitops"
	FieldOriginLive    FieldOrigin = "live"
	FieldOriginDefault FieldOrigin = "default"
	FieldOriginManual  FieldOrigin = "manual"
)

type ImportScanResult

type ImportScanResult struct {
	RepoPath  string                `json:"repo_path"`
	ScannedAt time.Time             `json:"scanned_at"`
	Clusters  []ClusterImportResult `json:"clusters"`
	Summary   ImportSummary         `json:"summary"`
	Warnings  []string              `json:"warnings,omitempty"`
}

type ImportSummary

type ImportSummary struct {
	ClustersDiscovered int `json:"clusters_discovered"`
	ClustersWithErrors int `json:"clusters_with_errors,omitempty"`
	ConflictCount      int `json:"conflict_count,omitempty"`
	SkippedFieldCount  int `json:"skipped_field_count,omitempty"`
}

type LiveSnapshot

type LiveSnapshot struct {
	KubernetesVersion string
	MasterCount       int
	WorkerCount       int
	Namespaces        map[string]struct{}
}

func CollectLiveSnapshot

func CollectLiveSnapshot(ctx context.Context, kubeconfigPath string) (*LiveSnapshot, error)

type NamespaceRegistry

type NamespaceRegistry struct {
	// contains filtered or unexported fields
}

func NewNamespaceRegistry

func NewNamespaceRegistry() *NamespaceRegistry

func (*NamespaceRegistry) ApplyOverrides

func (r *NamespaceRegistry) ApplyOverrides(overrides []string) error

func (*NamespaceRegistry) NamespacesFor

func (r *NamespaceRegistry) NamespacesFor(serviceName string) []string

type PatchResult

type PatchResult struct {
	Path    string
	Content []byte
	Diff    string
}

func PatchYAMLFile

func PatchYAMLFile(path string, updates []FieldInferenceResult) (*PatchResult, error)

type SavedArtifact

type SavedArtifact struct {
	RepoHash string            `json:"repo_hash"`
	Path     string            `json:"path"`
	SavedAt  time.Time         `json:"saved_at"`
	Result   *ImportScanResult `json:"result,omitempty"`
}

type Scanner

type Scanner struct {
	// contains filtered or unexported fields
}

func NewScanner

func NewScanner() *Scanner

func (*Scanner) ApplyNamespaceOverrides

func (s *Scanner) ApplyNamespaceOverrides(overrides []string) error

func (*Scanner) ScanRepo

func (s *Scanner) ScanRepo(ctx context.Context, repoPath string) (*ImportScanResult, error)

type ServiceDetector

type ServiceDetector interface {
	ServiceName() string
	Detect(context.Context, *detectContext) ServiceInferenceResult
}

type ServiceInferenceResult

type ServiceInferenceResult struct {
	ServiceName  string                       `json:"service_name"`
	Namespaces   []string                     `json:"namespaces,omitempty"`
	Enabled      *bool                        `json:"enabled,omitempty"`
	AdoptionMode *configservices.AdoptionMode `json:"adoption_mode,omitempty"`
	Fields       []FieldInferenceResult       `json:"fields,omitempty"`
	Conflicts    []FieldConflict              `json:"conflicts,omitempty"`
	Skipped      []SkippedField               `json:"skipped,omitempty"`
}

type SkippedField

type SkippedField struct {
	Path       string          `json:"path"`
	Reason     string          `json:"reason"`
	Confidence ConfidenceLevel `json:"confidence,omitempty"`
}

Jump to

Keyboard shortcuts

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