oh-my-fish / theme-bobthefish

A Powerline-style, Git-aware fish theme optimized for awesome.
MIT License
1.44k stars 222 forks source link

replace AWS_SESSION_EXPIRATION for aws-vault #341

Closed ismailyenigul closed 4 months ago

ismailyenigul commented 1 year ago

aws-vault 7.X removed AWS_SESSION_EXPIRATION env and replaced with AWS_CREDENTIAL_EXPIRATION To make this theme works for aws-vault 7.X, we must replace this env.

see: https://github.com/99designs/aws-vault/pull/1143

bobthecow commented 1 year ago

do older versions of aws-vault support AWS_CREDENTIAL_EXPIRATION as well, or does this change break the AWS prompt integration unless everyone has updated?

ismailyenigul commented 1 year ago

No it is not supported in older versions. It is breaking changes in v7.0

bobthecow commented 1 year ago

Gotcha. If that's the case it probably makes the most sense if bobthefish falls back to the old variable if the new one isn't available.

ismailyenigul commented 1 year ago

let me try to add conditions to support AWS_CREDENTIAL_EXPIRATION as well

ismailyenigul commented 1 year ago

what do you think about the following changes

[ -n "$AWS_VAULT" -a -n "$AWS_CREDENTIAL_EXPIRATION" -o "$AWS_SESSION_EXPIRATION" ]
    or return

    set -l profile $AWS_VAULT
    set -l now (gdate --utc +%s)

    if [ -n  "$AWS_CREDENTIAL_EXPIRATION" ]
        set  aws_vault_expiry (gdate -d "$AWS_CREDENTIAL_EXPIRATION" +%s)
    else
        set  aws_vault_expiry (gdate -d "$AWS_SESSION_EXPIRATION" +%s)
    end

    #set -l expiry (gdate -d "$AWS_CREDENTIAL_EXPIRATION" +%s)
    set -l diff_mins (math "floor(( $aws_vault_expiry - $now ) / 60)")
bobthecow commented 4 months ago

@ismailyenigul thanks for this! i merged the fix in #351 because I missed that this one came first 😬