Skip to content

Commit

Permalink
Merge pull request #151 from Jougan-0/UpdateWriteFunction
Browse files Browse the repository at this point in the history
Update write function
  • Loading branch information
leecalcote authored Aug 24, 2024
2 parents 96371fe + de3e4ac commit 424fb69
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions models/v1beta1/component/component_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package component

import (
"fmt"
"os"
"path/filepath"

"github.com/gofrs/uuid"
Expand Down Expand Up @@ -64,11 +65,14 @@ func (m *ComponentDefinition) UpdateStatus(db *database.Handler, status entity.E
return nil
}

func (c ComponentDefinition) WriteComponentDefinition(componentDirPath string) error {
func (c ComponentDefinition) WriteComponentDefinition(componentDirPath string) (bool, error) {
if c.Component.Kind == "" {
return nil
return false, nil
}
componentPath := filepath.Join(componentDirPath, c.Component.Kind+".json")
err := utils.WriteJSONToFile[ComponentDefinition](componentPath, c)
return err
if _, err := os.Stat(componentPath); err != nil {
err := utils.WriteJSONToFile[ComponentDefinition](componentPath, c)
return false, err
}
return true, nil
}

0 comments on commit 424fb69

Please sign in to comment.