Skip to content

Commit 95787e6

Browse files
authored
chore: refactor provider (#2507)
1 parent c9ead0e commit 95787e6

40 files changed

+1061
-635
lines changed

.github/workflows/apisix-conformance-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ jobs:
8989
9090
- name: Install And Run Cloud Provider KIND
9191
run: |
92-
go install sigs.k8s.io/cloud-provider-kind@latest
92+
go install sigs.k8s.io/cloud-provider-kind@v0.6.0
9393
nohup cloud-provider-kind > /tmp/kind-loadbalancer.log 2>&1 &
9494
9595
- name: Install Gateway API And CRDs

api/adc/types.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,3 +726,24 @@ func (s *StringOrSlice) UnmarshalJSON(p []byte) error {
726726
}
727727
return json.Unmarshal(p, &s.StrVal)
728728
}
729+
730+
type Config struct {
731+
Name string
732+
ServerAddrs []string
733+
Token string
734+
TlsVerify bool
735+
}
736+
737+
// MarshalJSON implements custom JSON marshaling for adcConfig
738+
// It excludes the Token field for security reasons
739+
func (c Config) MarshalJSON() ([]byte, error) {
740+
return json.Marshal(struct {
741+
Name string `json:"name"`
742+
ServerAddrs []string `json:"serverAddrs"`
743+
TlsVerify bool `json:"tlsVerify"`
744+
}{
745+
Name: c.Name,
746+
ServerAddrs: c.ServerAddrs,
747+
TlsVerify: c.TlsVerify,
748+
})
749+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.

internal/provider/adc/store.go renamed to internal/adc/cache/store.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
package adc
18+
package cache
1919

2020
import (
2121
"fmt"
@@ -27,37 +27,36 @@ import (
2727

2828
adctypes "github.com/apache/apisix-ingress-controller/api/adc"
2929
"github.com/apache/apisix-ingress-controller/internal/controller/label"
30-
"github.com/apache/apisix-ingress-controller/internal/provider/adc/cache"
3130
)
3231

3332
type Store struct {
34-
cacheMap map[string]cache.Cache
33+
cacheMap map[string]Cache
3534
pluginMetadataMap map[string]adctypes.PluginMetadata
3635

3736
sync.Mutex
3837
}
3938

4039
func NewStore() *Store {
4140
return &Store{
42-
cacheMap: make(map[string]cache.Cache),
41+
cacheMap: make(map[string]Cache),
4342
pluginMetadataMap: make(map[string]adctypes.PluginMetadata),
4443
}
4544
}
4645

47-
func (s *Store) Insert(name string, resourceTypes []string, resources adctypes.Resources, Labels map[string]string) error {
46+
func (s *Store) Insert(name string, resourceTypes []string, resources *adctypes.Resources, Labels map[string]string) error {
4847
s.Lock()
4948
defer s.Unlock()
5049
targetCache, ok := s.cacheMap[name]
5150
if !ok {
52-
db, err := cache.NewMemDBCache()
51+
db, err := NewMemDBCache()
5352
if err != nil {
5453
return err
5554
}
5655
s.cacheMap[name] = db
5756
targetCache = s.cacheMap[name]
5857
}
5958
log.Debugw("Inserting resources into cache for", zap.String("name", name))
60-
selector := &cache.KindLabelSelector{
59+
selector := &KindLabelSelector{
6160
Kind: Labels[label.LabelKind],
6261
Name: Labels[label.LabelName],
6362
Namespace: Labels[label.LabelNamespace],
@@ -153,7 +152,7 @@ func (s *Store) Delete(name string, resourceTypes []string, Labels map[string]st
153152
if !ok {
154153
return nil
155154
}
156-
selector := &cache.KindLabelSelector{
155+
selector := &KindLabelSelector{
157156
Kind: Labels[label.LabelKind],
158157
Name: Labels[label.LabelName],
159158
Namespace: Labels[label.LabelNamespace],

0 commit comments

Comments
 (0)