Skip to content

refactor: implements overlay fs in all packages #151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cli/cmd/cmds/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"

"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
)

type DumpCmd struct {
Expand All @@ -12,6 +13,13 @@ type DumpCmd struct {
}

func (c *DumpCmd) Run(ctx run.RunContext) error {
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

project, err := ctx.ProjectLoader.Load(c.Project)
if err != nil {
return fmt.Errorf("could not load project: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions cli/cmd/cmds/module/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
"github.com/input-output-hk/catalyst-forge/lib/project/deployment"
"github.com/input-output-hk/catalyst-forge/lib/project/deployment/deployer"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
)

type DeployCmd struct {
Expand All @@ -15,6 +16,13 @@ type DeployCmd struct {
}

func (c *DeployCmd) Run(ctx run.RunContext) error {
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

project, err := ctx.ProjectLoader.Load(c.Project)
if err != nil {
return fmt.Errorf("could not load project: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions cli/cmd/cmds/module/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ import (

"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
"github.com/input-output-hk/catalyst-forge/lib/project/deployment"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
)

type DumpCmd struct {
Project string `arg:"" help:"The path to the project to dump." kong:"arg,predictor=path"`
}

func (c *DumpCmd) Run(ctx run.RunContext) error {
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

project, err := ctx.ProjectLoader.Load(c.Project)
if err != nil {
return fmt.Errorf("could not load project: %w", err)
Expand Down
8 changes: 8 additions & 0 deletions cli/cmd/cmds/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/input-output-hk/catalyst-forge/cli/pkg/release"
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
)

type ReleaseCmd struct {
Expand All @@ -14,6 +15,13 @@ type ReleaseCmd struct {
}

func (c *ReleaseCmd) Run(ctx run.RunContext) error {
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

project, err := ctx.ProjectLoader.Load(c.Project)
if err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions cli/cmd/cmds/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
"github.com/input-output-hk/catalyst-forge/cli/pkg/scan"
"github.com/input-output-hk/catalyst-forge/cli/pkg/utils"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
"golang.org/x/exp/maps"
)

Expand All @@ -34,6 +35,13 @@ func (c *ScanCmd) Run(ctx run.RunContext) error {
rootPath = c.RootPath
}

exists, err := fs.Exists(rootPath)
if err != nil {
return fmt.Errorf("could not check if root path exists: %w", err)
} else if !exists {
return fmt.Errorf("root path does not exist: %s", rootPath)
}

projects, err := scan.ScanProjects(rootPath, ctx.ProjectLoader, &ctx.FSWalker, ctx.Logger)
if err != nil {
return err
Expand Down
15 changes: 15 additions & 0 deletions cli/cmd/cmds/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/input-output-hk/catalyst-forge/cli/pkg/utils"
"github.com/input-output-hk/catalyst-forge/lib/project/secrets"
sc "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/common"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
)

const (
Expand Down Expand Up @@ -41,6 +42,13 @@ func (c *Get) Run(ctx run.RunContext) error {
var maps map[string]string

if c.Project != "" {
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

project, err := ctx.ProjectLoader.Load(c.Project)
if err != nil {
return fmt.Errorf("could not load project: %w", err)
Expand Down Expand Up @@ -127,6 +135,13 @@ func (c *Set) Run(ctx run.RunContext) error {
var path, provider string

if c.Project != "" {
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

project, err := ctx.ProjectLoader.Load(c.Project)
if err != nil {
return fmt.Errorf("could not load project: %w", err)
Expand Down
12 changes: 11 additions & 1 deletion cli/cmd/cmds/validate.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
package cmds

import (
"fmt"

"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
)

type ValidateCmd struct {
Project string `kong:"arg,predictor=path" help:"Path to the project."`
}

func (c *ValidateCmd) Run(ctx run.RunContext) error {
_, err := ctx.ProjectLoader.Load(c.Project)
exists, err := fs.Exists(c.Project)
if err != nil {
return fmt.Errorf("could not check if project exists: %w", err)
} else if !exists {
return fmt.Errorf("project does not exist: %s", c.Project)
}

_, err = ctx.ProjectLoader.Load(c.Project)
if err != nil {
return err
}
Expand Down
2 changes: 0 additions & 2 deletions cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/migueleliasweb/go-github-mock v1.0.1
github.com/posener/complete v1.2.3
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a
github.com/spf13/afero v1.11.0
github.com/stretchr/testify v1.10.0
github.com/willabides/kongplete v0.4.0
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
Expand Down Expand Up @@ -241,7 +240,6 @@ require (
google.golang.org/protobuf v1.35.2 // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/jfontan/go-billy-desfacer.v0 v0.0.0-20210209210102-b43512b1cad0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
helm.sh/helm/v3 v3.17.0 // indirect
Expand Down
14 changes: 0 additions & 14 deletions cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ github.com/containers/storage v1.56.0/go.mod h1:c6WKowcAlED/DkWGNuL9bvGYqIWCVy7i
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM=
Expand Down Expand Up @@ -442,7 +441,6 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
Expand Down Expand Up @@ -680,10 +678,8 @@ github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
Expand Down Expand Up @@ -775,7 +771,6 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
Expand All @@ -799,10 +794,8 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down Expand Up @@ -861,9 +854,6 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
github.com/spf13/afero v1.5.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
Expand Down Expand Up @@ -965,7 +955,6 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
Expand Down Expand Up @@ -1509,7 +1498,6 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
Expand All @@ -1518,8 +1506,6 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/jfontan/go-billy-desfacer.v0 v0.0.0-20210209210102-b43512b1cad0 h1:RAPPCkBPBHlvlpW08F2O89GdvRaPxsmMpLNajhP+OHk=
gopkg.in/jfontan/go-billy-desfacer.v0 v0.0.0-20210209210102-b43512b1cad0/go.mod h1:CQMKdTNOicrocr1TkOB2H1X3ARIYOjLnlr1cFxGigxQ=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
11 changes: 6 additions & 5 deletions cli/pkg/release/providers/cue.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
"github.com/input-output-hk/catalyst-forge/lib/schema"
sp "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/project"
lc "github.com/input-output-hk/catalyst-forge/lib/tools/cue"
"github.com/spf13/afero"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs/billy"
)

const CUE_BINARY = "cue"
Expand All @@ -31,7 +32,7 @@ type CueReleaser struct {
cue executor.WrappedExecuter
ecr aws.ECRClient
force bool
fs afero.Fs
fs fs.Filesystem
handler events.EventHandler
logger *slog.Logger
project project.Project
Expand Down Expand Up @@ -96,14 +97,14 @@ func (r *CueReleaser) Release() error {
// loadModule loads the CUE module file.
func (r *CueReleaser) loadModule() (string, error) {
modulePath := filepath.Join(r.project.Path, "cue.mod", "module.cue")
if exists, err := afero.Exists(r.fs, modulePath); err != nil {
if exists, err := r.fs.Exists(modulePath); err != nil {
return "", fmt.Errorf("failed to check if module file exists: %w", err)
} else if !exists {
return "", fmt.Errorf("module file does not exist: %s", modulePath)
}

r.logger.Info("Loading module", "path", modulePath)
contents, err := afero.ReadFile(r.fs, modulePath)
contents, err := r.fs.ReadFile(modulePath)
if err != nil {
return "", fmt.Errorf("failed to read module file: %w", err)
}
Expand Down Expand Up @@ -157,7 +158,7 @@ func NewCueReleaser(ctx run.RunContext,
config: config,
cue: cue,
ecr: ecr,
fs: afero.NewOsFs(),
fs: billy.NewBaseOsFS(),
force: force,
handler: &handler,
logger: ctx.Logger,
Expand Down
4 changes: 2 additions & 2 deletions cli/pkg/release/providers/cue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import (
sg "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/global"
spr "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/global/providers"
sp "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/project"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs/billy"
"github.com/input-output-hk/catalyst-forge/lib/tools/testutils"
"github.com/spf13/afero"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down Expand Up @@ -175,7 +175,7 @@ func TestCueReleaserRelease(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
fs := afero.NewMemMapFs()
fs := billy.NewInMemoryFs()
testutils.SetupFS(t, fs, tt.files)

var repoName string
Expand Down
13 changes: 7 additions & 6 deletions cli/pkg/release/providers/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import (
"github.com/input-output-hk/catalyst-forge/lib/project/providers"
sp "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/project"
"github.com/input-output-hk/catalyst-forge/lib/tools/archive"
"github.com/spf13/afero"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
"github.com/input-output-hk/catalyst-forge/lib/tools/fs/billy"
)

type GithubReleaserConfig struct {
Expand All @@ -27,7 +28,7 @@ type GithubReleaser struct {
client *github.Client
config GithubReleaserConfig
force bool
fs afero.Fs
fs fs.Filesystem
handler events.EventHandler
logger *slog.Logger
project project.Project
Expand Down Expand Up @@ -151,14 +152,14 @@ func (r *GithubReleaser) validateArtifacts(path string) error {
for _, platform := range r.getPlatforms() {
r.logger.Info("Validating artifacts", "platform", platform)
path := filepath.Join(path, platform)
exists, err := afero.DirExists(r.fs, path)
exists, err := r.fs.Exists(path)
if err != nil {
return fmt.Errorf("failed to check if output folder exists: %w", err)
} else if !exists {
return fmt.Errorf("unable to find output folder for platform: %s", path)
}

children, err := afero.ReadDir(r.fs, path)
children, err := r.fs.ReadDir(path)
if err != nil {
return fmt.Errorf("failed to read output folder: %w", err)
}
Expand Down Expand Up @@ -198,8 +199,8 @@ func NewGithubReleaser(
return nil, fmt.Errorf("failed to parse release config: %w", err)
}

fs := afero.NewOsFs()
workdir, err := afero.TempDir(fs, "", "catalyst-forge-")
fs := billy.NewBaseOsFS()
workdir, err := fs.TempDir("", "catalyst-forge-")
if err != nil {
return nil, fmt.Errorf("failed to create temporary directory: %w", err)
}
Expand Down
Loading