Skip to content

Commit

Permalink
Merge pull request #254 from xnox/port-to-embed
Browse files Browse the repository at this point in the history
Port from vfs to embed
  • Loading branch information
xnox authored Jan 4, 2024
2 parents 1288669 + 25f2b31 commit 7543cff
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 273 deletions.
36 changes: 0 additions & 36 deletions .github/ci/check-generate

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/repo-quality.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ jobs:
GOPATH=`pwd` go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && \
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
cd -
- name: Check generated files
run: PATH=../bin:$PATH ./.github/ci/check-generate
extended-quality:
name: Extended quality checks
Expand Down
1 change: 1 addition & 0 deletions debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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

# Tell go generate to only install on-the-fly assets
export ZSYS_GENERATE_ONLY_INSTALL_SHARE_PREFIX=$(CURDIR)/debian/zsys/usr/share
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ require (
github.com/godbus/dbus/v5 v5.1.0
github.com/google/go-cmp v0.5.9
github.com/k0kubun/pp v3.0.1+incompatible
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92
github.com/sirupsen/logrus v1.9.3
github.com/snapcore/go-gettext v0.0.0-20201130093759-38740d1bd3d2
github.com/spf13/cobra v1.7.0
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c h1:aqg5Vm5dwtvL+YgDpBcK1ITf3o96N/K7/wsRXQnUTEs=
github.com/shurcooL/httpfs v0.0.0-20230704072500-f1e31cf0ba5c/go.mod h1:owqhoLW1qZoYLZzLnBw+QkPP9WZnjlSWihhxAJC1+/M=
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92 h1:OfRzdxCzDhp+rsKWXuOO2I/quKMJ/+TQwVbIP/gltZg=
github.com/shurcooL/vfsgen v0.0.0-20230704071429-0000e147ea92/go.mod h1:7/OT02F6S6I7v6WXb+IjhMuZEYfH/RJ5RwEWnEo5BMg=
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/snapcore/go-gettext v0.0.0-20201130093759-38740d1bd3d2 h1:nETXPg0CiJrMAwC2gqkcam9BiBWYGvTsSYRfrjOz2Kg=
Expand Down
25 changes: 7 additions & 18 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@ package config

import (
"context"
_ "embed"
"fmt"
"io/ioutil"
"net/http"
"os"
"path/filepath"

"github.com/ubuntu/zsys/internal/i18n"
"github.com/ubuntu/zsys/internal/log"
yaml "gopkg.in/yaml.v3"
)

//go:generate go run generator.go
//go:embed zsys.conf
var internalconf []byte

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

var c ZConfig
var dir http.FileSystem = http.Dir(filepath.Dir(path))
f, err := dir.Open(filepath.Base(path))
if err != nil {
if path != DefaultPath {
return c, fmt.Errorf(i18n.G("failed to load configuration file %s: %v "), path, err)
}
log.Debug(ctx, i18n.G("couldn't find default configuration path, fallback to internal default"))
if f, err = internalAssets.Open(filepath.Base(path)); err != nil {
return c, fmt.Errorf(i18n.G("couldn't read our internal configuration: %v "), path, err)
}
}
defer f.Close()

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

err = yaml.Unmarshal(b, &c)
Expand Down
28 changes: 0 additions & 28 deletions internal/config/generator.go

This file was deleted.

183 changes: 0 additions & 183 deletions internal/config/internalassets_vfsdata.go

This file was deleted.

0 comments on commit 7543cff

Please sign in to comment.