Skip to content

Commit

Permalink
refactor(项目): 使用别名的方式来重构框架接入
Browse files Browse the repository at this point in the history
  • Loading branch information
storezhang committed Mar 23, 2023
1 parent faf9bb4 commit 6dd6c1d
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 74 deletions.
59 changes: 37 additions & 22 deletions .drone.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
kind: secret
name: token_github
get:
path: secrets
name: token_github_storezhang
---


kind: pipeline
type: docker
name: # TODO
name: 发布


clone:
disable: true


environment:
CHANGELOG_TAG_OUTPUT: CHANGELOG.tag.md


steps:
- name: 代码
image: ccr.ccs.tencentyun.com/dronestock/git
pull: always

- name: 编译
image: ccr.ccs.tencentyun.com/pangum/drone
pull: always
volumes:
- name: go
path: /var/lib/go
settings:
output: # TODO
compress:
enabled: false

- name: 改变
image: ccr.ccs.tencentyun.com/dronestock/changelog
pull: always
when:
event:
- tag
settings:
output: $${CHANGELOG_TAG_OUTPUT}

- name: 发布
image: ccr.ccs.tencentyun.com/dronestock/docker
privileged: true
volumes:
- name: docker
path: /var/lib/docker
image: ccr.ccs.tencentyun.com/dronestock/github
pull: always
when:
event:
- tag
environment:
PASSWORD_DOCKER:
from_secret: token_docker
PASSWORD_CCR:
from_secret: password_tencentyun_ccr
TOKEN:
from_secret: token_github
settings:
repository: # TODO
registries:
- username: # TODO
password: $${PASSWORD_DOCKER}
- hostname: ccr.ccs.tencentyun.com
username: "160290688"
password: $${PASSWORD_CCR}
required: true
release:
tag: $${DRONE_TAG}
token: $${TOKEN}
body: file('$${CHANGELOG_TAG_OUTPUT}')


volumes:
- name: go
host:
path: /var/lib/cache/go
- name: docker
host:
path: /var/lib/cache/docker
13 changes: 1 addition & 12 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,7 @@ updates:
- package-ecosystem: gomod
directory: /
schedule:
interval: weekly
pull-request-branch-name:
separator: "-"
assignees:
- storezhang
reviewers:
- storezhang

- package-ecosystem: npm
directory: /doc
schedule:
interval: weekly
interval: daily
pull-request-branch-name:
separator: "-"
assignees:
Expand Down
26 changes: 2 additions & 24 deletions generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,7 @@ package pid

import (
"github.com/goexl/id"
"github.com/pangum/logging"
"github.com/pangum/pangu"
)

// Generator 点位,以直接引入带替间接引入
type Generator struct {
id.Generator
}

func newGenerator(config *pangu.Config, logger *logging.Logger) (generator *Generator, err error) {
panguConfig := new(panguConfig)
if err = config.Load(panguConfig); nil != err {
return
}

generator = new(Generator)
_config := panguConfig.Id
builder := id.New(id.Logger(logger))
if nil != _config.Autoincrement {
generator.Generator = builder.Autoincrement().From(_config.Autoincrement.From).Build()
} else if nil != _config.Snowflake {
generator.Generator = builder.Snowflake(_config.Snowflake.Node).Build()
}

return
}
// Generator 以直接引入带替间接引入
type Generator = id.Generator
30 changes: 15 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@ go 1.19

require (
github.com/goexl/id v0.0.2
github.com/pangum/logging v0.1.9
github.com/pangum/pangu v0.3.0
github.com/pangum/logging v0.2.0
github.com/pangum/pangu v0.3.1
)

require (
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/drone/envsubst v1.0.3 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.11.1 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/goexl/baozheng v0.0.1 // indirect
github.com/goexl/env v0.0.2 // indirect
github.com/goexl/exc v0.0.5 // indirect
github.com/goexl/gfx v0.1.6 // indirect
github.com/goexl/gox v0.1.6 // indirect
github.com/goexl/mengpo v0.2.3 // indirect
github.com/goexl/simaqian v0.2.1 // indirect
github.com/goexl/gfx v0.1.7 // indirect
github.com/goexl/gox v0.3.0 // indirect
github.com/goexl/mengpo v0.2.4 // indirect
github.com/goexl/simaqian v0.2.4 // indirect
github.com/goexl/xiren v0.0.5 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/rs/xid v1.4.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/storezhang/dig v0.0.1 // indirect
github.com/urfave/cli/v2 v2.23.6 // indirect
github.com/urfave/cli/v2 v2.25.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
github.com/zs5460/art v0.2.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/multierr v1.10.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/crypto v0.3.0 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/text v0.8.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
24 changes: 24 additions & 0 deletions new.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package pid

import (
"github.com/goexl/id"
"github.com/pangum/logging"
"github.com/pangum/pangu"
)

func newGenerator(config *pangu.Config, logger logging.Logger) (generator Generator, err error) {
wrap := new(wrapper)
if err = config.Load(wrap); nil != err {
return
}

conf := wrap.Id
builder := id.New(id.Logger(logger))
if nil != conf.Autoincrement {
generator = builder.Autoincrement().From(conf.Autoincrement.From).Build()
} else if nil != conf.Snowflake {
generator = builder.Snowflake(conf.Snowflake.Node).Build()
}

return
}
2 changes: 1 addition & 1 deletion pangu_config.go → wrapper.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package pid

type panguConfig struct {
type wrapper struct {
Id *config
}

0 comments on commit 6dd6c1d

Please sign in to comment.