mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 17:15:08 -05:00
Plugins: Require signing of external back-end plugins (#24075)
* PluginManager: Require signing of external plugins Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
This commit is contained in:
co-authored by
Marcus Efraimsson
Diana Payton
parent
827f99f0cb
commit
96ffcaa134
@@ -0,0 +1,18 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"os"
|
||||
)
|
||||
|
||||
// Exists determines whether a file/directory exists or not.
|
||||
func Exists(fpath string) (bool, error) {
|
||||
_, err := os.Stat(fpath)
|
||||
if err != nil {
|
||||
if !os.IsNotExist(err) {
|
||||
return false, err
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"github.com/stretchr/testify/require"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestExists_NonExistent(t *testing.T) {
|
||||
exists, err := Exists("non-existent")
|
||||
require.NoError(t, err)
|
||||
|
||||
require.False(t, exists)
|
||||
}
|
||||
|
||||
func TestExists_Existent(t *testing.T) {
|
||||
f, err := ioutil.TempFile("", "")
|
||||
require.NoError(t, err)
|
||||
defer os.Remove(f.Name())
|
||||
|
||||
exists, err := Exists(f.Name())
|
||||
require.NoError(t, err)
|
||||
|
||||
require.True(t, exists)
|
||||
}
|
||||
Reference in New Issue
Block a user