Add token endpoint
This change adds a github registration endpoint that instances can use to fetch a github registration token. This change also invalidates disables access to an instance to the token and status updates endpoints once the instance transitions from "pending" or "installing" to any other state.
This commit is contained in:
parent
eba42b0481
commit
a078645ab2
18 changed files with 252 additions and 77 deletions
|
|
@ -20,6 +20,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
|
@ -169,8 +170,11 @@ type Default struct {
|
|||
// ConfigDir is the folder where the runner may save any aditional files
|
||||
// or configurations it may need. Things like auto-generated SSH keys that
|
||||
// may be used to access the runner instances.
|
||||
ConfigDir string `toml:"config_dir,omitempty" json:"config-dir,omitempty"`
|
||||
ConfigDir string `toml:"config_dir,omitempty" json:"config-dir,omitempty"`
|
||||
// CallbackURL is the URL where the instances can send back status reports.
|
||||
CallbackURL string `toml:"callback_url" json:"callback-url"`
|
||||
// TokenURL is the URL where instances can fetch a github runner registration token.
|
||||
TokenURL string `toml:"token_url" json:"token-url"`
|
||||
// LogFile is the location of the log file.
|
||||
LogFile string `toml:"log_file,omitempty" json:"log-file"`
|
||||
EnableLogStreamer bool `toml:"enable_log_streamer"`
|
||||
|
|
@ -181,6 +185,17 @@ func (d *Default) Validate() error {
|
|||
return fmt.Errorf("missing callback_url")
|
||||
}
|
||||
|
||||
_, err := url.Parse(d.CallbackURL)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "validating callback_url")
|
||||
}
|
||||
|
||||
if d.TokenURL != "" {
|
||||
if _, err := url.Parse(d.TokenURL); err != nil {
|
||||
return errors.Wrap(err, "validating token_url")
|
||||
}
|
||||
}
|
||||
|
||||
if d.ConfigDir == "" {
|
||||
return fmt.Errorf("config_dir cannot be empty")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue