support for convert plugin extension
This commit is contained in:
parent
20d66be182
commit
6283b20972
4 changed files with 15 additions and 5 deletions
|
@ -302,6 +302,7 @@ type (
|
|||
|
||||
// Convert provides the converter webhook configuration.
|
||||
Convert struct {
|
||||
Extension string `envconfig:"DRONE_CONVERT_PLUGIN_EXTENSION"`
|
||||
Endpoint string `envconfig:"DRONE_CONVERT_PLUGIN_ENDPOINT"`
|
||||
Secret string `envconfig:"DRONE_CONVERT_PLUGIN_SECRET"`
|
||||
SkipVerify bool `envconfig:"DRONE_CONVERT_PLUGIN_SKIP_VERIFY"`
|
||||
|
|
|
@ -79,6 +79,7 @@ func provideConvertPlugin(client *scm.Client, conf spec.Config) core.ConvertServ
|
|||
converter.Remote(
|
||||
conf.Convert.Endpoint,
|
||||
conf.Convert.Secret,
|
||||
conf.Convert.Extension,
|
||||
conf.Convert.SkipVerify,
|
||||
),
|
||||
),
|
||||
|
@ -91,9 +92,9 @@ func provideConvertPlugin(client *scm.Client, conf spec.Config) core.ConvertServ
|
|||
func provideRegistryPlugin(config spec.Config) core.RegistryService {
|
||||
return registry.Combine(
|
||||
registry.External(
|
||||
config.Convert.Endpoint,
|
||||
config.Convert.Secret,
|
||||
config.Convert.SkipVerify,
|
||||
config.Secrets.Endpoint,
|
||||
config.Secrets.Password,
|
||||
config.Secrets.SkipVerify,
|
||||
),
|
||||
registry.FileSource(
|
||||
config.Docker.Config,
|
||||
|
|
|
@ -8,6 +8,7 @@ package converter
|
|||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/drone/drone-go/drone"
|
||||
|
@ -17,8 +18,9 @@ import (
|
|||
|
||||
// Remote returns a conversion service that converts the
|
||||
// configuration file using a remote http service.
|
||||
func Remote(endpoint, signer string, skipVerify bool) core.ConvertService {
|
||||
func Remote(endpoint, signer, extension string, skipVerify bool) core.ConvertService {
|
||||
return &remote{
|
||||
extension: extension,
|
||||
endpoint: endpoint,
|
||||
secret: signer,
|
||||
skipVerify: skipVerify,
|
||||
|
@ -26,6 +28,7 @@ func Remote(endpoint, signer string, skipVerify bool) core.ConvertService {
|
|||
}
|
||||
|
||||
type remote struct {
|
||||
extension string
|
||||
endpoint string
|
||||
secret string
|
||||
skipVerify bool
|
||||
|
@ -35,6 +38,11 @@ func (g *remote) Convert(ctx context.Context, in *core.ConvertArgs) (*core.Confi
|
|||
if g.endpoint == "" {
|
||||
return nil, nil
|
||||
}
|
||||
if g.extension != "" {
|
||||
if !strings.HasSuffix(in.Repo.Config, g.extension) {
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
// include a timeout to prevent an API call from
|
||||
// hanging the build process indefinitely. The
|
||||
// external service must return a request within
|
||||
|
|
|
@ -22,6 +22,6 @@ import (
|
|||
|
||||
// Remote returns a conversion service that converts the
|
||||
// configuration file using a remote http service.
|
||||
func Remote(endpoint, signer string, skipVerify bool) core.ConvertService {
|
||||
func Remote(endpoint, signer, extension string, skipVerify bool) core.ConvertService {
|
||||
return new(noop)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue