@@ -31,19 +31,23 @@ var (
31
31
// packageArchMap provides a mapping for the endings of the builds of Elastic Agent based on the
32
32
// operating system and architecture.
33
33
var packageArchMap = map [string ]string {
34
- "linux-amd64" : "linux-x86_64.tar.gz" ,
35
- "linux-arm64" : "linux-arm64.tar.gz" ,
36
- "windows-amd64" : "windows-x86_64.zip" ,
37
- "darwin-amd64" : "darwin-x86_64.tar.gz" ,
38
- "darwin-arm64" : "darwin-aarch64.tar.gz" ,
34
+ "linux-amd64-targz" : "linux-x86_64.tar.gz" ,
35
+ "linux-amd64-deb" : "amd64.deb" ,
36
+ "linux-amd64-rpm" : "x86_64.rpm" ,
37
+ "linux-arm64-targz" : "linux-arm64.tar.gz" ,
38
+ "linux-arm64-deb" : "arm64.deb" ,
39
+ "linux-arm64-rpm" : "aarch64.rpm" ,
40
+ "windows-amd64-zip" : "windows-x86_64.zip" ,
41
+ "darwin-amd64-targz" : "darwin-x86_64.tar.gz" ,
42
+ "darwin-arm64-targz" : "darwin-aarch64.tar.gz" ,
39
43
}
40
44
41
45
// GetPackageSuffix returns the suffix ending for the builds of Elastic Agent based on the
42
46
// operating system and architecture.
43
- func GetPackageSuffix (operatingSystem string , architecture string ) (string , error ) {
44
- suffix , ok := packageArchMap [fmt .Sprintf ("%s-%s" , operatingSystem , architecture )]
47
+ func GetPackageSuffix (operatingSystem string , architecture string , packageFormat string ) (string , error ) {
48
+ suffix , ok := packageArchMap [fmt .Sprintf ("%s-%s-%s " , operatingSystem , architecture , packageFormat )]
45
49
if ! ok {
46
- return "" , fmt .Errorf ("%w: %s/%s" , ErrUnsupportedPlatform , operatingSystem , architecture )
50
+ return "" , fmt .Errorf ("%w: %s/%s/%s " , ErrUnsupportedPlatform , operatingSystem , architecture , packageFormat )
47
51
}
48
52
return suffix , nil
49
53
}
@@ -68,7 +72,7 @@ type Fetcher interface {
68
72
//
69
73
// The extraction is handled by the caller. This should only download the file
70
74
// and place it into the directory.
71
- Fetch (ctx context.Context , operatingSystem string , architecture string , version string ) (FetcherResult , error )
75
+ Fetch (ctx context.Context , operatingSystem string , architecture string , version string , packageFormat string ) (FetcherResult , error )
72
76
}
73
77
74
78
// fetchCache is global to all tests, reducing the time required to fetch the needed artifacts
@@ -105,6 +109,12 @@ func splitFileType(name string) (string, string, error) {
105
109
if strings .HasSuffix (name , ".zip" ) {
106
110
return strings .TrimSuffix (name , ".zip" ), ".zip" , nil
107
111
}
112
+ if strings .HasSuffix (name , ".deb" ) {
113
+ return strings .TrimSuffix (name , ".deb" ), ".deb" , nil
114
+ }
115
+ if strings .HasSuffix (name , ".rpm" ) {
116
+ return strings .TrimSuffix (name , ".rpm" ), ".rpm" , nil
117
+ }
108
118
return "" , "" , fmt .Errorf ("unknown file extension type: %s" , filepath .Ext (name ))
109
119
}
110
120
0 commit comments