in reverse_replication/reverse-replication-runner.go [117:194]
func prechecks() error {
if projectId == "" {
return fmt.Errorf("please specify a valid projectId")
}
if dataflowRegion == "" {
return fmt.Errorf("please specify a valid dataflowRegion")
}
if jobNamePrefix == "" {
return fmt.Errorf("please specify a non-empty jobNamePrefix")
} else {
// Capital letters not allowed in Dataflow job names.
jobNamePrefix = strings.ToLower(jobNamePrefix)
}
if gcsPath == "" {
return fmt.Errorf("please specify a non-empty gcsPath")
} else if !strings.HasPrefix(gcsPath, "gs://") {
return fmt.Errorf("please specify a valid GCS path for gcsPath, like gs://<>")
}
if changeStreamName == "" {
return fmt.Errorf("please specify a valid changeStreamName")
} else {
changeStreamName = strings.ReplaceAll(changeStreamName, "-", "_")
}
if instanceId == "" {
return fmt.Errorf("please specify a valid instanceId")
}
if dbName == "" {
return fmt.Errorf("please specify a valid dbName")
}
if metadataInstance == "" {
metadataInstance = instanceId
fmt.Println("metadataInstance not provided, defaulting to target spanner instance id: ", metadataInstance)
}
if metadataDatabase == "" {
metadataDatabase = "rev_repl_metadata"
fmt.Println("metadataDatabase not provided, defaulting to: ", metadataDatabase)
}
if sourceShardsFilePath == "" {
return fmt.Errorf("please specify a valid sourceShardsFilePath")
} else if !strings.HasPrefix(sourceShardsFilePath, "gs://") {
return fmt.Errorf("please specify a valid GCS path for sourceShardsFilePath, like gs://<>")
}
if sessionFilePath == "" {
return fmt.Errorf("please specify a valid sessionFilePath")
} else if !strings.HasPrefix(sessionFilePath, "gs://") {
return fmt.Errorf("please specify a valid GCS path for sessionFilePath, like gs://<>")
}
if machineType == "" {
machineType = "n2-standard-4"
fmt.Println("machineType not provided, defaulting to: ", machineType)
}
if vpcHostProjectId == "" {
vpcHostProjectId = projectId
}
if readerShardingCustomJarPath != "" && readerShardingCustomClassName == "" {
return fmt.Errorf("When supplying readerShardingCustomJarPath value, the readerShardingCustomClassName should also be supplied ")
}
if readerShardingCustomClassName != "" && readerShardingCustomJarPath == "" {
return fmt.Errorf("When supplying readerShardingCustomClassName value, the readerShardingCustomJarPath should also be supplied ")
}
if readerShardingCustomJarPath != "" && !strings.HasPrefix(readerShardingCustomJarPath, "gs://") {
return fmt.Errorf("please specify a valid GCS path for readerShardingCustomJarPath, like gs://<>")
}
if spannerProjectId == "" {
fmt.Println("Setting the Spanner Project Id to Dataflow project id: ", projectId)
spannerProjectId = projectId
}
return nil
}