Skip to content

Commit cdad50b

Browse files
authored
fix(cli_update): fix ak-sk of cli update (#298)
* fix(cli_update): fix ak-sk of cli update * fix(cli_update): fix ak-sk of cli update (cloudapp)
1 parent d48235e commit cdad50b

File tree

3 files changed

+33
-14
lines changed

3 files changed

+33
-14
lines changed

veadk/cli/cli_update.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
# limitations under the License.
1414

1515
import click
16-
import os
1716

1817
from veadk.cloud.cloud_agent_engine import CloudAgentEngine
1918
from veadk.utils.logger import get_logger
19+
from veadk.config import getenv
2020

2121
logger = get_logger(__name__)
2222

@@ -79,13 +79,16 @@ def update(
7979
FileNotFoundError: If local path does not exist.
8080
"""
8181
# Set environment variables if provided
82-
if volcengine_access_key and "VOLCENGINE_ACCESS_KEY" not in os.environ:
83-
os.environ["VOLCENGINE_ACCESS_KEY"] = volcengine_access_key
84-
if volcengine_secret_key and "VOLCENGINE_SECRET_KEY" not in os.environ:
85-
os.environ["VOLCENGINE_SECRET_KEY"] = volcengine_secret_key
82+
if not volcengine_access_key:
83+
volcengine_access_key = getenv("VOLCENGINE_ACCESS_KEY")
84+
if not volcengine_secret_key:
85+
volcengine_secret_key = getenv("VOLCENGINE_SECRET_KEY")
8686

8787
# Initialize cloud agent engine
88-
engine = CloudAgentEngine()
88+
engine = CloudAgentEngine(
89+
volcengine_access_key=volcengine_access_key,
90+
volcengine_secret_key=volcengine_secret_key,
91+
)
8992

9093
try:
9194
# Update function code

veadk/cloud/cloud_agent_engine.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ class CloudAgentEngine(BaseModel):
5757
```
5858
"""
5959

60-
volcengine_access_key: str = getenv("VOLCENGINE_ACCESS_KEY")
61-
volcengine_secret_key: str = getenv("VOLCENGINE_SECRET_KEY")
60+
volcengine_access_key: str = getenv(
61+
"VOLCENGINE_ACCESS_KEY", "", allow_false_values=True
62+
)
63+
volcengine_secret_key: str = getenv(
64+
"VOLCENGINE_SECRET_KEY", "", allow_false_values=True
65+
)
6266
region: str = "cn-beijing"
6367

6468
def model_post_init(self, context: Any, /) -> None:

veadk/cloud/cloud_app.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ def __init__(
124124

125125
def _get_vefaas_endpoint(
126126
self,
127-
volcengine_ak: str = getenv("VOLCENGINE_ACCESS_KEY"),
128-
volcengine_sk: str = getenv("VOLCENGINE_SECRET_KEY"),
127+
volcengine_ak: str = getenv(
128+
"VOLCENGINE_ACCESS_KEY", "", allow_false_values=True
129+
),
130+
volcengine_sk: str = getenv(
131+
"VOLCENGINE_SECRET_KEY", "", allow_false_values=True
132+
),
129133
) -> str:
130134
"""Fetches the application endpoint from VeFaaS details if not directly provided.
131135
@@ -244,8 +248,12 @@ async def _get_a2a_client(self) -> A2AClient:
244248
def update_self(
245249
self,
246250
path: str,
247-
volcengine_ak: str = getenv("VOLCENGINE_ACCESS_KEY"),
248-
volcengine_sk: str = getenv("VOLCENGINE_SECRET_KEY"),
251+
volcengine_ak: str = getenv(
252+
"VOLCENGINE_ACCESS_KEY", "", allow_false_values=True
253+
),
254+
volcengine_sk: str = getenv(
255+
"VOLCENGINE_SECRET_KEY", "", allow_false_values=True
256+
),
249257
):
250258
"""Updates the configuration of this cloud application.
251259
@@ -291,8 +299,12 @@ def update_self(
291299

292300
def delete_self(
293301
self,
294-
volcengine_ak: str = getenv("VOLCENGINE_ACCESS_KEY"),
295-
volcengine_sk: str = getenv("VOLCENGINE_SECRET_KEY"),
302+
volcengine_ak: str = getenv(
303+
"VOLCENGINE_ACCESS_KEY", "", allow_false_values=True
304+
),
305+
volcengine_sk: str = getenv(
306+
"VOLCENGINE_SECRET_KEY", "", allow_false_values=True
307+
),
296308
):
297309
"""Deletes this cloud application after interactive confirmation.
298310

0 commit comments

Comments
 (0)