tflock icon indicating copy to clipboard operation
tflock copied to clipboard

print lock id

Open illegalprime opened this issue 4 years ago • 1 comments

not really a go programmer, what do you think about this idea? please ignore the .nix it's just how i'm testing it

illegalprime avatar Jun 14 '21 16:06 illegalprime

Hi, @illegalprime. Thank you for your proposal, but I hesitant to merge this because the implementation accesses a private field by using reflection. It's fragile and hard to maintain the feature. However it seems that there is no way to do this with public methods.

As a workaround, you can parse an error message of terraform plan. Of course it's also fragile. 😇

$ tflock

$ LOCK_ID=$(terraform plan -input=false -no-color 2>&1 | gsed -rn 's/^\s*ID\:\s+(\w+)\s*/\1/p')

$ echo $LOCK_ID
c496859b-21db-dffb-f489-cb452586935f

$ terraform force-unlock -force $LOCK_ID

minamijoyo avatar Jul 21 '21 08:07 minamijoyo