From: Vincent Vanwaelscappel Date: Mon, 26 May 2025 18:04:59 +0000 (+0200) Subject: wip #7567 @1 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=73b082192181465aa3517b197a1cace2072743b1;p=cubist_util.git wip #7567 @1 --- diff --git a/src/CommandLine/LocalToGCSRclone.php b/src/CommandLine/LocalToGCSRclone.php new file mode 100644 index 0000000..3653da4 --- /dev/null +++ b/src/CommandLine/LocalToGCSRclone.php @@ -0,0 +1,69 @@ +setArg(null, $this->getMirror() ? 'sync' : 'copy'); + $this->setArg(null, $this->getSrc()); + foreach ($this->_gcs_config as $k => $v) { + $this->setArg('gcs-' . str_replace('_', '-', $k), $v); + } + + if ($this->isDryRun()) { + $this->setArg('dry-run'); + } + foreach ($this->_cloneArgs as $name => $value) { + $this->setArg($name, $value); + } + $dest = ':gcs:' . $this->getBucket() . '/' . rtrim($this->getDest(), '/') . '/'; + $this->setManualArg($dest); + } + + public function setS3Config($config) + { + $this->_gcs_config = $config; + } + + public function setServer(IServer $server) + { + parent::setServer($server); + + $config = [ + 'provider' => $server->getS3Provider(), + 'env_auth' => 'false', + 'access_key_id' => $server->getAccessKey(), + 'secret_access_key' => $server->getSecret(), + 'region' => $server->getRegion(), + 'endpoint' => $server->getEndpoint(), + ]; + + $this->setS3Config($config); + $this->setBucket($server->getBucket()); + } + + /** + * @return mixed + */ + public function getBucket() + { + return $this->_bucket; + } + + /** + * @param mixed $bucket + */ + public function setBucket($bucket): void + { + $this->_bucket = $bucket; + } +} \ No newline at end of file