Merge pull request #347 from smira/skip-contents

Make 'skipContents' configurable in API. #345
This commit is contained in:
Andrey Smirnov
2016-02-14 15:06:49 +03:00
10 changed files with 31 additions and 2 deletions
+11
View File
@@ -97,6 +97,7 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
Label string Label string
Origin string Origin string
ForceOverwrite bool ForceOverwrite bool
SkipContents *bool
Architectures []string Architectures []string
Signing SigningOptions Signing SigningOptions
} }
@@ -183,6 +184,11 @@ func apiPublishRepoOrSnapshot(c *gin.Context) {
published.Origin = b.Origin published.Origin = b.Origin
published.Label = b.Label published.Label = b.Label
published.SkipContents = context.Config().SkipContentsPublishing
if b.SkipContents != nil {
published.SkipContents = *b.SkipContents
}
duplicate := collection.CheckDuplicate(published) duplicate := collection.CheckDuplicate(published)
if duplicate != nil { if duplicate != nil {
context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory()) context.CollectionFactory().PublishedRepoCollection().LoadComplete(duplicate, context.CollectionFactory())
@@ -213,6 +219,7 @@ func apiPublishUpdateSwitch(c *gin.Context) {
var b struct { var b struct {
ForceOverwrite bool ForceOverwrite bool
Signing SigningOptions Signing SigningOptions
SkipContents *bool
Snapshots []struct { Snapshots []struct {
Component string `binding:"required"` Component string `binding:"required"`
Name string `binding:"required"` Name string `binding:"required"`
@@ -291,6 +298,10 @@ func apiPublishUpdateSwitch(c *gin.Context) {
c.Fail(500, fmt.Errorf("unknown published repository type")) c.Fail(500, fmt.Errorf("unknown published repository type"))
} }
if b.SkipContents != nil {
published.SkipContents = *b.SkipContents
}
err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite) err = published.Publish(context.PackagePool(), context, context.CollectionFactory(), signer, nil, b.ForceOverwrite)
if err != nil { if err != nil {
c.Fail(500, fmt.Errorf("unable to update: %s", err)) c.Fail(500, fmt.Errorf("unable to update: %s", err))
+2
View File
@@ -119,6 +119,8 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
published.Origin = context.Flags().Lookup("origin").Value.String() published.Origin = context.Flags().Lookup("origin").Value.String()
published.Label = context.Flags().Lookup("label").Value.String() published.Label = context.Flags().Lookup("label").Value.String()
published.SkipContents = context.Config().SkipContentsPublishing
if context.Flags().IsSet("skip-contents") { if context.Flags().IsSet("skip-contents") {
published.SkipContents = context.Flags().Lookup("skip-contents").Value.Get().(bool) published.SkipContents = context.Flags().Lookup("skip-contents").Value.Get().(bool)
} }
+1
View File
@@ -290,6 +290,7 @@ func (p *PublishedRepo) MarshalJSON() ([]byte, error) {
"SourceKind": p.SourceKind, "SourceKind": p.SourceKind,
"Sources": sources, "Sources": sources,
"Storage": p.Storage, "Storage": p.Storage,
"SkipContents": p.SkipContents,
}) })
} }
+5 -2
View File
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3 .\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3
. .
.TH "APTLY" "1" "January 2016" "" "" .TH "APTLY" "1" "February 2016" "" ""
. .
.SH "NAME" .SH "NAME"
\fBaptly\fR \- Debian repository management tool \fBaptly\fR \- Debian repository management tool
@@ -48,6 +48,7 @@ Configuration file is stored in JSON format (default values shown below):
"downloadSourcePackages": false, "downloadSourcePackages": false,
"ppaDistributorID": "ubuntu", "ppaDistributorID": "ubuntu",
"ppaCodename": "", "ppaCodename": "",
"skipContentsPublishing": false,
"S3PublishEndpoints": { "S3PublishEndpoints": {
"test": { "test": {
"region": "us\-east\-1", "region": "us\-east\-1",
@@ -55,7 +56,6 @@ Configuration file is stored in JSON format (default values shown below):
"endpoint": "", "endpoint": "",
"awsAccessKeyID": "", "awsAccessKeyID": "",
"awsSecretAccessKey": "", "awsSecretAccessKey": "",
"awsSessionToken": "",
"prefix": "", "prefix": "",
"acl": "public\-read", "acl": "public\-read",
"storageClass": "", "storageClass": "",
@@ -1819,5 +1819,8 @@ Vincent Bernat (https://github\.com/vincentbernat)
.IP "\[ci]" 4 .IP "\[ci]" 4
x539 (https://github\.com/x539) x539 (https://github\.com/x539)
. .
.IP "\[ci]" 4
Phil Frost (https://github\.com/bitglue)
.
.IP "" 0 .IP "" 0
+1
View File
@@ -40,6 +40,7 @@ Configuration file is stored in JSON format (default values shown below):
"downloadSourcePackages": false, "downloadSourcePackages": false,
"ppaDistributorID": "ubuntu", "ppaDistributorID": "ubuntu",
"ppaCodename": "", "ppaCodename": "",
"skipContentsPublishing": false,
"S3PublishEndpoints": { "S3PublishEndpoints": {
"test": { "test": {
"region": "us-east-1", "region": "us-east-1",
+1
View File
@@ -12,6 +12,7 @@
"downloadSourcePackages": false, "downloadSourcePackages": false,
"ppaDistributorID": "ubuntu", "ppaDistributorID": "ubuntu",
"ppaCodename": "", "ppaCodename": "",
"skipContentsPublishing": false,
"S3PublishEndpoints": {}, "S3PublishEndpoints": {},
"SwiftPublishEndpoints": {} "SwiftPublishEndpoints": {}
} }
+1
View File
@@ -12,6 +12,7 @@
"downloadSourcePackages": false, "downloadSourcePackages": false,
"ppaDistributorID": "ubuntu", "ppaDistributorID": "ubuntu",
"ppaCodename": "", "ppaCodename": "",
"skipContentsPublishing": false,
"S3PublishEndpoints": {}, "S3PublishEndpoints": {},
"SwiftPublishEndpoints": {} "SwiftPublishEndpoints": {}
} }
+7
View File
@@ -41,6 +41,7 @@ class PublishAPITestRepo(APITest):
'Label': '', 'Label': '',
'Origin': '', 'Origin': '',
'Prefix': prefix, 'Prefix': prefix,
'SkipContents': False,
'SourceKind': 'local', 'SourceKind': 'local',
'Sources': [{'Component': 'main', 'Name': repo_name}], 'Sources': [{'Component': 'main', 'Name': repo_name}],
'Storage': ''} 'Storage': ''}
@@ -74,6 +75,7 @@ class PublishAPITestRepo(APITest):
'Label': '', 'Label': '',
'Origin': '', 'Origin': '',
'Prefix': ".", 'Prefix': ".",
'SkipContents': False,
'SourceKind': 'local', 'SourceKind': 'local',
'Sources': [{'Component': 'main', 'Name': repo_name}], 'Sources': [{'Component': 'main', 'Name': repo_name}],
'Storage': ''} 'Storage': ''}
@@ -129,6 +131,7 @@ class PublishSnapshotAPITest(APITest):
'Label': '', 'Label': '',
'Origin': '', 'Origin': '',
'Prefix': prefix, 'Prefix': prefix,
'SkipContents': False,
'SourceKind': 'snapshot', 'SourceKind': 'snapshot',
'Sources': [{'Component': 'main', 'Name': snapshot_name}], 'Sources': [{'Component': 'main', 'Name': snapshot_name}],
'Storage': ''}) 'Storage': ''})
@@ -188,6 +191,7 @@ class PublishUpdateAPITestRepo(APITest):
'Label': '', 'Label': '',
'Origin': '', 'Origin': '',
'Prefix': prefix, 'Prefix': prefix,
'SkipContents': False,
'SourceKind': 'local', 'SourceKind': 'local',
'Sources': [{'Component': 'main', 'Name': repo_name}], 'Sources': [{'Component': 'main', 'Name': repo_name}],
'Storage': ''} 'Storage': ''}
@@ -238,6 +242,7 @@ class PublishSwitchAPITestRepo(APITest):
'Label': '', 'Label': '',
'Origin': '', 'Origin': '',
'Prefix': prefix, 'Prefix': prefix,
'SkipContents': False,
'SourceKind': 'snapshot', 'SourceKind': 'snapshot',
'Sources': [{'Component': 'main', 'Name': snapshot1_name}], 'Sources': [{'Component': 'main', 'Name': snapshot1_name}],
'Storage': ''} 'Storage': ''}
@@ -261,6 +266,7 @@ class PublishSwitchAPITestRepo(APITest):
json={ json={
"Snapshots": [{"Component": "main", "Name": snapshot2_name}], "Snapshots": [{"Component": "main", "Name": snapshot2_name}],
"Signing": DefaultSigningOptions, "Signing": DefaultSigningOptions,
"SkipContents": True,
}) })
repo_expected = { repo_expected = {
'Architectures': ['i386', 'source'], 'Architectures': ['i386', 'source'],
@@ -268,6 +274,7 @@ class PublishSwitchAPITestRepo(APITest):
'Label': '', 'Label': '',
'Origin': '', 'Origin': '',
'Prefix': prefix, 'Prefix': prefix,
'SkipContents': True,
'SourceKind': 'snapshot', 'SourceKind': 'snapshot',
'Sources': [{'Component': 'main', 'Name': snapshot2_name}], 'Sources': [{'Component': 'main', 'Name': snapshot2_name}],
'Storage': ''} 'Storage': ''}
+1
View File
@@ -21,6 +21,7 @@ type ConfigStructure struct {
DownloadSourcePackages bool `json:"downloadSourcePackages"` DownloadSourcePackages bool `json:"downloadSourcePackages"`
PpaDistributorID string `json:"ppaDistributorID"` PpaDistributorID string `json:"ppaDistributorID"`
PpaCodename string `json:"ppaCodename"` PpaCodename string `json:"ppaCodename"`
SkipContentsPublishing bool `json:"skipContentsPublishing"`
S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints"` S3PublishRoots map[string]S3PublishRoot `json:"S3PublishEndpoints"`
SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"` SwiftPublishRoots map[string]SwiftPublishRoot `json:"SwiftPublishEndpoints"`
} }
+1
View File
@@ -62,6 +62,7 @@ func (s *ConfigSuite) TestSaveConfig(c *C) {
" \"downloadSourcePackages\": false,\n"+ " \"downloadSourcePackages\": false,\n"+
" \"ppaDistributorID\": \"\",\n"+ " \"ppaDistributorID\": \"\",\n"+
" \"ppaCodename\": \"\",\n"+ " \"ppaCodename\": \"\",\n"+
" \"skipContentsPublishing\": false,\n"+
" \"S3PublishEndpoints\": {\n"+ " \"S3PublishEndpoints\": {\n"+
" \"test\": {\n"+ " \"test\": {\n"+
" \"region\": \"us-east-1\",\n"+ " \"region\": \"us-east-1\",\n"+