forked from traefik/traefik
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,025 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,4 @@ | |
*.exe | ||
cover.out | ||
vendor/ | ||
plugins-storage/ |
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,42 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/containous/traefik/v2/pkg/config/static" | ||
"github.com/containous/traefik/v2/pkg/plugins" | ||
) | ||
|
||
const outputDir = "./plugins-storage/" | ||
|
||
func initPlugins(staticCfg *static.Configuration) (*plugins.Client, map[string]plugins.Descriptor, *plugins.DevPlugin, error) { | ||
if !isPilotEnabled(staticCfg) || !hasPlugins(staticCfg) { | ||
return nil, map[string]plugins.Descriptor{}, nil, nil | ||
} | ||
|
||
opts := plugins.ClientOptions{ | ||
Output: outputDir, | ||
Token: staticCfg.Experimental.Pilot.Token, | ||
} | ||
|
||
client, err := plugins.NewClient(opts) | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
|
||
err = plugins.Setup(client, staticCfg.Experimental.Plugins, staticCfg.Experimental.DevPlugin) | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
|
||
return client, staticCfg.Experimental.Plugins, staticCfg.Experimental.DevPlugin, nil | ||
} | ||
|
||
func isPilotEnabled(staticCfg *static.Configuration) bool { | ||
return staticCfg.Experimental != nil && | ||
staticCfg.Experimental.Pilot != nil && | ||
staticCfg.Experimental.Pilot.Token != "" | ||
} | ||
|
||
func hasPlugins(staticCfg *static.Configuration) bool { | ||
return staticCfg.Experimental != nil && | ||
len(staticCfg.Experimental.Plugins) > 0 || staticCfg.Experimental.DevPlugin != nil | ||
} |
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,27 @@ | ||
package dynamic | ||
|
||
import "k8s.io/apimachinery/pkg/runtime" | ||
|
||
// +k8s:deepcopy-gen=false | ||
|
||
// PluginConf holds the plugin configuration. | ||
type PluginConf map[string]interface{} | ||
|
||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. | ||
func (in *PluginConf) DeepCopyInto(out *PluginConf) { | ||
if in == nil { | ||
*out = nil | ||
} else { | ||
*out = runtime.DeepCopyJSON(*in) | ||
} | ||
} | ||
|
||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PluginConf. | ||
func (in *PluginConf) DeepCopy() *PluginConf { | ||
if in == nil { | ||
return nil | ||
} | ||
out := new(PluginConf) | ||
in.DeepCopyInto(out) | ||
return out | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package static | ||
|
||
import "github.com/containous/traefik/v2/pkg/plugins" | ||
|
||
// Experimental experimental Traefik features. | ||
type Experimental struct { | ||
Pilot *Pilot `description:"Traefik Pilot configuration." json:"pilot,omitempty" toml:"pilot,omitempty" yaml:"pilot,omitempty"` | ||
|
||
Plugins map[string]plugins.Descriptor `description:"Plugins configuration." json:"plugins,omitempty" toml:"plugins,omitempty" yaml:"plugins,omitempty"` | ||
DevPlugin *plugins.DevPlugin `description:"Dev plugin configuration." json:"devPlugin,omitempty" toml:"devPlugin,omitempty" yaml:"devPlugin,omitempty"` | ||
} | ||
|
||
// Pilot Configuration related to Traefik Pilot. | ||
type Pilot struct { | ||
Token string `description:"Traefik Pilot token." json:"token,omitempty" toml:"token,omitempty" yaml:"token,omitempty"` | ||
} |
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.