Skip to content

Conversation

summingyu
Copy link

Description

new develop validate-plugin command,

  1. add MustExistFlag bool to TplFile and File struct of internal/pkg/develop/plugin/template/template.go
  2. add var xxx_go_mustExistFlag = true to internal/pkg/develop/plugin/template/create.go and some need validate file
  3. Render template files
  4. Validate need validate files
  5. if MustExistFlag is true, validate file.Dir and file.Name

Related Issues

#436

Screenshots

$ for plugin in `./dtm list plugins`;do ./dtm develop validate-plugin --name="$plugin" 2>&1;done
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/argocd/argocd.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/argocd/argocd.go: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin argocd passed validatio process: 10/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ℹ [INFO]  Plugin argocdapp passed validatio process: 11/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ℹ [INFO]  Plugin devlake passed validatio process: 11/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/github-repo-scaffolding-golang/github-repo-scaffolding-golang.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/github-repo-scaffolding-golang/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/github-repo-scaffolding-golang/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/github-repo-scaffolding-golang/: no such file or directory;
stat internal/pkg/plugin/github-repo-scaffolding-golang/: no such file or directory;
stat internal/pkg/plugin/github-repo-scaffolding-golang/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin github-repo-scaffolding-golang passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-golang/githubactions-golang.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-golang/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-golang/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/githubactions-golang/: no such file or directory;
stat internal/pkg/plugin/githubactions-golang/: no such file or directory;
stat internal/pkg/plugin/githubactions-golang/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin githubactions-golang passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-nodejs/githubactions-nodejs.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-nodejs/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-nodejs/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/githubactions-nodejs/: no such file or directory;
stat internal/pkg/plugin/githubactions-nodejs/: no such file or directory;
stat internal/pkg/plugin/githubactions-nodejs/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin githubactions-nodejs passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-python/githubactions-python.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-python/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/githubactions-python/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/githubactions-python/: no such file or directory;
stat internal/pkg/plugin/githubactions-python/: no such file or directory;
stat internal/pkg/plugin/githubactions-python/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin githubactions-python passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlab-repo-scaffolding-golang/gitlab-repo-scaffolding-golang.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlab-repo-scaffolding-golang/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlab-repo-scaffolding-golang/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/gitlab-repo-scaffolding-golang/: no such file or directory;
stat internal/pkg/plugin/gitlab-repo-scaffolding-golang/: no such file or directory;
stat internal/pkg/plugin/gitlab-repo-scaffolding-golang/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin gitlab-repo-scaffolding-golang passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlabci-generic/gitlabci-generic.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlabci-generic/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlabci-generic/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/gitlabci-generic/: no such file or directory;
stat internal/pkg/plugin/gitlabci-generic/: no such file or directory;
stat internal/pkg/plugin/gitlabci-generic/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin gitlabci-generic passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlabci-golang/gitlabci-golang.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlabci-golang/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/gitlabci-golang/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/gitlabci-golang/: no such file or directory;
stat internal/pkg/plugin/gitlabci-golang/: no such file or directory;
stat internal/pkg/plugin/gitlabci-golang/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin gitlabci-golang passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/hashicorp-vault/hashicorp-vault.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/hashicorp-vault/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/hashicorp-vault/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/hashicorp-vault/: no such file or directory;
stat internal/pkg/plugin/hashicorp-vault/: no such file or directory;
stat internal/pkg/plugin/hashicorp-vault/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin hashicorp-vault passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/jenkins/jenkins.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/jenkins/jenkins.go: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin jenkins passed validatio process: 10/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/jira-github-integ/jira-github-integ.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/jira-github-integ/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/jira-github-integ/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/jira-github-integ/: no such file or directory;
stat internal/pkg/plugin/jira-github-integ/: no such file or directory;
stat internal/pkg/plugin/jira-github-integ/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin jira-github-integ passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/kube-prometheus/kube-prometheus.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/kube-prometheus/create.go.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/kube-prometheus/delete.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/kube-prometheus/: no such file or directory;
stat internal/pkg/plugin/kube-prometheus/: no such file or directory;
stat internal/pkg/plugin/kube-prometheus/: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin kube-prometheus passed validatio process: 8/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:46 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:46 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/openldap/openldap.go.
2022-05-04 10:12:46 ✖ [ERROR]  stat internal/pkg/plugin/openldap/openldap.go: no such file or directory
2022-05-04 10:12:46 ℹ [INFO]  Plugin openldap passed validatio process: 10/11.
2022-05-04 10:12:46 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:47 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:47 ℹ [INFO]  Plugin trello passed validatio process: 11/11.
2022-05-04 10:12:47 ℹ [INFO]  Validate all files finished.
2022-05-04 10:12:47 ℹ [INFO]  Render template files finished.
2022-05-04 10:12:47 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/trello-github-integ/trello-github-integ.go.
2022-05-04 10:12:47 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/trello-github-integ/create.go.
2022-05-04 10:12:47 ✖ [ERROR]  Failed to validate: internal/pkg/plugin/trello-github-integ/delete.go.
2022-05-04 10:12:47 ✖ [ERROR]  stat internal/pkg/plugin/trello-github-integ/: no such file or directory;
stat internal/pkg/plugin/trello-github-integ/: no such file or directory;
stat internal/pkg/plugin/trello-github-integ/: no such file or directory
2022-05-04 10:12:47 ℹ [INFO]  Plugin trello-github-integ passed validatio process: 8/11.
2022-05-04 10:12:47 ℹ [INFO]  Validate all files finished.

@IronCore864
Copy link
Member

An elegant solution to a very developer-friendly feature! Kudos to @summingyu

It's worth noting that some plugins had been developed when the create-plugin feature was added, so not all existing plugins can pass this check now. For future new plugins, it's highly recommended to use this command to do a verification before submitting a pull request. I will update the English documentation accordingly.

Thanks again to @summingyu.

@IronCore864
Copy link
Member

Closes #436

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.

2 participants