Skip to content

Commit

Permalink
fix: bsf.hcl regeneration for oci tag
Browse files Browse the repository at this point in the history
Signed-off-by: Rakshit Gondwal <rakshitgondwal3@gmail.com>
  • Loading branch information
rakshitgondwal committed Jul 13, 2024
1 parent 7cf0ef0 commit 85635d9
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 33 deletions.
6 changes: 0 additions & 6 deletions cmd/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ var OCICmd = &cobra.Command{
fmt.Println(styles.ErrorStyle.Render("error: ", err.Error()))
os.Exit(1)
}
oldName := artifact.Name
artifact.Name = newName
err = hcl2nix.ModifyConfig(oldName, artifact, conf)
if err != nil {
fmt.Println(styles.ErrorStyle.Render("error: ", err.Error()))
os.Exit(1)
}
}

if dfSwap {
Expand Down
27 changes: 0 additions & 27 deletions pkg/hcl2nix/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,33 +68,6 @@ func WriteConfig(config Config, wr io.Writer) error {
return nil
}

// ModifyConfig modifes the config
func ModifyConfig(oldName string, artifact OCIArtifact, config *Config) error {
updated := false
for i, existingArtifact := range config.OCIArtifact {
if existingArtifact.Name == oldName {
config.OCIArtifact[i] = artifact
updated = true
break
}
}

if updated {
var buf bytes.Buffer
err := WriteConfig(*config, &buf)
if err != nil {
return err
}

err = os.WriteFile("bsf.hcl", buf.Bytes(), 0644)
if err != nil {
return err
}
}

return nil
}

// ReadConfig reads config from bytes and returns Config. If any errors are encountered, they are written to dstErr
func ReadConfig(src []byte, dstErr io.Writer) (*Config, error) {
parser := hclparse.NewParser()
Expand Down

0 comments on commit 85635d9

Please sign in to comment.