akamai / cli-sandbox

Akamai CLI for Sandbox
https://github.com/akamai/cli
Apache License 2.0
13 stars 12 forks source link

Credentials not using default section #62

Closed RafPe closed 3 years ago

RafPe commented 4 years ago

When using custom credentials file with default section it bails out with exception

[root@6713dfa464d8 cli-sandbox]# akamai sandbox --edgerc ~/.edgerc2  create --hostname www.xxx.com --name sandbox_for_www.xxx.com --debug
TypeError: Cannot read property 'clientToken' of undefined
    at Object.getEdgeGrid (/cli/.akamai-cli/src/cli-sandbox/bin/utils/env-utils.js:41:26)
    at sendEdgeRequest (/cli/.akamai-cli/src/cli-sandbox/bin/service/sandbox-svc.js:32:27)
    at postJson (/cli/.akamai-cli/src/cli-sandbox/bin/service/sandbox-svc.js:91:12)
    at Object.createFromProperty (/cli/.akamai-cli/src/cli-sandbox/bin/service/sandbox-svc.js:199:12)
    at /cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:550:50
    at Generator.next (<anonymous>)
    at /cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:8:71
    at Promise (<anonymous>)
    at __awaiter (/cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:4:12)
    at createFromHostname (/cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:548:12)
    at Command.<anonymous> (/cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:821:27)
    at Generator.next (<anonymous>)
    at /cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:8:71
    at Promise (<anonymous>)
    at __awaiter (/cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:4:12)
    at Command.<anonymous> (/cli/.akamai-cli/src/cli-sandbox/bin/cli-main.js:770:12)
[default]
client_secret = a*****=
host = akab-******.luna.akamaiapis.net
access_token = akab-**-**
client_token = akab-**-**
kporowski commented 4 years ago

I am unable to reproduce the issue with akamai sandbox version 1.2.2. Do you use dockerized CLI or a standalone one?

RafPe commented 4 years ago

@kporowski here is more info

kporowski commented 4 years ago

I would like to to confirm if by 'edge rc file' you mean ~/.edgerc file used in a command line.

I tried to reproduce it in docker env, but the only way I can see this error is when ~/.edgerc2 file doesn't contain [default] section. e.g. when I introduce a typo in that section name like [defualt].

RafPe commented 4 years ago

Edgerc file has the following

[root@7f0f5eee9192 cli-sandbox]# cat ~/.edgerc2
[default]
client_secret = *****/****=
host = akab-****-***.luna.akamaiapis.net
access_token = akab-***-****
client_token = akab-****-****
[root@7f0f5eee9192 cli-sandbox]#
dctheobald commented 4 years ago

@kporowski - I fixed this and similar edgerc issues in EdgeWorkers CLI which was based roughly on Sandbox CLI - see: https://github.com/akamai/cli-edgeworkers/issues/1 which is resolved in EWCLI v0.1.1. Ping me if you want to discuss.

kporowski commented 4 years ago

@dctheobald: thank you, I have a fix already prepared, but would like to recreate this issue to make sure it is properly handled.

kporowski commented 3 years ago

Already fixed.