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

Creates 'version.json' in each plugin directory. Closes #3492 #3494

Conversation

binaek
Copy link
Contributor

@binaek binaek commented May 29, 2023

No description provided.

@binaek binaek added the enhancement New feature or request label May 29, 2023
@binaek binaek added this to the 0.21.x milestone May 29, 2023
@binaek binaek self-assigned this May 29, 2023
@binaek binaek force-pushed the 3492-plugin-install-should-create-individual-version-files-along-side-the-plugin-binary branch 2 times, most recently from ce83acf to c1c1282 Compare June 7, 2023 12:52
@binaek binaek force-pushed the 3492-plugin-install-should-create-individual-version-files-along-side-the-plugin-binary branch from 8f816ad to 03bb3e8 Compare June 22, 2023 18:52
This reverts commit d813338.
@binaek binaek force-pushed the 3492-plugin-install-should-create-individual-version-files-along-side-the-plugin-binary branch from d813338 to 928a5fb Compare June 23, 2023 16:16
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
Copy link
Contributor

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
Comment on lines 100 to 101
// no point doing this for the plugin-manager since that would have been done
// by the initiating CLI process anyway
Copy link
Contributor

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 {
Copy link
Contributor

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

@@ -73,23 +72,31 @@ func updateVersionFilePlugin(image *SteampipeImage) error {

pluginFullName := image.ImageRef.DisplayImageRef()

plugin, ok := v.Plugins[pluginFullName]
installation, ok := v.Plugins[pluginFullName]
Copy link
Contributor

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


v.Plugins[pluginFullName] = installation

// Ensure that the version file is written.
Copy link
Contributor

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 {
Copy link
Contributor

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
}

Copy link
Contributor

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)
Copy link
Contributor

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)

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)
Copy link
Contributor

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 {
Copy link
Contributor

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?

@kaidaguerre kaidaguerre merged commit 9754ed0 into main Jun 30, 2023
50 checks passed
@kaidaguerre kaidaguerre deleted the 3492-plugin-install-should-create-individual-version-files-along-side-the-plugin-binary branch June 30, 2023 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugin install should create individual version files along side the plugin binary
2 participants