Skip to content

Commit 5f295dc

Browse files
committed
fix update flow
Signed-off-by: mermerlin320 <mrmerlin320@gmail.com>
1 parent fc0b444 commit 5f295dc

File tree

1 file changed

+14
-39
lines changed
  • mesheryctl/internal/cli/root/registry

1 file changed

+14
-39
lines changed

mesheryctl/internal/cli/root/registry/update.go

Lines changed: 14 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
package registry
1616

1717
import (
18-
"bytes"
18+
// "bytes"
1919
"encoding/json"
2020
"fmt"
2121
"os"
@@ -195,45 +195,20 @@ func InvokeCompUpdate() error {
195195
utils.Log.Error(ErrUpdateComponent(err, modelName, component.Component))
196196
continue
197197
}
198-
tmpFilePath := filepath.Join(versionPath, "components", "tmp_model.json")
199-
200-
// Ensure the temporary file is removed regardless of what happens
201-
defer func() {
202-
_ = os.Remove(tmpFilePath)
203-
}()
204-
205-
if _, err := os.Stat(compPath); err == nil {
206-
existingData, err := os.ReadFile(compPath)
207-
if err != nil {
208-
utils.Log.Error(err)
209-
continue
210-
}
211-
212-
err = mutils.WriteJSONToFile[comp.ComponentDefinition](tmpFilePath, componentDef)
213-
if err != nil {
214-
utils.Log.Error(err)
215-
continue
216-
}
217-
218-
newData, err := os.ReadFile(tmpFilePath)
219-
if err != nil {
220-
utils.Log.Error(err)
221-
continue
222-
}
223-
224-
if bytes.Equal(existingData, newData) {
225-
utils.Log.Info("No changes detected for ", componentDef.Component.Kind)
226-
continue
227-
} else {
228-
err = mutils.WriteJSONToFile[comp.ComponentDefinition](compPath, componentDef)
229-
if err != nil {
230-
utils.Log.Error(err)
231-
continue
232-
}
233-
totalCompsUpdatedPerModelPerVersion++
234-
235-
}
198+
199+
_, err = os.Stat(compPath)
200+
201+
if err != nil {
202+
utils.Log.Error(err)
203+
continue
204+
}
205+
206+
err = mutils.WriteJSONToFile[comp.ComponentDefinition](compPath, componentDef)
207+
if err != nil {
208+
utils.Log.Error(err)
209+
continue
236210
}
211+
totalCompsUpdatedPerModelPerVersion++
237212
}
238213

239214
compUpdateArray = append(compUpdateArray, compUpdateTracker{

0 commit comments

Comments
 (0)