mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-08 22:30:41 +00:00
Separate out LocalPublishedStorage interface. #15
This commit is contained in:
+6
-2
@@ -25,8 +25,6 @@ type PackagePool interface {
|
|||||||
|
|
||||||
// PublishedStorage is abstraction of filesystem storing all published repositories
|
// PublishedStorage is abstraction of filesystem storing all published repositories
|
||||||
type PublishedStorage interface {
|
type PublishedStorage interface {
|
||||||
// XXX: REMOVE: PublicPath returns root of public part
|
|
||||||
PublicPath() string
|
|
||||||
// MkDir creates directory recursively under public path
|
// MkDir creates directory recursively under public path
|
||||||
MkDir(path string) error
|
MkDir(path string) error
|
||||||
// PutFile puts file into published storage at specified path
|
// PutFile puts file into published storage at specified path
|
||||||
@@ -43,6 +41,12 @@ type PublishedStorage interface {
|
|||||||
RenameFile(oldName, newName string) error
|
RenameFile(oldName, newName string) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// LocalPublishedStorage is published storage on local filesystem
|
||||||
|
type LocalPublishedStorage interface {
|
||||||
|
// PublicPath returns root of public part
|
||||||
|
PublicPath() string
|
||||||
|
}
|
||||||
|
|
||||||
// Progress is a progress displaying entity, it allows progress bars & simple prints
|
// Progress is a progress displaying entity, it allows progress bars & simple prints
|
||||||
type Progress interface {
|
type Progress interface {
|
||||||
// Writer interface to support progress bar ticking
|
// Writer interface to support progress bar ticking
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/smira/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/smira/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/smira/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
@@ -146,8 +147,13 @@ func aptlyPublishSnapshotOrRepo(cmd *commander.Command, args []string) error {
|
|||||||
prefix += "/"
|
prefix += "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Progress().Printf("\n%s been successfully published.\nPlease setup your webserver to serve directory '%s' with autoindexing.\n",
|
context.Progress().Printf("\n%s been successfully published.\n", message)
|
||||||
message, context.PublishedStorage().PublicPath())
|
|
||||||
|
if localStorage, ok := context.PublishedStorage().(aptly.LocalPublishedStorage); ok {
|
||||||
|
context.Progress().Printf("Please setup your webserver to serve directory '%s' with autoindexing.\n",
|
||||||
|
localStorage.PublicPath())
|
||||||
|
}
|
||||||
|
|
||||||
context.Progress().Printf("Now you can add following line to apt sources:\n")
|
context.Progress().Printf("Now you can add following line to apt sources:\n")
|
||||||
context.Progress().Printf(" deb http://your-server/%s %s %s\n", prefix, distribution, repoComponents)
|
context.Progress().Printf(" deb http://your-server/%s %s %s\n", prefix, distribution, repoComponents)
|
||||||
if utils.StrSliceHasItem(published.Architectures, "source") {
|
if utils.StrSliceHasItem(published.Architectures, "source") {
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/smira/aptly/aptly"
|
||||||
"github.com/smira/aptly/deb"
|
"github.com/smira/aptly/deb"
|
||||||
"github.com/smira/aptly/utils"
|
"github.com/smira/aptly/utils"
|
||||||
"github.com/smira/commander"
|
"github.com/smira/commander"
|
||||||
@@ -83,7 +84,7 @@ func aptlyServe(cmd *commander.Command, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
publicPath := context.PublishedStorage().PublicPath()
|
publicPath := context.PublishedStorage().(aptly.LocalPublishedStorage).PublicPath()
|
||||||
ShutdownContext()
|
ShutdownContext()
|
||||||
|
|
||||||
fmt.Printf("\nStarting web server at: %s (press Ctrl+C to quit)...\n", listen)
|
fmt.Printf("\nStarting web server at: %s (press Ctrl+C to quit)...\n", listen)
|
||||||
|
|||||||
+2
-2
@@ -50,7 +50,7 @@ type PublishedRepoSuite struct {
|
|||||||
PackageListMixinSuite
|
PackageListMixinSuite
|
||||||
repo, repo2, repo3, repo4 *PublishedRepo
|
repo, repo2, repo3, repo4 *PublishedRepo
|
||||||
root string
|
root string
|
||||||
publishedStorage aptly.PublishedStorage
|
publishedStorage *files.PublishedStorage
|
||||||
packagePool aptly.PackagePool
|
packagePool aptly.PackagePool
|
||||||
localRepo *LocalRepo
|
localRepo *LocalRepo
|
||||||
snapshot, snapshot2 *Snapshot
|
snapshot, snapshot2 *Snapshot
|
||||||
@@ -560,7 +560,7 @@ type PublishedRepoRemoveSuite struct {
|
|||||||
snapshotCollection *SnapshotCollection
|
snapshotCollection *SnapshotCollection
|
||||||
collection *PublishedRepoCollection
|
collection *PublishedRepoCollection
|
||||||
root string
|
root string
|
||||||
publishedStorage aptly.PublishedStorage
|
publishedStorage *files.PublishedStorage
|
||||||
snap1 *Snapshot
|
snap1 *Snapshot
|
||||||
repo1, repo2, repo3, repo4 *PublishedRepo
|
repo1, repo2, repo3, repo4 *PublishedRepo
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -14,9 +14,10 @@ type PublishedStorage struct {
|
|||||||
rootPath string
|
rootPath string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check interface
|
// Check interfaces
|
||||||
var (
|
var (
|
||||||
_ aptly.PublishedStorage = (*PublishedStorage)(nil)
|
_ aptly.PublishedStorage = (*PublishedStorage)(nil)
|
||||||
|
_ aptly.LocalPublishedStorage = (*PublishedStorage)(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPublishedStorage creates new instance of PublishedStorage which specified root
|
// NewPublishedStorage creates new instance of PublishedStorage which specified root
|
||||||
|
|||||||
@@ -51,11 +51,6 @@ func NewPublishedStorage(accessKey, secretKey, region, bucket, defaultACL, prefi
|
|||||||
return NewPublishedStorageRaw(auth, awsRegion, bucket, defaultACL, prefix)
|
return NewPublishedStorageRaw(auth, awsRegion, bucket, defaultACL, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// PublicPath returns root of public part
|
|
||||||
func (storage *PublishedStorage) PublicPath() string {
|
|
||||||
panic("never would be implemented")
|
|
||||||
}
|
|
||||||
|
|
||||||
// MkDir creates directory recursively under public path
|
// MkDir creates directory recursively under public path
|
||||||
func (storage *PublishedStorage) MkDir(path string) error {
|
func (storage *PublishedStorage) MkDir(path string) error {
|
||||||
// no op for S3
|
// no op for S3
|
||||||
|
|||||||
Reference in New Issue
Block a user