2015-08-08 2 views
3

Je souhaite utiliser gsutil dans un conteneur Docker. J'ai créé un fichier JSON de compte de service O2Auth.Google gsutil auth sans invite

Comment configurer gsutil auth pour utiliser le fichier de configuration JSON et exécuter des commandes sans invite?

Actuellement je reçois quelque chose comme ceci:

$ gsutil config -e 
It looks like you are trying to run "/.../google-cloud-sdk/bin/bootstrapping/gsutil.py config". 
The "config" command is no longer needed with the Cloud SDK. 
To authenticate, run: gcloud auth login 
Really run this command? (y/N) y 
This command will create a boto config file at /.../.boto 
containing your credentials, based on your responses to the following questions. 
What is the full path to your private key file? 

Quelle commande/paramètres/configuration dois-je utiliser aux circonstances invites?

Répondre

6

Résolu ce problème en exécutant:

gcloud auth activate-service-account --key-file=/opt/gcloud/auth.json 

L'exemple entier et récipient fini peuvent être trouvés ici: blacklabelops/gcloud

0

Si vous voulez GSUtil seulement et contourner l'invite, vous pouvez le faire facilement avec Expect scénario:

#!/usr/bin/expect 
spawn gsutil config -e 
expect "What is the full path to your private key file?" { send "/path/your.key\r" } 
expect "Would you like gsutil to change the file permissions for you? (y/N)" { send "y\r" } 
expect "What is your project-id?" { send "your-projet-42\r" } 
interact 
0

en utilisant uniquement gsutil:

première exécution de cette commande pour configurer manuellement l'authentification

gsutil config -a 

Cela va créer fichier /root/.boto avec les informations d'identification nécessaires. Copiez ce chemin/fichier dans votre image docker.

gsutil va maintenant fonctionner avec ces informations d'identification.