Skip to content

Commit dfbbe6e

Browse files
authored
refactor: implements overlay fs in all packages (#151)
1 parent 29b58e3 commit dfbbe6e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+701
-568
lines changed

cli/cmd/cmds/dump.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55

66
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
7+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
78
)
89

910
type DumpCmd struct {
@@ -12,6 +13,13 @@ type DumpCmd struct {
1213
}
1314

1415
func (c *DumpCmd) Run(ctx run.RunContext) error {
16+
exists, err := fs.Exists(c.Project)
17+
if err != nil {
18+
return fmt.Errorf("could not check if project exists: %w", err)
19+
} else if !exists {
20+
return fmt.Errorf("project does not exist: %s", c.Project)
21+
}
22+
1523
project, err := ctx.ProjectLoader.Load(c.Project)
1624
if err != nil {
1725
return fmt.Errorf("could not load project: %w", err)

cli/cmd/cmds/module/deploy.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
88
"github.com/input-output-hk/catalyst-forge/lib/project/deployment"
99
"github.com/input-output-hk/catalyst-forge/lib/project/deployment/deployer"
10+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
1011
)
1112

1213
type DeployCmd struct {
@@ -15,6 +16,13 @@ type DeployCmd struct {
1516
}
1617

1718
func (c *DeployCmd) Run(ctx run.RunContext) error {
19+
exists, err := fs.Exists(c.Project)
20+
if err != nil {
21+
return fmt.Errorf("could not check if project exists: %w", err)
22+
} else if !exists {
23+
return fmt.Errorf("project does not exist: %s", c.Project)
24+
}
25+
1826
project, err := ctx.ProjectLoader.Load(c.Project)
1927
if err != nil {
2028
return fmt.Errorf("could not load project: %w", err)

cli/cmd/cmds/module/dump.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ import (
55

66
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
77
"github.com/input-output-hk/catalyst-forge/lib/project/deployment"
8+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
89
)
910

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

1415
func (c *DumpCmd) Run(ctx run.RunContext) error {
16+
exists, err := fs.Exists(c.Project)
17+
if err != nil {
18+
return fmt.Errorf("could not check if project exists: %w", err)
19+
} else if !exists {
20+
return fmt.Errorf("project does not exist: %s", c.Project)
21+
}
22+
1523
project, err := ctx.ProjectLoader.Load(c.Project)
1624
if err != nil {
1725
return fmt.Errorf("could not load project: %w", err)

cli/cmd/cmds/release.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/input-output-hk/catalyst-forge/cli/pkg/release"
77
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
8+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
89
)
910

1011
type ReleaseCmd struct {
@@ -14,6 +15,13 @@ type ReleaseCmd struct {
1415
}
1516

1617
func (c *ReleaseCmd) Run(ctx run.RunContext) error {
18+
exists, err := fs.Exists(c.Project)
19+
if err != nil {
20+
return fmt.Errorf("could not check if project exists: %w", err)
21+
} else if !exists {
22+
return fmt.Errorf("project does not exist: %s", c.Project)
23+
}
24+
1725
project, err := ctx.ProjectLoader.Load(c.Project)
1826
if err != nil {
1927
return err

cli/cmd/cmds/scan.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
1111
"github.com/input-output-hk/catalyst-forge/cli/pkg/scan"
1212
"github.com/input-output-hk/catalyst-forge/cli/pkg/utils"
13+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
1314
"golang.org/x/exp/maps"
1415
)
1516

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

38+
exists, err := fs.Exists(rootPath)
39+
if err != nil {
40+
return fmt.Errorf("could not check if root path exists: %w", err)
41+
} else if !exists {
42+
return fmt.Errorf("root path does not exist: %s", rootPath)
43+
}
44+
3745
projects, err := scan.ScanProjects(rootPath, ctx.ProjectLoader, &ctx.FSWalker, ctx.Logger)
3846
if err != nil {
3947
return err

cli/cmd/cmds/secret.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/input-output-hk/catalyst-forge/cli/pkg/utils"
1010
"github.com/input-output-hk/catalyst-forge/lib/project/secrets"
1111
sc "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/common"
12+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
1213
)
1314

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

4344
if c.Project != "" {
45+
exists, err := fs.Exists(c.Project)
46+
if err != nil {
47+
return fmt.Errorf("could not check if project exists: %w", err)
48+
} else if !exists {
49+
return fmt.Errorf("project does not exist: %s", c.Project)
50+
}
51+
4452
project, err := ctx.ProjectLoader.Load(c.Project)
4553
if err != nil {
4654
return fmt.Errorf("could not load project: %w", err)
@@ -127,6 +135,13 @@ func (c *Set) Run(ctx run.RunContext) error {
127135
var path, provider string
128136

129137
if c.Project != "" {
138+
exists, err := fs.Exists(c.Project)
139+
if err != nil {
140+
return fmt.Errorf("could not check if project exists: %w", err)
141+
} else if !exists {
142+
return fmt.Errorf("project does not exist: %s", c.Project)
143+
}
144+
130145
project, err := ctx.ProjectLoader.Load(c.Project)
131146
if err != nil {
132147
return fmt.Errorf("could not load project: %w", err)

cli/cmd/cmds/validate.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
package cmds
22

33
import (
4+
"fmt"
5+
46
"github.com/input-output-hk/catalyst-forge/cli/pkg/run"
7+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
58
)
69

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

1114
func (c *ValidateCmd) Run(ctx run.RunContext) error {
12-
_, err := ctx.ProjectLoader.Load(c.Project)
15+
exists, err := fs.Exists(c.Project)
16+
if err != nil {
17+
return fmt.Errorf("could not check if project exists: %w", err)
18+
} else if !exists {
19+
return fmt.Errorf("project does not exist: %s", c.Project)
20+
}
21+
22+
_, err = ctx.ProjectLoader.Load(c.Project)
1323
if err != nil {
1424
return err
1525
}

cli/go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ require (
2020
github.com/migueleliasweb/go-github-mock v1.0.1
2121
github.com/posener/complete v1.2.3
2222
github.com/rogpeppe/go-internal v1.13.2-0.20241226121412-a5dc8ff20d0a
23-
github.com/spf13/afero v1.11.0
2423
github.com/stretchr/testify v1.10.0
2524
github.com/willabides/kongplete v0.4.0
2625
golang.org/x/exp v0.0.0-20241009180824-f66d83c29e7c
@@ -241,7 +240,6 @@ require (
241240
google.golang.org/protobuf v1.35.2 // indirect
242241
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
243242
gopkg.in/inf.v0 v0.9.1 // indirect
244-
gopkg.in/jfontan/go-billy-desfacer.v0 v0.0.0-20210209210102-b43512b1cad0 // indirect
245243
gopkg.in/warnings.v0 v0.1.2 // indirect
246244
gopkg.in/yaml.v3 v3.0.1 // indirect
247245
helm.sh/helm/v3 v3.17.0 // indirect

cli/go.sum

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,6 @@ github.com/containers/storage v1.56.0/go.mod h1:c6WKowcAlED/DkWGNuL9bvGYqIWCVy7i
357357
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
358358
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
359359
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
360-
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
361360
github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
362361
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
363362
github.com/cyphar/filepath-securejoin v0.3.6 h1:4d9N5ykBnSp5Xn2JkhocYDkOpURL/18CYMpo6xB9uWM=
@@ -442,7 +441,6 @@ github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxI
442441
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
443442
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI=
444443
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
445-
github.com/go-git/go-billy/v5 v5.0.0/go.mod h1:pmpqyWchKfYfrkb/UVH4otLvyi/5gJlGI4Hb3ZqZ3W0=
446444
github.com/go-git/go-billy/v5 v5.5.0 h1:yEY4yhzCDuMGSv83oGxiBotRzhwhNr8VZyphhiu+mTU=
447445
github.com/go-git/go-billy/v5 v5.5.0/go.mod h1:hmexnoNsr2SJU1Ju67OaNz5ASJY3+sHgFRpCtpDCKow=
448446
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMje31YglSBqCdIqdhKBW8lokaMrL3uTkpGYlE2OOT4=
@@ -680,10 +678,8 @@ github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90
680678
github.com/klauspost/pgzip v1.2.6 h1:8RXeL5crjEUFnR2/Sn6GJNWtSQ3Dk8pq4CL3jvdDyjU=
681679
github.com/klauspost/pgzip v1.2.6/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs=
682680
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
683-
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
684681
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
685682
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
686-
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
687683
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
688684
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
689685
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -775,7 +771,6 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m
775771
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
776772
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus=
777773
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw=
778-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
779774
github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg=
780775
github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo=
781776
github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw=
@@ -799,10 +794,8 @@ github.com/phayes/freeport v0.0.0-20220201140144-74d24b5ae9f5/go.mod h1:iIss55rK
799794
github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4=
800795
github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI=
801796
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
802-
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
803797
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
804798
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
805-
github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI=
806799
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
807800
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
808801
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -861,9 +854,6 @@ github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVs
861854
github.com/skeema/knownhosts v1.2.2 h1:Iug2P4fLmDw9f41PB6thxUkNUkJzB5i+1/exaj40L3A=
862855
github.com/skeema/knownhosts v1.2.2/go.mod h1:xYbVRSPxqBZFrdmDyMmsOs+uX1UZC3nTN3ThzgDxUwo=
863856
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
864-
github.com/spf13/afero v1.5.1/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
865-
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
866-
github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
867857
github.com/spf13/cast v1.7.0 h1:ntdiHjuueXFgm5nzDRdOS4yfT43P5Fnud6DH50rz/7w=
868858
github.com/spf13/cast v1.7.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
869859
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
@@ -965,7 +955,6 @@ golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnf
965955
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
966956
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
967957
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
968-
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
969958
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
970959
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
971960
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
@@ -1509,7 +1498,6 @@ gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLks
15091498
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15101499
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15111500
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
1512-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
15131501
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
15141502
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
15151503
gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw=
@@ -1518,8 +1506,6 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
15181506
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
15191507
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
15201508
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
1521-
gopkg.in/jfontan/go-billy-desfacer.v0 v0.0.0-20210209210102-b43512b1cad0 h1:RAPPCkBPBHlvlpW08F2O89GdvRaPxsmMpLNajhP+OHk=
1522-
gopkg.in/jfontan/go-billy-desfacer.v0 v0.0.0-20210209210102-b43512b1cad0/go.mod h1:CQMKdTNOicrocr1TkOB2H1X3ARIYOjLnlr1cFxGigxQ=
15231509
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
15241510
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
15251511
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

cli/pkg/release/providers/cue.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import (
1717
"github.com/input-output-hk/catalyst-forge/lib/schema"
1818
sp "github.com/input-output-hk/catalyst-forge/lib/schema/blueprint/project"
1919
lc "github.com/input-output-hk/catalyst-forge/lib/tools/cue"
20-
"github.com/spf13/afero"
20+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs"
21+
"github.com/input-output-hk/catalyst-forge/lib/tools/fs/billy"
2122
)
2223

2324
const CUE_BINARY = "cue"
@@ -31,7 +32,7 @@ type CueReleaser struct {
3132
cue executor.WrappedExecuter
3233
ecr aws.ECRClient
3334
force bool
34-
fs afero.Fs
35+
fs fs.Filesystem
3536
handler events.EventHandler
3637
logger *slog.Logger
3738
project project.Project
@@ -96,14 +97,14 @@ func (r *CueReleaser) Release() error {
9697
// loadModule loads the CUE module file.
9798
func (r *CueReleaser) loadModule() (string, error) {
9899
modulePath := filepath.Join(r.project.Path, "cue.mod", "module.cue")
99-
if exists, err := afero.Exists(r.fs, modulePath); err != nil {
100+
if exists, err := r.fs.Exists(modulePath); err != nil {
100101
return "", fmt.Errorf("failed to check if module file exists: %w", err)
101102
} else if !exists {
102103
return "", fmt.Errorf("module file does not exist: %s", modulePath)
103104
}
104105

105106
r.logger.Info("Loading module", "path", modulePath)
106-
contents, err := afero.ReadFile(r.fs, modulePath)
107+
contents, err := r.fs.ReadFile(modulePath)
107108
if err != nil {
108109
return "", fmt.Errorf("failed to read module file: %w", err)
109110
}
@@ -157,7 +158,7 @@ func NewCueReleaser(ctx run.RunContext,
157158
config: config,
158159
cue: cue,
159160
ecr: ecr,
160-
fs: afero.NewOsFs(),
161+
fs: billy.NewBaseOsFS(),
161162
force: force,
162163
handler: &handler,
163164
logger: ctx.Logger,

0 commit comments

Comments
 (0)