Update config.go, config.go, and 5 more files...

This commit is contained in:
Rami Berman
2021-10-31 16:22:56 +02:00
parent aebf4d70a2
commit e906bac9e7
7 changed files with 13 additions and 40 deletions
+2 -1
View File
@@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"github.com/up9inc/mizu/shared"
"github.com/up9inc/mizu/tap/api"
"io/ioutil"
"os"
)
@@ -46,7 +47,7 @@ func applyDefaultConfig() error {
}
func getDefaultConfig() (*shared.MizuAgentConfig, error) {
regex, err := shared.CompileRegexToSerializableRegexp(defaultRegexTarget)
regex, err := api.CompileRegexToSerializableRegexp(defaultRegexTarget)
if err != nil {
return nil, err
}
+2 -1
View File
@@ -3,6 +3,7 @@ package config
import (
"errors"
"fmt"
"github.com/up9inc/mizu/tap/api"
"io/ioutil"
"k8s.io/apimachinery/pkg/util/json"
"os"
@@ -378,7 +379,7 @@ func GetSerializedMizuConfig() (string, error) {
}
func getMizuConfig() (*shared.MizuAgentConfig, error) {
serializableRegex, err := shared.CompileRegexToSerializableRegexp(Config.Tap.PodRegexStr)
serializableRegex, err := api.CompileRegexToSerializableRegexp(Config.Tap.PodRegexStr)
if err != nil {
return nil, err
}
+4 -4
View File
@@ -167,8 +167,8 @@ func (provider *Provider) CreateMizuApiServerPod(ctx context.Context, opts *ApiS
}
}
configMapVolumeName := &core.ConfigMapVolumeSource{}
configMapVolumeName.Name = ConfigMapName
configMapVolume := &core.ConfigMapVolumeSource{}
configMapVolume.Name = ConfigMapName
cpuLimit, err := resource.ParseQuantity(opts.Resources.CpuLimit)
if err != nil {
@@ -263,7 +263,7 @@ func (provider *Provider) CreateMizuApiServerPod(ctx context.Context, opts *ApiS
{
Name: ConfigMapName,
VolumeSource: core.VolumeSource{
ConfigMap: configMapVolumeName,
ConfigMap: configMapVolume,
},
},
},
@@ -788,4 +788,4 @@ func validateKubernetesVersion(clientSet *kubernetes.Clientset) error {
}
return nil
}
}
+1 -1
View File
@@ -64,4 +64,4 @@ func getRerouteHttpHandlerMizuStatic(proxyHandler http.Handler, mizuNamespace st
r.URL.Path = strings.Replace(r.URL.Path, "/static/", fmt.Sprintf("%s/static/", getMizuApiServerProxiedHostAndPath(mizuNamespace, mizuServiceName)), 1)
proxyHandler.ServeHTTP(w, r)
})
}
}
+1 -1
View File
@@ -55,4 +55,4 @@ func getMissingPods(pods1 []core.Pod, pods2 []core.Pod) []core.Pod {
}
}
return missingPods
}
}
+3 -2
View File
@@ -1,6 +1,7 @@
package shared
import (
"github.com/up9inc/mizu/tap/api"
"io/ioutil"
"log"
"strings"
@@ -26,8 +27,8 @@ type Resources struct {
}
type MizuAgentConfig struct {
TapTargetRegex SerializableRegexp `yaml:"tapTargetRegex"`
MaxDBSizeBytes int64 `yaml:"maxDBSizeBytes"`
TapTargetRegex api.SerializableRegexp `yaml:"tapTargetRegex"`
MaxDBSizeBytes int64 `yaml:"maxDBSizeBytes"`
}
type WebSocketMessageMetadata struct {
-30
View File
@@ -1,30 +0,0 @@
package shared
import "regexp"
type SerializableRegexp struct {
regexp.Regexp
}
func CompileRegexToSerializableRegexp(expr string) (*SerializableRegexp, error) {
re, err := regexp.Compile(expr)
if err != nil {
return nil, err
}
return &SerializableRegexp{*re}, nil
}
// UnmarshalText is by json.Unmarshal.
func (r *SerializableRegexp) UnmarshalText(text []byte) error {
rr, err := CompileRegexToSerializableRegexp(string(text))
if err != nil {
return err
}
*r = *rr
return nil
}
// MarshalText is used by json.Marshal.
func (r *SerializableRegexp) MarshalText() ([]byte, error) {
return []byte(r.String()), nil
}