Skip to content

Commit

Permalink
go fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
pickledish committed Dec 13, 2023
1 parent 07d41c0 commit 1879eef
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 44 deletions.
6 changes: 3 additions & 3 deletions cmd/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ func (s Server) CreateSite(out http.ResponseWriter, req *http.Request) {
// get the nickname
var body CreateSiteRequest

err = json.NewDecoder(req.Body).Decode(&body)
if err != nil {
err = json.NewDecoder(req.Body).Decode(&body)
if err != nil {
log.Printf("[ERROR] Request body did not parse as expected: %w, body %v", err, req.Body)
http.Error(out, "Malformed input, just send JSON with a nickname field", http.StatusBadRequest)
return
}
}

// needed by pretty much all the below functions, so let's gen it here
siteId := fmt.Sprintf("%v-%v-%v", util.RandomString(3), util.RandomString(3), util.RandomString(3))
Expand Down
44 changes: 22 additions & 22 deletions cmd/api/bunny.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,27 +127,27 @@ func (b BunnyClient) CreateStorageZone(ctx context.Context, siteId string) *Crea
func (b BunnyClient) CreatePullZone(ctx context.Context, siteId string, storage *CreateStorageZoneResponse) string {

body := CreatePullZoneBody{
Name: siteId,
Type: 0, // Premium (SSD)
StorageZoneId: storage.Id,
OriginType: 2, // StorageZone
EnableGeoZoneUS: true,
EnableGeoZoneEU: true,
EnableGeoZoneASIA: true,
EnableGeoZoneSA: true,
EnableGeoZoneAF: true,
EnableLogging: true,
LogFormat: 0, // plaintext
LogForwardingFormat: 0, // plaintext
LoggingIPAnonymizationEnabled: true,
LogAnonymizationType: 0, // one-octet
LogForwardingEnabled: true,
LogForwardingHostname: "intake.cbnr.xyz",
LogForwardingPort: 517,
LogForwardingProtocol: 0, // UDP
UseStaleWhileUpdating: true,
UseStaleWhileOffline: true,
EnableAutoSSL: true,
Name: siteId,
Type: 0, // Premium (SSD)
StorageZoneId: storage.Id,
OriginType: 2, // StorageZone
EnableGeoZoneUS: true,
EnableGeoZoneEU: true,
EnableGeoZoneASIA: true,
EnableGeoZoneSA: true,
EnableGeoZoneAF: true,
EnableLogging: true,
LogFormat: 0, // plaintext
LogForwardingFormat: 0, // plaintext
LoggingIPAnonymizationEnabled: true,
LogAnonymizationType: 0, // one-octet
LogForwardingEnabled: true,
LogForwardingHostname: "intake.cbnr.xyz",
LogForwardingPort: 517,
LogForwardingProtocol: 0, // UDP
UseStaleWhileUpdating: true,
UseStaleWhileOffline: true,
EnableAutoSSL: true,
}

log.Printf("[INFO] Creating bunny pull zone with request body: %+v", body)
Expand All @@ -171,7 +171,7 @@ func (b BunnyClient) CreatePullZone(ctx context.Context, siteId string, storage
return ""
}

if !resp.Enabled {
if !resp.Enabled {
log.Printf("[ERROR] Unexpected not enabled created pull zone: %v", resp.Id)
return ""
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/api/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ var ApiCmd = &cobra.Command{
r.Use(util.CheckJwtMiddleware(permissive, false))

sup := SupabaseClient{
SupabaseUrl: "",
SupabaseUrl: "",
SupabaseAdminToken: "",
}

bun := BunnyClient{
BunnyUrl: "https://api.bunny.net",
BunnyUrl: "https://api.bunny.net",
BunnyAccessKey: "aaaaa",
}

Expand Down
14 changes: 7 additions & 7 deletions cmd/api/supabase.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ type AuthorizeHostnameBody struct {
func (s SupabaseClient) CreateSiteRow(ctx context.Context, jwt, userId, siteId, nickname string, storage *CreateStorageZoneResponse) bool {

body := CreateSiteRowBody{
Id: siteId,
Nickname: nickname,
UserId: userId,
StorageName: storage.Name,
Id: siteId,
Nickname: nickname,
UserId: userId,
StorageName: storage.Name,
StorageToken: storage.Password,
}

Expand Down Expand Up @@ -70,10 +70,10 @@ func (s SupabaseClient) CreateSiteRow(ctx context.Context, jwt, userId, siteId,
func (s SupabaseClient) CreateAliasRow(ctx context.Context, jwt, userId, siteId, hostname string) bool {

body := CreateAliasRowBody{
UserId: userId,
SiteId: siteId,
UserId: userId,
SiteId: siteId,
Hostname: hostname,
Default: true,
Default: true,
}

log.Printf("[INFO] Creating new ALIAS row with request body: %+v", body)
Expand Down
6 changes: 3 additions & 3 deletions cmd/git/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func RenderPostReceiveHookMiddleware(next http.Handler) http.Handler {
log.Printf("site ID found for repo %s, storage %s", repoName, storage[0])

hookValues := HookValues{
SiteId: repoName,
StorageHost: "storage.bunnycdn.com",
StorageName: storage[0].Name,
SiteId: repoName,
StorageHost: "storage.bunnycdn.com",
StorageName: storage[0].Name,
StorageToken: storage[0].Token,
}

Expand Down
6 changes: 3 additions & 3 deletions cmd/git/template.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package git

type HookValues struct {
SiteId string
StorageHost string
StorageName string
SiteId string
StorageHost string
StorageName string
StorageToken string
}

Expand Down
8 changes: 4 additions & 4 deletions util/random.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ func RandomString(length int) string {
res := make([]rune, length)
alphabet := []rune("abcdefghijklmnopqrstuvwxyz")

for i := 0; i < length; i++ {
res[i] = alphabet[rand.Intn(26)]
}
for i := 0; i < length; i++ {
res[i] = alphabet[rand.Intn(26)]
}

return string(res)
return string(res)
}

0 comments on commit 1879eef

Please sign in to comment.