Skip to content

Commit

Permalink
Merge pull request #3 from opengapps:update-deps-gapps
Browse files Browse the repository at this point in the history
Update deps, switch to own gapps package
  • Loading branch information
nezorflame authored Jul 11, 2021
2 parents ed6d083 + ff70bd4 commit f59b3e3
Show file tree
Hide file tree
Showing 18 changed files with 514 additions and 159 deletions.
6 changes: 2 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ output:
linters-settings:
govet:
check-shadowing: true
golint:
min-confidence: 0
dupl:
threshold: 100
goconst:
Expand All @@ -31,7 +29,7 @@ linters-settings:
linters:
disable-all: true
enable:
- golint
- revive
- govet
- errcheck
- deadcode
Expand All @@ -51,7 +49,7 @@ issues:
# _ instead of err checks
- G104
# for "public interface + private struct implementation" cases only!
- exported func * returns unexported type *, which can be annoying to use
- exported func .* returns unexported type .*, which can be annoying to use
# can be removed in the development phase
# - (comment on exported (method|function|type|const)|should have( a package)? comment|comment should be of the form)
# not for the active development - can be removed in the stable phase
Expand Down
2 changes: 1 addition & 1 deletion cmd/package-api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func main() {

// init graceful stop chan
log.Debug("Initiating system signal watcher")
var gracefulStop = make(chan os.Signal)
var gracefulStop = make(chan os.Signal, 1)
signal.Notify(gracefulStop, syscall.SIGTERM)
signal.Notify(gracefulStop, syscall.SIGINT)

Expand Down
20 changes: 11 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ module github.com/opengapps/package-api
go 1.13

require (
github.com/google/go-github/v32 v32.1.0
github.com/google/go-github/v37 v37.0.0
github.com/gorilla/feeds v1.1.1
github.com/gorilla/handlers v1.5.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/mux v1.8.0
github.com/nezorflame/opengapps-mirror-bot/pkg/gapps v1.3.0
github.com/sirupsen/logrus v1.6.0
github.com/opengapps/package-api/pkg/gapps v1.0.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
github.com/stretchr/testify v1.6.1
go.etcd.io/bbolt v1.3.5
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
go.etcd.io/bbolt v1.3.6
golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
)

replace github.com/opengapps/package-api/pkg/gapps => ./pkg/gapps
308 changes: 176 additions & 132 deletions go.sum

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions internal/app/package-api/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"time"

"github.com/opengapps/package-api/internal/pkg/models"

"github.com/nezorflame/opengapps-mirror-bot/pkg/gapps"
"github.com/opengapps/package-api/pkg/gapps"
)

const mirrorTemplate = "?r=&ts=%d&use_mirror=autoselect"
Expand Down
5 changes: 2 additions & 3 deletions internal/app/package-api/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ import (

"github.com/opengapps/package-api/internal/pkg/db"
"github.com/opengapps/package-api/internal/pkg/models"

"github.com/nezorflame/opengapps-mirror-bot/pkg/gapps"
"github.com/opengapps/package-api/pkg/gapps"
log "github.com/sirupsen/logrus"
)

func (a *application) listHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, _ *http.Request) {
resp := models.ListResponse{
ArchList: make(map[string]models.ArchRecord, 4),
}
Expand Down
3 changes: 1 addition & 2 deletions internal/app/package-api/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ import (
"strings"
"time"

"github.com/nezorflame/opengapps-mirror-bot/pkg/gapps"

"github.com/opengapps/package-api/internal/pkg/db"
"github.com/opengapps/package-api/pkg/gapps"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion internal/app/package-api/rss.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (

"github.com/gorilla/feeds"
"github.com/gorilla/mux"
"github.com/nezorflame/opengapps-mirror-bot/pkg/gapps"

"github.com/opengapps/package-api/pkg/gapps"
)

const archAll = "all"
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/models/link.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package models
import (
"fmt"

"github.com/nezorflame/opengapps-mirror-bot/pkg/gapps"
"github.com/opengapps/package-api/pkg/gapps"
)

// Public consts
Expand Down
2 changes: 1 addition & 1 deletion internal/pkg/models/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync"
"time"

"github.com/nezorflame/opengapps-mirror-bot/pkg/gapps"
"github.com/opengapps/package-api/pkg/gapps"
)

// Public consts
Expand Down
77 changes: 77 additions & 0 deletions pkg/gapps/android_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions pkg/gapps/gapps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//go:generate enumer -type=Android -json -transform=snake -trimprefix=Android
//go:generate enumer -type=Platform -json -transform=snake -trimprefix=Platform
//go:generate enumer -type=Variant -json -transform=snake -trimprefix=Variant

package gapps

import (
"fmt"
)

// Platform is an enum for different chip architectures
type Platform uint

// Platform consts
const (
PlatformArm Platform = iota
PlatformArm64
PlatformX86
PlatformX86_64
)

// Android is an enum for different Android versions
type Android uint

// Android consts
const (
Android44 Android = iota
Android50
Android51
Android60
Android70
Android71
Android80
Android81
Android90
Android100
Android110
)

// HumanString is required for human-readable Android version with . delimiter
func (a Android) HumanString() string {
result := a.String()
return result[:len(result)-1] + "." + result[len(result)-1:]
}

// Variant is an enum for different package variations
type Variant uint

// Variant consts
const (
VariantTvstock Variant = iota
VariantPico
VariantNano
VariantMicro
VariantMini
VariantFull
VariantStock
VariantSuper
VariantAroma
VariantTvmini
)

const parsingErrText = "parsing error: %w"

// ParsePackageParts helps to parse package info args into proper parts
func ParsePackageParts(args []string) (Platform, Android, Variant, error) {
if len(args) != 3 {
return 0, 0, 0, fmt.Errorf("bad number of arguments: want 4, got %d", len(args))
}

platform, err := PlatformString(args[0])
if err != nil {
return 0, 0, 0, fmt.Errorf(parsingErrText, err)
}

android, err := AndroidString(args[1])
if err != nil {
return 0, 0, 0, fmt.Errorf(parsingErrText, err)
}

variant, err := VariantString(args[2])
if err != nil {
return 0, 0, 0, fmt.Errorf(parsingErrText, err)
}

return platform, android, variant, nil
}
3 changes: 3 additions & 0 deletions pkg/gapps/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/opengapps/package-api/pkg/gapps

go 1.13
Empty file added pkg/gapps/go.sum
Empty file.
70 changes: 70 additions & 0 deletions pkg/gapps/platform_enumer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f59b3e3

Please sign in to comment.