MCPcopy Index your code
hub / github.com/aws/aws-cli / _run_main

Method _run_main

awscli/customizations/eks/get_token.py:113–157  ·  view source on GitHub ↗
(self, parsed_args, parsed_globals)

Source from the content-addressed store, hash-verified

111 return token_expiration.strftime('%Y-%m-%dT%H:%M:%SZ')
112
113 def _run_main(self, parsed_args, parsed_globals):
114 client_factory = STSClientFactory(self._session)
115 sts_client = client_factory.get_sts_client(
116 region_name=parsed_globals.region, role_arn=parsed_args.role_arn
117 )
118
119 validate_mutually_exclusive(
120 parsed_args, ['cluster_name'], ['cluster_id']
121 )
122
123 if parsed_args.cluster_id:
124 identifier = parsed_args.cluster_id
125 elif parsed_args.cluster_name:
126 identifier = parsed_args.cluster_name
127 else:
128 return ValueError(
129 "Either parameter --cluster-name or --cluster-id must be specified."
130 )
131
132 token = TokenGenerator(sts_client).get_token(identifier)
133
134 # By default STS signs the url for 15 minutes so we are creating a
135 # rfc3339 timestamp with expiration in 14 minutes as part of the token, which
136 # is used by some clients (client-go) who will refresh the token after 14 mins
137 token_expiration = self.get_expiration_time()
138
139 full_object = {
140 "kind": "ExecCredential",
141 "apiVersion": self.discover_api_version(),
142 "spec": {},
143 "status": {
144 "expirationTimestamp": token_expiration,
145 "token": token,
146 },
147 }
148
149 output = parsed_globals.output
150 if output is None:
151 output = self._session.get_config_variable('output')
152 formatter = get_formatter(output, parsed_globals)
153 formatter.query = parsed_globals.query
154
155 formatter(self.NAME, full_object)
156 uni_print('\n')
157 return 0
158
159 def discover_api_version(self):
160 """

Callers

nothing calls this directly

Calls 10

get_sts_clientMethod · 0.95
get_expiration_timeMethod · 0.95
discover_api_versionMethod · 0.95
get_formatterFunction · 0.90
uni_printFunction · 0.90
STSClientFactoryClass · 0.85
TokenGeneratorClass · 0.85
get_tokenMethod · 0.80
get_config_variableMethod · 0.45

Tested by

no test coverage detected