2013-12-28 23:03:58 +00:00
/ *
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
Copyright 2013 The Perkeep Authors .
2013-12-28 23:03:58 +00:00
Licensed under the Apache License , Version 2.0 ( the "License" ) ;
you may not use this file except in compliance with the License .
You may obtain a copy of the License at
http : //www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing , software
distributed under the License is distributed on an "AS IS" BASIS ,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND , either express or implied .
See the License for the specific language governing permissions and
limitations under the License .
* /
package main
import (
"flag"
"fmt"
"os"
2014-01-08 03:21:24 +00:00
"strconv"
2013-12-28 23:03:58 +00:00
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
"perkeep.org/pkg/client"
"perkeep.org/pkg/cmdmain"
2013-12-28 23:03:58 +00:00
)
type indexCmd struct {
2014-01-08 03:21:24 +00:00
wipe bool
insecureTLS bool
2013-12-28 23:03:58 +00:00
}
func init ( ) {
2018-03-06 21:39:14 +00:00
cmdmain . RegisterMode ( "index" , func ( flags * flag . FlagSet ) cmdmain . CommandRunner {
2013-12-28 23:03:58 +00:00
cmd := new ( indexCmd )
flags . BoolVar ( & cmd . wipe , "wipe" , false , "Erase and recreate all discovered indexes. NOOP for now." )
2014-01-08 03:21:24 +00:00
if debug , _ := strconv . ParseBool ( os . Getenv ( "CAMLI_DEBUG" ) ) ; debug {
flags . BoolVar ( & cmd . insecureTLS , "insecure" , false , "If set, when using TLS, the server's certificates verification is disabled, and they are not checked against the trustedCerts in the client configuration either." )
}
2013-12-28 23:03:58 +00:00
return cmd
} )
}
func ( c * indexCmd ) Describe ( ) string {
return "Synchronize blobs for all discovered blobs storage - indexer pairs."
}
func ( c * indexCmd ) Usage ( ) {
2018-03-05 23:07:54 +00:00
fmt . Fprintf ( os . Stderr , "Usage: pk [globalopts] index [indexopts] \n" )
2013-12-28 23:03:58 +00:00
}
func ( c * indexCmd ) RunCommand ( args [ ] string ) error {
dc := c . discoClient ( )
syncHandlers , err := dc . SyncHandlers ( )
if err != nil {
return fmt . Errorf ( "sync handlers discovery failed: %v" , err )
}
for _ , sh := range syncHandlers {
if sh . ToIndex {
if err := c . sync ( sh . From , sh . To ) ; err != nil {
return fmt . Errorf ( "Error while indexing from %v to %v: %v" , sh . From , sh . To , err )
}
}
}
return nil
}
func ( c * indexCmd ) sync ( from , to string ) error {
return ( & syncCmd {
2016-11-17 23:01:43 +00:00
src : from ,
dest : to ,
wipe : c . wipe ,
2013-12-28 23:03:58 +00:00
} ) . RunCommand ( nil )
}
// discoClient returns a client initialized with a server
// based from the configuration file. The returned client
// can then be used to discover the blobRoot and syncHandlers.
func ( c * indexCmd ) discoClient ( ) * client . Client {
2014-02-09 23:48:07 +00:00
return newClient ( "" )
2013-12-28 23:03:58 +00:00
}