Feat: load git remote from drone env
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d964a5c94c
commit
560450aeed
1 changed files with 11 additions and 6 deletions
|
@ -23,9 +23,10 @@ type Args struct {
|
||||||
// Level defines the plugin log level.
|
// Level defines the plugin log level.
|
||||||
Level string `envconfig:"PLUGIN_LOG_LEVEL"`
|
Level string `envconfig:"PLUGIN_LOG_LEVEL"`
|
||||||
|
|
||||||
Folder string `envconfig:"PLUGIN_FOLDER"`
|
Folder string `envconfig:"PLUGIN_FOLDER"`
|
||||||
SshKey string `envconfig:"PLUGIN_SSH_KEY"`
|
SshKey string `envconfig:"PLUGIN_SSH_KEY"`
|
||||||
GitRemote string `envconfig:"PLUGIN_GIT_REMOTE"`
|
GitRemote string `envconfig:"PLUGIN_GIT_REMOTE"`
|
||||||
|
GitRemoteFromDrone string `envconfig:"DRONE_GIT_SSH_URL"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const BRANCH_NAME = "pages"
|
const BRANCH_NAME = "pages"
|
||||||
|
@ -33,7 +34,7 @@ const BRANCH_NAME = "pages"
|
||||||
// Exec executes the plugin.
|
// Exec executes the plugin.
|
||||||
func Exec(ctx context.Context, args Args) error {
|
func Exec(ctx context.Context, args Args) error {
|
||||||
|
|
||||||
if err := checkArgs(args); err != nil {
|
if err := checkArgs(&args); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +66,7 @@ func Exec(ctx context.Context, args Args) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func checkArgs(args Args) error {
|
func checkArgs(args *Args) error {
|
||||||
if args.Folder == "" {
|
if args.Folder == "" {
|
||||||
return errors.New("PLUGIN_FOLDER is required!")
|
return errors.New("PLUGIN_FOLDER is required!")
|
||||||
}
|
}
|
||||||
|
@ -78,10 +79,14 @@ func checkArgs(args Args) error {
|
||||||
return errors.New("PLUGIN_SSH_KEY is required!")
|
return errors.New("PLUGIN_SSH_KEY is required!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if args.GitRemote == "" {
|
if args.GitRemote == "" && args.GitRemoteFromDrone == "" {
|
||||||
return errors.New("PLUGIN_GIT_REMOTE is required!")
|
return errors.New("PLUGIN_GIT_REMOTE is required!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if args.GitRemote == "" && args.GitRemoteFromDrone != "" {
|
||||||
|
args.GitRemote = args.GitRemoteFromDrone
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue