Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update module github.com/hashicorp/vault/api to v1.9.1 #12

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
f7faf2d
Feature: Add support method create database
huuhait Jul 8, 2022
c44decb
Add support system event for rango
huuhait Jul 8, 2022
f9cfe8a
Feature: add support trace level for logger
huuhait Jul 9, 2022
f4e81c2
Fix: gpa select wrong logic
huuhait Jul 9, 2022
3034620
Feature: add support extract query string for epa
huuhait Jul 9, 2022
717d9c4
Add support pg client
huuhait Jul 10, 2022
b35c7ce
Upgrade: add more func to utils
huuhait Jul 11, 2022
905d9de
Upgrade: Add support repository
huuhait Jul 11, 2022
7e7d1b8
Upgrade: add support event callback for database
huuhait Jul 11, 2022
c203f0d
Fix: missing raw sql for repository
huuhait Jul 12, 2022
3150336
Fix missing Last method for repository
huuhait Jul 12, 2022
187baf4
Add support context for repository
huuhait Jul 13, 2022
7d06efd
Add support context for all infrastucture
huuhait Jul 13, 2022
b0fbd89
Fix: transaction error handle
huuhait Jul 14, 2022
f280407
Fix: decrypt vault transit
huuhait Jul 22, 2022
56c3074
Merge branch 'v2' of ssh://github.com/zsmartex/pkg into v2
huuhait Jul 22, 2022
3f52e74
Feature: add support Aggregations for epa
huuhait Jul 26, 2022
352d519
Add support HExists for redis
huuhait Jul 28, 2022
93c025f
Allow stack trace handle for repository transaction
huuhait Jul 30, 2022
402b085
Add support filters for create method in repository
huuhait Jul 30, 2022
19362ab
Fix: query IN on elasticsearch
huuhait Jul 31, 2022
36241b9
Fix: query IN on elasticsearch
huuhait Jul 31, 2022
1de276d
Add support elasticsearch logger
huuhait Jul 31, 2022
8b6d8ef
Adđ support uploader context
huuhait Aug 1, 2022
c8963a4
Fix: missing WithFieldIsNotNull for gpa
huuhait Aug 5, 2022
f8e4607
feature: add aws sdk go (#32)
hoangnd02 Aug 10, 2022
a73b399
Allow return phone for jwt
huuhait Aug 15, 2022
736fd16
Update: has phone for jwwt
huuhait Aug 15, 2022
26c1fcb
Add support utils.RemoveDuplicateSpace
huuhait Aug 18, 2022
65afe6f
Add support return DB in repository
huuhait Aug 18, 2022
3586b0f
Merge remote-tracking branch 'origin/v2' into v2
huuhait Aug 19, 2022
f07eb96
Add support return DB in repository
huuhait Aug 19, 2022
54bf326
Add support TableName for repo
shinhagunn Aug 19, 2022
d4a7262
Add support compare and diff for utils
huuhait Aug 22, 2022
ebe457c
Disable nested transaction savepoint
huuhait Aug 23, 2022
a150910
Allow return no such index in elasticsearch
huuhait Aug 24, 2022
5a933a2
Add support elasticsearch v8
huuhait Aug 24, 2022
03f61a0
Change jwt level types
huuhait Aug 25, 2022
c621caf
Add support Aggregations for epa
huuhait Aug 25, 2022
65cbcdf
Fix: multiple query for epa not working
huuhait Aug 25, 2022
ed6390b
Add support more validate for queries
huuhait Aug 29, 2022
fb26676
Remove unused validate for queries
huuhait Aug 29, 2022
8c85d42
Add support OTP for jwt
huuhait Aug 30, 2022
deeb824
Fix 1
huuhait Sep 1, 2022
b0fa280
Allow return pointer in value for epa
huuhait Sep 2, 2022
9fb8d4b
add support usecase interface for pkg
huuhait Sep 2, 2022
c871d6e
Fix: usecase struct name
huuhait Sep 2, 2022
ecaac97
Fix: usecase struct name
huuhait Sep 2, 2022
7e188b2
Fix: add missing interface for usecase
huuhait Sep 2, 2022
b3949de
Add missing RawFind method
huuhait Sep 2, 2022
06a7903
Fix uploader
huuhait Sep 2, 2022
23dadf4
Fix mergo missing method to merge only empty dst value
huuhait Sep 3, 2022
d2e5095
Fix compare diff
huuhait Sep 5, 2022
eb04b27
Add support data jwt
huuhait Sep 26, 2022
baaa354
Feature: Add support exec query sql
huuhait Oct 2, 2022
f281789
Feature: remove all extra spaces in database logging
huuhait Oct 2, 2022
8981841
feature: add support sum aggregation elasticsearch
shinhagunn Oct 6, 2022
ef5bb30
Feature: make kafka fetch offset with only topic
shinhagunn Oct 8, 2022
74a4933
Trst
shinhagunn Oct 8, 2022
c81ac1f
Test
shinhagunn Oct 8, 2022
0dc45ba
Trest
shinhagunn Oct 8, 2022
8d33433
Test
shinhagunn Oct 8, 2022
1445d8f
Add support health check for infrastucture
huuhait Nov 10, 2022
6c6f979
Add support validate limitUntil for queries.Period
huuhait Nov 11, 2022
2d5a6a3
Add support docs for queries
huuhait Nov 11, 2022
093bf49
Add support init for queries.Period
huuhait Nov 11, 2022
8924e31
Fix queries
huuhait Nov 14, 2022
e213b41
Fix
huuhait Nov 14, 2022
a4a23ca
Fix
huuhait Nov 14, 2022
39c5466
Fix
huuhait Nov 14, 2022
91e0926
Fix
huuhait Nov 14, 2022
9e973ed
Fix
huuhait Nov 14, 2022
7f1c3fb
Fix queries
huuhait Nov 15, 2022
e328873
Add support simple protocol for gorm
huuhait Nov 16, 2022
8d3ad8d
Add support retry for questdb
huuhait Nov 17, 2022
24a7a5e
Add support pgx query logger and uuid & decimal type
huuhait Nov 17, 2022
45f3bf4
Change questdb usecase
huuhait Nov 17, 2022
b6e343b
Fix attrs in questdb usecase
huuhait Nov 17, 2022
405d9a5
Fix
huuhait Nov 17, 2022
3944d65
Add support multiple index for epa
huuhait Nov 18, 2022
e3cb581
Fix prevent usecase callback
huuhait Nov 22, 2022
5a56044
Fix
huuhait Dec 11, 2022
2a1db23
Fix
shinhagunn Dec 16, 2022
f0d112b
test pg log
shinhagunn Dec 16, 2022
5a5fb96
Test log pg
shinhagunn Dec 16, 2022
282818c
Fix
shinhagunn Dec 16, 2022
8b4525a
Test log
shinhagunn Dec 16, 2022
39a3d71
Done log
shinhagunn Dec 16, 2022
b520441
Feature: Add support error handler for funcDefaultData in redis
huuhait Dec 21, 2022
fd390e8
Test
huuhait Dec 26, 2022
55ba733
Fix callback not running
huuhait Jan 15, 2023
91b3274
Fix usecase callback
huuhait Jan 15, 2023
2142de2
Create README.md
huuhait Mar 4, 2023
283ab15
Add more information about pkg
huuhait Mar 4, 2023
1585c32
add support phone and kyc for jwt
shinhagunn Mar 15, 2023
bfeda9d
Update module github.com/hashicorp/vault/api to v1.9.1
renovate[bot] Apr 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
!jwt/testdata/.gitkeep
jwt/testdata/*
.idea/*
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nuxt.isNuxtApp": false
}
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# pkg

ZSmartex common packages

### Why pkg is public?
- pkg just is a common packages for a normal application build in Go
- there is no security or anything on this package

### What pkg support?
- Repository/Queries for Gorm (Very friendly)
- Queries for Elasticsearch (Very friendly)
- Usecase interface for Gorm
- PGX
- S3 Object Storage Upload/Download/Read
- JWT
- Logging
- EventAPI
- Redis
- Gorm
- Twilio
- Elasticsearch
- Kafka (unstable)

### TODO list of ZSmartex:
- temporal (Q1 2024)
- grpc-gateway (Q1 2024)
- saga (Q1 2024)
- microservices (Q2 2024)
- futures trading (Q4 2024)
12 changes: 12 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@ services:
- ELASTICSEARCH_PASSWORD=elastic
ports:
- "5601:5601"

questdb:
image: questdb/questdb:6.5.5
restart: always
ports:
- "8812:8812"
- "9009:9009"
- "8041:9000"
- "9003:9003"
volumes:
- questdb:/root/.questdb/db

volumes:
esdata:
questdb:
37 changes: 37 additions & 0 deletions epa/aggregation/aggregation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package aggregation

import "encoding/json"

type Aggregation interface {
Source() (interface{}, error)
}

type Aggregations map[string]json.RawMessage

func (a Aggregations) DateHistogram(name string) (items *AggregationBucketHistogramItems, found bool) {
if raw, found := a[name]; found {
agg := new(AggregationBucketHistogramItems)
if raw == nil {
return agg, true
}
if err := json.Unmarshal(raw, agg); err == nil {
return agg, true
}
}

return nil, false
}

func (a Aggregations) Sum(name string) (value *AggregationSumValue, found bool) {
if raw, found := a[name]; found {
agg := new(AggregationSumValue)
if raw == nil {
return agg, true
}
if err := json.Unmarshal(raw, agg); err == nil {
return agg, true
}
}

return nil, false
}
64 changes: 64 additions & 0 deletions epa/aggregation/aggregation_bucket_histogram_items.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package aggregation

import "encoding/json"

// AggregationBucketHistogramItem is a single bucket of an AggregationBucketHistogramItems structure.
type AggregationBucketHistogramItem struct {
Aggregations

Key float64 //`json:"key"`
KeyAsString *string //`json:"key_as_string"`
DocCount int64 //`json:"doc_count"`
}

// UnmarshalJSON decodes JSON data and initializes an AggregationBucketHistogramItem structure.
func (a *AggregationBucketHistogramItem) UnmarshalJSON(data []byte) error {
var aggs map[string]json.RawMessage
if err := json.Unmarshal(data, &aggs); err != nil {
return err
}
if v, ok := aggs["key"]; ok && v != nil {
if err := json.Unmarshal(v, &a.Key); err != nil {
return err
}
}
if v, ok := aggs["key_as_string"]; ok && v != nil {
if err := json.Unmarshal(v, &a.KeyAsString); err != nil {
return err
}
}
if v, ok := aggs["doc_count"]; ok && v != nil {
if err := json.Unmarshal(v, &a.DocCount); err != nil {
return err
}
}
a.Aggregations = aggs
return nil
}

type AggregationBucketHistogramItems struct {
Aggregations

Buckets []*AggregationBucketHistogramItem `json:"buckets,omitempty"`
Meta map[string]interface{} `json:"meta,omitempty"`
}

// UnmarshalJSON decodes JSON data and initializes an AggregationBucketHistogramItems structure.
func (a *AggregationBucketHistogramItems) UnmarshalJSON(data []byte) error {
var aggs map[string]json.RawMessage
if err := json.Unmarshal(data, &aggs); err != nil {
return err
}
if v, ok := aggs["buckets"]; ok && v != nil {
if err := json.Unmarshal(v, &a.Buckets); err != nil {
return err
}
}
if v, ok := aggs["meta"]; ok && v != nil {
if err := json.Unmarshal(v, &a.Meta); err != nil {
return err
}
}
a.Aggregations = aggs
return nil
}
27 changes: 27 additions & 0 deletions epa/aggregation/aggregation_sum_value.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package aggregation

import (
"encoding/json"

"github.com/shopspring/decimal"
)

type AggregationSumValue struct {
Aggregations

Value decimal.Decimal `json:"value,omitempty"`
}

func (a *AggregationSumValue) UnmarshalJSON(data []byte) error {
var aggs map[string]json.RawMessage
if err := json.Unmarshal(data, &aggs); err != nil {
return err
}
if v, ok := aggs["value"]; ok && v != nil {
if err := json.Unmarshal(v, &a.Value); err != nil {
return err
}
}
a.Aggregations = aggs
return nil
}
105 changes: 105 additions & 0 deletions epa/aggregation/date_histogram_aggregation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
package aggregation

import "github.com/zsmartex/pkg/v2/queries"

type DateHistogramAggregation struct {
field string
fixedInterval string
calendarInterval string
order string
ordering queries.Ordering
minDocCount *int64
timeZone string
format string
offset string
}

func NewDateHistogramAggregation(field string) *DateHistogramAggregation {
return &DateHistogramAggregation{
field: field,
ordering: queries.OrderingAsc,
}
}

func (a *DateHistogramAggregation) FixedInterval(fixedInterval string) *DateHistogramAggregation {
a.fixedInterval = fixedInterval
return a
}

func (a *DateHistogramAggregation) CalendarInterval(calendarInterval string) *DateHistogramAggregation {
a.calendarInterval = calendarInterval
return a
}

func (a *DateHistogramAggregation) Order(order string, ordering queries.Ordering) *DateHistogramAggregation {
a.order = order
a.ordering = ordering
return a
}

func (a *DateHistogramAggregation) OrderByCount(ordering queries.Ordering) *DateHistogramAggregation {
a.order = "_count"
a.ordering = ordering
return a
}

func (a *DateHistogramAggregation) MinDocCount(minDocCount int64) *DateHistogramAggregation {
a.minDocCount = &minDocCount
return a
}

func (a *DateHistogramAggregation) TimeZone(timeZone string) *DateHistogramAggregation {
a.timeZone = timeZone
return a
}

func (a *DateHistogramAggregation) Format(format string) *DateHistogramAggregation {
a.format = format
return a
}

func (a *DateHistogramAggregation) Offset(offset string) *DateHistogramAggregation {
a.offset = offset
return a
}

func (a *DateHistogramAggregation) Source() (interface{}, error) {
// Example:
// {
// "date_histogram" : {
// "field" : "date",
// "fixed_interval" : "month"
// }
// }
//
// This method returns only the { "date_histogram" : { ... } } part.
source := make(map[string]interface{})
dateHistogram := make(map[string]interface{})
source["date_histogram"] = dateHistogram
dateHistogram["field"] = a.field
if a.fixedInterval != "" {
dateHistogram["fixed_interval"] = a.fixedInterval
}
if a.calendarInterval != "" {
dateHistogram["calendar_interval"] = a.calendarInterval
}
if a.order != "" {
dateHistogram["order"] = map[string]interface{}{
a.order: a.ordering,
}
}
if a.minDocCount != nil {
dateHistogram["min_doc_count"] = *a.minDocCount
}
if a.timeZone != "" {
dateHistogram["time_zone"] = a.timeZone
}
if a.format != "" {
dateHistogram["format"] = a.format
}
if a.offset != "" {
dateHistogram["offset"] = a.offset
}

return source, nil
}
33 changes: 33 additions & 0 deletions epa/aggregation/sum_aggregation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package aggregation

type SumAggregation struct {
field string
}

func NewSumAggregation(field string) *SumAggregation {
return &SumAggregation{
field: field,
}
}

func (a *SumAggregation) Source() (interface{}, error) {
// Example
//
// {
// "hat_prices" : {
// "sum": {
// "field": "price"
// }
// }
// }
//
//
// This method returns only the { "sum": { "field": "..." } } part.

source := make(map[string]interface{})
sum := make(map[string]interface{})
source["sum"] = sum
sum["field"] = a.field

return source, nil
}
38 changes: 17 additions & 21 deletions epa/filter.go
Original file line number Diff line number Diff line change
@@ -1,39 +1,35 @@
package epa

import (
"github.com/olivere/elastic/v7"
)

type Ordering string

const (
OrderingAscending Ordering = "asc"
OrderingDescending Ordering = "desc"
"github.com/zsmartex/pkg/v2/epa/aggregation"
"github.com/zsmartex/pkg/v2/epa/query"
"github.com/zsmartex/pkg/v2/queries"
)

type Query struct {
Page int
Limit int
OrderBy string
Ordering Ordering
Filters []Filter
Addons func(*elastic.SearchService) *elastic.SearchService
Indexes []string
Page int
Limit int
OrderBy string
Ordering queries.Ordering
Filters []Filter
Aggregations map[string]aggregation.Aggregation
}

type Filter func(query *elastic.BoolQuery) *elastic.BoolQuery
type Filter func(*query.BoolQuery) *query.BoolQuery

func ApplyFilters(query *elastic.BoolQuery, filters []Filter) *elastic.BoolQuery {
func ApplyFilters(q *query.BoolQuery, filters []Filter) *query.BoolQuery {
for _, f := range filters {
query = f(query)
q = f(q)
}
return query
return q
}

func ChainFilters(filters ...Filter) Filter {
return func(query *elastic.BoolQuery) *elastic.BoolQuery {
return func(q *query.BoolQuery) *query.BoolQuery {
for _, f := range filters {
query = f(query)
q = f(q)
}
return query
return q
}
}
Loading