File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
src/hyperpod_cli/commands Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -1142,4 +1142,6 @@ def get_user_name():
11421142 user_name = 'Unknown'
11431143
11441144 # label value does not allow slash
1145- return user_name .replace ('/' , '-' )
1145+ user_name = user_name .replace ('/' , '-' )
1146+ # 63 is the max length for a Kubernetes label
1147+ return user_name [:63 ]
Original file line number Diff line number Diff line change 2727from hyperpod_cli .commands .job import (
2828 cancel_job ,
2929 get_job ,
30+ get_user_name ,
3031 list_jobs ,
3132 list_pods ,
3233 patch_job ,
@@ -2126,3 +2127,16 @@ def test_start_job_with_recipe_missing_required_args(self):
21262127 ],
21272128 )
21282129 self .assertNotEqual (result .exit_code , 0 )
2130+
2131+ @mock .patch ("boto3.client" )
2132+ def test_get_user_name_long_arn (self , mock_boto3_client ):
2133+ mock_client = MagicMock ()
2134+ mock_boto3_client .return_value = mock_client
2135+
2136+ mock_identity = MagicMock ()
2137+ mock_client .get_caller_identity .return_value = mock_identity
2138+
2139+ long_user_name = "ReadOnly/AmazonSageMaker-a-long-long-long-long-long-long-long-arn-for-testing-get-user-name"
2140+ long_arn = "arn:aws:iam::0123456789012:assumed-role/" + long_user_name
2141+ mock_identity .get .return_value = long_arn
2142+ self .assertEqual (get_user_name (), "AssumedRole-" + long_user_name .replace ("/" , "-" )[:51 ])
You can’t perform that action at this time.
0 commit comments