diff --git a/dot_config/powershell/Async/resolve.ps1 b/dot_config/powershell/Async/resolve.ps1 new file mode 100644 index 0000000..4c5a550 --- /dev/null +++ b/dot_config/powershell/Async/resolve.ps1 @@ -0,0 +1,109 @@ +function Convert-ResolveVideo +{ + param( + [Parameter(Mandatory)] + [string] $InputFile, + [string] $OutputFile, + [string] $Fps = "30" + ) + + if (-not $OutputFile) + { + $base = [System.IO.Path]::GetFileNameWithoutExtension($InputFile) + $OutputFile = "${base}_davinci.mov" + } + + try + { + ffmpeg -fflags +genpts ` + -hide_banner ` + -i "$InputFile" ` + -r $Fps ` + -c:v dnxhd ` + -profile:v 3 ` + -pix_fmt yuv422p ` + -c:a copy ` + "$OutputFile" + + if ($LASTEXITCODE -ne 0) + { + throw "ffmpeg failed" + } + + } catch + { + if (Test-Path $OutputFile) + { + Remove-Item $OutputFile -Force + Write-Host "Deleted broken file: $OutputFile" + } + throw + } +} + +function Convert-AllToResolve +{ + param( + [string] $Fps = "30" + ) + + $videoExts = @(".mp4", ".mov", ".mxf", ".avi") + + $files = Get-ChildItem -File | Where-Object { + $videoExts -contains $_.Extension.ToLower() -and + -not $_.Name.EndsWith("_davinci.mov") -and + -not (Test-Path "$($_.BaseName)_davinci.mov") + } + + if (-not $files) + { + Write-Host(Get-ColorString "No videos to convert.") + return + } + + Write-Host "Videos to convert:`n" + + foreach ($f in $files) + { + Write-Host(Get-ColorString " - $($f.Name)") + } + Write-Host "" + + foreach ($f in $files) + { + $out = "$($f.BaseName)_davinci.mov" + Write-Host(Get-ColorString "Converting $($f.Name) → $out") + Convert-ResolveVideo -InputFile $f.FullName -OutputFile $out -Fps $Fps + } +} + +function Remove-ResolveVideos +{ + [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')] + param () + + $files = Get-ChildItem -File | Where-Object { + $_.Name.EndsWith("_davinci.mov") + } + + if (-not $files) + { + Write-Host(Get-ColorString "No resolve videos to delete.") + return + } + + Write-Host "Resolve videos to delete:`n" + + foreach ($f in $files) + { + Write-Host(Get-ColorString " - $($f.Name)") + } + Write-Host "" + + foreach ($f in $files) + { + Remove-Item $f.FullName -Force -Confirm:$ConfirmPreference -WhatIf:$WhatIfPreference + } + + Write-Host(Get-ColorString "All selected resolve videos deleted") +} diff --git a/dot_config/powershell/main.ps1 b/dot_config/powershell/main.ps1 index 3220eab..6386e4d 100644 --- a/dot_config/powershell/main.ps1 +++ b/dot_config/powershell/main.ps1 @@ -32,6 +32,7 @@ $global:myAsync = [ordered]@{ catppuccin = Join-Path $powershellAsync "catppuccin.ps1" scrcpy = Join-Path $powershellAsync "scrcpy.ps1" direnv = Join-Path $powershellAsync "direnv.ps1" + resolve = Join-Path $powershellAsync "resolve.ps1" } # Load Core @@ -105,6 +106,7 @@ $AsyncScriptblock = { . $global:myAsync.psprofiler . $global:myAsync.scrcpy . $global:myAsync.direnv + . $global:myAsync.resolve Save-ProfileHints } diff --git a/dot_config/private_k9s/plugins/flux.yaml b/dot_config/private_k9s/plugins/flux.yaml new file mode 100644 index 0000000..3efd896 --- /dev/null +++ b/dot_config/private_k9s/plugins/flux.yaml @@ -0,0 +1,297 @@ +# $HOME/.k9s/plugin.yml +# move selected line to chosen resource in K9s, then: +# Shift-T (with confirmation) to toggle helm releases or kustomizations suspend and resume +# Shift-R (no confirmation) to reconcile a git source or a helm release or a kustomization +plugins: + toggle-helmrelease: + shortCut: Shift-T + confirm: true + scopes: + - helmreleases + description: Toggle to suspend or resume a HelmRelease + command: bash + background: false + args: + - -c + - >- + suspended=$(kubectl --context $CONTEXT get helmreleases -n $NAMESPACE $NAME -o=custom-columns=TYPE:.spec.suspend | tail -1); + verb=$([ $suspended = "true" ] && echo "resume" || echo "suspend"); + flux + $verb helmrelease + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + toggle-kustomization: + shortCut: Shift-T + confirm: true + scopes: + - kustomizations + description: Toggle to suspend or resume a Kustomization + command: bash + background: false + args: + - -c + - >- + suspended=$(kubectl --context $CONTEXT get kustomizations -n $NAMESPACE $NAME -o=custom-columns=TYPE:.spec.suspend | tail -1); + verb=$([ $suspended = "true" ] && echo "resume" || echo "suspend"); + flux + $verb kustomization + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-git: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - gitrepositories + command: bash + background: false + args: + - -c + - >- + flux + reconcile source git + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-hr: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - helmreleases + command: bash + background: false + args: + - -c + - >- + flux + reconcile helmrelease + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-helm-repo: + shortCut: Shift-Z + description: Flux reconcile + scopes: + - helmrepositories + command: bash + background: false + confirm: false + args: + - -c + - >- + flux + reconcile source helm + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-oci-repo: + shortCut: Shift-Z + description: Flux reconcile + scopes: + - ocirepositories + command: bash + background: false + confirm: false + args: + - -c + - >- + flux + reconcile source oci + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-ks: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - kustomizations + command: bash + background: false + args: + - -c + - >- + flux + reconcile kustomization + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-ir: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - imagerepositories + command: sh + background: false + args: + - -c + - >- + flux + reconcile image repository + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-iua: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - imageupdateautomations + command: sh + background: false + args: + - -c + - >- + flux + reconcile image update + --context $CONTEXT + -n $NAMESPACE $NAME + | less -K + toggle-rset: + shortCut: Shift-T + confirm: false + scopes: + - resourcesets + description: Toggle to suspend or resume a ResourceSet + command: bash + background: false + args: + - -c + - >- + reconcile=$(kubectl --context $CONTEXT get resourceset -n $NAMESPACE $NAME -o=custom-columns='TYPE:.metadata.annotations.fluxcd\.controlplane\.io/reconcile' | tail -1); + verb=$([ $reconcile = "disabled" ] && echo "resume" || echo "suspend"); + flux-operator + $verb rset + --kube-context $CONTEXT + -n $NAMESPACE $NAME + | less -K + toggle-inputprovider: + shortCut: Shift-T + confirm: false + scopes: + - resourcesetinputprovider + description: Toggle to suspend or resume an InputProvider + command: bash + background: false + args: + - -c + - >- + reconcile=$(kubectl --context $CONTEXT get resourcesetinputprovider -n $NAMESPACE $NAME -o=custom-columns='TYPE:.metadata.annotations.fluxcd\.controlplane\.io/reconcile' | tail -1); + verb=$([ $reconcile = "disabled" ] && echo "resume" || echo "suspend"); + flux-operator + $verb inputprovider + --kube-context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-rset: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - resourcesets + command: bash + background: false + args: + - -c + - >- + flux-operator + reconcile rset + --kube-context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-inputprovider: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - resources + command: bash + background: false + args: + - -c + - >- + flux-operator + reconcile inputprovider + --kube-context $CONTEXT + -n $NAMESPACE $NAME + | less -K + reconcile-fluxinstance: + shortCut: Shift-R + confirm: false + description: Flux reconcile + scopes: + - fluxinstances + command: bash + background: false + args: + - -c + - >- + flux-operator + reconcile instance + --kube-context $CONTEXT + -n $NAMESPACE $NAME + | less -K + trace: + shortCut: Shift-Q + confirm: false + description: Flux trace + scopes: + - all + command: bash + background: false + args: + - -c + - >- + if [ -n "$RESOURCE_GROUP" ]; then api_endpoint="/apis/$RESOURCE_GROUP/$RESOURCE_VERSION"; else api_endpoint="/api/$RESOURCE_VERSION"; fi; + api_resource=$(kubectl get --raw "${api_endpoint}" | jq -r ".resources[] | select(.name==\"$RESOURCE_NAME\")"); + kind=$(echo ${api_resource} | jq -r '.kind'); + namespace_arg=$(echo ${api_resource} | jq -r "if .namespaced == true then \"--namespace $NAMESPACE\" else \"\" end"); + [ -n "$RESOURCE_GROUP" ] && api_version=$RESOURCE_GROUP/; + api_version=${api_version}$RESOURCE_VERSION; + flux + trace + --context $CONTEXT + --kind ${kind} + --api-version ${api_version} + ${namespace_arg} + $NAME + |& less -K + # credits: https://github.com/fluxcd/flux2/discussions/2494 + get-suspended-helmreleases: + shortCut: Shift-S + confirm: false + description: Suspended Helm Releases + scopes: + - helmrelease + command: sh + background: false + args: + - -c + - >- + kubectl get + --context $CONTEXT + --all-namespaces + helmreleases.helm.toolkit.fluxcd.io -o json + | jq -r '.items[] | select(.spec.suspend==true) | [.metadata.namespace,.metadata.name,.spec.suspend] | @tsv' + | less -K + get-suspended-kustomizations: + shortCut: Shift-S + confirm: false + description: Suspended Kustomizations + scopes: + - kustomizations + command: sh + background: false + args: + - -c + - >- + kubectl get + --context $CONTEXT + --all-namespaces + kustomizations.kustomize.toolkit.fluxcd.io -o json + | jq -r '.items[] | select(.spec.suspend==true) | [.metadata.name,.spec.suspend] | @tsv' + | less -K