Backend: Refactor config initialization

Signed-off-by: Michael Mayer <michael@lastzero.net>
This commit is contained in:
Michael Mayer 2020-10-08 08:52:03 +02:00
parent 27dff245a5
commit 5fa47652ee
24 changed files with 130 additions and 113 deletions

View file

@ -51,6 +51,8 @@ stop:
go run cmd/photoprism/photoprism.go stop
terminal:
docker-compose exec photoprism bash
root-terminal:
docker-compose exec -u root photoprism bash
migrate:
go run cmd/photoprism/photoprism.go migrate
generate:

16
go.mod
View file

@ -2,7 +2,7 @@ module github.com/photoprism/photoprism
require (
github.com/allegro/bigcache v1.2.1
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1
github.com/araddon/dateparse v0.0.0-20201001162425-8aadafed4dc4
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/disintegration/imaging v1.6.2
github.com/djherbis/times v1.2.0
@ -35,8 +35,8 @@ require (
github.com/lib/pq v1.3.0 // indirect
github.com/lucasb-eyer/go-colorful v1.0.3
github.com/lunixbochs/vtclean v1.0.0 // indirect
github.com/manifoldco/promptui v0.7.0
github.com/mattn/go-colorable v0.1.7 // indirect
github.com/manifoldco/promptui v0.8.0
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-sqlite3 v2.0.1+incompatible // indirect
github.com/melihmucuk/geocache v0.0.0-20160621165317-521b336a001c
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
@ -46,17 +46,17 @@ require (
github.com/satori/go.uuid v1.2.0
github.com/sevlyar/go-daemon v0.1.5
github.com/shopspring/decimal v1.2.0 // indirect
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.7.0
github.com/stretchr/testify v1.6.1
github.com/studio-b12/gowebdav v0.0.0-20200303150724-9380631c29a1
github.com/studio-b12/gowebdav v0.0.0-20200929080739-bdacfab94796
github.com/tensorflow/tensorflow v1.15.2
github.com/tidwall/gjson v1.6.1
github.com/ulule/deepcopier v0.0.0-20200430083143-45decc6639b6
github.com/urfave/cli v1.22.4
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
golang.org/x/image v0.0.0-20200618115811-c13761719519 // indirect
golang.org/x/net v0.0.0-20200904194848-62affa334b73
golang.org/x/sys v0.0.0-20200819035508-9a32b3aa38f5 // indirect
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0
golang.org/x/sys v0.0.0-20201008063127-280f808b4a53 // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/ugjka/go-tz.v2 v2.0.10
gopkg.in/yaml.v2 v2.3.0

43
go.sum
View file

@ -22,8 +22,8 @@ github.com/PuerkitoBio/goquery v1.5.1/go.mod h1:GsLWisAFVj4WgDibEWF4pvYnkVQBpKBK
github.com/allegro/bigcache v1.2.1 h1:hg1sY1raCwic3Vnsvje6TT7/pnZba83LeFck5NrFKSc=
github.com/allegro/bigcache v1.2.1/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM=
github.com/andybalholm/cascadia v1.1.0/go.mod h1:GsXiBklL0woXo1j/WYWtSYYC4ouU9PqHO0sqidkEA4Y=
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1 h1:TEBmxO80TM04L8IuMWk77SGL1HomBmKTdzdJLLWznxI=
github.com/araddon/dateparse v0.0.0-20200409225146-d820a6159ab1/go.mod h1:SLqhdZcd+dF3TEVL2RMoob5bBP5R1P1qkox+HtCBgGI=
github.com/araddon/dateparse v0.0.0-20201001162425-8aadafed4dc4 h1:OkS1BqB3CzLtGRznRyvriSY8jeaVk2CrDn2ZiRQgMUI=
github.com/araddon/dateparse v0.0.0-20201001162425-8aadafed4dc4/go.mod h1:hMAUZFIkk4B1FouGxqlogyMyU6BwY/UiVmmbbzz9Up8=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/chzyer/logex v1.1.10 h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
@ -156,8 +156,6 @@ github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/open-location-code/go v0.0.0-20200805234123-bf1466f508dc h1:5o8mwzXVSBcozZ0Ry1Twel6LWli2q4NIa/QfxmaClqA=
github.com/google/open-location-code/go v0.0.0-20200805234123-bf1466f508dc/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk=
github.com/google/open-location-code/go v0.0.0-20200910235652-4c861c2fa9dc h1:RH376QjUXMELdfjjt2M0UBH9YFS7qlcL1EH+Y0ZapOQ=
github.com/google/open-location-code/go v0.0.0-20200910235652-4c861c2fa9dc/go.mod h1:eJfRN6aj+kR/rnua/rw9jAgYhqoMHldQkdTi+sePRKk=
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
@ -195,8 +193,6 @@ github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0/go.mod h1:1NbS8ALr
github.com/karrick/godirwalk v1.16.1 h1:DynhcF+bztK8gooS0+NDJFrdNZjJ3gzVzC545UNA9iw=
github.com/karrick/godirwalk v1.16.1/go.mod h1:j4mkqPuvaLI8mp1DroR3P6ad7cyYd4c1qeJ3RV7ULlk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.3 h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@ -218,16 +214,17 @@ github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQN
github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
github.com/machinebox/progress v0.2.0/go.mod h1:hl4FywxSjfmkmCrersGhmJH7KwuKl+Ueq9BXkOny+iE=
github.com/manifoldco/promptui v0.7.0 h1:3l11YT8tm9MnwGFQ4kETwkzpAwY2Jt9lCrumCUW4+z4=
github.com/manifoldco/promptui v0.7.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ=
github.com/manifoldco/promptui v0.8.0 h1:R95mMF+McvXZQ7j1g8ucVZE1gLP3Sv6j9vlF9kyRqQo=
github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEXGwov2nIKuGQ=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.7 h1:bQGKb3vps/j0E9GfJQ03JyhRuxsvdAanXlT9BTw3mdw=
github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-sqlite3 v1.14.0/go.mod h1:JIl7NbARA7phWnGvh0LKTyg7S9BA+6gx71ShQilpsus=
github.com/mattn/go-sqlite3 v2.0.1+incompatible h1:xQ15muvnzGBHpIpdrNi1DA5x0+TcBZzsIDwmw9uTHzw=
github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
@ -255,14 +252,15 @@ github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd h1:CmH9+J6ZSsIjUK
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd/go.mod h1:hPqNNc0+uJM6H+SuU8sEs5K5IQeKccPqeSjfgcKGgPk=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/scylladb/termtables v0.0.0-20191203121021-c4c0b6d42ff4/go.mod h1:C1a7PQSMz9NShzorzCiG2fk9+xuCgLkPeCvMHYR2OWg=
github.com/sevlyar/go-daemon v0.1.5 h1:Zy/6jLbM8CfqJ4x4RPr7MJlSKt90f00kNM1D401C+Qk=
github.com/sevlyar/go-daemon v0.1.5/go.mod h1:6dJpPatBT9eUwM5VCw9Bt6CdX9Tk6UWvhW3MebLDRKE=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.6.0 h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
@ -273,8 +271,8 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/studio-b12/gowebdav v0.0.0-20200303150724-9380631c29a1 h1:TPyHV/OgChqNcnYqCoCvIFjR9TU60gFXXBKnhOBzVEI=
github.com/studio-b12/gowebdav v0.0.0-20200303150724-9380631c29a1/go.mod h1:gCcfDlA1Y7GqOaeEKw5l9dOGx1VLdc/HuQSlQAaZ30s=
github.com/studio-b12/gowebdav v0.0.0-20200929080739-bdacfab94796 h1:vkok9HUaplVRvHgwuyEGxBhdGtOUdMr7/KprS+6k8TQ=
github.com/studio-b12/gowebdav v0.0.0-20200929080739-bdacfab94796/go.mod h1:gCcfDlA1Y7GqOaeEKw5l9dOGx1VLdc/HuQSlQAaZ30s=
github.com/tensorflow/tensorflow v1.15.2 h1:7/f/A664Tml/nRJg04+p3StcrsT53mkcvmxYHXI21Qo=
github.com/tensorflow/tensorflow v1.15.2/go.mod h1:itOSERT4trABok4UOoG+X4BoKds9F3rIsySdn+Lvu90=
github.com/tidwall/gjson v1.6.1 h1:LRbvNuNuvAiISWg6gxLEFuCe72UKy5hDqhxW/8183ws=
@ -305,8 +303,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 h1:hb9wdF1z5waM+dSIICn1l0DkLVDT3hqhhQsDNUmHPRE=
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@ -360,8 +358,8 @@ golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200513185701-a91f0712d120 h1:EZ3cVSzKOlJxAd8e8YAJ7no8nNypTxexh/YE/xW3ZEY=
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0 h1:wBouT66WTYFXdxfVdz9sVWARVd/2vfGcmI45D2gj45M=
golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
@ -378,12 +376,12 @@ golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
@ -391,14 +389,17 @@ golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200819035508-9a32b3aa38f5 h1:2r6BWB+sWBIRVv2mC6sYNpdbplZte/1k1drwUKUpS60=
golang.org/x/sys v0.0.0-20200819035508-9a32b3aa38f5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201008063127-280f808b4a53 h1:oY/NCLjoZph2rq+dNr2Xv5Qz2o8r1igXkvcGvz3EDsg=
golang.org/x/sys v0.0.0-20201008063127-280f808b4a53/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=

View file

@ -78,7 +78,6 @@ func configAction(ctx *cli.Context) error {
fmt.Printf("%-25s %s\n", "build-path", conf.BuildPath())
fmt.Printf("%-25s %s\n", "img-path", conf.ImgPath())
fmt.Printf("%-25s %s\n", "templates-path", conf.TemplatesPath())
fmt.Printf("%-25s %s\n", "template-name", conf.TemplateName())
fmt.Printf("%-25s %s\n", "cache-path", conf.CachePath())
fmt.Printf("%-25s %s\n", "temp-path", conf.TempPath())
fmt.Printf("%-25s %s\n", "config-file", conf.ConfigFile())

View file

@ -1,6 +1,7 @@
package commands
import (
"context"
"time"
"github.com/photoprism/photoprism/internal/config"
@ -26,11 +27,14 @@ func convertAction(ctx *cli.Context) error {
return config.ErrReadOnly
}
if err := conf.CreateDirectories(); err != nil {
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(); err != nil {
return err
}
log.Infof("converting RAW images in %s to JPEG", conf.OriginalsPath())
log.Infof("creating JPEGs for other files types in %s", conf.OriginalsPath())
convert := service.Convert()
@ -40,7 +44,7 @@ func convertAction(ctx *cli.Context) error {
elapsed := time.Since(start)
log.Infof("image conversion completed in %s", elapsed)
log.Infof("converting to JPEG completed in %s", elapsed)
return nil
}

View file

@ -33,13 +33,10 @@ func copyAction(ctx *cli.Context) error {
return config.ErrReadOnly
}
if err := conf.CreateDirectories(); err != nil {
return err
}
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -33,13 +33,10 @@ func importAction(ctx *cli.Context) error {
return config.ErrReadOnly
}
if err := conf.CreateDirectories(); err != nil {
return err
}
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -35,13 +35,10 @@ func indexAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
service.SetConfig(conf)
if err := conf.CreateDirectories(); err != nil {
return err
}
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -20,9 +20,11 @@ func migrateAction(ctx *cli.Context) error {
start := time.Now()
conf := config.NewConfig(ctx)
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -23,9 +23,10 @@ func momentsAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
service.SetConfig(conf)
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -27,9 +27,10 @@ var PasswdCommand = cli.Command{
func passwdAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -40,9 +40,10 @@ func purgeAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
service.SetConfig(conf)
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -30,7 +30,7 @@ func resampleAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
service.SetConfig(conf)
if err := conf.CreateDirectories(); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -39,9 +39,10 @@ func resetAction(ctx *cli.Context) error {
start := time.Now()
conf := config.NewConfig(ctx)
cctx, cancel := context.WithCancel(context.Background())
_, cancel := context.WithCancel(context.Background())
defer cancel()
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
return err
}

View file

@ -45,10 +45,6 @@ func startAction(ctx *cli.Context) error {
conf := config.NewConfig(ctx)
service.SetConfig(conf)
if err := conf.CreateDirectories(); err != nil {
return err
}
if ctx.IsSet("config") {
fmt.Printf("NAME VALUE\n")
fmt.Printf("detach-server %t\n", conf.DetachServer())
@ -60,18 +56,14 @@ func startAction(ctx *cli.Context) error {
return nil
}
// pass this context down the chain
cctx, cancel := context.WithCancel(context.Background())
if conf.HttpServerPort() < 1 || conf.HttpServerPort() > 65535 {
log.Fatal("server port must be a number between 1 and 65535")
}
if err := conf.CreateDirectories(); err != nil {
log.Fatal(err)
}
// pass this context down the chain
cctx, cancel := context.WithCancel(context.Background())
if err := conf.Init(cctx); err != nil {
if err := conf.Init(); err != nil {
log.Fatal(err)
}

View file

@ -43,11 +43,13 @@ func statusAction(ctx *cli.Context) error {
status = string(body)
}
fmt.Println(status)
message := gjson.Get(status, "status").String()
message := gjson.Get(status, "status")
fmt.Printf("status %s\n", message.String())
if message != "" {
fmt.Println(message)
} else {
fmt.Println("unknown")
}
return nil
}

View file

@ -1,7 +1,6 @@
package config
import (
"context"
"fmt"
"runtime"
"strings"
@ -70,9 +69,6 @@ func NewConfig(ctx *cli.Context) *Config {
token: rnd.Token(8),
}
c.initSettings()
c.initPro()
return c
}
@ -90,9 +86,17 @@ func (c *Config) Propagate() {
c.Pro().Propagate()
}
// Init initialises the database connection and dependencies.
func (c *Config) Init(_ context.Context) error {
// Init creates directories, parses additional config files, opens a database connection and initializes dependencies.
func (c *Config) Init() error {
if err := c.CreateDirectories(); err != nil {
return err
}
c.initSettings()
c.initPro()
c.Propagate()
return c.connectDb()
}
@ -269,27 +273,27 @@ func (c *Config) OriginalsLimit() int64 {
return c.params.OriginalsLimit * 1024 * 1024
}
// UpdatePro updates photoprism.pro api credentials.
// UpdatePro updates photoprism.pro api credentials for maps & places.
func (c *Config) UpdatePro() {
if err := c.pro.Refresh(); err != nil {
log.Debugf("pro: %s", err)
log.Debugf("config: %s", err)
} else if err := c.pro.Save(); err != nil {
log.Debugf("pro: %s", err)
log.Debugf("config: %s", err)
} else {
c.pro.Propagate()
}
}
// initPro initializes photoprism.pro api credentials.
// initPro initializes photoprism.pro api credentials for maps & places.
func (c *Config) initPro() {
c.pro = pro.NewConfig(c.Version(), c.ProConfigFile())
if err := c.pro.Load(); err == nil {
// Do nothing.
} else if err := c.pro.Refresh(); err != nil {
log.Debugf("pro: %s", err)
log.Debugf("config: %s", err)
} else if err := c.pro.Save(); err != nil {
log.Debugf("pro: %s", err)
log.Debugf("config: %s", err)
}
c.pro.Propagate()
@ -308,5 +312,9 @@ func (c *Config) initPro() {
// Config returns the photoprism.pro api credentials.
func (c *Config) Pro() *pro.Config {
if c.pro == nil {
c.initPro()
}
return c.pro
}

View file

@ -59,8 +59,10 @@ func (c *Config) TemplateExists(name string) bool {
// TemplateName returns the name of the default template (e.g. index.tmpl).
func (c *Config) TemplateName() string {
if c.TemplateExists(c.Settings().Templates.Default) {
return c.Settings().Templates.Default
if s := c.Settings(); s != nil {
if c.TemplateExists(s.Templates.Default) {
return s.Templates.Default
}
}
return "index.tmpl"

View file

@ -33,6 +33,7 @@ func TestConfig_HttpServerMode2(t *testing.T) {
func TestConfig_TemplateName(t *testing.T) {
c := NewConfig(CliTestContext())
c.initSettings()
assert.Equal(t, "index.tmpl", c.TemplateName())
c.settings.Templates.Default = "rainbow.tmpl"

View file

@ -172,5 +172,9 @@ func (c *Config) initSettings() {
// Settings returns the current user settings.
func (c *Config) Settings() *Settings {
if c.settings == nil {
c.initSettings()
}
return c.settings
}

View file

@ -1,7 +1,6 @@
package config
import (
"context"
"flag"
"os"
"path/filepath"
@ -129,10 +128,7 @@ func NewTestConfig() *Config {
log.Fatalf("config: %s", err.Error())
}
c.initSettings()
c.initPro()
if err := c.Init(context.Background()); err != nil {
if err := c.Init(); err != nil {
log.Fatalf("config: %s", err.Error())
}
@ -150,10 +146,7 @@ func NewTestConfig() *Config {
func NewTestErrorConfig() *Config {
c := &Config{params: NewTestParamsError()}
c.initSettings()
c.initPro()
if err := c.Init(context.Background()); err != nil {
if err := c.Init(); err != nil {
log.Fatalf("config: %s", err.Error())
}

View file

@ -135,9 +135,9 @@ func (c *Config) Refresh() (err error) {
if c.Key != "" {
url = fmt.Sprintf(ApiURL+"/%s", c.Key)
method = http.MethodPut
log.Debugf("pro: updating api key for maps & places")
log.Debugf("getting updated api key for maps & places from %s", ApiHost())
} else {
log.Debugf("pro: requesting api key for maps & places")
log.Debugf("requesting api key for maps & places from %s", ApiHost())
}
if j, err := json.Marshal(NewRequest(c.Version)); err != nil {
@ -159,17 +159,15 @@ func (c *Config) Refresh() (err error) {
}
if err != nil {
log.Errorf("pro: %s", err.Error())
return err
} else if r.StatusCode >= 400 {
err = fmt.Errorf("api key request for maps & places failed with code %d", r.StatusCode)
err = fmt.Errorf("getting api key from %s failed (error %d)", ApiHost(), r.StatusCode)
return err
}
err = json.NewDecoder(r.Body).Decode(c)
if err != nil {
log.Errorf("pro: %s", err.Error())
return err
}
@ -179,7 +177,7 @@ func (c *Config) Refresh() (err error) {
// Load photoprism.pro api credentials from a YAML file.
func (c *Config) Load() error {
if !fs.FileExists(c.FileName) {
return fmt.Errorf("api key file not found: %s", txt.Quote(c.FileName))
return fmt.Errorf("settings file not found: %s", txt.Quote(c.FileName))
}
mutex.Lock()

View file

@ -4,11 +4,12 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/photoprism/photoprism/internal/form"
"github.com/photoprism/photoprism/pkg/txt"
"net/http"
"runtime"
"time"
"github.com/photoprism/photoprism/internal/form"
"github.com/photoprism/photoprism/pkg/txt"
)
var FeedbackURL = ApiURL + "/%s/feedback"
@ -52,7 +53,7 @@ func (c *Config) SendFeedback(f form.Feedback) (err error) {
method := http.MethodPost
var req *http.Request
log.Debugf("pro: sending feedback")
log.Debugf("sending feedback to %s", ApiHost())
if j, err := json.Marshal(feedback); err != nil {
return err
@ -74,17 +75,15 @@ func (c *Config) SendFeedback(f form.Feedback) (err error) {
}
if err != nil {
log.Errorf("pro: %s", err.Error())
return err
} else if r.StatusCode >= 400 {
err = fmt.Errorf("sending feedback failed with code %d", r.StatusCode)
err = fmt.Errorf("sending feedback to %s failed (error %d)", ApiHost(), r.StatusCode)
return err
}
err = json.NewDecoder(r.Body).Decode(c)
if err != nil {
log.Errorf("pro: %s", err.Error())
return err
}

View file

@ -1,6 +1,9 @@
package pro
import "runtime"
import (
"net/url"
"runtime"
)
var ApiURL = "https://api-int.photoprism.pro/v1/hello"
@ -21,3 +24,15 @@ func NewRequest(version string) *Request {
ClientCPU: runtime.NumCPU(),
}
}
// ApiHost returns the full API URL host name.
func ApiHost() string {
u, err := url.Parse(ApiURL)
if err != nil {
log.Warn(err)
return ""
}
return u.Host
}