Config options for S3 storage. #15

This commit is contained in:
Andrey Smirnov
2014-07-18 17:37:08 +04:00
parent 076ecd586f
commit 7a7bb56557
3 changed files with 41 additions and 16 deletions
+3 -2
View File
@@ -1,5 +1,5 @@
{ {
"rootDir": "${HOME}/.aptly", "rootDir": "/Users/smira/.aptly",
"downloadConcurrency": 4, "downloadConcurrency": 4,
"downloadSpeedLimit": 0, "downloadSpeedLimit": 0,
"architectures": [], "architectures": [],
@@ -11,5 +11,6 @@
"gpgDisableVerify": false, "gpgDisableVerify": false,
"downloadSourcePackages": false, "downloadSourcePackages": false,
"ppaDistributorID": "ubuntu", "ppaDistributorID": "ubuntu",
"ppaCodename": "" "ppaCodename": "",
"S3PublishRoots": {}
} }
+24 -13
View File
@@ -8,19 +8,29 @@ import (
// ConfigStructure is structure of main configuration // ConfigStructure is structure of main configuration
type ConfigStructure struct { type ConfigStructure struct {
RootDir string `json:"rootDir"` RootDir string `json:"rootDir"`
DownloadConcurrency int `json:"downloadConcurrency"` DownloadConcurrency int `json:"downloadConcurrency"`
DownloadLimit int64 `json:"downloadSpeedLimit"` DownloadLimit int64 `json:"downloadSpeedLimit"`
Architectures []string `json:"architectures"` Architectures []string `json:"architectures"`
DepFollowSuggests bool `json:"dependencyFollowSuggests"` DepFollowSuggests bool `json:"dependencyFollowSuggests"`
DepFollowRecommends bool `json:"dependencyFollowRecommends"` DepFollowRecommends bool `json:"dependencyFollowRecommends"`
DepFollowAllVariants bool `json:"dependencyFollowAllVariants"` DepFollowAllVariants bool `json:"dependencyFollowAllVariants"`
DepFollowSource bool `json:"dependencyFollowSource"` DepFollowSource bool `json:"dependencyFollowSource"`
GpgDisableSign bool `json:"gpgDisableSign"` GpgDisableSign bool `json:"gpgDisableSign"`
GpgDisableVerify bool `json:"gpgDisableVerify"` GpgDisableVerify bool `json:"gpgDisableVerify"`
DownloadSourcePackages bool `json:"downloadSourcePackages"` DownloadSourcePackages bool `json:"downloadSourcePackages"`
PpaDistributorID string `json:"ppaDistributorID"` PpaDistributorID string `json:"ppaDistributorID"`
PpaCodename string `json:"ppaCodename"` PpaCodename string `json:"ppaCodename"`
S3PublishRoots map[string]S3PublishRoot `json:"S3PublishRoots"`
}
type S3PublishRoot struct {
Region string `json:"region"`
Bucket string `json:"bucket"`
AccessKeyID string `json:"awsAccessKeyID"`
SecretAccessKey string `json:"awsSecretAccessKey"`
Prefix string `json:"prefix"`
ACL string `json:"acl"`
} }
// Config is configuration for aptly, shared by all modules // Config is configuration for aptly, shared by all modules
@@ -38,6 +48,7 @@ var Config = ConfigStructure{
DownloadSourcePackages: false, DownloadSourcePackages: false,
PpaDistributorID: "ubuntu", PpaDistributorID: "ubuntu",
PpaCodename: "", PpaCodename: "",
S3PublishRoots: map[string]S3PublishRoot{},
} }
// LoadConfig loads configuration from json file // LoadConfig loads configuration from json file
+14 -1
View File
@@ -29,6 +29,9 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
s.config.RootDir = "/tmp/aptly" s.config.RootDir = "/tmp/aptly"
s.config.DownloadConcurrency = 5 s.config.DownloadConcurrency = 5
s.config.S3PublishRoots = map[string]S3PublishRoot{"test": S3PublishRoot{
Region: "us-east-1",
Bucket: "repo"}}
err := SaveConfig(configname, &s.config) err := SaveConfig(configname, &s.config)
c.Assert(err, IsNil) c.Assert(err, IsNil)
@@ -54,7 +57,17 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
" \"gpgDisableVerify\": false,\n"+ " \"gpgDisableVerify\": false,\n"+
" \"downloadSourcePackages\": false,\n"+ " \"downloadSourcePackages\": false,\n"+
" \"ppaDistributorID\": \"\",\n"+ " \"ppaDistributorID\": \"\",\n"+
" \"ppaCodename\": \"\"\n"+ " \"ppaCodename\": \"\",\n"+
" \"S3PublishRoots\": {\n"+
" \"test\": {\n"+
" \"region\": \"us-east-1\",\n"+
" \"bucket\": \"repo\",\n"+
" \"awsAccessKeyID\": \"\",\n"+
" \"awsSecretAccessKey\": \"\",\n"+
" \"prefix\": \"\",\n"+
" \"acl\": \"\"\n"+
" }\n"+
" }\n"+
"}") "}")
} }