Remove retired cleanup manifest state
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package manifest
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -69,7 +70,16 @@ func (s *LocalStore) LoadReader(ctx context.Context, source io.Reader) (*Manifes
|
||||
}
|
||||
|
||||
var m Manifest
|
||||
if err := json.Unmarshal(data, &m); err != nil {
|
||||
decoder := json.NewDecoder(bytes.NewReader(data))
|
||||
decoder.DisallowUnknownFields()
|
||||
if err := decoder.Decode(&m); err != nil {
|
||||
return nil, fmt.Errorf("decode manifest: %w", err)
|
||||
}
|
||||
var trailing any
|
||||
if err := decoder.Decode(&trailing); err != io.EOF {
|
||||
if err == nil {
|
||||
return nil, fmt.Errorf("decode manifest: multiple JSON values are not allowed")
|
||||
}
|
||||
return nil, fmt.Errorf("decode manifest: %w", err)
|
||||
}
|
||||
|
||||
@@ -104,9 +114,6 @@ func (s *LocalStore) Save(ctx context.Context, path string, m *Manifest) error {
|
||||
if err := validateManifestIdentities(m.SessionID, m.Campaign, m.RunID); err != nil {
|
||||
return fmt.Errorf("save manifest: %w", err)
|
||||
}
|
||||
if err := validatePostPublishCleanup(m.PostPublishCleanup); err != nil {
|
||||
return fmt.Errorf("save manifest: %w", err)
|
||||
}
|
||||
if err := validateSessionStages(m.Stages); err != nil {
|
||||
return fmt.Errorf("save manifest: %w", err)
|
||||
}
|
||||
@@ -149,9 +156,6 @@ func validateLoadedManifest(m *Manifest) error {
|
||||
if err := validateManifestIdentities(m.SessionID, m.Campaign, m.RunID); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validatePostPublishCleanup(m.PostPublishCleanup); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := validateSessionStages(m.Stages); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -175,27 +179,6 @@ func normalizeManifest(m *Manifest) {
|
||||
}
|
||||
}
|
||||
|
||||
func validatePostPublishCleanup(cleanup *PostPublishCleanup) error {
|
||||
if cleanup == nil {
|
||||
return nil
|
||||
}
|
||||
if err := pathsafe.ValidateOpaqueSegment(cleanup.CommittedRunID); err != nil {
|
||||
return fmt.Errorf("post_publish_cleanup.committed_run_id is not a portable opaque identifier: %w", err)
|
||||
}
|
||||
if strings.TrimSpace(cleanup.RemoteCommitKey) == "" || strings.TrimSpace(cleanup.CurrentCommitPointerKey) == "" {
|
||||
return fmt.Errorf("post_publish_cleanup commit identity is required")
|
||||
}
|
||||
if len(cleanup.Targets) == 0 {
|
||||
return fmt.Errorf("post_publish_cleanup.targets is required")
|
||||
}
|
||||
for index, target := range cleanup.Targets {
|
||||
if strings.TrimSpace(target.Policy) == "" || strings.TrimSpace(target.Root) == "" || strings.TrimSpace(target.Path) == "" {
|
||||
return fmt.Errorf("post_publish_cleanup.targets[%d] policy, root, and path are required", index)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func validateManifestIdentities(sessionID, campaign, runID string) error {
|
||||
identities := []struct {
|
||||
field string
|
||||
|
||||
Reference in New Issue
Block a user