5 "git.curoverse.com/arvados.git/sdk/go/arvadosclient"
6 "git.curoverse.com/arvados.git/sdk/go/keepclient"
12 // keep-rsync arguments
14 srcConfig map[string]string
15 dstConfig map[string]string
16 srcKeepServicesJSON string
17 dstKeepServicesJSON string
23 var srcConfigFile string
24 var dstConfigFile string
30 "Source configuration filename with full path that contains "+
31 "an ARVADOS_API_TOKEN which is a valid datamanager token recognized by the source keep servers, "+
32 "ARVADOS_API_HOST, ARVADOS_API_HOST_INSECURE, and ARVADOS_BLOB_SIGNING_KEY.")
38 "Destination configuration filename with full path that contains "+
39 "an ARVADOS_API_TOKEN which is a valid datamanager token recognized by the destination keep servers, "+
40 "ARVADOS_API_HOST, ARVADOS_API_HOST_INSECURE, and ARVADOS_BLOB_SIGNING_KEY.")
44 "src-keep-services-json",
46 "An optional list of available source keepservices. "+
47 "If not provided, this list is obtained from api server configured in src-config-file.")
51 "dst-keep-services-json",
53 "An optional list of available destination keepservices. "+
54 "If not provided, this list is obtained from api server configured in dst-config-file.")
60 "Number of replications to write to the destination.")
72 if srcConfigFile == "" {
73 log.Fatal("-src-config-file must be specified.")
75 srcConfig, err = readConfigFromFile(srcConfigFile)
77 log.Fatal("Error reading source configuration: %s", err.Error())
80 if dstConfigFile == "" {
81 log.Fatal("-dst-config-file must be specified.")
83 dstConfig, err = readConfigFromFile(dstConfigFile)
85 log.Fatal("Error reading destination configuration: %s", err.Error())
88 err = initializeKeepRsync()
90 log.Fatal("Error configurating keep-rsync: %s", err.Error())
94 // Reads config from file
95 func readConfigFromFile(filename string) (map[string]string, error) {
96 content, err := ioutil.ReadFile(filename)
101 config := make(map[string]string)
102 lines := strings.Split(string(content), "\n")
103 for _, line := range lines {
107 kv := strings.Split(line, "=")
108 config[kv[0]] = kv[1]
113 // keep-rsync source and destination clients
115 arvSrc arvadosclient.ArvadosClient
116 arvDst arvadosclient.ArvadosClient
117 kcSrc *keepclient.KeepClient
118 kcDst *keepclient.KeepClient
121 // Initializes keep-rsync using the config provided
122 func initializeKeepRsync() (err error) {
123 arvSrc, err = arvadosclient.MakeArvadosClientWithConfig(srcConfig)
128 arvDst, err = arvadosclient.MakeArvadosClientWithConfig(dstConfig)
133 kcSrc, err = keepclient.MakeKeepClient(&arvSrc)
138 kcDst, err = keepclient.MakeKeepClient(&arvDst)