|
1 | 1 | # coding: utf-8 |
2 | 2 |
|
3 | | -# Copyright 2021, 2024 IBM All Rights Reserved. |
| 3 | +# Copyright 2021, 2025 IBM All Rights Reserved. |
4 | 4 | # |
5 | 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
6 | 6 | # you may not use this file except in compliance with the License. |
@@ -53,8 +53,9 @@ class ContainerTokenManager(IAMRequestBasedTokenManager): |
53 | 53 | This can be used to obtain an access token with a specific scope. |
54 | 54 |
|
55 | 55 | Keyword Args: |
56 | | - cr_token_filename: The name of the file containing the injected CR token value |
57 | | - (applies to IKS-managed compute resources). Defaults to "/var/run/secrets/tokens/vault-token". |
| 56 | + cr_token_filename: The name of the file containing the injected CR token value. Defaults to |
| 57 | + "/var/run/secrets/tokens/vault-token", or "/var/run/secrets/tokens/sa-token" and |
| 58 | + "/var/run/secrets/codeengine.cloud.ibm.com/compute-resource-token/token" when not provided. |
58 | 59 | iam_profile_name: The name of the linked trusted IAM profile to be used when obtaining the IAM access token |
59 | 60 | (a CR token might map to multiple IAM profiles). |
60 | 61 | One of iam_profile_name or iam_profile_id must be specified. |
@@ -82,6 +83,7 @@ class ContainerTokenManager(IAMRequestBasedTokenManager): |
82 | 83 |
|
83 | 84 | DEFAULT_CR_TOKEN_FILENAME1 = '/var/run/secrets/tokens/vault-token' |
84 | 85 | DEFAULT_CR_TOKEN_FILENAME2 = '/var/run/secrets/tokens/sa-token' |
| 86 | + DEFAULT_CR_TOKEN_FILENAME3 = '/var/run/secrets/codeengine.cloud.ibm.com/compute-resource-token/token' |
85 | 87 |
|
86 | 88 | def __init__( |
87 | 89 | self, |
@@ -129,11 +131,14 @@ def retrieve_cr_token(self) -> str: |
129 | 131 | # If the user specified a filename, then use that. |
130 | 132 | cr_token = self.read_file(self.cr_token_filename) |
131 | 133 | else: |
132 | | - # If the user didn't specify a filename, then try our two defaults. |
| 134 | + # If the user didn't specify a filename, then try our three defaults. |
133 | 135 | try: |
134 | 136 | cr_token = self.read_file(self.DEFAULT_CR_TOKEN_FILENAME1) |
135 | 137 | except: |
136 | | - cr_token = self.read_file(self.DEFAULT_CR_TOKEN_FILENAME2) |
| 138 | + try: |
| 139 | + cr_token = self.read_file(self.DEFAULT_CR_TOKEN_FILENAME2) |
| 140 | + except: |
| 141 | + cr_token = self.read_file(self.DEFAULT_CR_TOKEN_FILENAME3) |
137 | 142 | return cr_token |
138 | 143 | except Exception as ex: |
139 | 144 | # pylint: disable=broad-exception-raised |
|
0 commit comments