-
Notifications
You must be signed in to change notification settings - Fork 264
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
Creates 'version.json' in each plugin directory. Closes #3492 #3494
Creates 'version.json' in each plugin directory. Closes #3492 #3494
Conversation
ce83acf
to
c1c1282
Compare
8f816ad
to
03bb3e8
Compare
This reverts commit d813338.
d813338
to
928a5fb
Compare
cmd/root.go
Outdated
@@ -96,6 +96,13 @@ var rootCmd = &cobra.Command{ | |||
// runScheduledTasks skips running tasks if this instance is the plugin manager | |||
waitForTasksChannel = runScheduledTasks(cmd.Context(), cmd, args, ew) | |||
|
|||
// decompose the plugin version file |
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.
what does // decompose the plugin version file
mean?
How about
// ensure all plugin installation directories have a version.json file
// (this is to handle the case of migrating an existing installation to v0.21)
cmd/root.go
Outdated
// no point doing this for the plugin-manager since that would have been done | ||
// by the initiating CLI process anyway |
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.
// no point doing this for the plugin-manager since that would have been done by the initiating CLI process
var versionFileUpdateLock = &sync.Mutex{} | ||
|
||
func updateVersionFilePlugin(image *SteampipeImage) error { | ||
func updatePluginVersionFiles(image *SteampipeImage) error { |
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.
comment - what does this function do
pkg/ociinstaller/plugin.go
Outdated
@@ -73,23 +72,31 @@ func updateVersionFilePlugin(image *SteampipeImage) error { | |||
|
|||
pluginFullName := image.ImageRef.DisplayImageRef() | |||
|
|||
plugin, ok := v.Plugins[pluginFullName] | |||
installation, ok := v.Plugins[pluginFullName] |
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.
what is installation
?
should it be installedVersion
pkg/ociinstaller/plugin.go
Outdated
|
||
v.Plugins[pluginFullName] = installation | ||
|
||
// Ensure that the version file is written. |
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.
// Ensure that the version file is written to the plugin installation folder
const ( | ||
PluginStructVersion = 20220411 | ||
pluginVersionFileName = "version.json" | ||
) | ||
|
||
type PluginVersionFile struct { |
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.
is this the top level version file?
a comment is probably worthwhile
@@ -37,26 +54,26 @@ func (f *PluginVersionFile) MigrateFrom() migrate.Migrateable { | |||
return f | |||
} | |||
|
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.
I'm not loving the force
}) | ||
|
||
if err != nil { | ||
log.Println("[TRACE]", "error while walking plugin directory for version files", err) |
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.
"recomposePluginVersionFile failed - error while walking plugin directory for version files", err)
pkg/plugin/actions.go
Outdated
item.Version = installation.Version | ||
// but if the modtime of the binary is after the installation date, | ||
// this is "local" | ||
installDate, err := time.Parse(time.RFC3339, installation.InstallDate) |
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.
can you extract a detectLocalPlugin
function to do most of this?
@@ -84,12 +101,109 @@ func (f *PluginVersionFile) write(path string) error { | |||
return os.WriteFile(path, versionFileJSON, 0644) | |||
} | |||
|
|||
// delete the file on disk if it exists | |||
func (f *PluginVersionFile) delete() { | |||
func (f *PluginVersionFile) backfill() error { |
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.
comment
I'm also not convince backfill is the best function name - can we be more descriptive?
No description provided.