about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-07-02 21:22:55 +0200
committerAlan Pearce2024-07-02 21:22:55 +0200
commitf0d41d1e42a5e24536ff249409f26256e025a797 (patch)
tree162b269d030fefbc59aa1edb566ab6b5240e9272
parent8bb58b0e8d38e949b5cb4a5ec7b04b0f099b71f7 (diff)
downloadwebsite-f0d41d1e42a5e24536ff249409f26256e025a797.tar.lz
website-f0d41d1e42a5e24536ff249409f26256e025a797.tar.zst
website-f0d41d1e42a5e24536ff249409f26256e025a797.zip
warn if VCS configuration not supplied in production
-rw-r--r--internal/server/server.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/internal/server/server.go b/internal/server/server.go
index 8523bc9..ba5effe 100644
--- a/internal/server/server.go
+++ b/internal/server/server.go
@@ -110,20 +110,24 @@ func New(runtimeConfig *Config, log *log.Logger) (*Server, error) {
 		if err != nil {
 			return nil, err
 		}
-		_, err = vcs.CloneOrUpdate(vcsConfig, log.Named("vcs"))
-		if err != nil {
-			return nil, err
-		}
-		err = os.Chdir(runtimeConfig.Root)
-		if err != nil {
-			return nil, err
-		}
+		if vcsConfig.LocalPath != "" {
+			_, err = vcs.CloneOrUpdate(vcsConfig, log.Named("vcs"))
+			if err != nil {
+				return nil, err
+			}
+			err = os.Chdir(runtimeConfig.Root)
+			if err != nil {
+				return nil, err
+			}
 
-		builderConfig.Source = vcsConfig.LocalPath
+			builderConfig.Source = vcsConfig.LocalPath
 
-		publicDir := filepath.Join(runtimeConfig.Root, "public")
-		builderConfig.Destination = publicDir
-		runtimeConfig.Root = publicDir
+			publicDir := filepath.Join(runtimeConfig.Root, "public")
+			builderConfig.Destination = publicDir
+			runtimeConfig.Root = publicDir
+		} else {
+			log.Warn("in production mode without VCS configuration")
+		}
 	}
 
 	config, err := cfg.GetConfig(builderConfig.Source, log.Named("config"))