diff --git a/internal/app/app.go b/internal/app/app.go index 030cbd8..85d0460 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -7,7 +7,7 @@ import ( ) func Run(rootPath string) { - context := ConfigureContext(rootPath) + context := configureContext(rootPath) loginToPiwigoAndConfigureContext(context) @@ -22,22 +22,6 @@ func Run(rootPath string) { authentication.Logout(context.Piwigo) } -func ConfigureContext(rootPath string) *AppContext { - logrus.Infoln("Preparing application context and configuration") - - context := new(AppContext) - context.LocalRootPath = rootPath - context.Piwigo = new(authentication.PiwigoContext) - - //TODO: Move this values to configuration files - //No, these are not real credentials :-P - context.Piwigo.Url = "http://pictures.haefelfinger.net/ws.php?format=json" - context.Piwigo.Username = "admin" - context.Piwigo.Password = "asdf" - - return context -} - func ScanLocalDirectories(context *AppContext) { var fileNodes map[string]localFileStructure.FilesystemNode = localFileStructure.ScanLocalFileStructure(context.LocalRootPath) for _, node := range fileNodes { @@ -67,6 +51,22 @@ func UploadImages() { logrus.Warnln("Uploading missing images (NotImplemented)") } +func configureContext(rootPath string) *AppContext { + logrus.Infoln("Preparing application context and configuration") + + context := new(AppContext) + context.LocalRootPath = rootPath + context.Piwigo = new(authentication.PiwigoContext) + + //TODO: Move this values to configuration files + //No, these are not real credentials :-P + context.Piwigo.Url = "http://pictures.haefelfinger.net/ws.php?format=json" + context.Piwigo.Username = "admin" + context.Piwigo.Password = "asdf" + + return context +} + func loginToPiwigoAndConfigureContext(context *AppContext) { logrus.Infoln("Logging in to piwigo and getting chunk size configuration for uploads") authentication.Login(context.Piwigo) diff --git a/internal/pkg/piwigo/authentication/authentication.go b/internal/pkg/piwigo/authentication/authentication.go index 0475792..4c4c8ba 100644 --- a/internal/pkg/piwigo/authentication/authentication.go +++ b/internal/pkg/piwigo/authentication/authentication.go @@ -14,7 +14,7 @@ func Login(context *PiwigoContext) { logrus.Debugf("Logging in to %s using user %s", context.Url, context.Username) - if !strings.HasPrefix(context.Url,"https") { + if !strings.HasPrefix(context.Url, "https") { logrus.Warnf("The server url %s does not use https! Credentials are not encrypted!", context.Url) }