Skip to content

Commit

Permalink
Remove public_dir config (#632)
Browse files Browse the repository at this point in the history
This config is replaced by package_paths and not needed anymore.
  • Loading branch information
ruflin authored Sep 7, 2020
1 parent 67600a8 commit 509d0db
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Breaking changes

* Rename version to service.version in index handler. [#633](https://github.com/elastic/package-registry/pull/633)
* Remove config `public_dir` which is replaced by `package_paths`. [#632](https://github.com/elastic/package-registry/pull/632)

### Bugfixes

Expand Down
2 changes: 0 additions & 2 deletions config.docker.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
public_dir: ./public

# If users want to add their own packages, they should be put under
# /packages/package-registry or the config must be adjusted.
package_paths:
Expand Down
18 changes: 1 addition & 17 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,13 @@ var (
// GoLicenserImportPath controls the import path used to install go-licenser.
GoLicenserImportPath = "github.com/elastic/go-licenser"

publicDir = "./public"
buildDir = "./build"
storageRepoDir = filepath.Join(buildDir, "package-storage")
packagePaths = []string{filepath.Join(storageRepoDir, "packages"), "./testdata/package/"}
)

func Build() error {
err := os.RemoveAll(publicDir)
if err != nil {
return err
}

err = os.MkdirAll(publicDir, 0755)
if err != nil {
return err
}

err = FetchPackageStorage()
err := FetchPackageStorage()
if err != nil {
return err
}
Expand Down Expand Up @@ -103,7 +92,6 @@ func Check() error {
Format()

// Setup the variables for the tests and not create tarGz files
publicDir = "./testdata/public"
packagePaths = []string{"testdata/package"}

err := Build()
Expand Down Expand Up @@ -211,10 +199,6 @@ func Clean() error {
return err
}

err = os.RemoveAll(publicDir)
if err != nil {
return err
}
return os.RemoveAll("package-registry")
}

Expand Down
7 changes: 0 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"net/http"
"os"
"os/signal"
"path/filepath"
"strings"
"syscall"
"time"
Expand All @@ -38,7 +37,6 @@ var (
configPath = "config.yml"

defaultConfig = Config{
PublicDir: "./public", // left for legacy purposes
CacheTimeIndex: 10 * time.Second,
CacheTimeSearch: 10 * time.Minute,
CacheTimeCategories: 10 * time.Minute,
Expand All @@ -53,7 +51,6 @@ func init() {
}

type Config struct {
PublicDir string `config:"public_dir"` // left for legacy purposes
PackagePaths []string `config:"package_paths"`
CacheTimeIndex time.Duration `config:"cache_time.index"`
CacheTimeSearch time.Duration `config:"cache_time.search"`
Expand Down Expand Up @@ -124,15 +121,11 @@ func getConfig() (*Config, error) {

func getPackagesBasePaths(config *Config) []string {
var paths []string
if config.PublicDir != "" {
paths = append(paths, filepath.Join(config.PublicDir, packageDir)) // left for legacy purposes
}
paths = append(paths, config.PackagePaths...)
return paths
}

func printConfig(config *Config) {
log.Printf("Public dir (legacy): %s\n", config.PublicDir)
log.Printf("Packages paths: %s\n", strings.Join(config.PackagePaths, ", "))
log.Println("Cache time for /search: ", config.CacheTimeSearch)
log.Println("Cache time for /categories: ", config.CacheTimeCategories)
Expand Down

0 comments on commit 509d0db

Please sign in to comment.