@@ -26,6 +26,7 @@ type httpDoer interface {
2626
2727type artifactFetcher struct {
2828 snapshotOnly bool
29+ fipsOnly bool
2930
3031 doer httpDoer
3132}
@@ -39,6 +40,13 @@ func WithArtifactSnapshotOnly() artifactFetcherOpt {
3940 }
4041}
4142
43+ // WithArtifactFIPSOnly sets the ArtifactFetcher to only pull a FIPS-compliant build.
44+ func WithArtifactFIPSOnly () artifactFetcherOpt {
45+ return func (f * artifactFetcher ) {
46+ f .fipsOnly = true
47+ }
48+ }
49+
4250// ArtifactFetcher returns a fetcher that pulls the binary of the Elastic Agent from the Elastic artifacts API.
4351//
4452// It tries to pull the latest version and if it cannot find that version it tries to pull a SNAPSHOT build for
@@ -60,6 +68,7 @@ func (f *artifactFetcher) Name() string {
6068
6169// Fetch fetches the Elastic Agent and places the resulting binary at the path.
6270func (f * artifactFetcher ) Fetch (ctx context.Context , operatingSystem string , architecture string , version string , packageFormat string ) (FetcherResult , error ) {
71+ prefix := GetPackagePrefix (f .fipsOnly )
6372 suffix , err := GetPackageSuffix (operatingSystem , architecture , packageFormat )
6473 if err != nil {
6574 return nil , err
@@ -84,7 +93,7 @@ func (f *artifactFetcher) Fetch(ctx context.Context, operatingSystem string, arc
8493 }
8594
8695 // this remote path cannot have the build metadata in it
87- srcPath := fmt .Sprintf ("elastic-agent-%s-%s" , ver .VersionWithPrerelease (), suffix )
96+ srcPath := fmt .Sprintf ("elastic-agent-%s-%s-%s" , prefix , ver .VersionWithPrerelease (), suffix )
8897 downloadSrc := fmt .Sprintf ("%s%s" , uri , srcPath )
8998
9099 return & artifactResult {
0 commit comments