Handle fetcher credentials on the command line.

This allows the binary to be driven by something else that can provide
build API credentials, like acloud.

Bug: 137304531
Test: ./fetch_cvd
Change-Id: I31ad2820d3c1309cd2e2dda1f01613378be2df58
diff --git a/host/commands/fetcher/credential_source.cc b/host/commands/fetcher/credential_source.cc
index 6133149..579272f 100644
--- a/host/commands/fetcher/credential_source.cc
+++ b/host/commands/fetcher/credential_source.cc
@@ -47,3 +47,16 @@
 std::unique_ptr<CredentialSource> GceMetadataCredentialSource::make() {
   return std::unique_ptr<CredentialSource>(new GceMetadataCredentialSource());
 }
+
+FixedCredentialSource::FixedCredentialSource(const std::string& credential) {
+  this->credential = credential;
+}
+
+std::string FixedCredentialSource::Credential() {
+  return credential;
+}
+
+std::unique_ptr<CredentialSource> FixedCredentialSource::make(
+    const std::string& credential) {
+  return std::unique_ptr<CredentialSource>(new FixedCredentialSource(credential));
+}
diff --git a/host/commands/fetcher/credential_source.h b/host/commands/fetcher/credential_source.h
index f50bd12..fa82eab 100644
--- a/host/commands/fetcher/credential_source.h
+++ b/host/commands/fetcher/credential_source.h
@@ -40,3 +40,13 @@
 
   static std::unique_ptr<CredentialSource> make();
 };
+
+class FixedCredentialSource : public CredentialSource {
+  std::string credential;
+public:
+  FixedCredentialSource(const std::string& credential);
+
+  virtual std::string Credential();
+
+  static std::unique_ptr<CredentialSource> make(const std::string& credential);
+};
diff --git a/host/commands/fetcher/main.cc b/host/commands/fetcher/main.cc
index 2300d3c..f675118 100644
--- a/host/commands/fetcher/main.cc
+++ b/host/commands/fetcher/main.cc
@@ -122,6 +122,8 @@
     std::unique_ptr<CredentialSource> credential_source;
     if (FLAGS_credential_source == "gce") {
       credential_source = GceMetadataCredentialSource::make();
+    } else if (FLAGS_credential_source != "") {
+      credential_source = FixedCredentialSource::make(FLAGS_credential_source);
     }
     BuildApi build_api(std::move(credential_source));
     std::string build_id = FLAGS_build_id;