-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linter and Drone config fixes, code linting.
- Loading branch information
Showing
22 changed files
with
152 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
*DS_Store* | ||
data/* | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
package serverv1 | ||
|
||
import ( | ||
// stdlib | ||
"net/http" | ||
|
||
// local | ||
"github.com/labstack/echo" | ||
"go.dev.pztrn.name/giredore/internal/configuration" | ||
"go.dev.pztrn.name/giredore/internal/structs" | ||
|
||
// other | ||
"github.com/labstack/echo" | ||
) | ||
|
||
// This function responsible for getting runtime configuration. | ||
func configurationGET(ec echo.Context) error { | ||
// nolint:wrapcheck | ||
return ec.JSON(http.StatusOK, configuration.Cfg) | ||
} | ||
|
||
func configurationAllowedIPsSET(ec echo.Context) error { | ||
func configurationAllowedIPsSET(ectx echo.Context) error { | ||
// nolint:exhaustivestruct | ||
req := &structs.AllowedIPsSetRequest{} | ||
if err := ec.Bind(req); err != nil { | ||
if err := ectx.Bind(req); err != nil { | ||
log.Error().Err(err).Msg("Failed to parse allowed IPs set request") | ||
return ec.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: []structs.Error{structs.ErrParsingAllowedIPsSetRequest}}) | ||
// nolint:exhaustivestruct,wrapcheck | ||
return ectx.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: []structs.Error{structs.ErrParsingAllowedIPsSetRequest}}) | ||
} | ||
|
||
log.Debug().Msgf("Got set allowed IPs request: %+v", req) | ||
|
||
configuration.Cfg.SetAllowedIPs(req.AllowedIPs) | ||
|
||
return ec.JSON(http.StatusOK, &structs.Reply{Status: structs.StatusSuccess}) | ||
// nolint:exhaustivestruct,wrapcheck | ||
return ectx.JSON(http.StatusOK, &structs.Reply{Status: structs.StatusSuccess}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,50 @@ | ||
package serverv1 | ||
|
||
import ( | ||
// stdlib | ||
"net/http" | ||
"strings" | ||
|
||
// local | ||
"github.com/labstack/echo" | ||
"go.dev.pztrn.name/giredore/internal/configuration" | ||
"go.dev.pztrn.name/giredore/internal/structs" | ||
|
||
// other | ||
"github.com/labstack/echo" | ||
) | ||
|
||
func throwGoImports(ec echo.Context) error { | ||
func throwGoImports(ectx echo.Context) error { | ||
// Getting real path. This might be the package itself, or namespace | ||
// to list available packages. | ||
// For now only package itself is supported, all other features in ToDo. | ||
packageNameRaw := ec.Request().URL.Path | ||
packageNameRaw := ectx.Request().URL.Path | ||
|
||
pkgs, errs := configuration.Cfg.GetPackagesInfo([]string{packageNameRaw}) | ||
|
||
if errs != nil { | ||
log.Error().Str("package", packageNameRaw).Msgf("Failed to get package information: %+v", errs) | ||
return ec.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: errs}) | ||
|
||
// nolint:exhaustivestruct,wrapcheck | ||
return ectx.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: errs}) | ||
} | ||
|
||
if len(pkgs) == 0 { | ||
return ec.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: []structs.Error{structs.ErrNoPackagesFound}}) | ||
// nolint:exhaustivestruct,wrapcheck | ||
return ectx.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: []structs.Error{structs.ErrNoPackagesFound}}) | ||
} | ||
|
||
pkg, found := pkgs[packageNameRaw] | ||
if !found { | ||
return ec.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: []structs.Error{structs.ErrNoPackagesFound}}) | ||
// nolint:exhaustivestruct,wrapcheck | ||
return ectx.JSON(http.StatusBadRequest, &structs.Reply{Status: structs.StatusFailure, Errors: []structs.Error{structs.ErrNoPackagesFound}}) | ||
} | ||
|
||
// We should compose package name using our domain under which giredore | ||
// is working. | ||
domain := ec.Request().Host | ||
domain := ectx.Request().Host | ||
packageName := domain + packageNameRaw | ||
|
||
tmpl := singlePackageTemplate | ||
tmpl = strings.Replace(tmpl, "{PKGNAME}", packageName, -1) | ||
tmpl = strings.Replace(tmpl, "{VCS}", pkg.VCS, 1) | ||
tmpl = strings.Replace(tmpl, "{REPOPATH}", pkg.RealPath, 1) | ||
|
||
return ec.HTML(http.StatusOK, tmpl) | ||
// nolint:wrapcheck | ||
return ectx.HTML(http.StatusOK, tmpl) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
package configuration | ||
|
||
import ( | ||
// other | ||
"github.com/vrischmann/envconfig" | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.