Skip to content
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions internal/telemetrymanifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,21 @@ func TestValidationRejectsMutableUnsafeOrSharedInputs(t *testing.T) {
}
}

func TestStoreAcceptsAnExactPrereleaseIdentity(t *testing.T) {
manifest := mustLoadManifest(t)
manifest.Store.Version = "v1.0.0-rc1"
manifest.Store.Archive.Name = "openobserve-v1.0.0-rc1-linux-amd64.tar.gz"
manifest.Store.Archive.URL = "https://downloads.openobserve.ai/releases/openobserve/v1.0.0-rc1/openobserve-v1.0.0-rc1-linux-amd64.tar.gz"
if err := manifest.Validate(); err != nil {
t.Fatalf("exact prerelease artifact was refused: %v", err)
}

manifest.Store.Version = "v1.0.0-rc1/latest"
if err := manifest.Validate(); err == nil || !strings.Contains(err.Error(), "store.version") {
t.Fatalf("mutable or malformed prerelease identity was accepted: %v", err)
}
}

func TestDecodeRejectsUnknownAndMultipleDocuments(t *testing.T) {
t.Parallel()

Expand Down
17 changes: 9 additions & 8 deletions internal/telemetrymanifest/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import (
)

var (
filePattern = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$`)
shaPattern = regexp.MustCompile(`^[0-9a-f]{64}$`)
streamPattern = regexp.MustCompile(`^[a-z][a-z0-9_]{2,63}$`)
versionPattern = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
bucketPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{2,62}$`)
filePattern = regexp.MustCompile(`^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$`)
shaPattern = regexp.MustCompile(`^[0-9a-f]{64}$`)
streamPattern = regexp.MustCompile(`^[a-z][a-z0-9_]{2,63}$`)
versionPattern = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+$`)
releaseVersionPattern = regexp.MustCompile(`^v[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$`)
bucketPattern = regexp.MustCompile(`^[a-z0-9][a-z0-9-]{2,62}$`)
)

type Issue struct {
Expand Down Expand Up @@ -99,13 +100,13 @@ func validateStore(add func(string, string), store Store) {
if store.Implementation != "openobserve" {
add("store.implementation", "must be openobserve")
}
if !versionPattern.MatchString(store.Version) {
add("store.version", "must be an exact vMAJOR.MINOR.PATCH version")
if !releaseVersionPattern.MatchString(store.Version) {
add("store.version", "must be an exact semantic release version")
}
if store.BinaryPath != "openobserve" {
add("store.binary_path", "must be the exact extracted openobserve executable")
}
if versionPattern.MatchString(store.Version) {
if releaseVersionPattern.MatchString(store.Version) {
name := "openobserve-" + store.Version + "-linux-amd64.tar.gz"
validateAsset(add, "store.archive", store.Archive, "downloads.openobserve.ai",
"/releases/openobserve/"+store.Version+"/"+name, name)
Expand Down