Skip to content
This repository was archived by the owner on Feb 2, 2022. It is now read-only.

Commit 687fa7d

Browse files
authored
Login if passed a secret on the command line. (#238)
Use exit codes to propagate failure to the shell.
1 parent 0804e35 commit 687fa7d

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

cli/raft.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import os
66
import uuid
77
import textwrap
8+
import sys
89

910
import raft_sdk.raft_common
1011
from raft_sdk.raft_service import RaftCLI, RaftJobConfig
@@ -574,5 +575,7 @@ def main():
574575
if __name__ == "__main__":
575576
try:
576577
main()
578+
sys.exit(0)
577579
except Exception as ex:
578580
print(ex)
581+
sys.exit(1)

cli/raft_sdk/raft_deploy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,18 @@ def __init__(self, context, defaults_path, secret=None):
7575

7676
if not secret:
7777
self.is_logged_in()
78+
else:
79+
# If we are given a secret on the command line, then we assume that
80+
# we are running in some automation context and need
81+
# to login this way.
82+
az(f'login --service-principal -u {self.context["clientId"]} -p {secret} --tenant {self.context["tenantId"]}')
7883

7984
az(f'account set --subscription {self.definitions.subscription}')
8085

8186
def is_logged_in(self):
87+
# If your not logged in this command will throw
88+
# an exception and say in the error message
89+
# that you need to login.
8290
az('ad signed-in-user show')
8391

8492
def hash(self, txt):

docs/how-to-use-raft-local.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ CLI //root folder where you downloaded the CLI
3535
* The `storage` folder will contain all of the data produced by RAFT job runs.
3636
* The `secrets` folder is a user maintained folder. </br>
3737
The files in this folder are the names of the secret used in the job definition file.
38-
These files should not have an extension.
38+
These files should not have an extension.</br>
39+
**Note:** The contents of the secret file must not contain line breaks. This data is passed
40+
on the docker command line. Line breaks will cause the docker command to fail.
3941

4042
For example if my RAFT job configuration requires a text token.
4143
I can store the token in file `MyToken` under `CLI/local/secrets/MyToken` and use `MyToken`

0 commit comments

Comments
 (0)