@@ -17,8 +17,8 @@ import (
1717//////////
1818
1919var dockerCliVersionRegexp * regexp.Regexp = regexp .MustCompile (`(?m)^(\d+)\.(\d+)\.(\d+)$` )
20- var dockerComposeVersionRegexp * regexp.Regexp = regexp .MustCompile (`(?m)^v(\d+)\.(\d+)\.(\d+)$` )
21- var dockerBuildxVersionRegexp * regexp.Regexp = regexp .MustCompile (`(?m)^v(\d+)\.(\d+)\.(\d+)$` )
20+ var dockerComposeVersionRegexp * regexp.Regexp = regexp .MustCompile (`(?m)^v(?P<raw>( \d+)\.(\d+)\.(\d+) )$` )
21+ var dockerBuildxVersionRegexp * regexp.Regexp = regexp .MustCompile (`(?m)^v(?P<raw>( \d+)\.(\d+)\.(\d+) )$` )
2222
2323//////////
2424// Main
@@ -42,6 +42,10 @@ func runMain() error {
4242 downloadUrlBase := flag .String ("downloadUrlBase" , "" , "" )
4343 downloadUrlPath := flag .String ("downloadUrlPath" , "" , "" )
4444 versionsUrl := flag .String ("versionsUrl" , "" , "" )
45+ composeDownloadUrlBase := flag .String ("composeDownloadUrlBase" , "" , "" )
46+ composeDownloadUrlPath := flag .String ("composeDownloadUrlPath" , "" , "" )
47+ buildxDownloadUrlBase := flag .String ("buildxDownloadUrlBase" , "" , "" )
48+ buildxDownloadUrlPath := flag .String ("buildxDownloadUrlPath" , "" , "" )
4549 flag .Parse ()
4650
4751 // Load settings from an external file
@@ -52,6 +56,8 @@ func runMain() error {
5256 installer .HandleOverride (downloadUrlBase , "https://download.docker.com" , "docker-out-download-url-base" )
5357 installer .HandleOverride (downloadUrlPath , "/linux/static/stable" , "docker-out-download-url-path" )
5458 installer .HandleOverride (versionsUrl , "https://download.docker.com/linux/static/stable" , "docker-out-versions-url" )
59+ installer .HandleGitHubOverride (composeDownloadUrlBase , composeDownloadUrlPath , "docker/compose" , "docker-out-compose-download-url" )
60+ installer .HandleGitHubOverride (buildxDownloadUrlBase , buildxDownloadUrlPath , "docker/buildx" , "docker-out-buildx-download-url" )
5561
5662 // Create and process the feature
5763 feature := installer .NewFeature ("Docker-Out" , false ,
@@ -62,10 +68,14 @@ func runMain() error {
6268 VersionsUrl : * versionsUrl ,
6369 },
6470 & dockerComposeComponent {
65- ComponentBase : installer .NewComponentBase ("Docker Compose" , * composeVersion , * composeVersionResolve ),
71+ ComponentBase : installer .NewComponentBase ("Docker Compose" , * composeVersion , * composeVersionResolve ),
72+ DownloadUrlBase : * composeDownloadUrlBase ,
73+ DownloadUrlPath : * composeDownloadUrlPath ,
6674 },
6775 & dockerBuildxComponent {
68- ComponentBase : installer .NewComponentBase ("Docker buildx" , * buildxVersion , * buildxVersionResolve ),
76+ ComponentBase : installer .NewComponentBase ("Docker buildx" , * buildxVersion , * buildxVersionResolve ),
77+ DownloadUrlBase : * buildxDownloadUrlBase ,
78+ DownloadUrlPath : * buildxDownloadUrlPath ,
6979 },
7080 )
7181 return feature .Process ()
@@ -152,6 +162,8 @@ func (c *dockerCliComponent) getArchitecturePathPart() (string, error) {
152162
153163type dockerComposeComponent struct {
154164 * installer.ComponentBase
165+ DownloadUrlBase string
166+ DownloadUrlPath string
155167}
156168
157169func (c * dockerComposeComponent ) GetAllVersions () ([]* gover.Version , error ) {
@@ -181,7 +193,12 @@ func (c *dockerComposeComponent) InstallVersion(version *gover.Version) error {
181193 if err != nil {
182194 return err
183195 }
184- downloadUrl := fmt .Sprintf ("https://github.com/docker/compose/releases/download/%s/docker-compose-linux-%s" , version .Raw , archPart )
196+ // https://github.com/docker/compose/releases/download/v2.39.2/docker-compose-linux-x86_64
197+ versionPart := fmt .Sprintf ("v%s" , version .Raw )
198+ downloadUrl , err := installer .Tools .Http .BuildUrl (c .DownloadUrlBase , c .DownloadUrlPath , versionPart , fmt .Sprintf ("docker-compose-linux-%s" , archPart ))
199+ if err != nil {
200+ return err
201+ }
185202 if err := installer .Tools .Download .ToFile (downloadUrl , "/usr/local/lib/docker/cli-plugins/docker-compose" , "Docker Compose" ); err != nil {
186203 return err
187204 }
@@ -196,6 +213,8 @@ func (c *dockerComposeComponent) InstallVersion(version *gover.Version) error {
196213
197214type dockerBuildxComponent struct {
198215 * installer.ComponentBase
216+ DownloadUrlBase string
217+ DownloadUrlPath string
199218}
200219
201220func (c * dockerBuildxComponent ) GetAllVersions () ([]* gover.Version , error ) {
@@ -225,7 +244,12 @@ func (c *dockerBuildxComponent) InstallVersion(version *gover.Version) error {
225244 if err != nil {
226245 return err
227246 }
228- downloadUrl := fmt .Sprintf ("https://github.com/docker/buildx/releases/download/%s/buildx-%s.linux-%s" , version .Raw , version .Raw , archPart )
247+ // https://github.com/docker/buildx/releases/download/v0.26.1/buildx-v0.26.1.linux-amd64
248+ versionPart := fmt .Sprintf ("v%s" , version .Raw )
249+ downloadUrl , err := installer .Tools .Http .BuildUrl (c .DownloadUrlBase , c .DownloadUrlPath , versionPart , fmt .Sprintf ("buildx-%s.linux-%s" , versionPart , archPart ))
250+ if err != nil {
251+ return err
252+ }
229253 if err := installer .Tools .Download .ToFile (downloadUrl , "/usr/local/lib/docker/cli-plugins/docker-buildx" , "Docker buildx" ); err != nil {
230254 return err
231255 }
0 commit comments