Skip to content
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

fix: bsf.hcl regeneration for oci tag #87

Merged
merged 1 commit into from
Jul 13, 2024
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
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
Loading