forked from puppetlabs-toy-chest/wash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support volume and transport features for external plugins
Add features that external plugins can request Wash provide them from its core capabilities. Implement `volume.FS` and `transport`. Signed-off-by: Michael Smith <[email protected]>
- Loading branch information
1 parent
9caefba
commit b6396ae
Showing
7 changed files
with
260 additions
and
14 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package external | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"github.com/puppetlabs/wash/plugin" | ||
"github.com/puppetlabs/wash/volume" | ||
) | ||
|
||
type coreEntry interface { | ||
createInstance(parent *pluginEntry, decodedEntry decodedExternalPluginEntry) (plugin.Entry, error) | ||
schema() *plugin.EntrySchema | ||
} | ||
|
||
var coreEntries = map[string]coreEntry{ | ||
"__volume::fs__": volumeFS{}, | ||
} | ||
|
||
type volumeFS struct{} | ||
|
||
func (volumeFS) createInstance(parent *pluginEntry, e decodedExternalPluginEntry) (plugin.Entry, error) { | ||
var opts struct{ Maxdepth uint } | ||
// Use a default of 3 if unspecified. | ||
opts.Maxdepth = 3 | ||
|
||
if err := json.Unmarshal([]byte(e.State), &opts); err != nil { | ||
return nil, fmt.Errorf("volume filesystem options invalid: %v", err) | ||
} | ||
|
||
return volume.NewFS(e.Name, parent, int(opts.Maxdepth)), nil | ||
} | ||
|
||
func (volumeFS) schema() *plugin.EntrySchema { | ||
return (&volume.FS{}).Schema() | ||
} |
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.