Skip to content

Commit

Permalink
Fix unwanted root in the manifest.
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Ortel <[email protected]>
  • Loading branch information
jortel committed Oct 16, 2023
1 parent 88d6518 commit 1be0f86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions cmd/ruleset/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (r *Cmd) Main() (err error) {
r.Path = *resources
r.Remote.URL = *remote
r.Remote.Ref = *ref
r.Manifest.Current.Root = *resources
r.Manifest.Current.root = *resources

fmt.Printf("\nResources: %s\n", *resources)
fmt.Printf("Remote: %s\n", *remote)
Expand Down Expand Up @@ -110,7 +110,7 @@ func (r *Cmd) Reconcile() (err error) {
if err != nil {
return
}
r.Manifest.Remote.Root = tmpDir
r.Manifest.Remote.root = tmpDir
err = r.Manifest.Remote.Build()
if err != nil {
return
Expand Down Expand Up @@ -165,7 +165,7 @@ func (r *Cmd) Apply() (err error) {

func (r *Cmd) ReplaceDir(ruleSet *pkg.RuleSet) (err error) {
bash := Bash{Silent: true}
remote := path.Join(r.Manifest.Remote.Root, ruleSet.Dir())
remote := path.Join(r.Manifest.Remote.root, ruleSet.Dir())
current := path.Join(r.Path, ruleSet.Dir())
err = bash.Run("rm -rf", current)
if err != nil {
Expand Down
12 changes: 6 additions & 6 deletions cmd/ruleset/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (

type Manifest struct {
pkg.Seed `yaml:",inline"`
Root string
root string
path string
ruleSets []*pkg.RuleSet
dirMap map[string]*pkg.RuleSet
Expand Down Expand Up @@ -70,7 +70,7 @@ func (r *Manifest) Write() (err error) {

func (r *Manifest) Build() (err error) {
r.dirMap = make(map[string]*pkg.RuleSet)
p := path.Join(r.Root, RuleSets)
p := path.Join(r.root, RuleSets)
entries, err := os.ReadDir(p)
if err != nil {
return
Expand Down Expand Up @@ -163,7 +163,7 @@ func (r *Manifest) Delete(ruleSet *pkg.RuleSet) {
}

func (r *Manifest) SetDetails(ruleSet *pkg.RuleSet) (err error) {
p := path.Join(r.Root, ruleSet.Dir(), "ruleset.yaml")
p := path.Join(r.root, ruleSet.Dir(), "ruleset.yaml")
object := struct {
Name string
Description string
Expand Down Expand Up @@ -195,7 +195,7 @@ func (r *Manifest) SetDetails(ruleSet *pkg.RuleSet) (err error) {
}

func (r *Manifest) SetDigest(ruleSet *pkg.RuleSet) (err error) {
p := path.Join(r.Root, ruleSet.Dir())
p := path.Join(r.root, ruleSet.Dir())
b, err := pkg.ChecksumDir(p)
if err == nil {
ruleSet.Checksum = hex.EncodeToString(b)
Expand Down Expand Up @@ -249,7 +249,7 @@ func (r *Manifest) Dirty() (b bool) {
}

func (r *Manifest) find() (err error) {
entries, err := os.ReadDir(r.Root)
entries, err := os.ReadDir(r.root)
if err != nil {
return
}
Expand All @@ -261,7 +261,7 @@ func (r *Manifest) find() (err error) {
if entry.IsDir() {
continue
}
r.path = path.Join(r.Root, entry.Name())
r.path = path.Join(r.root, entry.Name())
f, err = os.Open(r.path)
if err != nil {
return
Expand Down

0 comments on commit 1be0f86

Please sign in to comment.