projectmigrate

package
v0.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(ctx context.Context, plan *Plan) error

Apply writes exactly the changes in plan after revalidating Git state and every input digest. A failure rolls back files written by this invocation.

func CompatibilityAssetPaths

func CompatibilityAssetPaths(sourceFamily string) ([]string, error)

CompatibilityAssetPaths returns the existing paths that the selected source family can map to pkg v0.5.0-compatible managed content.

func IsKnownLegacyMarkerFile

func IsKnownLegacyMarkerFile(relativePath string, body []byte) bool

IsKnownLegacyMarkerFile recognizes only the exact frozen public/embed.go output affected by the historical non-.tmpl generator bug.

func RenderCompatibilityAsset

func RenderCompatibilityAsset(project Project, relativePath, targetCLIVersion string) ([]byte, error)

RenderCompatibilityAsset renders one frozen asset entirely in memory.

func ValidateTargetCLIVersion

func ValidateTargetCLIVersion(raw string) (string, error)

ValidateTargetCLIVersion accepts only a stable, release-build semantic version and returns the marker representation without a leading v.

func WritePlan

func WritePlan(output io.Writer, plan Plan) error

Types

type Change

type Change struct {
	Path         string
	Before       []byte
	After        []byte
	Mode         fs.FileMode
	BeforeSHA256 [sha256.Size]byte
}

type Diagnostic

type Diagnostic struct {
	Code    string
	Path    string
	Line    int
	Message string
}

func ScanManualActions

func ScanManualActions(project Project, changedPaths map[string]struct{}, targetCLIVersion string) ([]Diagnostic, error)

ScanManualActions reports known pkg v0.5.0 incompatibilities without modifying source. Paths already replaced by the managed plan are excluded. targetCLIVersion is the migration target used to recognize up-to-date generate.sh content.

type Marker

type Marker struct {
	Version       string
	SourceFamily  string
	CommentPrefix string
}

Marker is a strict first-line grpc-kit-cli ownership declaration.

func ParseMarkerLine

func ParseMarkerLine(line string) (Marker, error)

ParseMarkerLine parses an exact Go or script marker. Similar comments, placeholders and non-canonical versions do not grant write ownership.

func (Marker) Supported

func (m Marker) Supported() bool

Supported reports whether the marker maps to a frozen source family.

type Plan

type Plan struct {
	Project          Project
	FromCLIVersions  []string
	TargetCLIVersion string
	TargetPkgVersion string
	Status           Status
	Changes          []Change
	Warnings         []Diagnostic
	ApplyBlockers    []Diagnostic
	ManualActions    []Diagnostic
	Conflicts        []Diagnostic
}

func BuildPlan

func BuildPlan(projectPath, targetCLIVersion string) (Plan, error)

BuildPlan computes the complete write set without modifying the project.

func (Plan) Blocked

func (p Plan) Blocked() bool

type Project

type Project struct {
	Root             string
	ModulePath       string
	SourceCLIVersion string
	SourceFamily     string
	ProductCode      string
	ShortName        string
	APIVersion       string
}

Project contains the identity required to render managed migration assets.

func LoadProject

func LoadProject(path string) (Project, error)

LoadProject identifies a project without executing its scripts or changing any files.

type SourceFixture

type SourceFixture struct {
	Name              string
	Commit            string
	ProjectCLIVersion string
	Files             map[string]string
}

SourceFixture records the immutable evidence used to select compatibility assets. SHA-256 values are over the exact Git blob contents at Commit.

func CLIV038SourceFixture

func CLIV038SourceFixture() SourceFixture

CLIV038SourceFixture returns a defensive copy of the official v0.3.8 template evidence.

func SpiderSourceFixture

func SpiderSourceFixture() SourceFixture

SpiderSourceFixture returns a defensive copy of the frozen source evidence.

type Status

type Status string
const (
	StatusManagedUpToDate Status = "managed_up_to_date"
	StatusReady           Status = "ready"
	StatusApplied         Status = "applied"
	StatusConflict        Status = "conflict"
	StatusUnsupported     Status = "unsupported"
)

Jump to

Keyboard shortcuts

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