all repos — website @ f0d41d1e42a5e24536ff249409f26256e025a797

My website

warn if VCS configuration not supplied in production
Alan Pearce alan@alanpearce.eu
Tue, 02 Jul 2024 21:22:55 +0200
commit

f0d41d1e42a5e24536ff249409f26256e025a797

parent

8bb58b0e8d38e949b5cb4a5ec7b04b0f099b71f7

1 files changed, 16 insertions(+), 12 deletions(-)

jump to
M internal/server/server.gointernal/server/server.go
@@ -110,20 +110,24 @@ _, err := conf.Parse("VCS", vcsConfig) 		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"))