Skip to content

Commit a9f4d82

Browse files
committed
Cloud API: Use environment variable CRATEDB_CLOUD_ORGANIZATION_ID
When not logged in using `croud login`, the "create project" operation needs an organization identifier.
1 parent 78b2165 commit a9f4d82

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

cratedb_toolkit/cluster/croud.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def list_clusters(self):
6262
wr = CroudWrapper(call=call)
6363
return wr.invoke()
6464

65-
def create_project(self, name: str):
65+
def create_project(self, name: str, organization_id: str = None):
6666
"""
6767
Create project.
6868
@@ -74,10 +74,14 @@ def create_project(self, name: str):
7474
from croud.__main__ import command_tree
7575
from croud.projects.commands import project_create
7676

77+
# TODO: Refactor elsewhere.
78+
organization_id = organization_id or os.environ.get("CRATEDB_CLOUD_ORGANIZATION_ID")
79+
7780
call = CroudCall(
7881
fun=project_create,
7982
specs=command_tree["projects"]["commands"]["create"]["extra_args"],
8083
arguments=[
84+
f"--org-id={organization_id}",
8185
f"--name={name}",
8286
],
8387
)

tests/cluster/test_examples.py

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def test_example_cloud_cluster_with_deploy(mocker, mock_cloud_cluster_deploy):
4343
mocker.patch.dict(
4444
"os.environ",
4545
{
46+
"CRATEDB_CLOUD_ORGANIZATION_ID": "4148156d-b842-4a86-8024-ecb380be1fc2",
4647
"CRATEDB_CLOUD_SUBSCRIPTION_ID": "f33a2f55-17d1-4f21-8130-b6595d7c52db",
4748
"CRATEDB_CLOUD_CLUSTER_NAME": "testcluster",
4849
"CRATEDB_USERNAME": "crate",

0 commit comments

Comments
 (0)