-
Notifications
You must be signed in to change notification settings - Fork 11.7k
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
Improve apiVersion in plugin models #87639
Closed
Closed
Changes from 10 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ed7e92c
Draft: Add apiVersion to plugins
andresmgot 063051e
Remove errors. Use plugin-sdk new version
andresmgot ce89ee5
openapi3-gen
andresmgot 80c57ff
Add apiVersion to DTOs
andresmgot 0a5c02e
fix and add more tests
andresmgot e9ef889
various checks
andresmgot 7187936
merge main
andresmgot 3100642
fix workflow syntax
andresmgot b7cad12
fix regex
andresmgot 92d4e55
update models
ryantxu d1e83f8
set the apiversion
ryantxu File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package validation | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/grafana/grafana/pkg/plugins" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestAPIVersionValidation(t *testing.T) { | ||
s := APIVersionValidationStep() | ||
|
||
tests := []struct { | ||
name string | ||
plugin *plugins.Plugin | ||
err bool | ||
}{ | ||
{ | ||
name: "valid plugin", | ||
plugin: &plugins.Plugin{ | ||
JSONData: plugins.JSONData{ | ||
Backend: true, | ||
Type: plugins.TypeDataSource, | ||
APIVersion: "v0alpha1", | ||
}, | ||
}, | ||
err: false, | ||
}, | ||
{ | ||
name: "invalid plugin - not backend", | ||
plugin: &plugins.Plugin{ | ||
JSONData: plugins.JSONData{ | ||
Backend: false, | ||
Type: plugins.TypeDataSource, | ||
APIVersion: "v0alpha1", | ||
}, | ||
}, | ||
err: true, | ||
}, | ||
{ | ||
name: "invalid plugin - not datasource", | ||
plugin: &plugins.Plugin{ | ||
JSONData: plugins.JSONData{ | ||
Backend: true, | ||
Type: plugins.TypeApp, | ||
APIVersion: "v0alpha1", | ||
}, | ||
}, | ||
err: true, | ||
}, | ||
{ | ||
name: "invalid plugin - invalid API version", | ||
plugin: &plugins.Plugin{ | ||
JSONData: plugins.JSONData{ | ||
Backend: true, | ||
Type: plugins.TypeDataSource, | ||
APIVersion: "invalid", | ||
}, | ||
}, | ||
err: true, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
err := s(context.Background(), tt.plugin) | ||
if tt.err { | ||
require.Error(t, err) | ||
} else { | ||
require.NoError(t, err) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
we can remove the comment if it helps 🤷🏻
But I keep getting confused which one indicates where it is running vs where it was saved!