This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 569c4bd  chore: delete unused file (#1568)
569c4bd is described below

commit 569c4bdbb934ab6d6a063750b931b22db99bae90
Author: Peter Zhu <[email protected]>
AuthorDate: Wed Mar 10 11:28:32 2021 +0800

    chore: delete unused file (#1568)
---
 api/internal/core/entity/query.go        | 142 ----------------
 api/internal/core/store/query.go         | 137 ----------------
 api/internal/core/store/selector.go      | 128 ---------------
 api/internal/core/store/selector_test.go | 269 -------------------------------
 api/internal/core/store/store.go         |   5 +
 api/internal/handler/ssl/ssl.go          |  70 ++++----
 6 files changed, 39 insertions(+), 712 deletions(-)

diff --git a/api/internal/core/entity/query.go 
b/api/internal/core/entity/query.go
deleted file mode 100644
index ae38342..0000000
--- a/api/internal/core/entity/query.go
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package entity
-
-import (
-       "strings"
-
-       "github.com/apisix/manager-api/internal/utils"
-)
-
-type PropertyName string
-
-const (
-       IdProperty         = "id"
-       NameProperty       = "name"
-       SniProperty        = "sni"
-       SnisProperty       = "snis"
-       CreateTimeProperty = "create_time"
-       UpdateTimeProperty = "update_time"
-)
-
-type ComparableValue interface {
-       Compare(ComparableValue) int
-       Contains(ComparableValue) bool
-}
-
-type ComparingString string
-
-func (comparing ComparingString) Compare(compared ComparableValue) int {
-       other := compared.(ComparingString)
-       return strings.Compare(string(comparing), string(other))
-}
-
-func (comparing ComparingString) Contains(compared ComparableValue) bool {
-       other := compared.(ComparingString)
-       return strings.Contains(string(comparing), string(other))
-}
-
-type ComparingStringArray []string
-
-func (comparing ComparingStringArray) Compare(compared ComparableValue) int {
-       other := compared.(ComparingString)
-       res := -1
-       for _, str := range comparing {
-               result := strings.Compare(str, string(other))
-               if result == 0 {
-                       res = 0
-                       break
-               }
-       }
-       return res
-}
-
-func (comparing ComparingStringArray) Contains(compared ComparableValue) bool {
-       other := compared.(ComparingString)
-       res := false
-       for _, str := range comparing {
-               if strings.Contains(str, string(other)) {
-                       res = true
-                       break
-               }
-       }
-       return res
-}
-
-type ComparingInt int64
-
-func int64Compare(a, b int64) int {
-       if a > b {
-               return 1
-       } else if a == b {
-               return 0
-       }
-       return -1
-}
-
-func (comparing ComparingInt) Compare(compared ComparableValue) int {
-       other := compared.(ComparingInt)
-       return int64Compare(int64(comparing), int64(other))
-}
-
-func (comparing ComparingInt) Contains(compared ComparableValue) bool {
-       return comparing.Compare(compared) == 0
-}
-
-func (info BaseInfo) GetProperty(name PropertyName) ComparableValue {
-       switch name {
-       case IdProperty:
-               id := utils.InterfaceToString(info.ID)
-               return ComparingString(id)
-       case CreateTimeProperty:
-               return ComparingInt(info.CreateTime)
-       case UpdateTimeProperty:
-               return ComparingInt(info.UpdateTime)
-       default:
-               return nil
-       }
-}
-
-func (route Route) GetProperty(name PropertyName) ComparableValue {
-       switch name {
-       case NameProperty:
-               return ComparingString(route.Name)
-       default:
-               return nil
-       }
-}
-
-func (upstream Upstream) GetProperty(name PropertyName) ComparableValue {
-       switch name {
-       case NameProperty:
-               return ComparingString(upstream.Name)
-       default:
-               return nil
-       }
-}
-
-func (ssl SSL) GetProperty(name PropertyName) ComparableValue {
-       switch name {
-       case SniProperty:
-               return ComparingString(ssl.Sni)
-       case SnisProperty:
-               return ComparingStringArray(ssl.Snis)
-       default:
-               return nil
-       }
-}
diff --git a/api/internal/core/store/query.go b/api/internal/core/store/query.go
deleted file mode 100644
index e4c27c1..0000000
--- a/api/internal/core/store/query.go
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2017 The Kubernetes Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package store
-
-import (
-       "github.com/apisix/manager-api/internal/core/entity"
-       "github.com/apisix/manager-api/internal/log"
-)
-
-type Query struct {
-       Sort       *Sort
-       Filter     *Filter
-       Pagination *Pagination
-}
-
-type Sort struct {
-       List []SortBy
-}
-
-type SortBy struct {
-       Property  entity.PropertyName
-       Ascending bool
-}
-
-var NoSort = &Sort{
-       List: []SortBy{},
-}
-
-type Filter struct {
-       List []FilterBy
-}
-
-type FilterBy struct {
-       Property entity.PropertyName
-       Value    entity.ComparableValue
-}
-
-var NoFilter = &Filter{
-       List: []FilterBy{},
-}
-
-type Pagination struct {
-       PageSize   int `json:"page_size" form:"page_size" auto_read:"page_size"`
-       PageNumber int `json:"page" form:"page" auto_read:"page"`
-}
-
-func NewPagination(PageSize, pageNumber int) *Pagination {
-       return &Pagination{PageSize, pageNumber}
-}
-
-func (p *Pagination) IsValid() bool {
-       return p.PageSize >= 0 && p.PageNumber >= 0
-}
-
-func (p *Pagination) IsAvailable(itemsCount, startingIndex int) bool {
-       return itemsCount > startingIndex && p.PageSize > 0
-}
-
-func (p *Pagination) Index(itemsCount int) (startIndex int, endIndex int) {
-       startIndex = p.PageSize * p.PageNumber
-       endIndex = startIndex + p.PageSize
-
-       if endIndex > itemsCount {
-               endIndex = itemsCount
-       }
-
-       return startIndex, endIndex
-}
-
-func NewQuery(sort *Sort, filter *Filter, pagination *Pagination) *Query {
-       return &Query{
-               Sort:       sort,
-               Filter:     filter,
-               Pagination: pagination,
-       }
-}
-
-func NewSort(sortRaw []string) *Sort {
-       if sortRaw == nil || len(sortRaw)%2 == 1 {
-               log.Info("empty sort for query")
-               return NoSort
-       }
-       list := []SortBy{}
-       for i := 0; i+1 < len(sortRaw); i += 2 {
-               var ascending bool
-               orderOption := sortRaw[i]
-               if orderOption == "a" {
-                       ascending = true
-               } else if orderOption == "d" {
-                       ascending = false
-               } else {
-                       return NoSort
-               }
-
-               propertyName := sortRaw[i+1]
-               sortBy := SortBy{
-                       Property:  entity.PropertyName(propertyName),
-                       Ascending: ascending,
-               }
-               list = append(list, sortBy)
-       }
-       return &Sort{
-               List: list,
-       }
-}
-
-func NewFilter(filterRaw []string) *Filter {
-       if filterRaw == nil || len(filterRaw)%2 == 1 {
-               log.Info("empty filter for query")
-               return NoFilter
-       }
-       list := []FilterBy{}
-       for i := 0; i+1 < len(filterRaw); i += 2 {
-               propertyName := filterRaw[i]
-               propertyValue := filterRaw[i+1]
-               filterBy := FilterBy{
-                       Property: entity.PropertyName(propertyName),
-                       Value:    entity.ComparingString(propertyValue),
-               }
-               list = append(list, filterBy)
-       }
-       return &Filter{
-               List: list,
-       }
-}
diff --git a/api/internal/core/store/selector.go 
b/api/internal/core/store/selector.go
deleted file mode 100644
index 4aac32c..0000000
--- a/api/internal/core/store/selector.go
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright 2017 The Kubernetes Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package store
-
-import (
-       "sort"
-
-       "github.com/apisix/manager-api/internal/core/entity"
-)
-
-type Row interface {
-       GetProperty(entity.PropertyName) entity.ComparableValue
-}
-
-type Selector struct {
-       List  []Row
-       Query *Query
-}
-
-func (self Selector) Len() int { return len(self.List) }
-
-func (self Selector) Swap(i, j int) {
-       self.List[i], self.List[j] = self.List[j], self.List[i]
-}
-
-func (self Selector) Less(i, j int) bool {
-       for _, sortBy := range self.Query.Sort.List {
-               a := self.List[i].GetProperty(sortBy.Property)
-               b := self.List[j].GetProperty(sortBy.Property)
-               if a == nil || b == nil {
-                       break
-               }
-               cmp := a.Compare(b)
-               if cmp == 0 {
-                       continue
-               } else {
-                       return (cmp == -1 && sortBy.Ascending) || (cmp == 1 && 
!sortBy.Ascending)
-               }
-       }
-       return false
-}
-
-func (self *Selector) Sort() *Selector {
-       sort.Sort(*self)
-       return self
-}
-
-func (self *Selector) Filter() *Selector {
-       filteredList := []Row{}
-       for _, c := range self.List {
-               matches := true
-               for _, filterBy := range self.Query.Filter.List {
-                       v := c.GetProperty(filterBy.Property)
-                       if v == nil || v.Compare(filterBy.Value) != 0 {
-                               matches = false
-                               break
-                       }
-               }
-               if matches {
-                       filteredList = append(filteredList, c)
-               }
-       }
-
-       self.List = filteredList
-       return self
-}
-
-func (self *Selector) Paginate() *Selector {
-       pagination := self.Query.Pagination
-       dataList := self.List
-       TotalSize := len(dataList)
-       startIndex, endIndex := pagination.Index(TotalSize)
-
-       if startIndex == 0 && endIndex == 0 {
-               return self
-       }
-
-       if !pagination.IsValid() {
-               self.List = []Row{}
-               return self
-       }
-
-       if startIndex > TotalSize {
-               self.List = []Row{}
-               return self
-       }
-
-       if endIndex >= TotalSize {
-               self.List = dataList[startIndex:]
-               return self
-       }
-
-       self.List = dataList[startIndex:endIndex]
-       return self
-}
-
-func NewFilterSelector(list []Row, query *Query) []Row {
-       selector := Selector{
-               List:  list,
-               Query: query,
-       }
-       filtered := selector.Filter()
-       paged := filtered.Paginate()
-       return paged.List
-}
-
-func DefaultSelector(list []Row, query *Query) ([]Row, int) {
-       selector := Selector{
-               List:  list,
-               Query: query,
-       }
-       filtered := selector.Filter()
-       filteredTotal := len(filtered.List)
-       paged := filtered.Sort().Paginate()
-       return paged.List, filteredTotal
-}
diff --git a/api/internal/core/store/selector_test.go 
b/api/internal/core/store/selector_test.go
deleted file mode 100644
index 8e52551..0000000
--- a/api/internal/core/store/selector_test.go
+++ /dev/null
@@ -1,269 +0,0 @@
-// Copyright 2017 The Kubernetes Authors.
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package store
-
-import (
-       "reflect"
-       "testing"
-
-       "github.com/apisix/manager-api/internal/core/entity"
-)
-
-type PaginationTestCase struct {
-       Info          string
-       Pagination    *Pagination
-       ExpectedOrder []int
-}
-
-type SortTestCase struct {
-       Info          string
-       Sort          *Sort
-       ExpectedOrder []int
-}
-
-type FilterTestCase struct {
-       Info          string
-       Filter        *Filter
-       ExpectedOrder []int
-}
-
-type TestRow struct {
-       Name       string
-       CreateTime int64
-       Id         int
-       Snis       []string
-}
-
-func (self TestRow) GetProperty(name entity.PropertyName) 
entity.ComparableValue {
-       switch name {
-       case entity.NameProperty:
-               return entity.ComparingString(self.Name)
-       case entity.SnisProperty:
-               return entity.ComparingStringArray(self.Snis)
-       case entity.CreateTimeProperty:
-               return entity.ComparingInt(self.CreateTime)
-       default:
-               return nil
-       }
-}
-
-func toRows(std []TestRow) []Row {
-       rows := make([]Row, len(std))
-       for i := range std {
-               rows[i] = std[i]
-       }
-       return rows
-}
-
-func fromRows(rows []Row) []TestRow {
-       std := make([]TestRow, len(rows))
-       for i := range std {
-               std[i] = rows[i].(TestRow)
-       }
-       return std
-}
-
-func getDataList() []Row {
-       return toRows([]TestRow{
-               {"b", 1, 1, []string{"a", "b"}},
-               {"a", 2, 2, []string{"c", "d"}},
-               {"a", 3, 3, []string{"f", "e"}},
-               {"c", 4, 4, []string{"g", "h"}},
-               {"c", 5, 5, []string{"k", "j"}},
-               {"d", 6, 6, []string{"i", "h"}},
-               {"e", 7, 7, []string{"t", "r"}},
-               {"e", 8, 8, []string{"q", "w"}},
-               {"f", 9, 9, []string{"x", "z"}},
-               {"a", 10, 10, []string{"v", "n"}},
-       })
-}
-
-func getOrder(dataList []TestRow) []int {
-       ordered := []int{}
-       for _, e := range dataList {
-               ordered = append(ordered, e.Id)
-       }
-       return ordered
-}
-
-func TestSort(t *testing.T) {
-       testCases := []SortTestCase{
-               {
-                       "no sort - do not change the original order",
-                       NoSort,
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "ascending sort by 1 property - all items sorted by 
this property",
-                       NewSort([]string{"a", "create_time"}),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "descending sort by 1 property - all items sorted by 
this property",
-                       NewSort([]string{"d", "create_time"}),
-                       []int{10, 9, 8, 7, 6, 5, 4, 3, 2, 1},
-               },
-               {
-                       "sort by 2 properties - items should first be sorted by 
first property and later by second",
-                       NewSort([]string{"a", "name", "d", "create_time"}),
-                       []int{10, 3, 2, 1, 5, 4, 6, 8, 7, 9},
-               },
-               {
-                       "empty sort list - no sort",
-                       NewSort([]string{}),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "nil - no sort",
-                       NewSort(nil),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               // Invalid arguments to the NewSortQuery
-               {
-                       "sort by few properties where at least one property 
name is invalid - no sort",
-                       NewSort([]string{"a", "INVALID_PROPERTY", "d", 
"creationTimestamp"}),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "sort by few properties where at least one order option 
is invalid - no sort",
-                       NewSort([]string{"d", "name", "INVALID_ORDER", 
"creationTimestamp"}),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "sort by few properties where one order tag is missing 
property - no sort",
-                       NewSort([]string{""}),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "sort by few properties where one order tag is missing 
property - no sort",
-                       NewSort([]string{"d", "name", "a", "creationTimestamp", 
"a"}),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-       }
-       for _, testCase := range testCases {
-               selector := Selector{
-                       List:  getDataList(),
-                       Query: &Query{Sort: testCase.Sort},
-               }
-               sortedData := fromRows(selector.Sort().List)
-               order := getOrder(sortedData)
-               if !reflect.DeepEqual(order, testCase.ExpectedOrder) {
-                       t.Errorf(`Sort: %s. Received invalid items for %+v. Got 
%v, expected %v.`,
-                               testCase.Info, testCase.Sort, order, 
testCase.ExpectedOrder)
-               }
-       }
-
-}
-
-func TestPagination(t *testing.T) {
-       testCases := []PaginationTestCase{
-               {
-                       "no pagination - all existing elements should be 
returned",
-                       NewPagination(0, 0),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "request one item from existing page - element should 
be returned",
-                       NewPagination(1, 5),
-                       []int{6},
-               },
-               {
-                       "request one item from non existing page - no elements 
should be returned",
-                       NewPagination(1, 10),
-                       []int{},
-               },
-               {
-                       "request 2 items from existing page - 2 elements should 
be returned",
-                       NewPagination(2, 1),
-                       []int{3, 4},
-               },
-               {
-                       "request 3 items from partially existing page - last 
few existing should be returned",
-                       NewPagination(3, 3),
-                       []int{10},
-               },
-               {
-                       "request more than total number of elements from page 1 
- all existing elements should be returned",
-                       NewPagination(11, 0),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "request 3 items from non existing page - no elements 
should be returned",
-                       NewPagination(3, 4),
-                       []int{},
-               },
-               {
-                       "Invalid pagination - all elements should be returned",
-                       NewPagination(-1, 4),
-                       []int{},
-               },
-               {
-                       "Invalid pagination - all elements should be returned",
-                       NewPagination(1, -4),
-                       []int{},
-               },
-       }
-       for _, testCase := range testCases {
-               selector := Selector{
-                       List:  getDataList(),
-                       Query: &Query{Pagination: testCase.Pagination},
-               }
-               paginatedData := fromRows(selector.Paginate().List)
-               order := getOrder(paginatedData)
-               if !reflect.DeepEqual(order, testCase.ExpectedOrder) {
-                       t.Errorf(`Pagination: %s. Received invalid items for 
%+v. Got %v, expected %v.`,
-                               testCase.Info, testCase.Pagination, order, 
testCase.ExpectedOrder)
-               }
-       }
-
-}
-
-func TestFilter(t *testing.T) {
-       testCases := []FilterTestCase{
-               {
-                       "no sort - do not change the original order",
-                       NewFilter(nil),
-                       []int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
-               },
-               {
-                       "string filter",
-                       NewFilter([]string{"name", "a"}),
-                       []int{2, 3, 10},
-               },
-               {
-                       "string array filter",
-                       NewFilter([]string{"snis", "x"}),
-                       []int{9},
-               },
-               {
-                       "multi filter",
-                       NewFilter([]string{"snis", "t", "name", "e"}),
-                       []int{7},
-               },
-       }
-       for _, testCase := range testCases {
-               selector := Selector{
-                       List:  getDataList(),
-                       Query: &Query{Filter: testCase.Filter},
-               }
-               filteredData := fromRows(selector.Filter().List)
-               order := getOrder(filteredData)
-               if !reflect.DeepEqual(order, testCase.ExpectedOrder) {
-                       t.Errorf(`Filter: %s. Received invalid items for %+v. 
Got %v, expected %v.`,
-                               testCase.Info, testCase.Filter, order, 
testCase.ExpectedOrder)
-               }
-       }
-
-}
diff --git a/api/internal/core/store/store.go b/api/internal/core/store/store.go
index ce1c107..9f13f62 100644
--- a/api/internal/core/store/store.go
+++ b/api/internal/core/store/store.go
@@ -35,6 +35,11 @@ import (
        "github.com/apisix/manager-api/internal/utils/runtime"
 )
 
+type Pagination struct {
+       PageSize   int `json:"page_size" form:"page_size" auto_read:"page_size"`
+       PageNumber int `json:"page" form:"page" auto_read:"page"`
+}
+
 type Interface interface {
        Get(ctx context.Context, key string) (interface{}, error)
        List(ctx context.Context, input ListInput) (*ListOutput, error)
diff --git a/api/internal/handler/ssl/ssl.go b/api/internal/handler/ssl/ssl.go
index a536f20..da69f36 100644
--- a/api/internal/handler/ssl/ssl.go
+++ b/api/internal/handler/ssl/ssl.go
@@ -51,6 +51,35 @@ func NewHandler() (handler.RouteRegister, error) {
        }, nil
 }
 
+func checkSniExists(rows []interface{}, sni string) bool {
+       for _, item := range rows {
+               ssl := item.(*entity.SSL)
+
+               if ssl.Sni == sni {
+                       return true
+               }
+
+               if inArray(sni, ssl.Snis) {
+                       return true
+               }
+
+               // Wildcard Domain
+               firstDot := strings.Index(sni, ".")
+               if firstDot > 0 && sni[0:1] != "*" {
+                       wildcardDomain := "*" + sni[firstDot:]
+                       if ssl.Sni == wildcardDomain {
+                               return true
+                       }
+
+                       if inArray(wildcardDomain, ssl.Snis) {
+                               return true
+                       }
+               }
+       }
+
+       return false
+}
+
 func (h *Handler) ApplyRoute(r *gin.Engine) {
        r.GET("/apisix/admin/ssl/:id", wgin.Wraps(h.Get,
                wrapper.InputType(reflect.TypeOf(GetInput{}))))
@@ -403,40 +432,9 @@ type ExistInput struct {
        Name string `auto_read:"name,query"`
 }
 
-func toRows(list *store.ListOutput) []store.Row {
-       rows := make([]store.Row, list.TotalSize)
-       for i := range list.Rows {
-               rows[i] = list.Rows[i].(*entity.SSL)
-       }
-       return rows
-}
-
-func checkValueExists(rows []store.Row, field, value string) bool {
-       selector := store.Selector{
-               List:  rows,
-               Query: &store.Query{Filter: store.NewFilter([]string{field, 
value})},
-       }
-
-       list := selector.Filter().List
-
-       return len(list) > 0
-}
-
-func checkSniExists(rows []store.Row, sni string) bool {
-       if res := checkValueExists(rows, "sni", sni); res {
-               return true
-       }
-       if res := checkValueExists(rows, "snis", sni); res {
-               return true
-       }
-       //extensive domain
-       firstDot := strings.Index(sni, ".")
-       if firstDot > 0 && sni[0:1] != "*" {
-               sni = "*" + sni[firstDot:]
-               if res := checkValueExists(rows, "sni", sni); res {
-                       return true
-               }
-               if res := checkValueExists(rows, "snis", sni); res {
+func inArray(key string, array []string) bool {
+       for _, item := range array {
+               if key == item {
                        return true
                }
        }
@@ -490,8 +488,8 @@ func (h *Handler) Exist(c droplet.Context) (interface{}, 
error) {
        }
 
        for _, host := range input.Hosts {
-               res := checkSniExists(toRows(ret), host)
-               if !res {
+               exist := checkSniExists(ret.Rows, host)
+               if !exist {
                        return &data.SpecCodeResponse{StatusCode: 
http.StatusNotFound},
                                consts.InvalidParam("SSL cert not exists for 
sni:" + host)
                }

Reply via email to