mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): vendor update for zstack secgroup rule (#19169)
This commit is contained in:
@@ -88,14 +88,14 @@ require (
|
||||
k8s.io/client-go v0.19.3
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231229064726-2667f17e2b91
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240104114120-c31ea84ff957
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20230613121553-0f3b41e2ef19
|
||||
yunion.io/x/log v1.0.1-0.20230411060016-feb3f46ab361
|
||||
yunion.io/x/ovsdb v0.0.0-20230306173834-f164f413a900
|
||||
yunion.io/x/pkg v1.0.1-0.20231101105448-abef64cdc142
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20231219103237-8264e6ead2fc
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20240103021517-2be4fb49bd3b
|
||||
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c
|
||||
)
|
||||
|
||||
|
||||
@@ -1201,8 +1201,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231229064726-2667f17e2b91 h1:ni5/L8VKHAOadTbzYY/IgA78SCoZPmXjG+IK6w+pjIU=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231229064726-2667f17e2b91/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240104114120-c31ea84ff957 h1:Gu9JkjXTLsKiO5F95q7MUcxuEtzeoBqEPszSNoXiUa4=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240104114120-c31ea84ff957/go.mod h1:aj1gR9PPb6eqqKOwvANe26CoZFY8ydmXy0fuvgKYXH0=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
@@ -1220,7 +1220,7 @@ yunion.io/x/pkg v1.0.1-0.20231101105448-abef64cdc142 h1:L6LqxfP08eWUx+A6yQdrL6VB
|
||||
yunion.io/x/pkg v1.0.1-0.20231101105448-abef64cdc142/go.mod h1:ksCJVQ+DwKrJ5QBEoU8pzrDFfDaZVAFH/iJ6yQCYxJk=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e h1:v+EzIadodSwkdZ/7bremd7J8J50Cise/HCylsOJngmo=
|
||||
yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e/go.mod h1:0iFKpOs1y4lbCxeOmq3Xx/0AcQoewVPwj62eRluioEo=
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20231219103237-8264e6ead2fc h1:CVg5BdiSrw8yaxT2bpTiu63JHuHKDgjaDHI3zVDT1gY=
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20231219103237-8264e6ead2fc/go.mod h1:uuPVZEyEq3sWd5vf9VjGSy6lZzof22X87OEHw9sddJQ=
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20240103021517-2be4fb49bd3b h1:W87Fe3H4wVm2CIrsVXNuypnO3yV7nhkiWozd2lDruKM=
|
||||
yunion.io/x/sqlchemy v1.1.3-0.20240103021517-2be4fb49bd3b/go.mod h1:uuPVZEyEq3sWd5vf9VjGSy6lZzof22X87OEHw9sddJQ=
|
||||
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c h1:QuLab2kSRECZRxo4Lo2KcYn6XjQFDGaZ1+x0pYDVVwQ=
|
||||
yunion.io/x/structarg v0.0.0-20231017124457-df4d5009457c/go.mod h1:EP6NSv2C0zzqBDTKumv8hPWLb3XvgMZDHQRfyuOrQng=
|
||||
|
||||
Vendored
+2
-2
@@ -1465,7 +1465,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20231229064726-2667f17e2b91
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240104114120-c31ea84ff957
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
@@ -1615,7 +1615,7 @@ yunion.io/x/pkg/utils
|
||||
# yunion.io/x/s3cli v0.0.0-20190917004522-13ac36d8687e
|
||||
## explicit; go 1.12
|
||||
yunion.io/x/s3cli
|
||||
# yunion.io/x/sqlchemy v1.1.3-0.20231219103237-8264e6ead2fc
|
||||
# yunion.io/x/sqlchemy v1.1.3-0.20240103021517-2be4fb49bd3b
|
||||
## explicit; go 1.17
|
||||
yunion.io/x/sqlchemy
|
||||
yunion.io/x/sqlchemy/backends
|
||||
|
||||
+3
@@ -95,6 +95,9 @@ type Pool struct {
|
||||
|
||||
func (self *SLoadbalancer) GetEip() (*SEipAddress, error) {
|
||||
for _, ip := range self.Publicips {
|
||||
if ip.IpVersion != "4" {
|
||||
continue
|
||||
}
|
||||
eip, err := self.region.GetEip(ip.PublicipId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
+19
-9
@@ -113,7 +113,15 @@ func (self *SSecurityGroup) GetProjectId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (region *SRegion) CreateSecurityGroupRule(secgroupId string, opts *cloudprovider.SecurityGroupRuleCreateOptions) error {
|
||||
func (self *SSecurityGroup) CreateRule(opts *cloudprovider.SecurityGroupRuleCreateOptions) (cloudprovider.ISecurityGroupRule, error) {
|
||||
rule, err := self.region.CreateSecurityGroupRule(self.UUID, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rule, nil
|
||||
}
|
||||
|
||||
func (region *SRegion) CreateSecurityGroupRule(secgroupId string, opts *cloudprovider.SecurityGroupRuleCreateOptions) (*SSecurityGroupRule, error) {
|
||||
ruleParam := map[string]interface{}{
|
||||
"allowedCidr": opts.CIDR,
|
||||
"type": "Ingress",
|
||||
@@ -145,15 +153,17 @@ func (region *SRegion) CreateSecurityGroupRule(secgroupId string, opts *cloudpro
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(ruleParam) > 0 {
|
||||
params := map[string]interface{}{
|
||||
"params": map[string]interface{}{
|
||||
"rules": []map[string]interface{}{ruleParam},
|
||||
},
|
||||
}
|
||||
return region.client.create(fmt.Sprintf("security-groups/%s/rules", secgroupId), jsonutils.Marshal(params), nil)
|
||||
params := map[string]interface{}{
|
||||
"params": map[string]interface{}{
|
||||
"rules": []map[string]interface{}{ruleParam},
|
||||
},
|
||||
}
|
||||
return nil
|
||||
rule := &SSecurityGroupRule{region: region}
|
||||
err := region.client.create(fmt.Sprintf("security-groups/%s/rules", secgroupId), jsonutils.Marshal(params), rule)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return rule, nil
|
||||
}
|
||||
|
||||
func (region *SRegion) DeleteSecurityGroupRules(ruleIds []string) error {
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// 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 sqlchemy
|
||||
|
||||
import (
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/util/reflectutils"
|
||||
)
|
||||
|
||||
func (c *STableField) IsAscii() bool {
|
||||
return c.spec.IsAscii()
|
||||
}
|
||||
|
||||
func isFieldRequireAscii(f IQueryField) bool {
|
||||
if gotypes.IsNil(f) {
|
||||
return false
|
||||
}
|
||||
if tableField, ok := f.(*STableField); ok {
|
||||
return tableField.IsAscii()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isVariableAscii(v interface{}) bool {
|
||||
if gotypes.IsNil(v) {
|
||||
return true
|
||||
}
|
||||
switch v.(type) {
|
||||
case IQueryField, *SQuery, *SSubQuery:
|
||||
return true
|
||||
default:
|
||||
vals := reflectutils.ExpandInterface(v)
|
||||
for _, val := range vals {
|
||||
if strVal, ok := val.(string); ok && len(strVal) > 0 {
|
||||
if !isPrintableAsciiString(strVal) {
|
||||
return false
|
||||
}
|
||||
} else if strVal, ok := val.(*string); ok && !gotypes.IsNil(strVal) && len(*strVal) > 0 {
|
||||
if !isPrintableAsciiString(*strVal) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func isPrintableAscii(b byte) bool {
|
||||
if b >= 32 && b <= 126 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func isPrintableAsciiString(str string) bool {
|
||||
for _, b := range []byte(str) {
|
||||
if !isPrintableAscii(b) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
+11
@@ -367,6 +367,9 @@ type STupleCondition struct {
|
||||
}
|
||||
|
||||
func tupleConditionWhereClause(t *STupleCondition, op string) string {
|
||||
if isFieldRequireAscii(t.left) && !isVariableAscii(t.right) {
|
||||
return "0"
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
buf.WriteString(t.left.Reference())
|
||||
buf.WriteByte(' ')
|
||||
@@ -439,6 +442,9 @@ func (t *STupleCondition) GetRight() interface{} {
|
||||
|
||||
// Variables implementation of STupleCondition for ICondition
|
||||
func (t *STupleCondition) Variables() []interface{} {
|
||||
if isFieldRequireAscii(t.left) && !isVariableAscii(t.right) {
|
||||
return []interface{}{}
|
||||
}
|
||||
return varConditionVariables(t.right)
|
||||
}
|
||||
|
||||
@@ -750,3 +756,8 @@ func (t *SFalseCondition) Variables() []interface{} {
|
||||
func (t *SFalseCondition) database() *SDatabase {
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
AlwaysTrue = &STrueCondition{}
|
||||
AlwaysFalse = &SFalseCondition{}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user