Skip to content

Commit

Permalink
Fix snapshot source URI override, add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmacknz committed Oct 16, 2023
1 parent a680be2 commit 2329b71
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func snapshotConfig(config *artifact.Config, versionOverride *agtversion.ParsedS
func snapshotURI(versionOverride *agtversion.ParsedSemVer, config *artifact.Config) (string, error) {
// Respect a non-default source URI even if the version is a snapshot.
if config.SourceURI != artifact.DefaultSourceURI {
return "", fmt.Errorf("skip snapshot download due to non-default sourceURI %s", config.SourceURI)
return config.SourceURI, nil
}

// snapshot downloader is used also by the 'localremote' impl in case of agent currently running off a snapshot build:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package snapshot

import (
"testing"

"github.com/stretchr/testify/require"

"github.com/elastic/elastic-agent/internal/pkg/agent/application/upgrade/artifact"
"github.com/elastic/elastic-agent/pkg/version"
)

func TestNonDefaultSourceURI(t *testing.T) {
version, err := version.ParseVersion("8.12.0-SNAPSHOT")
require.NoError(t, err)

config := artifact.Config{
SourceURI: "localhost:1234",
}
sourceURI, err := snapshotURI(version, &config)
require.NoError(t, err)
require.Equal(t, config.SourceURI, sourceURI)

}

0 comments on commit 2329b71

Please sign in to comment.