Files
wehub-resource-sync 498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:17 +08:00

61 lines
1.2 KiB
Go

package backend
import (
"encoding/json"
"github.com/milvus-io/milvus/cmd/tools/migration/console"
)
type BackupHeaderVersion int32
const (
BackupHeaderVersionV1 BackupHeaderVersion = iota
)
type BackupHeaderExtra struct {
EntryIncludeRootPath bool `json:"entry_include_root_path"`
}
type extraOption func(extra *BackupHeaderExtra)
func setEntryIncludeRootPath(include bool) extraOption {
return func(extra *BackupHeaderExtra) {
extra.EntryIncludeRootPath = include
}
}
func newDefaultBackupHeaderExtra() *BackupHeaderExtra {
return &BackupHeaderExtra{EntryIncludeRootPath: false}
}
func newBackupHeaderExtra(opts ...extraOption) *BackupHeaderExtra {
v := newDefaultBackupHeaderExtra()
v.apply(opts...)
return v
}
func (v *BackupHeaderExtra) apply(opts ...extraOption) {
for _, opt := range opts {
opt(v)
}
}
func (v *BackupHeaderExtra) ToJSONBytes() []byte {
bs, err := json.Marshal(v)
if err != nil {
console.Error(err.Error())
return nil
}
return bs
}
func GetExtra(extra []byte) *BackupHeaderExtra {
v := newDefaultBackupHeaderExtra()
err := json.Unmarshal(extra, v)
if err != nil {
console.Error(err.Error())
return v
}
return v
}