Skip to content

Commit

Permalink
trying to get windows build, move into src
Browse files Browse the repository at this point in the history
  • Loading branch information
clbx committed Jul 25, 2024
1 parent 3e66111 commit c0ce184
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 64 deletions.
57 changes: 33 additions & 24 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
- name: Check out Code
uses: actions/[email protected]

- name: cd into src
run: cd src

- name: Build
run: go build -v -ldflags "-X main.Version=${{ inputs.version }}" -o kubectl-browse-pvc .

Expand All @@ -44,6 +47,9 @@ jobs:
- name: Check out Code
uses: actions/[email protected]

- name: cd into src
run: cd src

- name: Build
run: go build -v -ldflags "-X main.Version=${{ inputs.version }}" -o kubectl-browse-pvc .

Expand All @@ -69,30 +75,8 @@ jobs:
- name: Check out Code
uses: actions/[email protected]

- name: Build
run: go build -v -ldflags "-X main.Version=${GITHUB_SHA::7}" -o kubectl-browse-pvc .

- name: Fix permissions
run: chmod +x ./kubectl-browse-pvc

- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: kubectl-browse-pvc-linux-x86_64
path: |
./kubectl-browse-pvc
LICENSE
build-windows-x86_64:
runs-on: windows-latest
steps:
- name: Set up Go
uses: actions/[email protected]
with:
go-version: "1.22.0"

- name: Check out Code
uses: actions/[email protected]
- name: cd into src
run: cd src

- name: Build
run: go build -v -ldflags "-X main.Version=${GITHUB_SHA::7}" -o kubectl-browse-pvc .
Expand All @@ -107,3 +91,28 @@ jobs:
path: |
./kubectl-browse-pvc
LICENSE
# build-windows-x86_64:
# runs-on: windows-latest
# steps:
# - name: Set up Go
# uses: actions/[email protected]
# with:
# go-version: "1.22.0"

# - name: Check out Code
# uses: actions/[email protected]

# - name: Build
# run: go build -v -ldflags "-X main.Version=${GITHUB_SHA::7}" -o kubectl-browse-pvc .

# - name: Fix permissions
# run: chmod +x ./kubectl-browse-pvc

# - name: Upload Artifact
# uses: actions/upload-artifact@v4
# with:
# name: kubectl-browse-pvc-linux-x86_64
# path: |
# ./kubectl-browse-pvc
# LICENSE
File renamed without changes.
File renamed without changes.
40 changes: 0 additions & 40 deletions main.go → src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"fmt"
"log"
"os"
"os/signal"
"syscall"
"time"

"github.com/briandowns/spinner"
Expand Down Expand Up @@ -56,44 +54,6 @@ func main() {

}

type sizeQueue struct {
resizeChan chan remotecommand.TerminalSize
stopResizing chan struct{}
}

func (s *sizeQueue) Next() *remotecommand.TerminalSize {
size, ok := <-s.resizeChan
if !ok {
return nil
}
return &size
}

func (s *sizeQueue) MonitorSize() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGWINCH)

for {
select {
case <-sigCh:
width, height, err := term.GetSize(int(os.Stdout.Fd()))
if err == nil {
select {
case s.resizeChan <- remotecommand.TerminalSize{Width: uint16(width), Height: uint16(height)}:
default:
}
}
case <-s.stopResizing:
close(s.resizeChan)
return
}
}
}

func (s *sizeQueue) Stop() {
close(s.stopResizing)
}

func browseCommand(kubeConfigFlags *genericclioptions.ConfigFlags, pvcName string) error {

config, err := kubeConfigFlags.ToRESTConfig()
Expand Down
51 changes: 51 additions & 0 deletions src/monitor_size.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//go:build linux || darwin
// +build linux darwin

package main

import (
"os"
"os/signal"
"syscall"

"golang.org/x/term"
"k8s.io/client-go/tools/remotecommand"
)

type sizeQueue struct {
resizeChan chan remotecommand.TerminalSize
stopResizing chan struct{}
}

func (s *sizeQueue) Next() *remotecommand.TerminalSize {
size, ok := <-s.resizeChan
if !ok {
return nil
}
return &size
}

func (s *sizeQueue) Stop() {
close(s.stopResizing)
}

func (s *sizeQueue) MonitorSize() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGWINCH)

for {
select {
case <-sigCh:
width, height, err := term.GetSize(int(os.Stdout.Fd()))
if err == nil {
select {
case s.resizeChan <- remotecommand.TerminalSize{Width: uint16(width), Height: uint16(height)}:
default:
}
}
case <-s.stopResizing:
close(s.resizeChan)
return
}
}
}
50 changes: 50 additions & 0 deletions src/monitor_size_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
//go:build windows
// +build windows

package main

import (
"os"

"golang.org/x/term"
"k8s.io/client-go/tools/remotecommand"
)

type sizeQueue struct {
resizeChan chan remotecommand.TerminalSize
stopResizing chan struct{}
}

func (s *sizeQueue) Next() *remotecommand.TerminalSize {
size, ok := <-s.resizeChan
if !ok {
return nil
}
return &size
}

func (s *sizeQueue) Stop() {
close(s.stopResizing)
}

func (s *sizeQueue) MonitorSize() {
sigCh := make(chan os.Signal, 1)
// Need to fix this to get it working on windows
//signal.Notify(sigCh, syscall.SIGWINCH)

for {
select {
case <-sigCh:
width, height, err := term.GetSize(int(os.Stdout.Fd()))
if err == nil {
select {
case s.resizeChan <- remotecommand.TerminalSize{Width: uint16(width), Height: uint16(height)}:
default:
}
}
case <-s.stopResizing:
close(s.resizeChan)
return
}
}
}
File renamed without changes.

0 comments on commit c0ce184

Please sign in to comment.