
export-env {
    if $env.CURRENT_INFRA_PATH != null and $env.CURRENT_INFRA_PATH != "" {
        #use sops/lib.nu get_def_sops
        #use sops/lib.nu get_def_age
        if $env.CURRENT_KLOUD_PATH? != null {
            $env.PROVISIONING_SOPS = (get_def_sops $env.CURRENT_KLOUD_PATH)
            $env.PROVISIONING_KAGE = (get_def_age $env.CURRENT_KLOUD_PATH)
        } else {
            $env.PROVISIONING_SOPS = (get_def_sops $env.CURRENT_INFRA_PATH)
            $env.PROVISIONING_KAGE = (get_def_age $env.CURRENT_INFRA_PATH)
            # let context = (setup_user_context) 
            # let kage_path = ($context | get -o "kage_path" | default "" | str replace "KLOUD_PATH" $env.PROVISIONING_KLOUD_PATH) 
            # if $kage_path != "" { 
            #     $env.PROVISIONING_KAGE = $kage_path
            # }
        } 
        print $env
        if $env.PROVISIONING_KAGE? != null {  
            $env.SOPS_AGE_KEY_FILE = $env.PROVISIONING_KAGE
            $env.SOPS_AGE_RECIPIENTS = (grep "public key:" $env.SOPS_AGE_KEY_FILE | split row ":" |
                get -o 1  | str trim |  default "") 
            if $env.SOPS_AGE_RECIPIENTS == "" { 
                print $"❗Error no key found in (_ansi red_bold)($env.SOPS_AGE_KEY_FILE)(_ansi reset) file for secure AGE operations "
                exit 1
            }
        }
    }
}