Compare commits

..

3 Commits

Author SHA1 Message Date
baa8e51b3e clean up some log messages
Some checks failed
Declarative Tests / test (push) Waiting to run
Lint / golangci-lint (push) Has been cancelled
2025-08-24 23:52:28 +00:00
7bc66cae90 add config block undefined err 2025-08-24 23:50:04 +00:00
6a8aa6c5a3 add target to install deps for alpine 2025-08-24 23:41:56 +00:00
3 changed files with 20 additions and 12 deletions

View File

@ -15,6 +15,12 @@ jx-cli:
test: jx-cli test: jx-cli
go test -coverprofile=artifacts/coverage.profile ./... go test -coverprofile=artifacts/coverage.profile ./...
go tool cover -html=artifacts/coverage.profile -o artifacts/code-coverage.html go tool cover -html=artifacts/coverage.profile -o artifacts/code-coverage.html
alpine-deps:
apk add make
apk add golangci-lint
apk add git
apk add luajit luajit-dev
apk add gpg gpg-agent
fedora-deps: fedora-deps:
./jx apply build/rpm.jx.yaml ./jx apply build/rpm.jx.yaml
spectool -g -R build/jx.spec spectool -g -R build/jx.spec

View File

@ -8,6 +8,7 @@ import (
var ( var (
ErrConfigUndefinedName = errors.New("Config block is missing a defined name") ErrConfigUndefinedName = errors.New("Config block is missing a defined name")
ErrConfigUndefined = errors.New("Config block is missing")
) )

View File

@ -27,6 +27,7 @@ import (
"strings" "strings"
"embed" "embed"
"compress/gzip" "compress/gzip"
"path/filepath"
) )
const ( const (
@ -99,7 +100,6 @@ type File struct {
FileType FileType `json:"filetype" yaml:"filetype"` FileType FileType `json:"filetype" yaml:"filetype"`
SerializeContent bool `json:"serializecontent,omitempty" yaml:"serializecontent,omitempty"` SerializeContent bool `json:"serializecontent,omitempty" yaml:"serializecontent,omitempty"`
GzipContent bool `json:"gzipcontent,omitempty" yaml:"gzipcontent,omitempty"` GzipContent bool `json:"gzipcontent,omitempty" yaml:"gzipcontent,omitempty"`
Resources data.ResourceMapper `json:"-" yaml:"-"`
} }
type ResourceFileInfo struct { type ResourceFileInfo struct {
@ -135,10 +135,6 @@ func (f *File) Init(u data.URIParser) error {
return f.SetParsedURI(u) return f.SetParsedURI(u)
} }
func (f *File) NormalizePath() error {
return f.Common.NormalizePath()
}
func (f *File) ContentType() string { func (f *File) ContentType() string {
var ext strings.Builder var ext strings.Builder
if f.parsedURI.Scheme != "file" { if f.parsedURI.Scheme != "file" {
@ -153,10 +149,6 @@ func (f *File) ContentType() string {
return ext.String() return ext.String()
} }
func (f *File) SetResourceMapper(resources data.ResourceMapper) {
f.Resources = resources
}
func (f *File) Clone() data.Resource { func (f *File) Clone() data.Resource {
return &File { return &File {
Common: f.Common.Clone(), Common: f.Common.Clone(),
@ -372,6 +364,15 @@ func (f *File) ResolveId(ctx context.Context) string {
return f.Common.Path return f.Common.Path
} }
func (f *File) NormalizePath() error {
if f.config != nil {
if prefixPath, configErr := f.config.GetValue("prefix"); configErr == nil {
f.Common.Path = filepath.Join(prefixPath.(string), f.Common.Path)
}
}
return f.Common.NormalizePath()
}
/* /*
func (f *File) NormalizePath() (err error) { func (f *File) NormalizePath() (err error) {
if f.config != nil { if f.config != nil {
@ -595,11 +596,11 @@ func (f *File) ContentSourceRefStat() (info fs.FileInfo) {
func (f *File) ReadStat() (err error) { func (f *File) ReadStat() (err error) {
var info fs.FileInfo var info fs.FileInfo
slog.Info("ReadStat()", "filesystem", f.Filesystem, "path", f.Common.Path) slog.Info("File.ReadStat()", "filesystem", f.Filesystem, "path", f.Common.Path)
info, err = f.Stat() info, err = f.Stat()
slog.Info("ReadStat()", "filesystem", f.Filesystem, "path", f.Common.Path, "info", info, "error", err) slog.Info("File.ReadStat()", "filesystem", f.Filesystem, "path", f.Common.Path, "info", info, "error", err)
if err == nil { if err == nil {
_ = f.SetFileInfo(info) _ = f.SetFileInfo(info)
@ -613,7 +614,7 @@ func (f *File) ReadStat() (err error) {
} }
slog.Info("ReadStat()", "stat", info, "path", f.Common.Path) slog.Info("File.ReadStat()", "stat", info, "path", f.Common.Path)
if err != nil { if err != nil {
f.Common.State = "absent" f.Common.State = "absent"
return return