Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort datasetconfig for deterministic storage #97

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io/ioutil"
"path/filepath"
"sort"

"sigs.k8s.io/yaml"

Expand Down Expand Up @@ -37,6 +38,15 @@ func LoadDataSetConfig(data []byte) (configuration v1alpha1.DataSetConfiguration
if err = dec.Decode(&configuration); err != nil {
return configuration, err
}

// Sort the slices within the DataSetConfiguration and store the file
// in the manifest config of the OCI artifact for later.
sort.Slice(configuration.Collection.Files, func(i, j int) bool {
return configuration.Collection.Files[i].File < configuration.Collection.Files[j].File
})
sort.Slice(configuration.Collection.LinkedCollections, func(i, j int) bool {
return configuration.Collection.LinkedCollections[i] < configuration.Collection.LinkedCollections[j]
})
return configuration, err
}

Expand Down