Skip to content

Commit

Permalink
switch to embed from bindata
Browse files Browse the repository at this point in the history
  • Loading branch information
davidnewhall committed Jul 17, 2024
1 parent 9401987 commit 6d34b7d
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 352 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ clean:
rm -f unpackerr unpackerr.*.{macos,freebsd,linux,exe}{,.gz,.zip} unpackerr.1{,.gz} unpackerr.rb
rm -f unpackerr{_,-}*.{deb,rpm,txz} v*.tar.gz.sha256 examples/MANUAL .metadata.make rsrc_*.syso
rm -f cmd/unpackerr/README{,.html} README{,.html} ./unpackerr_manual.html rsrc.syso Unpackerr.*.app.zip
rm -f PKGBUILD pkg/bindata/bindata.go
rm -f PKGBUILD
rm -rf package_build_* release Unpackerr.*.app Unpackerr.app

####################
Expand All @@ -94,12 +94,12 @@ unpackerr.1.gz:

# TODO: provide a template that adds the date to the built html file.
readme: README.html
README.html:
README.html:
# This turns README.md into README.html
go run github.com/davidnewhall/[email protected] --manual unpackerr --version $(VERSION) --date "$(DATE)" README.md

rsrc: rsrc.syso
rsrc.syso: init/windows/application.ico init/windows/manifest.xml
rsrc.syso: init/windows/application.ico init/windows/manifest.xml
go run github.com/akavel/rsrc@latest -arch amd64 -ico init/windows/application.ico -manifest init/windows/manifest.xml

####################
Expand Down Expand Up @@ -337,8 +337,8 @@ lint: generate
GOOS=freebsd golangci-lint run
GOOS=windows golangci-lint run

generate: pkg/bindata/bindata.go
pkg/bindata/bindata.go: pkg/bindata/files/*
generate: examples/unpackerr.conf.example
examples/unpackerr.conf.example: init/config/*
find pkg -name .DS\* -delete
go generate ./...

Expand Down
12 changes: 12 additions & 0 deletions examples/examples.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package examples

// This file allows unpackerr to import the example config file into the binary.

import _ "embed"

var (
//go:embed unpackerr.conf.example
ConfigFile []byte
//go:embed docker-compose.yml
DockerCompose []byte
)
3 changes: 1 addition & 2 deletions pkg/bindata/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
The files in this folder are auto generated from the files/ folder.
Currently bindata is used to store the app GUI icon files.
The files in this folder are bundled into the compiled application binary.
329 changes: 0 additions & 329 deletions pkg/bindata/bindata.go

This file was deleted.

8 changes: 8 additions & 0 deletions pkg/bindata/bindata_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build !windows

package bindata

import _ "embed"

//go:embed macos.png
var SystrayIcon []byte
8 changes: 8 additions & 0 deletions pkg/bindata/bindata_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//go:build windows

package bindata

import _ "embed"

//go:embed windows.ico
var SystrayIcon []byte
4 changes: 0 additions & 4 deletions pkg/bindata/generate.go

This file was deleted.

File renamed without changes
File renamed without changes.
6 changes: 2 additions & 4 deletions pkg/unpackerr/cnfgfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"strings"
"time"

"github.com/Unpackerr/unpackerr/pkg/bindata"
"github.com/Unpackerr/unpackerr/examples"
"github.com/Unpackerr/unpackerr/pkg/ui"
"github.com/hako/durafmt"
homedir "github.com/mitchellh/go-homedir"
Expand Down Expand Up @@ -208,9 +208,7 @@ func (u *Unpackerr) createConfigFile(file string) (string, error) {
}
defer fOpen.Close()

if asset, err := bindata.Asset("../../examples/unpackerr.conf.example"); err != nil {
return "", fmt.Errorf("getting config file: %w", err)
} else if _, err = fOpen.Write(asset); err != nil {
if _, err = fOpen.Write(examples.ConfigFile); err != nil {
return "", fmt.Errorf("writing config file: %w", err)
}

Expand Down
9 changes: 1 addition & 8 deletions pkg/unpackerr/tray.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,7 @@ func (u *Unpackerr) exitTray() {

// readyTray creates the system tray/menu bar app items, and starts the web server.
func (u *Unpackerr) readyTray() {
b, err := bindata.Asset(ui.SystrayIcon)
if err == nil {
systray.SetTemplateIcon(b, b)
} else {
u.Errorf("Reading Icon: %v", err)
systray.SetTitle("DNC")
}

systray.SetTemplateIcon(bindata.SystrayIcon, bindata.SystrayIcon)
systray.SetTooltip("Unpackerr" + " v" + version.Version)
u.makeChannels()

Expand Down

0 comments on commit 6d34b7d

Please sign in to comment.