Skip to content

Commit

Permalink
image-push supports renaming via -t (nushell#750)
Browse files Browse the repository at this point in the history
fix nu-complete of `docker registry show`

Co-authored-by: nash <[email protected]>
  • Loading branch information
fj0r and nashvi committed Jan 26, 2024
1 parent 73955cd commit 302fd84
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions modules/docker/docker.nu
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,19 @@ export def image-tag [from: string@"nu-complete docker images" to: string -n: s
}

# push image
export def image-push [img: string@"nu-complete docker images" -n: string@"nu-complete docker ns" -i] {
export def image-push [
img: string@"nu-complete docker images"
--tag(-t): string
-n: string@"nu-complete docker ns" -i
] {
let $insecure = if $i {[--insecure-registry]} else {[]}
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $img
if ($tag | is-empty) {
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $img
} else {
^$env.docker-cli ...($n | with-flag -n) tag $img $tag
^$env.docker-cli ...($n | with-flag -n) ...$insecure push $tag
^$env.docker-cli ...($n | with-flag -n) rmi $tag
}
}

# pull image
Expand Down Expand Up @@ -395,9 +405,9 @@ def has [name] {
def "nu-complete registry show" [cmd: string, offset: int] {
let new = $cmd | str ends-with ' '
let cmd = $cmd | split row ' '
let url = $cmd.2?
let reg = $cmd.3?
let tag = $cmd.4?
let url = $cmd.3?
let reg = $cmd.4?
let tag = $cmd.5?
let auth = if ($env | has 'REGISTRY_TOKEN') {
[-H $"Authorization: Basic ($env.REGISTRY_TOKEN)"]
} else {
Expand Down

0 comments on commit 302fd84

Please sign in to comment.