Skip to content

Commit 7543cff

Browse files
authored
Merge pull request #254 from xnox/port-to-embed
Port from vfs to embed
2 parents 1288669 + 25f2b31 commit 7543cff

File tree

8 files changed

+8
-273
lines changed

8 files changed

+8
-273
lines changed

.github/ci/check-generate

Lines changed: 0 additions & 36 deletions
This file was deleted.

.github/workflows/repo-quality.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ jobs:
8787
GOPATH=`pwd` go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
8888
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
8989
cd -
90-
- name: Check generated files
91-
run: PATH=../bin:$PATH ./.github/ci/check-generate
9290
9391
extended-quality:
9492
name: Extended quality checks

debian/rules

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
export GOCACHE=$(shell mktemp -d /tmp/gocache-XXXX)
55
export GOFLAGS=-ldflags=-X=github.com/ubuntu/zsys/internal/config.Version=$(shell dpkg-parsechangelog -S Version) --mod=vendor
6+
export DH_GOLANG_INSTALL_ALL=1
67

78
# Tell go generate to only install on-the-fly assets
89
export ZSYS_GENERATE_ONLY_INSTALL_SHARE_PREFIX=$(CURDIR)/debian/zsys/usr/share

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ require (
88
github.com/godbus/dbus/v5 v5.1.0
99
github.com/google/go-cmp v0.5.9
1010
github.com/k0kubun/pp v3.0.1+incompatible
11-
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c
12-
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92
1311
github.com/sirupsen/logrus v1.9.3
1412
github.com/snapcore/go-gettext v0.0.0-20201130093759-38740d1bd3d2
1513
github.com/spf13/cobra v1.7.0

go.sum

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
2727
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
2828
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
2929
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
30-
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c h1:aqg5Vm5dwtvL+YgDpBcK1ITf3o96N/K7/wsRXQnUTEs=
31-
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c/go.mod h1:owqhoLW1qZoYLZzLnBw+QkPP9WZnjlSWihhxAJC1+/M=
32-
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 h1:OfRzdxCzDhp+rsKWXuOO2I/quKMJ/+TQwVbIP/gltZg=
33-
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92/go.mod h1:7/OT02F6S6I7v6WXb+IjhMuZEYfH/RJ5RwEWnEo5BMg=
3430
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
3531
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
3632
github.com/snapcore/go-gettext v0.0.0-20201130093759-38740d1bd3d2 h1:nETXPg0CiJrMAwC2gqkcam9BiBWYGvTsSYRfrjOz2Kg=

internal/config/config.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,17 @@ package config
22

33
import (
44
"context"
5+
_ "embed"
56
"fmt"
6-
"io/ioutil"
7-
"net/http"
87
"os"
9-
"path/filepath"
108

119
"github.com/ubuntu/zsys/internal/i18n"
1210
"github.com/ubuntu/zsys/internal/log"
1311
yaml "gopkg.in/yaml.v3"
1412
)
1513

16-
//go:generate go run generator.go
14+
//go:embed zsys.conf
15+
var internalconf []byte
1716

1817
// TEXTDOMAIN is the message domain used by snappy; see dgettext(3)
1918
// for more information.
@@ -66,22 +65,12 @@ func SetVerboseMode(level int) {
6665
func Load(ctx context.Context, path string) (ZConfig, error) {
6766

6867
var c ZConfig
69-
var dir http.FileSystem = http.Dir(filepath.Dir(path))
70-
f, err := dir.Open(filepath.Base(path))
71-
if err != nil {
72-
if path != DefaultPath {
73-
return c, fmt.Errorf(i18n.G("failed to load configuration file %s: %v "), path, err)
74-
}
75-
log.Debug(ctx, i18n.G("couldn't find default configuration path, fallback to internal default"))
76-
if f, err = internalAssets.Open(filepath.Base(path)); err != nil {
77-
return c, fmt.Errorf(i18n.G("couldn't read our internal configuration: %v "), path, err)
78-
}
79-
}
80-
defer f.Close()
8168

82-
b, err := ioutil.ReadAll(f)
69+
b, err := os.ReadFile(path)
8370
if err != nil {
84-
return c, fmt.Errorf(i18n.G("failed to read configuration file %s: %v "), path, err)
71+
log.Debug(ctx, i18n.G("failed to read configuration file %s: %v "), path, err)
72+
log.Debug(ctx, i18n.G("couldn't find default configuration path, fallback to internal default"))
73+
b = internalconf
8574
}
8675

8776
err = yaml.Unmarshal(b, &c)

internal/config/generator.go

Lines changed: 0 additions & 28 deletions
This file was deleted.

internal/config/internalassets_vfsdata.go

Lines changed: 0 additions & 183 deletions
This file was deleted.

0 commit comments

Comments
 (0)