Skip to content

Change to HOME isn't respected #3

@kmluck

Description

@kmluck

I don't want to create the .config/godaddy/credentials.json under the user's HOME directory, so I created it elsewhere and then in a subshell expected the change to HOME would be respected. Unfortunately, it didn't work. Looking at https://github.com/cabemo/godaddy-cli/blob/main/internal/config/config.go, I can see that it is actually getting the user.Current().HomeDir; not specifically the HOME environment variable. So even if the HOME environment variable changes, the program doesn't care. Here is a quick BASH script to illustrate the problem:

# Assume that HOME is initially /root
# Assume that the godaddy executable is in the working directory and is executable
# Assume that GODADDY_API_KEY contains a valid GoDaddy API key
# Assume that GODADDY_API_SECRET contains a valid GoDaddy API secret
mkdir -p /tmp/.config/godaddy
jq -n '$ARGS.named' \
  --arg key "${GODADDY_API_KEY}" \
  --arg secret "${GODADDY_API_SECRET}" > /tmp/.config/godaddy/credentials.json

# Assume that the domain acme.com is manageable by the GoDaddy account associated with the previously-set credentials
# I expect the following to work, but it fails to read credentials.json
(export HOME=/tmp ; ./godaddy records list --domain acme.com)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions