diff --git a/apiserver/controllers/controllers.go b/apiserver/controllers/controllers.go index 4f8dda02..797a42ae 100644 --- a/apiserver/controllers/controllers.go +++ b/apiserver/controllers/controllers.go @@ -6,11 +6,11 @@ import ( "log" "net/http" - "runner-manager/apiserver/params" - "runner-manager/auth" - gErrors "runner-manager/errors" - runnerParams "runner-manager/params" - "runner-manager/runner" + "garm/apiserver/params" + "garm/auth" + gErrors "garm/errors" + runnerParams "garm/params" + "garm/runner" "github.com/gorilla/mux" "github.com/pkg/errors" diff --git a/apiserver/routers/routers.go b/apiserver/routers/routers.go index 696a84da..de06d268 100644 --- a/apiserver/routers/routers.go +++ b/apiserver/routers/routers.go @@ -8,8 +8,8 @@ import ( gorillaHandlers "github.com/gorilla/handlers" "github.com/gorilla/mux" - "runner-manager/apiserver/controllers" - "runner-manager/auth" + "garm/apiserver/controllers" + "garm/auth" ) func NewAPIRouter(han *controllers.APIController, logWriter io.Writer, authMiddleware, initMiddleware, instanceMiddleware auth.Middleware) *mux.Router { diff --git a/auth/auth.go b/auth/auth.go index e400001a..b0718bd5 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -2,11 +2,11 @@ package auth import ( "context" - "runner-manager/config" - "runner-manager/database/common" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/util" + "garm/config" + "garm/database/common" + runnerErrors "garm/errors" + "garm/params" + "garm/util" "time" "github.com/golang-jwt/jwt" @@ -45,7 +45,7 @@ func (a *Authenticator) GetJWTToken(ctx context.Context) (string, error) { StandardClaims: jwt.StandardClaims{ ExpiresAt: expireToken, // TODO: make this configurable - Issuer: "runner-manager", + Issuer: "garm", }, UserID: UserID(ctx), TokenID: tokenID, diff --git a/auth/context.go b/auth/context.go index 130015ed..50e10578 100644 --- a/auth/context.go +++ b/auth/context.go @@ -3,7 +3,7 @@ package auth import ( "context" - "runner-manager/params" + "garm/params" ) type contextFlags string diff --git a/auth/init_required.go b/auth/init_required.go index a88f18d7..1a52e32d 100644 --- a/auth/init_required.go +++ b/auth/init_required.go @@ -3,8 +3,8 @@ package auth import ( "encoding/json" "net/http" - "runner-manager/apiserver/params" - "runner-manager/database/common" + "garm/apiserver/params" + "garm/database/common" ) // NewjwtMiddleware returns a populated jwtMiddleware diff --git a/auth/instance_middleware.go b/auth/instance_middleware.go index d577219b..e08a473c 100644 --- a/auth/instance_middleware.go +++ b/auth/instance_middleware.go @@ -4,11 +4,11 @@ import ( "context" "fmt" "net/http" - "runner-manager/config" - dbCommon "runner-manager/database/common" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/runner/common" + "garm/config" + dbCommon "garm/database/common" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" "strings" "time" @@ -34,7 +34,7 @@ func NewInstanceJWTToken(instance params.Instance, secret, entity string, poolTy claims := InstanceJWTClaims{ StandardClaims: jwt.StandardClaims{ ExpiresAt: expireToken, - Issuer: "runner-manager", + Issuer: "garm", }, ID: instance.ID, Name: instance.Name, diff --git a/auth/jwt.go b/auth/jwt.go index 0fed395a..35d74a35 100644 --- a/auth/jwt.go +++ b/auth/jwt.go @@ -7,10 +7,10 @@ import ( "net/http" "strings" - apiParams "runner-manager/apiserver/params" - "runner-manager/config" - dbCommon "runner-manager/database/common" - runnerErrors "runner-manager/errors" + apiParams "garm/apiserver/params" + "garm/config" + dbCommon "garm/database/common" + runnerErrors "garm/errors" "github.com/golang-jwt/jwt" ) diff --git a/cloudconfig/cloudconfig.go b/cloudconfig/cloudconfig.go index 17a4e0a2..365488cc 100644 --- a/cloudconfig/cloudconfig.go +++ b/cloudconfig/cloudconfig.go @@ -3,7 +3,7 @@ package cloudconfig import ( "encoding/base64" "fmt" - "runner-manager/config" + "garm/config" "strings" "sync" diff --git a/cmd/run-cli/LICENSE b/cmd/garm-cli/LICENSE similarity index 100% rename from cmd/run-cli/LICENSE rename to cmd/garm-cli/LICENSE diff --git a/cmd/run-cli/client/client.go b/cmd/garm-cli/client/client.go similarity index 98% rename from cmd/run-cli/client/client.go rename to cmd/garm-cli/client/client.go index daef0b3d..a812da61 100644 --- a/cmd/run-cli/client/client.go +++ b/cmd/garm-cli/client/client.go @@ -4,9 +4,9 @@ import ( "encoding/json" "fmt" - apiParams "runner-manager/apiserver/params" - "runner-manager/cmd/run-cli/config" - "runner-manager/params" + apiParams "garm/apiserver/params" + "garm/cmd/garm-cli/config" + "garm/params" "github.com/go-resty/resty/v2" "github.com/pkg/errors" diff --git a/cmd/run-cli/cmd/credentials.go b/cmd/garm-cli/cmd/credentials.go similarity index 90% rename from cmd/run-cli/cmd/credentials.go rename to cmd/garm-cli/cmd/credentials.go index 4f0e7fb6..05f2a0bc 100644 --- a/cmd/run-cli/cmd/credentials.go +++ b/cmd/garm-cli/cmd/credentials.go @@ -6,7 +6,7 @@ package cmd import ( "fmt" - "runner-manager/params" + "garm/params" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" @@ -21,7 +21,7 @@ var credentialsCmd = &cobra.Command{ config file. Currently, github personal tokens are configured statically in the config file -of the runner-manager service. This command lists the names of those credentials, +of the garm service. This command lists the names of those credentials, which in turn can be used to define pools of runners withing repositories.`, Run: nil, } @@ -32,7 +32,7 @@ func init() { Use: "list", Aliases: []string{"ls"}, Short: "List configured github credentials", - Long: `List the names of the github personal access tokens availabe to the runner-manager.`, + Long: `List the names of the github personal access tokens availabe to the garm.`, SilenceUsage: true, RunE: func(cmd *cobra.Command, args []string) error { if needsInit { diff --git a/cmd/run-cli/cmd/init.go b/cmd/garm-cli/cmd/init.go similarity index 90% rename from cmd/run-cli/cmd/init.go rename to cmd/garm-cli/cmd/init.go index 85605aa2..4d3eba51 100644 --- a/cmd/run-cli/cmd/init.go +++ b/cmd/garm-cli/cmd/init.go @@ -8,9 +8,9 @@ import ( "fmt" "strings" - "runner-manager/cmd/run-cli/common" - "runner-manager/cmd/run-cli/config" - "runner-manager/params" + "garm/cmd/garm-cli/common" + "garm/cmd/garm-cli/config" + "garm/params" "github.com/jedib0t/go-pretty/v6/table" "github.com/pkg/errors" @@ -21,8 +21,8 @@ import ( var initCmd = &cobra.Command{ Use: "init", SilenceUsage: true, - Short: "Initialize a newly installed runner-manager", - Long: `Initiallize a new installation of runner-manager. + Short: "Initialize a newly installed garm", + Long: `Initiallize a new installation of garm. A newly installed runner manager needs to be initialized to become functional. This command sets the administrative user and password, @@ -31,7 +31,7 @@ created by the manager and enables the service. Example usage: -run-cli login --name=dev --url=https://runner.example.com --username=admin --password=superSecretPassword +garm-cli login --name=dev --url=https://runner.example.com --username=admin --password=superSecretPassword `, RunE: func(cmd *cobra.Command, args []string) error { if cfg != nil { diff --git a/cmd/run-cli/cmd/login.go b/cmd/garm-cli/cmd/login.go similarity index 89% rename from cmd/run-cli/cmd/login.go rename to cmd/garm-cli/cmd/login.go index c680bceb..cbe92d0b 100644 --- a/cmd/run-cli/cmd/login.go +++ b/cmd/garm-cli/cmd/login.go @@ -6,9 +6,9 @@ package cmd import ( "fmt" - "runner-manager/cmd/run-cli/common" - "runner-manager/cmd/run-cli/config" - "runner-manager/params" + "garm/cmd/garm-cli/common" + "garm/cmd/garm-cli/config" + "garm/params" "strings" "github.com/spf13/cobra" @@ -28,9 +28,9 @@ var loginCmd = &cobra.Command{ Use: "login", SilenceUsage: true, Short: "Log into a manager", - Long: `Performs login for this machine on a remote runner-manager: + Long: `Performs login for this machine on a remote garm: -run-cli login --name=dev --url=https://runner.example.com`, +garm-cli login --name=dev --url=https://runner.example.com`, RunE: func(cmd *cobra.Command, args []string) error { if cfg != nil { if cfg.HasManager(loginProfileName) { diff --git a/cmd/run-cli/cmd/organization.go b/cmd/garm-cli/cmd/organization.go similarity index 100% rename from cmd/run-cli/cmd/organization.go rename to cmd/garm-cli/cmd/organization.go diff --git a/cmd/run-cli/cmd/provider.go b/cmd/garm-cli/cmd/provider.go similarity index 98% rename from cmd/run-cli/cmd/provider.go rename to cmd/garm-cli/cmd/provider.go index e108cae7..30eeee10 100644 --- a/cmd/run-cli/cmd/provider.go +++ b/cmd/garm-cli/cmd/provider.go @@ -6,7 +6,7 @@ package cmd import ( "fmt" - "runner-manager/params" + "garm/params" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" diff --git a/cmd/run-cli/cmd/repo_instances.go b/cmd/garm-cli/cmd/repo_instances.go similarity index 100% rename from cmd/run-cli/cmd/repo_instances.go rename to cmd/garm-cli/cmd/repo_instances.go diff --git a/cmd/run-cli/cmd/repo_pool.go b/cmd/garm-cli/cmd/repo_pool.go similarity index 99% rename from cmd/run-cli/cmd/repo_pool.go rename to cmd/garm-cli/cmd/repo_pool.go index 7d73ff2a..2115394d 100644 --- a/cmd/run-cli/cmd/repo_pool.go +++ b/cmd/garm-cli/cmd/repo_pool.go @@ -6,8 +6,8 @@ package cmd import ( "fmt" - "runner-manager/config" - "runner-manager/params" + "garm/config" + "garm/params" "strings" "github.com/jedib0t/go-pretty/v6/table" diff --git a/cmd/run-cli/cmd/repository.go b/cmd/garm-cli/cmd/repository.go similarity index 97% rename from cmd/run-cli/cmd/repository.go rename to cmd/garm-cli/cmd/repository.go index 13336a29..eef69d83 100644 --- a/cmd/run-cli/cmd/repository.go +++ b/cmd/garm-cli/cmd/repository.go @@ -6,7 +6,7 @@ package cmd import ( "fmt" - "runner-manager/params" + "garm/params" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" @@ -29,7 +29,7 @@ var repositoryCmd = &cobra.Command{ self hosted runners. This command allows you to define a new repository or manage an existing -repository for which the runner-manager maintains pools of self hosted runners.`, +repository for which the garm maintains pools of self hosted runners.`, Run: nil, } diff --git a/cmd/run-cli/cmd/root.go b/cmd/garm-cli/cmd/root.go similarity index 88% rename from cmd/run-cli/cmd/root.go rename to cmd/garm-cli/cmd/root.go index 159163cf..7b11d8ff 100644 --- a/cmd/run-cli/cmd/root.go +++ b/cmd/garm-cli/cmd/root.go @@ -7,8 +7,8 @@ package cmd import ( "fmt" "os" - "runner-manager/cmd/run-cli/client" - "runner-manager/cmd/run-cli/config" + "garm/cmd/garm-cli/client" + "garm/cmd/garm-cli/config" "github.com/spf13/cobra" ) @@ -20,12 +20,12 @@ var ( active string needsInit bool debug bool - needsInitError = fmt.Errorf("Please log into a runner-manager first") + needsInitError = fmt.Errorf("Please log into a garm first") ) // rootCmd represents the base command when called without any subcommands var rootCmd = &cobra.Command{ - Use: "run-cli", + Use: "garm-cli", Short: "Runner manager CLI app", Long: `CLI for the github self hosted runners manager.`, } diff --git a/cmd/run-cli/cmd/runner.go b/cmd/garm-cli/cmd/runner.go similarity index 99% rename from cmd/run-cli/cmd/runner.go rename to cmd/garm-cli/cmd/runner.go index 49d0a816..466d8fc3 100644 --- a/cmd/run-cli/cmd/runner.go +++ b/cmd/garm-cli/cmd/runner.go @@ -6,7 +6,7 @@ package cmd import ( "fmt" - "runner-manager/params" + "garm/params" "github.com/jedib0t/go-pretty/v6/table" "github.com/spf13/cobra" diff --git a/cmd/run-cli/common/common.go b/cmd/garm-cli/common/common.go similarity index 100% rename from cmd/run-cli/common/common.go rename to cmd/garm-cli/common/common.go diff --git a/cmd/run-cli/config/config.go b/cmd/garm-cli/config/config.go similarity index 96% rename from cmd/run-cli/config/config.go rename to cmd/garm-cli/config/config.go index cd88cb2d..48e65873 100644 --- a/cmd/run-cli/config/config.go +++ b/cmd/garm-cli/config/config.go @@ -7,11 +7,11 @@ import ( "github.com/BurntSushi/toml" "github.com/pkg/errors" - runnerErrors "runner-manager/errors" + runnerErrors "garm/errors" ) const ( - DefaultAppFolder = "run-cli" + DefaultAppFolder = "garm-cli" DefaultConfigFileName = "config.toml" ) diff --git a/cmd/run-cli/config/home.go b/cmd/garm-cli/config/home.go similarity index 100% rename from cmd/run-cli/config/home.go rename to cmd/garm-cli/config/home.go diff --git a/cmd/run-cli/config/home_nix.go b/cmd/garm-cli/config/home_nix.go similarity index 100% rename from cmd/run-cli/config/home_nix.go rename to cmd/garm-cli/config/home_nix.go diff --git a/cmd/run-cli/config/home_windows.go b/cmd/garm-cli/config/home_windows.go similarity index 100% rename from cmd/run-cli/config/home_windows.go rename to cmd/garm-cli/config/home_windows.go diff --git a/cmd/garm-cli/garm-cli b/cmd/garm-cli/garm-cli new file mode 100755 index 00000000..bc61e7e8 Binary files /dev/null and b/cmd/garm-cli/garm-cli differ diff --git a/cmd/run-cli/main.go b/cmd/garm-cli/main.go similarity index 70% rename from cmd/run-cli/main.go rename to cmd/garm-cli/main.go index 0d118156..521ebd69 100644 --- a/cmd/run-cli/main.go +++ b/cmd/garm-cli/main.go @@ -4,7 +4,7 @@ Copyright © 2022 NAME HERE */ package main -import "runner-manager/cmd/run-cli/cmd" +import "garm/cmd/garm-cli/cmd" func main() { cmd.Execute() diff --git a/cmd/runner-manager/create.go b/cmd/garm/create.go similarity index 94% rename from cmd/runner-manager/create.go rename to cmd/garm/create.go index 73938a5d..cdeff596 100644 --- a/cmd/runner-manager/create.go +++ b/cmd/garm/create.go @@ -7,10 +7,10 @@ package main // "log" // "os/signal" -// "runner-manager/config" -// "runner-manager/params" -// "runner-manager/runner/providers/lxd" -// "runner-manager/util" +// "garm/config" +// "garm/params" +// "garm/runner/providers/lxd" +// "garm/util" // "github.com/google/go-github/v43/github" // "golang.org/x/oauth2" @@ -18,7 +18,7 @@ package main // ) // var ( -// conf = flag.String("config", config.DefaultConfigFilePath, "runner-manager config file") +// conf = flag.String("config", config.DefaultConfigFilePath, "garm config file") // version = flag.Bool("version", false, "prints version") // ) @@ -110,7 +110,7 @@ package main // // fmt.Println(provider) -// // if err := provider.DeleteInstance(ctx, "runner-manager-2fbe5354-be28-4e00-95a8-11479912368d"); err != nil { +// // if err := provider.DeleteInstance(ctx, "garm-2fbe5354-be28-4e00-95a8-11479912368d"); err != nil { // // log.Fatal(err) // // } diff --git a/cmd/runner-manager/dbcreate.go b/cmd/garm/dbcreate.go similarity index 93% rename from cmd/runner-manager/dbcreate.go rename to cmd/garm/dbcreate.go index 2477b56b..5e2a8586 100644 --- a/cmd/runner-manager/dbcreate.go +++ b/cmd/garm/dbcreate.go @@ -6,14 +6,14 @@ package main // "fmt" // "log" // "os/signal" -// "runner-manager/config" -// "runner-manager/database/sql" -// "runner-manager/params" -// "runner-manager/util" +// "garm/config" +// "garm/database/sql" +// "garm/params" +// "garm/util" // ) // var ( -// conf = flag.String("config", config.DefaultConfigFilePath, "runner-manager config file") +// conf = flag.String("config", config.DefaultConfigFilePath, "garm config file") // version = flag.Bool("version", false, "prints version") // ) @@ -89,14 +89,14 @@ package main // "fmt" // "log" // "os/signal" -// "runner-manager/config" -// "runner-manager/database/sql" -// "runner-manager/params" -// "runner-manager/util" +// "garm/config" +// "garm/database/sql" +// "garm/params" +// "garm/util" // ) // var ( -// conf = flag.String("config", config.DefaultConfigFilePath, "runner-manager config file") +// conf = flag.String("config", config.DefaultConfigFilePath, "garm config file") // version = flag.Bool("version", false, "prints version") // ) diff --git a/cmd/runner-manager/main.go b/cmd/garm/main.go similarity index 90% rename from cmd/runner-manager/main.go rename to cmd/garm/main.go index be865f3b..c21531ef 100644 --- a/cmd/runner-manager/main.go +++ b/cmd/garm/main.go @@ -9,14 +9,14 @@ import ( "net/http" "os/signal" - "runner-manager/apiserver/controllers" - "runner-manager/apiserver/routers" - "runner-manager/auth" - "runner-manager/config" - "runner-manager/database" - "runner-manager/database/common" - "runner-manager/runner" - "runner-manager/util" + "garm/apiserver/controllers" + "garm/apiserver/routers" + "garm/auth" + "garm/config" + "garm/database" + "garm/database/common" + "garm/runner" + "garm/util" "github.com/pkg/errors" // "github.com/google/go-github/v43/github" @@ -25,7 +25,7 @@ import ( ) var ( - conf = flag.String("config", config.DefaultConfigFilePath, "runner-manager config file") + conf = flag.String("config", config.DefaultConfigFilePath, "garm config file") version = flag.Bool("version", false, "prints version") ) diff --git a/cmd/runner-manager/signal_nix.go b/cmd/garm/signal_nix.go similarity index 100% rename from cmd/runner-manager/signal_nix.go rename to cmd/garm/signal_nix.go diff --git a/cmd/runner-manager/signal_windows.go b/cmd/garm/signal_windows.go similarity index 100% rename from cmd/runner-manager/signal_windows.go rename to cmd/garm/signal_windows.go diff --git a/config/config.go b/config/config.go index 81503fef..5c3214d0 100644 --- a/config/config.go +++ b/config/config.go @@ -32,12 +32,12 @@ const ( // LXDProvider represents the LXD provider. LXDProvider ProviderType = "lxd" - // DefaultConfigFilePath is the default path on disk to the runner-manager + // DefaultConfigFilePath is the default path on disk to the garm // configuration file. - DefaultConfigFilePath = "/etc/runner-manager/config.toml" + DefaultConfigFilePath = "/etc/garm/config.toml" // DefaultConfigDir is the default path on disk to the config dir. The config // file will probably be in the same folder, but it is not mandatory. - DefaultConfigDir = "/etc/runner-manager" + DefaultConfigDir = "/etc/garm" // DefaultUser is the default username that should exist on the instances. DefaultUser = "runner" diff --git a/config/lxd.go b/config/lxd.go index 27f00fc9..47c7695c 100644 --- a/config/lxd.go +++ b/config/lxd.go @@ -66,8 +66,9 @@ type LXD struct { // the "default" profile to any newly created instance. IncludeDefaultProfile bool `toml:"include_default_profile" json:"include-default-profile"` - // URL holds the IP address. - URL string `toml:"address" json:"address"` + // URL holds the URL of the remote LXD server. + // example: https://10.10.10.1:8443/ + URL string `toml:"url" json:"url"` // ClientCertificate is the x509 client certificate path used for authentication. ClientCertificate string `toml:"client_certificate" json:"client_certificate"` // ClientKey is the key used for client certificate authentication. diff --git a/database/common/common.go b/database/common/common.go index d9f3e4d9..d1f50438 100644 --- a/database/common/common.go +++ b/database/common/common.go @@ -2,7 +2,7 @@ package common import ( "context" - "runner-manager/params" + "garm/params" ) type Store interface { diff --git a/database/database.go b/database/database.go index 30d2d143..33f3b760 100644 --- a/database/database.go +++ b/database/database.go @@ -3,9 +3,9 @@ package database import ( "context" "fmt" - "runner-manager/config" - "runner-manager/database/common" - "runner-manager/database/sql" + "garm/config" + "garm/database/common" + "garm/database/sql" ) func NewDatabase(ctx context.Context, cfg config.Database) (common.Store, error) { diff --git a/database/sql/models.go b/database/sql/models.go index b531a2ae..dc534d86 100644 --- a/database/sql/models.go +++ b/database/sql/models.go @@ -1,8 +1,8 @@ package sql import ( - "runner-manager/config" - "runner-manager/runner/providers/common" + "garm/config" + "garm/runner/providers/common" "time" "github.com/pkg/errors" diff --git a/database/sql/sql.go b/database/sql/sql.go index 1d424464..a97b722c 100644 --- a/database/sql/sql.go +++ b/database/sql/sql.go @@ -3,11 +3,11 @@ package sql import ( "context" "fmt" - "runner-manager/config" - "runner-manager/database/common" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/util" + "garm/config" + "garm/database/common" + runnerErrors "garm/errors" + "garm/params" + "garm/util" "github.com/pkg/errors" uuid "github.com/satori/go.uuid" diff --git a/go.mod b/go.mod index f95ff4dc..3abf5c0b 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module runner-manager +module garm go 1.18 diff --git a/params/params.go b/params/params.go index ae7c5a64..cc6244f0 100644 --- a/params/params.go +++ b/params/params.go @@ -1,8 +1,8 @@ package params import ( - "runner-manager/config" - "runner-manager/runner/providers/common" + "garm/config" + "garm/runner/providers/common" "time" "github.com/google/go-github/v43/github" @@ -73,7 +73,7 @@ type BootstrapInstance struct { // progress or status. CallbackURL string `json:"callback-url"` // InstanceToken is the token that needs to be set by the instance in the headers - // in order to send updated back to the runner-manager via CallbackURL. + // in order to send updated back to the garm via CallbackURL. InstanceToken string `json:"instance-token"` // SSHKeys are the ssh public keys we may want to inject inside the runners, if the // provider supports it. diff --git a/params/requests.go b/params/requests.go index 3e6d081e..e48ded2c 100644 --- a/params/requests.go +++ b/params/requests.go @@ -2,9 +2,9 @@ package params import ( "fmt" - "runner-manager/config" - "runner-manager/errors" - "runner-manager/runner/providers/common" + "garm/config" + "garm/errors" + "garm/runner/providers/common" ) type InstanceRequest struct { diff --git a/runner/common/pool.go b/runner/common/pool.go index 49df6aae..6a6d67d5 100644 --- a/runner/common/pool.go +++ b/runner/common/pool.go @@ -1,7 +1,7 @@ package common import ( - "runner-manager/params" + "garm/params" ) type PoolType string diff --git a/runner/common/provider.go b/runner/common/provider.go index 203ae7cc..0e8813b2 100644 --- a/runner/common/provider.go +++ b/runner/common/provider.go @@ -2,7 +2,7 @@ package common import ( "context" - "runner-manager/params" + "garm/params" ) type Provider interface { diff --git a/runner/pool/repository.go b/runner/pool/repository.go index e3af964a..fa894156 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -8,14 +8,14 @@ import ( "sync" "time" - "runner-manager/auth" - "runner-manager/config" - dbCommon "runner-manager/database/common" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/runner/common" - providerCommon "runner-manager/runner/providers/common" - "runner-manager/util" + "garm/auth" + "garm/config" + dbCommon "garm/database/common" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" + providerCommon "garm/runner/providers/common" + "garm/util" "github.com/google/go-github/v43/github" "github.com/google/uuid" @@ -268,7 +268,7 @@ func (r *Repository) cleanupOrphanedGithubRunners(runners []*github.Runner) erro // cleanupOrphanedProviderRunners compares runners in github with local runners and removes // any local runners that are not present in Github. Runners that are "idle" in our // provider, but do not exist in github, will be removed. This can happen if the -// runner-manager was offline while a job was executed by a github action. When this +// garm was offline while a job was executed by a github action. When this // happens, github will remove the ephemeral worker and send a webhook our way. // If we were offline and did not process the webhook, the instance will linger. // We need to remove it from the provider and database. @@ -363,21 +363,14 @@ func (r *Repository) githubURL() string { return fmt.Sprintf("%s/%s/%s", config.GithubBaseURL, r.cfg.Owner, r.cfg.Name) } -func (r *Repository) poolLabel() string { - return fmt.Sprintf("%s%s", poolIDLabelprefix, r.id) +func (r *Repository) poolLabel(poolID string) string { + return fmt.Sprintf("%s%s", poolIDLabelprefix, poolID) } func (r *Repository) controllerLabel() string { return fmt.Sprintf("%s%s", controllerLabelPrefix, r.controllerID) } -func (r *Repository) getLabels() []string { - return []string{ - r.poolLabel(), - r.controllerLabel(), - } -} - func (r *Repository) updateArgsFromProviderInstance(providerInstance params.Instance) params.UpdateInstanceParams { return params.UpdateInstanceParams{ ProviderID: providerInstance.ProviderID, @@ -425,7 +418,8 @@ func (r *Repository) addInstanceToProvider(instance params.Instance) error { for _, tag := range pool.Tags { labels = append(labels, tag.Name) } - labels = append(labels, r.getLabels()...) + labels = append(labels, r.controllerLabel()) + labels = append(labels, r.poolLabel(pool.ID)) tk, _, err := r.ghcli.Actions.CreateRegistrationToken(r.ctx, r.cfg.Owner, r.cfg.Name) @@ -470,7 +464,7 @@ func (r *Repository) AddRunner(ctx context.Context, poolID string) error { return errors.Wrap(err, "fetching pool") } - name := fmt.Sprintf("runner-manager-%s", uuid.New()) + name := fmt.Sprintf("garm-%s", uuid.New()) createParams := params.CreateInstanceParams{ Name: name, diff --git a/runner/providers/lxd/images.go b/runner/providers/lxd/images.go index 9a8ebb71..8dfd4445 100644 --- a/runner/providers/lxd/images.go +++ b/runner/providers/lxd/images.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "runner-manager/config" - runnerErrors "runner-manager/errors" + "garm/config" + runnerErrors "garm/errors" lxd "github.com/lxc/lxd/client" "github.com/lxc/lxd/shared/api" diff --git a/runner/providers/lxd/lxd.go b/runner/providers/lxd/lxd.go index 9cbc1f66..b2fa4ffb 100644 --- a/runner/providers/lxd/lxd.go +++ b/runner/providers/lxd/lxd.go @@ -3,12 +3,13 @@ package lxd import ( "context" "fmt" + "log" - "runner-manager/config" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/runner/common" - "runner-manager/util" + "garm/config" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" + "garm/util" "github.com/google/go-github/v43/github" lxd "github.com/lxc/lxd/client" @@ -53,8 +54,8 @@ var ( ) const ( - DefaultProjectDescription = "This project was created automatically by runner-manager to be used for github ephemeral action runners." - DefaultProjectName = "runner-manager-project" + DefaultProjectDescription = "This project was created automatically by garm to be used for github ephemeral action runners." + DefaultProjectName = "garm-project" ) func NewProvider(ctx context.Context, cfg *config.Provider, controllerID string) (common.Provider, error) { @@ -213,7 +214,7 @@ func (l *LXD) getCreateInstanceArgs(bootstrapParams params.BootstrapInstance) (a InstancePut: api.InstancePut{ Architecture: image.Architecture, Profiles: profiles, - Description: "Github runner provisioned by runner-manager", + Description: "Github runner provisioned by garm", Config: map[string]string{ "user.user-data": cloudCfg, "security.secureboot": l.secureBootEnabled(), @@ -232,6 +233,7 @@ func (l *LXD) getCreateInstanceArgs(bootstrapParams params.BootstrapInstance) (a } func (l *LXD) AsParams() params.Provider { + log.Printf("<<<<< %s", l.cfg.Name) return params.Provider{ Name: l.cfg.Name, ProviderType: l.cfg.ProviderType, diff --git a/runner/providers/lxd/util.go b/runner/providers/lxd/util.go index 70872ec1..6f4d404b 100644 --- a/runner/providers/lxd/util.go +++ b/runner/providers/lxd/util.go @@ -8,10 +8,10 @@ import ( "log" "net/http" "os" - "runner-manager/config" - "runner-manager/params" - "runner-manager/runner/providers/common" - "runner-manager/util" + "garm/config" + "garm/params" + "garm/runner/providers/common" + "garm/util" "strings" lxd "github.com/lxc/lxd/client" diff --git a/runner/providers/providers.go b/runner/providers/providers.go index cc0e5e0a..b1a3c961 100644 --- a/runner/providers/providers.go +++ b/runner/providers/providers.go @@ -2,9 +2,10 @@ package providers import ( "context" - "runner-manager/config" - "runner-manager/runner/common" - "runner-manager/runner/providers/lxd" + "log" + "garm/config" + "garm/runner/common" + "garm/runner/providers/lxd" "github.com/pkg/errors" ) @@ -12,11 +13,13 @@ import ( // LoadProvidersFromConfig loads all providers from the config and populates // a map with them. func LoadProvidersFromConfig(ctx context.Context, cfg config.Config, controllerID string) (map[string]common.Provider, error) { - providers := map[string]common.Provider{} + providers := make(map[string]common.Provider, len(cfg.Providers)) for _, providerCfg := range cfg.Providers { + log.Printf("Loading provider %s", providerCfg.Name) switch providerCfg.ProviderType { case config.LXDProvider: - provider, err := lxd.NewProvider(ctx, &providerCfg, controllerID) + conf := providerCfg + provider, err := lxd.NewProvider(ctx, &conf, controllerID) if err != nil { return nil, errors.Wrap(err, "creating provider") } diff --git a/runner/repositories.go b/runner/repositories.go index ad935406..463a2339 100644 --- a/runner/repositories.go +++ b/runner/repositories.go @@ -3,12 +3,12 @@ package runner import ( "context" "log" - "runner-manager/auth" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/runner/common" - "runner-manager/runner/pool" - "runner-manager/util" + "garm/auth" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" + "garm/runner/pool" + "garm/util" "strings" "github.com/pkg/errors" diff --git a/runner/runner.go b/runner/runner.go index 3199d019..295d4a19 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -15,14 +15,14 @@ import ( "strings" "sync" - "runner-manager/config" - "runner-manager/database" - dbCommon "runner-manager/database/common" - runnerErrors "runner-manager/errors" - "runner-manager/params" - "runner-manager/runner/common" - "runner-manager/runner/providers" - "runner-manager/util" + "garm/config" + "garm/database" + dbCommon "garm/database/common" + runnerErrors "garm/errors" + "garm/params" + "garm/runner/common" + "garm/runner/providers" + "garm/util" "github.com/pkg/errors" "golang.org/x/crypto/ssh" @@ -101,6 +101,8 @@ func (r *Runner) ListProviders(ctx context.Context) ([]params.Provider, error) { ret := []params.Provider{} for _, val := range r.providers { + params := val.AsParams() + log.Printf(">>>>> %s", params.Name) ret = append(ret, val.AsParams()) } return ret, nil diff --git a/runner/types.go b/runner/types.go index c59b63b7..169a0452 100644 --- a/runner/types.go +++ b/runner/types.go @@ -1,6 +1,6 @@ package runner -import "runner-manager/config" +import "garm/config" type HookTargetType string diff --git a/testdata/config.toml b/testdata/config.toml index 9165586f..b9aafb25 100644 --- a/testdata/config.toml +++ b/testdata/config.toml @@ -1,7 +1,7 @@ [default] -config_dir = "/etc/runner-manager" +config_dir = "/etc/garm" callback_url = "https://webhooks.samfira.com/api/v1/instances/status" -# log_file = "/tmp/runner-manager.log" +# log_file = "/tmp/garm.log" [jwt_auth] secret = "L&CGG?%VaV;Zs5CnGqaWINDBhx