-
Notifications
You must be signed in to change notification settings - Fork 220
enable ability to index new chart data for the same chart version #556
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,4 +57,5 @@ type chartFiles struct { | |
Readme string | ||
Values string | ||
Repo repo | ||
Digest string | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -315,7 +315,7 @@ func fetchAndImportFiles(dbSession datastore.Session, name string, r repo, cv ch | |
chartFilesID := fmt.Sprintf("%s/%s-%s", r.Name, name, cv.Version) | ||
db, closer := dbSession.DB() | ||
defer closer() | ||
if err := db.C(chartFilesCollection).FindId(chartFilesID).One(&chartFiles{}); err == nil { | ||
if err := db.C(chartFilesCollection).Find(bson.M{"_id": chartFilesID, "digest": cv.Digest}).One(&chartFiles{}); err == nil { | ||
log.WithFields(log.Fields{"name": name, "version": cv.Version}).Debug("skipping existing files") | ||
return nil | ||
} | ||
|
@@ -357,7 +357,7 @@ func fetchAndImportFiles(dbSession datastore.Session, name string, r repo, cv ch | |
return err | ||
} | ||
|
||
chartFiles := chartFiles{ID: chartFilesID, Repo: r} | ||
chartFiles := chartFiles{ID: chartFilesID, Repo: r, Digest: cv.Digest} | ||
if v, ok := files[readmeFileName]; ok { | ||
chartFiles.Readme = v | ||
} else { | ||
|
@@ -369,7 +369,7 @@ func fetchAndImportFiles(dbSession datastore.Session, name string, r repo, cv ch | |
log.WithFields(log.Fields{"name": name, "version": cv.Version}).Info("values.yaml not found") | ||
} | ||
|
||
db.C(chartFilesCollection).Insert(chartFiles) | ||
db.C(chartFilesCollection).UpsertId(chartFilesID, chartFiles) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here, explaining that if we get to this point is because we either don't have a chart for that version, or we do have it but with different digest. I personally don't like upserts much in general because its context sometimes can be difficult to understand, also, in some cases it could cause side effects. In any case, a comment like my suggestion above might be enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree in some cases, but I think in this case it should be fine since we are updating the entry with a full struct, and not doing a partial update. |
||
|
||
return nil | ||
} | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind adding a comment explaining the logic behind this query?