From 0367de7b614417546c038a23328ac7856ea5b703 Mon Sep 17 00:00:00 2001 From: mpl Date: Mon, 22 Aug 2016 19:41:37 +0200 Subject: [PATCH] publisher: restore SourceRoot configurability This change allows the publisher to use resources from a SourceRoot directory, without having to rebuild the publisher binary, instead of only using embedded resources. Change-Id: Ife29e3015b8595a33f175a62d98fcf5ffa689134 --- app/publisher/main.go | 5 ++--- pkg/serverinit/genconfig.go | 3 +++ pkg/types/serverconfig/config.go | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/app/publisher/main.go b/app/publisher/main.go index 969f3cad3..ae795e5f6 100644 --- a/app/publisher/main.go +++ b/app/publisher/main.go @@ -142,13 +142,12 @@ func newPublishHandler(conf *config) *publishHandler { } var CSSFiles, JSDeps []string if conf.SourceRoot != "" { - appRoot := filepath.Join(conf.SourceRoot, "app", "publisher") Files = &fileembed.Files{ - DirFallback: appRoot, + DirFallback: conf.SourceRoot, } // TODO(mpl): Can I readdir by listing with "/" on Files, even with DirFallBack? // Apparently not, but retry later. - dir, err := os.Open(appRoot) + dir, err := os.Open(conf.SourceRoot) if err != nil { logger.Fatal(err) } diff --git a/pkg/serverinit/genconfig.go b/pkg/serverinit/genconfig.go index 7a23a8763..dc7539507 100644 --- a/pkg/serverinit/genconfig.go +++ b/pkg/serverinit/genconfig.go @@ -152,6 +152,9 @@ func (b *lowBuilder) addPublishedConfig(tlsO *tlsOpts) error { "cacheRoot": v.CacheRoot, "goTemplate": v.GoTemplate, } + if v.SourceRoot != "" { + appConfig["sourceRoot"] = v.SourceRoot + } if v.HTTPSCert != "" && v.HTTPSKey != "" { // user can specify these directly in the publish section appConfig["httpsCert"] = v.HTTPSCert diff --git a/pkg/types/serverconfig/config.go b/pkg/types/serverconfig/config.go index 1d0af3334..a3d6d933a 100644 --- a/pkg/types/serverconfig/config.go +++ b/pkg/types/serverconfig/config.go @@ -134,6 +134,12 @@ type Publish struct { // caching blobserver (for images). No caching if empty. // An example value is Config.BlobPath + "/cache". CacheRoot string `json:"cacheRoot,omitempty"` + + // SourceRoot optionally defines the directory where to look for some resources + // such as HTML templates, as well as javascript, and CSS files. The + // default is to use the resources embedded in the publisher binary, found + // in the publisher app source directory. + SourceRoot string `json:"sourceRoot,omitempty"` } // invertedBool is a bool that marshals to and from JSON with the opposite of its in-memory value.