diff --git a/deb/ppa.go b/deb/ppa.go index 9668468c..e03860c2 100644 --- a/deb/ppa.go +++ b/deb/ppa.go @@ -28,6 +28,11 @@ func ParsePPA(ppaURL string, config *utils.ConfigStructure) (url string, distrib } } + baseurl := config.PpaBaseURL + if baseurl == "" { + baseurl = "http://ppa.launchpad.net" + } + codename := config.PpaCodename if codename == "" { codename, err = getCodename() @@ -39,7 +44,7 @@ func ParsePPA(ppaURL string, config *utils.ConfigStructure) (url string, distrib distribution = codename components = []string{"main"} - url = fmt.Sprintf("http://ppa.launchpad.net/%s/%s/%s", matches[1], matches[2], distributorID) + url = fmt.Sprintf("%s/%s/%s/%s", baseurl, matches[1], matches[2], distributorID) return } diff --git a/debian/aptly.conf b/debian/aptly.conf index c233118f..54360870 100644 --- a/debian/aptly.conf +++ b/debian/aptly.conf @@ -70,6 +70,9 @@ ppa_distributor_id: ubuntu # Codename for short PPA url expansion ppa_codename: "" +# PPA Base URL (default: launchpad) +# # ppa_baseurl: http://ppa.launchpad.net + # Aptly Server ############### diff --git a/system/t02_config/ConfigShowTest_gold b/system/t02_config/ConfigShowTest_gold index ba3b88d6..ccb8ed32 100644 --- a/system/t02_config/ConfigShowTest_gold +++ b/system/t02_config/ConfigShowTest_gold @@ -12,6 +12,7 @@ "dependencyVerboseResolve": false, "ppaDistributorID": "ubuntu", "ppaCodename": "", + "ppaBaseURL": "http://ppa.launchpad.net", "serveInAPIMode": true, "enableMetricsEndpoint": true, "enableSwaggerEndpoint": false, diff --git a/system/t02_config/ConfigShowYAMLTest_gold b/system/t02_config/ConfigShowYAMLTest_gold index 02efe23d..c5a03a9c 100644 --- a/system/t02_config/ConfigShowYAMLTest_gold +++ b/system/t02_config/ConfigShowYAMLTest_gold @@ -11,6 +11,7 @@ dep_follow_source: false dep_verboseresolve: false ppa_distributor_id: ubuntu ppa_codename: "" +ppa_baseurl: http://ppa.launchpad.net serve_in_api_mode: true enable_metrics_endpoint: true enable_swagger_endpoint: false diff --git a/system/t02_config/CreateConfigTest_gold b/system/t02_config/CreateConfigTest_gold index c233118f..54360870 100644 --- a/system/t02_config/CreateConfigTest_gold +++ b/system/t02_config/CreateConfigTest_gold @@ -70,6 +70,9 @@ ppa_distributor_id: ubuntu # Codename for short PPA url expansion ppa_codename: "" +# PPA Base URL (default: launchpad) +# # ppa_baseurl: http://ppa.launchpad.net + # Aptly Server ############### diff --git a/utils/config.go b/utils/config.go index cb72105f..08ca70ca 100644 --- a/utils/config.go +++ b/utils/config.go @@ -31,6 +31,7 @@ type ConfigStructure struct { // nolint: maligned // PPA PpaDistributorID string `json:"ppaDistributorID" yaml:"ppa_distributor_id"` PpaCodename string `json:"ppaCodename" yaml:"ppa_codename"` + PpaBaseURL string `json:"ppaBaseURL" yaml:"ppa_baseurl"` // Server ServeInAPIMode bool `json:"serveInAPIMode" yaml:"serve_in_api_mode"` @@ -235,6 +236,7 @@ var Config = ConfigStructure{ SkipLegacyPool: false, PpaDistributorID: "ubuntu", PpaCodename: "", + PpaBaseURL: "http://ppa.launchpad.net", FileSystemPublishRoots: map[string]FileSystemPublishRoot{}, S3PublishRoots: map[string]S3PublishRoot{}, SwiftPublishRoots: map[string]SwiftPublishRoot{}, diff --git a/utils/config_test.go b/utils/config_test.go index 294f4167..c3545964 100644 --- a/utils/config_test.go +++ b/utils/config_test.go @@ -85,6 +85,7 @@ func (s *ConfigSuite) TestSaveConfig(c *C) { " \"dependencyVerboseResolve\": false,\n" + " \"ppaDistributorID\": \"\",\n" + " \"ppaCodename\": \"\",\n" + + " \"ppaBaseURL\": \"\",\n" + " \"serveInAPIMode\": false,\n" + " \"enableMetricsEndpoint\": false,\n" + " \"enableSwaggerEndpoint\": false,\n" + @@ -252,6 +253,7 @@ func (s *ConfigSuite) TestSaveYAML2Config(c *C) { "dep_verboseresolve: false\n" + "ppa_distributor_id: \"\"\n" + "ppa_codename: \"\"\n" + + "ppa_baseurl: \"\"\n" + "serve_in_api_mode: false\n" + "enable_metrics_endpoint: false\n" + "enable_swagger_endpoint: false\n" + @@ -308,6 +310,7 @@ dep_follow_source: true dep_verboseresolve: true ppa_distributor_id: Ubuntu ppa_codename: code +ppa_baseurl: http://ppa.launchpad.net serve_in_api_mode: true enable_metrics_endpoint: true enable_swagger_endpoint: true