Remove legacy publish and state paths

This commit is contained in:
2026-06-19 17:12:21 +00:00
parent 2e0d903626
commit 5e47d89355
30 changed files with 228 additions and 3340 deletions

View File

@@ -265,9 +265,6 @@ func unsupportedStateDocumentError(document state.StateDocument) error {
if document.SupersededLegacy != nil {
return fmt.Errorf("destination state schema_version %d is superseded legacy state", document.SupersededLegacy.SchemaVersion)
}
if document.SingleOwner != nil || document.SharedRoot != nil {
return fmt.Errorf("legacy destination state is not supported by this command")
}
return fmt.Errorf("destination state document is empty")
}

View File

@@ -12,14 +12,13 @@ func shouldNotify(action publish.Action) bool {
func notifyEvent(plan publish.Plan) notify.Event {
outputs := make([]notify.Output, 0, len(plan.Outputs))
for _, output := range plan.Outputs {
stateOutput := output.StateOutputFile()
outputs = append(outputs, notify.Output{
Path: stateOutput.Path,
Kind: stateOutput.Kind,
SourcePath: stateOutput.SourcePath,
Transform: stateOutput.Transform,
SHA256: stateOutput.SHA256,
Size: stateOutput.Size,
Path: output.DestinationPath,
Kind: output.Kind,
SourcePath: output.SourcePath,
Transform: output.Transform,
SHA256: output.SHA256,
Size: output.Size,
})
}
return notify.Event{

View File

@@ -220,15 +220,14 @@ func errorAction(pipelineID, destinationID, backend, bundlePath string, err erro
func runOutputsFromPlan(outputs []publish.Output) []RunOutputRecord {
results := make([]RunOutputRecord, 0, len(outputs))
for _, output := range outputs {
stateOutput := output.StateOutputFile()
results = append(results, RunOutputRecord{
Path: stateOutput.Path,
Kind: stateOutput.Kind,
SourcePath: stateOutput.SourcePath,
Transform: stateOutput.Transform,
URL: stateOutput.URL,
SHA256: stateOutput.SHA256,
Size: stateOutput.Size,
Path: output.DestinationPath,
Kind: output.Kind,
SourcePath: output.SourcePath,
Transform: output.Transform,
URL: output.URL,
SHA256: output.SHA256,
Size: output.Size,
})
}
return results

View File

@@ -31,7 +31,7 @@ func (s *runSummary) recordPlan(action publish.Action) {
s.replaceCatalog++
case publish.ActionForceReplace:
s.forceReplace++
case publish.ActionSkipSame, publish.ActionSkipDestinationNewer:
case publish.ActionSkipSame:
s.skipSame++
}
}

View File

@@ -210,14 +210,14 @@ func TestRunPublishesNewLocalBundle(t *testing.T) {
if destinationState.PipelineID != "reports" || destinationState.DestinationID != "archive" {
t.Fatalf("state identity = %s/%s", destinationState.PipelineID, destinationState.DestinationID)
}
if destinationState.Source.Manifest.ID != manifest.ID {
t.Fatalf("state source id = %q, want %q", destinationState.Source.Manifest.ID, manifest.ID)
if destinationState.SourceID != manifest.ID {
t.Fatalf("state source id = %q, want %q", destinationState.SourceID, manifest.ID)
}
if got, want := len(destinationState.Outputs), 2; got != want {
t.Fatalf("state output count = %d, want %d", got, want)
}
if destinationState.Links != nil || destinationState.Outputs[0].URL != "" {
t.Fatalf("state links = %#v output URL=%q, want absent", destinationState.Links, destinationState.Outputs[0].URL)
if destinationState.PrimaryURL != "" || destinationState.Outputs[0].URL != "" {
t.Fatalf("state primary URL = %q output URL=%q, want absent", destinationState.PrimaryURL, destinationState.Outputs[0].URL)
}
}
@@ -362,8 +362,8 @@ func TestRunRecordsLinksForNestedBundlePath(t *testing.T) {
t.Fatalf("Run() error = %v", err)
}
destinationState := readStateFile(t, filepath.Join(destinationRoot, "daily", "brentwood", storage.StateFileName))
if destinationState.Links == nil || destinationState.Links.PrimaryURL != "https://reports.example.com/archive/daily/brentwood/report.md" {
t.Fatalf("state links = %#v, want source primary URL", destinationState.Links)
if destinationState.PrimaryURL != "https://reports.example.com/archive/daily/brentwood/report.md" {
t.Fatalf("state primary URL = %q, want source primary URL", destinationState.PrimaryURL)
}
outputs := outputsByPath(destinationState.Outputs)
if outputs["report.md"].URL != "https://reports.example.com/archive/daily/brentwood/report.md" {
@@ -387,8 +387,8 @@ func TestRunRecordsLinksForFixedIndexDestination(t *testing.T) {
t.Fatalf("Run() error = %v", err)
}
destinationState := readStateFile(t, filepath.Join(destinationRoot, storage.StateFileName))
if destinationState.Links == nil || destinationState.Links.PrimaryURL != "https://reports.example.com/latest/" {
t.Fatalf("state links = %#v, want fixed index primary URL", destinationState.Links)
if destinationState.PrimaryURL != "https://reports.example.com/latest/" {
t.Fatalf("state primary URL = %q, want fixed index primary URL", destinationState.PrimaryURL)
}
if got, want := len(destinationState.Outputs), 1; got != want {
t.Fatalf("state output count = %d, want %d", got, want)
@@ -427,8 +427,8 @@ func TestRunFixedPathPublishesNewestBundleAtDestinationRoot(t *testing.T) {
t.Fatalf("nested new report stat error = %v, want not exist", err)
}
destinationState := readStateFile(t, filepath.Join(destinationRoot, storage.StateFileName))
if destinationState.Source.Manifest.ID != "reports.new" {
t.Fatalf("state source id = %q, want reports.new", destinationState.Source.Manifest.ID)
if destinationState.SourceID != "reports.new" {
t.Fatalf("state source id = %q, want reports.new", destinationState.SourceID)
}
}
@@ -457,8 +457,8 @@ func TestRunFixedPathTieBreaksByBundlePath(t *testing.T) {
t.Fatalf("Run() error = %v", err)
}
destinationState := readStateFile(t, filepath.Join(destinationRoot, storage.StateFileName))
if destinationState.Source.Manifest.ID != "reports.a" {
t.Fatalf("state source id = %q, want reports.a", destinationState.Source.Manifest.ID)
if destinationState.SourceID != "reports.a" {
t.Fatalf("state source id = %q, want reports.a", destinationState.SourceID)
}
}
@@ -1807,11 +1807,6 @@ func writeConfigFile(t *testing.T, body string) string {
return path
}
func writeDestinationState(t *testing.T, root, relative string, manifest bundle.Manifest) {
t.Helper()
testutil.WriteDestinationState(t, root, relative, manifest, testutil.DestinationStateOptions{})
}
func writeJSONManifest(t *testing.T, root string, manifest bundle.Manifest) {
t.Helper()
if err := os.MkdirAll(root, 0o755); err != nil {
@@ -1829,8 +1824,10 @@ func writeJSONManifest(t *testing.T, root string, manifest bundle.Manifest) {
type testDestinationState struct {
PipelineID string
DestinationID string
Source state.SourceState
Links *state.LinkState
SourceID string
SourceDigest string
SourceCreated time.Time
PrimaryURL string
Outputs []testStateOutput
}
@@ -1859,11 +1856,11 @@ func readStateFile(t *testing.T, path string) testDestinationState {
if index == 0 {
view.PipelineID = output.PipelineID
view.DestinationID = output.DestinationID
view.Source.Manifest.ID = output.Source.ID
view.Source.Manifest.Digest = output.Source.Digest
view.Source.Manifest.Created = output.Source.Created
view.SourceID = output.Source.ID
view.SourceDigest = output.Source.Digest
view.SourceCreated = output.Source.Created
if output.URL != "" {
view.Links = &state.LinkState{PrimaryURL: output.URL}
view.PrimaryURL = output.URL
}
}
view.Outputs = append(view.Outputs, testStateOutput{