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: fix go plugin log error #503

Merged
merged 1 commit into from
May 18, 2022
Merged

fix: fix go plugin log error #503

merged 1 commit into from
May 18, 2022

Conversation

aFlyBird0
Copy link
Member

Description

fix go plugin log error

Related Issues

#502

@daniel-hutao daniel-hutao self-requested a review May 18, 2022 05:31
@daniel-hutao
Copy link
Member

I have a question about this change: how to test it?

image

@IronCore864 @aFlyBird0

@daniel-hutao
Copy link
Member

@IronCore864 Should we delete the main()? I deleted it and don't saw any errors.

Maybe we can refactor all main.go with plugins like below:

package main

import (
	"github.com/devstream-io/devstream/internal/pkg/plugin/argocd"
)

// NAME is the name of this DevStream plugin.
const NAME = "argocd"

// Plugin is the type used by DevStream core. It's a string.
type Plugin string

// DevStreamPlugin is the exported variable used by the DevStream core.
var DevStreamPlugin Plugin

// Create implements the create of ArgoCD.
func (p Plugin) Create(options map[string]interface{}) (map[string]interface{}, error) {
	return argocd.Create(options)
}

// Update implements the update of ArgoCD.
func (p Plugin) Update(options map[string]interface{}) (map[string]interface{}, error) {
	return argocd.Update(options)
}

// Delete implements the delete of ArgoCD.
func (p Plugin) Delete(options map[string]interface{}) (bool, error) {
	return argocd.Delete(options)
}

// Read implements the read of ArgoCD.
func (p Plugin) Read(options map[string]interface{}) (map[string]interface{}, error) {
	return argocd.Read(options)
}

@daniel-hutao daniel-hutao requested a review from IronCore864 May 18, 2022 05:41
@aFlyBird0
Copy link
Member Author

In fact, this main function will not be executed. But it's really wrong.

from IronCore: we only have it there to shut the IDE warnings up

I guess it is used to avoid the waning of "unused var"?

@IronCore864
Copy link
Member

20220518-141505

golangci-lint would report an error if we deleted the main() func.

Also, my IDE (VSCode) would give an error because of lacking the main() func.

I suggest that we keep the main() func so that beginners have less questions when they just get started.

Copy link
Member

@daniel-hutao daniel-hutao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@daniel-hutao daniel-hutao merged commit 856207f into devstream-io:main May 18, 2022
@aFlyBird0 aFlyBird0 deleted the fix-plugin-log branch May 19, 2022 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants