fix: gci section warnings
Signed-off-by: Mario Constanti <mario.constanti@mercedes-benz.com>
This commit is contained in:
parent
8fc001f5f6
commit
bd0b27ab10
51 changed files with 166 additions and 181 deletions
|
|
@ -22,6 +22,10 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
gErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
|
|
@ -30,10 +34,6 @@ import (
|
|||
runnerParams "github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner"
|
||||
wsWriter "github.com/cloudbase/garm/websocket"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
func NewAPIController(r *runner.Runner, authenticator *auth.Authenticator, hub *wsWriter.Hub) (*APIController, error) {
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ import (
|
|||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
gErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
runnerParams "github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route POST /enterprises enterprises CreateEnterprise
|
||||
|
|
@ -165,7 +165,6 @@ func (a *APIController) DeleteEnterpriseHandler(w http.ResponseWriter, r *http.R
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route PUT /enterprises/{enterpriseID} enterprises UpdateEnterprise
|
||||
|
|
@ -318,7 +317,6 @@ func (a *APIController) ListEnterprisePoolsHandler(w http.ResponseWriter, r *htt
|
|||
if err := json.NewEncoder(w).Encode(pools); err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "failed to encode response")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// swagger:route GET /enterprises/{enterpriseID}/pools/{poolID} enterprises pools GetEnterprisePool
|
||||
|
|
@ -414,7 +412,6 @@ func (a *APIController) DeleteEnterprisePoolHandler(w http.ResponseWriter, r *ht
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route PUT /enterprises/{enterpriseID}/pools/{poolID} enterprises pools UpdateEnterprisePool
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
gErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
runnerParams "github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route GET /pools/{poolID}/instances instances ListPoolInstances
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ import (
|
|||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
)
|
||||
|
||||
func (a *APIController) InstanceGithubRegistrationTokenHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
gErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
runnerParams "github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route POST /organizations organizations CreateOrg
|
||||
|
|
@ -174,7 +174,6 @@ func (a *APIController) DeleteOrgHandler(w http.ResponseWriter, r *http.Request)
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route PUT /organizations/{orgID} organizations UpdateOrg
|
||||
|
|
@ -423,7 +422,6 @@ func (a *APIController) DeleteOrgPoolHandler(w http.ResponseWriter, r *http.Requ
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route PUT /organizations/{orgID}/pools/{poolID} organizations pools UpdateOrgPool
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ import (
|
|||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
gErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
runnerParams "github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route GET /pools pools ListPools
|
||||
|
|
@ -37,7 +37,6 @@ func (a *APIController) ListAllPoolsHandler(w http.ResponseWriter, r *http.Reque
|
|||
ctx := r.Context()
|
||||
|
||||
pools, err := a.r.ListAllPools(ctx)
|
||||
|
||||
if err != nil {
|
||||
slog.With(slog.Any("error", err)).ErrorContext(ctx, "listing pools")
|
||||
handleError(ctx, w, err)
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@ import (
|
|||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
gErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/apiserver/params"
|
||||
runnerParams "github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
)
|
||||
|
||||
// swagger:route POST /repositories repositories CreateRepo
|
||||
|
|
@ -173,7 +173,6 @@ func (a *APIController) DeleteRepoHandler(w http.ResponseWriter, r *http.Request
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route PUT /repositories/{repoID} repositories UpdateRepo
|
||||
|
|
@ -422,7 +421,6 @@ func (a *APIController) DeleteRepoPoolHandler(w http.ResponseWriter, r *http.Req
|
|||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
}
|
||||
|
||||
// swagger:route PUT /repositories/{repoID}/pools/{poolID} repositories pools UpdateRepoPool
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ func requestLogger(h http.Handler) http.Handler {
|
|||
// gathers metrics from the upstream handlers
|
||||
metrics := httpsnoop.CaptureMetrics(h, w, r)
|
||||
|
||||
//prints log and metrics
|
||||
|
||||
slog.Info(
|
||||
"access_log",
|
||||
slog.String("method", r.Method),
|
||||
|
|
|
|||
10
auth/auth.go
10
auth/auth.go
|
|
@ -18,16 +18,16 @@ import (
|
|||
"context"
|
||||
"time"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
"github.com/nbutton23/zxcvbn-go"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
"github.com/cloudbase/garm/config"
|
||||
"github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
"github.com/nbutton23/zxcvbn-go"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
func NewAuthenticator(cfg config.JWTAuth, store common.Store) *Authenticator {
|
||||
|
|
|
|||
|
|
@ -22,15 +22,15 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/cloudbase/garm/config"
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// InstanceJWTClaims holds JWT claims
|
||||
|
|
@ -132,7 +132,6 @@ func (amw *instanceMiddleware) Middleware(next http.Handler) http.Handler {
|
|||
}
|
||||
return []byte(amw.cfg.Secret), nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
invalidAuthResponse(ctx, w)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -22,12 +22,12 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
apiParams "github.com/cloudbase/garm/apiserver/params"
|
||||
"github.com/cloudbase/garm/config"
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
)
|
||||
|
||||
// JWTClaims holds JWT claims
|
||||
|
|
@ -108,7 +108,6 @@ func (amw *jwtMiddleware) Middleware(next http.Handler) http.Handler {
|
|||
}
|
||||
return []byte(amw.cfg.Secret), nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
invalidAuthResponse(ctx, w)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudbase/garm/config"
|
||||
|
||||
jwt "github.com/golang-jwt/jwt/v5"
|
||||
|
||||
"github.com/cloudbase/garm/config"
|
||||
)
|
||||
|
||||
type MetricsMiddleware struct {
|
||||
|
|
@ -43,7 +43,6 @@ func (m *MetricsMiddleware) Middleware(next http.Handler) http.Handler {
|
|||
}
|
||||
return []byte(m.cfg.Secret), nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
invalidAuthResponse(ctx, w)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -17,10 +17,11 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
apiClientControllerInfo "github.com/cloudbase/garm/client/controller_info"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientControllerInfo "github.com/cloudbase/garm/client/controller_info"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var infoCmd = &cobra.Command{
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
apiClientCreds "github.com/cloudbase/garm/client/credentials"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientCreds "github.com/cloudbase/garm/client/credentials"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// credentialsCmd represents the credentials command
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
apiClientEnterprises "github.com/cloudbase/garm/client/enterprises"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientEnterprises "github.com/cloudbase/garm/client/enterprises"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -18,15 +18,15 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/common"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
apiClientFirstRun "github.com/cloudbase/garm/client/first_run"
|
||||
apiClientLogin "github.com/cloudbase/garm/client/login"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientFirstRun "github.com/cloudbase/garm/client/first_run"
|
||||
apiClientLogin "github.com/cloudbase/garm/client/login"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/common"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// initCmd represents the init command
|
||||
|
|
|
|||
|
|
@ -18,11 +18,12 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
apiClientJobs "github.com/cloudbase/garm/client/jobs"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/google/uuid"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientJobs "github.com/cloudbase/garm/client/jobs"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// runnerCmd represents the runner command
|
||||
|
|
|
|||
|
|
@ -11,11 +11,11 @@ import (
|
|||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
apiParams "github.com/cloudbase/garm/apiserver/params"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
apiParams "github.com/cloudbase/garm/apiserver/params"
|
||||
)
|
||||
|
||||
var logCmd = &cobra.Command{
|
||||
|
|
|
|||
|
|
@ -17,8 +17,9 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
apiClientMetricToken "github.com/cloudbase/garm/client/metrics_token"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientMetricToken "github.com/cloudbase/garm/client/metrics_token"
|
||||
)
|
||||
|
||||
// orgPoolCmd represents the pool command
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
apiClientOrgs "github.com/cloudbase/garm/client/organizations"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -20,18 +20,16 @@ import (
|
|||
"os"
|
||||
"strings"
|
||||
|
||||
apiClientEnterprises "github.com/cloudbase/garm/client/enterprises"
|
||||
apiClientOrgs "github.com/cloudbase/garm/client/organizations"
|
||||
apiClientPools "github.com/cloudbase/garm/client/pools"
|
||||
apiClientRepos "github.com/cloudbase/garm/client/repositories"
|
||||
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
apiClientEnterprises "github.com/cloudbase/garm/client/enterprises"
|
||||
apiClientOrgs "github.com/cloudbase/garm/client/organizations"
|
||||
apiClientPools "github.com/cloudbase/garm/client/pools"
|
||||
apiClientRepos "github.com/cloudbase/garm/client/repositories"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -18,13 +18,13 @@ import (
|
|||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientLogin "github.com/cloudbase/garm/client/login"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/common"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
apiClientProviders "github.com/cloudbase/garm/client/providers"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientProviders "github.com/cloudbase/garm/client/providers"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
// providerCmd represents the provider command
|
||||
|
|
|
|||
|
|
@ -17,12 +17,12 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
apiClientRepos "github.com/cloudbase/garm/client/repositories"
|
||||
"github.com/cloudbase/garm/params"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -19,14 +19,17 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
|
||||
apiClient "github.com/cloudbase/garm/client"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/go-openapi/runtime"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
|
||||
|
||||
openapiRuntimeClient "github.com/go-openapi/runtime/client"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClient "github.com/cloudbase/garm/client"
|
||||
"github.com/cloudbase/garm/cmd/garm-cli/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var Version string
|
||||
|
|
|
|||
|
|
@ -18,14 +18,17 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
apiClientEnterprises "github.com/cloudbase/garm/client/enterprises"
|
||||
apiClientInstances "github.com/cloudbase/garm/client/instances"
|
||||
apiClientOrgs "github.com/cloudbase/garm/client/organizations"
|
||||
apiClientRepos "github.com/cloudbase/garm/client/repositories"
|
||||
"github.com/jedib0t/go-pretty/v6/table"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -39,7 +39,6 @@ func PromptPassword(label string) (string, error) {
|
|||
Mask: '*',
|
||||
}
|
||||
result, err := prompt.Run()
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
@ -59,7 +58,6 @@ func PromptString(label string) (string, error) {
|
|||
Validate: validate,
|
||||
}
|
||||
result, err := prompt.Run()
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import (
|
|||
|
||||
func getHomeDir() (string, error) {
|
||||
home, err := os.UserHomeDir()
|
||||
|
||||
if err != nil {
|
||||
return "", errors.Wrap(err, "fetching home dir")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,11 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
"github.com/cloudbase/garm/apiserver/controllers"
|
||||
"github.com/cloudbase/garm/apiserver/routers"
|
||||
|
|
@ -41,11 +46,6 @@ import (
|
|||
garmUtil "github.com/cloudbase/garm/util"
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
"github.com/cloudbase/garm/websocket"
|
||||
lumberjack "gopkg.in/natefinch/lumberjack.v2"
|
||||
|
||||
"github.com/gorilla/handlers"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -140,7 +140,6 @@ func setupLogging(ctx context.Context, logCfg config.Logging, hub *websocket.Hub
|
|||
Handler: han,
|
||||
}
|
||||
slog.SetDefault(slog.New(wrapped))
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
|
|
|||
|
|
@ -26,15 +26,18 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
zxcvbn "github.com/nbutton23/zxcvbn-go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
)
|
||||
|
||||
type DBBackendType string
|
||||
type LogLevel string
|
||||
type LogFormat string
|
||||
type (
|
||||
DBBackendType string
|
||||
LogLevel string
|
||||
LogFormat string
|
||||
)
|
||||
|
||||
const (
|
||||
// MySQLBackend represents the MySQL DB backend
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -392,7 +393,6 @@ func TestGormParams(t *testing.T) {
|
|||
require.Nil(t, err)
|
||||
require.Equal(t, MySQLBackend, dbType)
|
||||
require.Equal(t, "test:test@tcp(127.0.0.1)/garm?charset=utf8&parseTime=True&loc=Local&timeout=5s", uri)
|
||||
|
||||
}
|
||||
|
||||
func TestSQLiteConfig(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util/exec"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/util/exec"
|
||||
)
|
||||
|
||||
// External represents the config for an external provider.
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ func getDefaultExternalConfig(t *testing.T) External {
|
|||
}
|
||||
t.Cleanup(func() { os.RemoveAll(dir) })
|
||||
|
||||
err = os.WriteFile(filepath.Join(dir, "garm-external-provider"), []byte{}, 0755)
|
||||
err = os.WriteFile(filepath.Join(dir, "garm-external-provider"), []byte{}, 0o755)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to write file: %s", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,8 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
GarmHealth = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: metricsNamespace,
|
||||
Name: "health",
|
||||
Help: "Health of the garm",
|
||||
}, []string{"metadata_url", "callback_url", "webhook_url", "controller_webhook_url", "controller_id"})
|
||||
)
|
||||
var GarmHealth = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: metricsNamespace,
|
||||
Name: "health",
|
||||
Help: "Health of the garm",
|
||||
}, []string{"metadata_url", "callback_url", "webhook_url", "controller_webhook_url", "controller_id"})
|
||||
|
|
|
|||
|
|
@ -4,15 +4,17 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
const metricsNamespace = "garm"
|
||||
const metricsRunnerSubsystem = "runner"
|
||||
const metricsPoolSubsystem = "pool"
|
||||
const metricsProviderSubsystem = "provider"
|
||||
const metricsOrganizationSubsystem = "organization"
|
||||
const metricsRepositorySubsystem = "repository"
|
||||
const metricsEnterpriseSubsystem = "enterprise"
|
||||
const metricsWebhookSubsystem = "webhook"
|
||||
const metricsGithubSubsystem = "github"
|
||||
const (
|
||||
metricsNamespace = "garm"
|
||||
metricsRunnerSubsystem = "runner"
|
||||
metricsPoolSubsystem = "pool"
|
||||
metricsProviderSubsystem = "provider"
|
||||
metricsOrganizationSubsystem = "organization"
|
||||
metricsRepositorySubsystem = "repository"
|
||||
metricsEnterpriseSubsystem = "enterprise"
|
||||
metricsWebhookSubsystem = "webhook"
|
||||
metricsGithubSubsystem = "github"
|
||||
)
|
||||
|
||||
// RegisterMetrics registers all the metrics
|
||||
func RegisterMetrics() error {
|
||||
|
|
|
|||
|
|
@ -4,11 +4,9 @@ import (
|
|||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
ProviderInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: metricsProviderSubsystem,
|
||||
Name: "info",
|
||||
Help: "Info of the organization",
|
||||
}, []string{"name", "type", "description"})
|
||||
)
|
||||
var ProviderInfo = prometheus.NewGaugeVec(prometheus.GaugeOpts{
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: metricsProviderSubsystem,
|
||||
Name: "info",
|
||||
Help: "Info of the organization",
|
||||
}, []string{"name", "type", "description"})
|
||||
|
|
|
|||
|
|
@ -2,11 +2,9 @@ package metrics
|
|||
|
||||
import "github.com/prometheus/client_golang/prometheus"
|
||||
|
||||
var (
|
||||
WebhooksReceived = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: metricsWebhookSubsystem,
|
||||
Name: "received",
|
||||
Help: "The total number of webhooks received",
|
||||
}, []string{"valid", "reason"})
|
||||
)
|
||||
var WebhooksReceived = prometheus.NewCounterVec(prometheus.CounterOpts{
|
||||
Namespace: metricsNamespace,
|
||||
Subsystem: metricsWebhookSubsystem,
|
||||
Name: "received",
|
||||
Help: "The total number of webhooks received",
|
||||
}, []string{"valid", "reason"})
|
||||
|
|
|
|||
|
|
@ -22,12 +22,11 @@ import (
|
|||
"fmt"
|
||||
"time"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/google/uuid"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/cloudbase/garm/util/appdefaults"
|
||||
)
|
||||
|
||||
type (
|
||||
|
|
|
|||
|
|
@ -18,9 +18,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
)
|
||||
|
||||
const DefaultRunnerPrefix = "garm"
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ import (
|
|||
"net/url"
|
||||
"strings"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
func validateHookRequest(controllerID, baseURL string, allHooks []*github.Hook, req *github.Hook) error {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
|
|
@ -17,9 +20,6 @@ import (
|
|||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
"github.com/cloudbase/garm/util"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// test that we implement PoolManager
|
||||
|
|
@ -344,7 +344,6 @@ func (r *enterprise) GetGithubRegistrationToken() (string, error) {
|
|||
).Inc()
|
||||
|
||||
tk, ghResp, err := r.ghcEnterpriseCli.CreateRegistrationToken(r.ctx, r.cfg.Name)
|
||||
|
||||
if err != nil {
|
||||
metrics.GithubOperationFailedCount.WithLabelValues(
|
||||
"CreateRegistrationToken", // label: operation
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ package pool
|
|||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
)
|
||||
|
||||
type poolHelper interface {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
|
|
@ -31,9 +34,6 @@ import (
|
|||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
"github.com/cloudbase/garm/util"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// test that we implement PoolManager
|
||||
|
|
@ -357,7 +357,6 @@ func (r *organization) GetGithubRegistrationToken() (string, error) {
|
|||
metricsLabelOrganizationScope, // label: scope
|
||||
).Inc()
|
||||
tk, ghResp, err := r.ghcli.CreateOrganizationRegistrationToken(r.ctx, r.cfg.Name)
|
||||
|
||||
if err != nil {
|
||||
metrics.GithubOperationFailedCount.WithLabelValues(
|
||||
"CreateOrganizationRegistrationToken", // label: operation
|
||||
|
|
|
|||
|
|
@ -25,19 +25,18 @@ import (
|
|||
"sync"
|
||||
"time"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/cloudbase/garm-provider-common/util"
|
||||
"github.com/cloudbase/garm/auth"
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/google/uuid"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -674,7 +673,7 @@ func (r *basePoolManager) cleanupOrphanedGithubRunners(runners []*github.Runner)
|
|||
slog.InfoContext(
|
||||
r.ctx, "instance was found in stopped state; starting",
|
||||
"runner_name", dbInstance.Name)
|
||||
//start the instance
|
||||
|
||||
if err := provider.Start(r.ctx, dbInstance.ProviderID); err != nil {
|
||||
return errors.Wrapf(err, "starting instance %s", dbInstance.ProviderID)
|
||||
}
|
||||
|
|
@ -1196,7 +1195,6 @@ func (r *basePoolManager) ensureIdleRunnersForOnePool(pool params.Pool) error {
|
|||
existingInstances, err := r.store.ListPoolInstances(r.ctx, pool.ID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to ensure minimum idle workers for pool %s: %w", pool.ID, err)
|
||||
|
||||
}
|
||||
|
||||
if uint(len(existingInstances)) >= pool.MaxRunners {
|
||||
|
|
|
|||
|
|
@ -24,6 +24,9 @@ import (
|
|||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
runnerErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
dbCommon "github.com/cloudbase/garm/database/common"
|
||||
|
|
@ -31,9 +34,6 @@ import (
|
|||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
"github.com/cloudbase/garm/util"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// test that we implement PoolManager
|
||||
|
|
@ -314,7 +314,6 @@ func (r *repository) GetGithubRegistrationToken() (string, error) {
|
|||
metricsLabelRepositoryScope, // label: scope
|
||||
).Inc()
|
||||
tk, ghResp, err := r.ghcli.CreateRegistrationToken(r.ctx, r.cfg.Owner, r.cfg.Name)
|
||||
|
||||
if err != nil {
|
||||
metrics.GithubOperationFailedCount.WithLabelValues(
|
||||
"CreateRegistrationToken", // label: operation
|
||||
|
|
|
|||
8
runner/providers/external/external.go
vendored
8
runner/providers/external/external.go
vendored
|
|
@ -7,18 +7,16 @@ import (
|
|||
"log/slog"
|
||||
"os/exec"
|
||||
|
||||
"github.com/cloudbase/garm-provider-common/execution"
|
||||
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
garmErrors "github.com/cloudbase/garm-provider-common/errors"
|
||||
"github.com/cloudbase/garm-provider-common/execution"
|
||||
commonParams "github.com/cloudbase/garm-provider-common/params"
|
||||
garmExec "github.com/cloudbase/garm-provider-common/util/exec"
|
||||
"github.com/cloudbase/garm/config"
|
||||
"github.com/cloudbase/garm/metrics"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var _ common.Provider = (*external)(nil)
|
||||
|
|
|
|||
|
|
@ -18,12 +18,12 @@ import (
|
|||
"context"
|
||||
"log/slog"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/cloudbase/garm/config"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
"github.com/cloudbase/garm/runner/providers/external"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// LoadProvidersFromConfig loads all providers from the config and populates
|
||||
|
|
|
|||
|
|
@ -4,10 +4,11 @@ import (
|
|||
"log/slog"
|
||||
"net/url"
|
||||
|
||||
"github.com/cloudbase/garm/client"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/go-openapi/runtime"
|
||||
openapiRuntimeClient "github.com/go-openapi/runtime/client"
|
||||
|
||||
"github.com/cloudbase/garm/client"
|
||||
"github.com/cloudbase/garm/params"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package e2e
|
||||
|
||||
import (
|
||||
"github.com/go-openapi/runtime"
|
||||
|
||||
"github.com/cloudbase/garm/client"
|
||||
clientControllerInfo "github.com/cloudbase/garm/client/controller_info"
|
||||
clientCredentials "github.com/cloudbase/garm/client/credentials"
|
||||
|
|
@ -14,7 +16,6 @@ import (
|
|||
clientProviders "github.com/cloudbase/garm/client/providers"
|
||||
clientRepositories "github.com/cloudbase/garm/client/repositories"
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/go-openapi/runtime"
|
||||
)
|
||||
|
||||
// ///////////
|
||||
|
|
|
|||
|
|
@ -21,12 +21,12 @@ import (
|
|||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
|
||||
"github.com/google/go-github/v57/github"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/oauth2"
|
||||
|
||||
"github.com/cloudbase/garm/params"
|
||||
"github.com/cloudbase/garm/runner/common"
|
||||
)
|
||||
|
||||
type githubClient struct {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue