-
-
Notifications
You must be signed in to change notification settings - Fork 188
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
[OSPP]Support Kubernetes ConfigMap for Apollo java, golang client #79 #318
Changes from 5 commits
9c177c8
e198427
c2edb74
d233b89
3a2e852
5703446
0a633c5
c2d16e9
13b46b5
ec52796
22911a6
c779a66
d8892ed
5df2d22
1bf6fdd
7a6f7c9
46c9f7d
0ccdf88
1bbb9e4
862ffe4
1d16552
f6e7a38
ccfda6b
b6aeff6
9914308
421d18d
7c213e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* 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 extension | ||
|
||
import "github.com/apolloconfig/agollo/v4/store" | ||
|
||
var configMapHandler store.ConfigMapHandler | ||
|
||
// SetConfigMapHandler Set the ConfigMap cache handler | ||
func SetConfigMapHandler(inConfigMapHandler store.ConfigMapHandler) { | ||
configMapHandler = inConfigMapHandler | ||
} | ||
|
||
// GetConfigMapHandler Get the ConfigMap cache handler | ||
func GetConfigMapHandler() store.ConfigMapHandler { | ||
return configMapHandler | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* 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 extension | ||
|
||
import ( | ||
"github.com/apolloconfig/agollo/v4/env/config" | ||
. "github.com/tevid/gohamcrest" | ||
"testing" | ||
) | ||
|
||
type TestConfigMapHandler struct { | ||
} | ||
|
||
func (t *TestConfigMapHandler) LoadConfigMap(configMapNamespace string) (*config.ApolloConfig, error) { | ||
return nil, nil | ||
} | ||
|
||
func (t *TestConfigMapHandler) WriteConfigMap(config *config.ApolloConfig, configMapNamespace string) error { | ||
return nil | ||
} | ||
|
||
// TestSetConfigMapHandler 测试 SetConfigMapHandler 函数 | ||
func TestSetConfigMapHandler(t *testing.T) { | ||
SetConfigMapHandler(&TestConfigMapHandler{}) | ||
|
||
resultConfigMapHandler := GetConfigMapHandler() | ||
|
||
Assert(t, resultConfigMapHandler, NotNilVal()) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,66 @@ | ||
module github.com/apolloconfig/agollo/v4 | ||
|
||
require ( | ||
github.com/agiledragon/gomonkey/v2 v2.11.0 // indirect | ||
github.com/agiledragon/gomonkey/v2 v2.11.0 | ||
github.com/spf13/viper v1.8.1 | ||
github.com/stretchr/testify v1.8.4 | ||
github.com/tevid/gohamcrest v1.1.1 | ||
k8s.io/api v0.30.1 | ||
k8s.io/apimachinery v0.30.1 | ||
k8s.io/client-go v0.30.1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verify the Versions of Kubernetes Dependencies The
As of April 2024, the latest stable versions of these modules are around |
||
) | ||
|
||
go 1.13 | ||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect | ||
github.com/evanphx/json-patch v4.12.0+incompatible // indirect | ||
github.com/fsnotify/fsnotify v1.4.9 // indirect | ||
github.com/go-logr/logr v1.4.1 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.6 // indirect | ||
github.com/go-openapi/jsonreference v0.20.2 // indirect | ||
github.com/go-openapi/swag v0.22.3 // indirect | ||
github.com/gogo/protobuf v1.3.2 // indirect | ||
github.com/golang/protobuf v1.5.4 // indirect | ||
github.com/google/gnostic-models v0.6.8 // indirect | ||
github.com/google/gofuzz v1.2.0 // indirect | ||
github.com/google/uuid v1.3.0 // indirect | ||
github.com/hashicorp/hcl v1.0.0 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/json-iterator/go v1.1.12 // indirect | ||
github.com/magiconair/properties v1.8.5 // indirect | ||
github.com/mailru/easyjson v0.7.7 // indirect | ||
github.com/mitchellh/mapstructure v1.4.1 // indirect | ||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | ||
github.com/modern-go/reflect2 v1.0.2 // indirect | ||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect | ||
github.com/pelletier/go-toml v1.9.3 // indirect | ||
github.com/pkg/errors v0.9.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
github.com/spf13/afero v1.9.2 // indirect | ||
github.com/spf13/cast v1.3.1 // indirect | ||
github.com/spf13/jwalterweatherman v1.1.0 // indirect | ||
github.com/spf13/pflag v1.0.5 // indirect | ||
github.com/subosito/gotenv v1.2.0 // indirect | ||
golang.org/x/net v0.23.0 // indirect | ||
golang.org/x/oauth2 v0.10.0 // indirect | ||
golang.org/x/sys v0.18.0 // indirect | ||
golang.org/x/term v0.18.0 // indirect | ||
golang.org/x/text v0.14.0 // indirect | ||
golang.org/x/time v0.3.0 // indirect | ||
google.golang.org/appengine v1.6.7 // indirect | ||
google.golang.org/protobuf v1.33.0 // indirect | ||
gopkg.in/inf.v0 v0.9.1 // indirect | ||
gopkg.in/ini.v1 v1.62.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
k8s.io/klog/v2 v2.120.1 // indirect | ||
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect | ||
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect | ||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect | ||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect | ||
sigs.k8s.io/yaml v1.3.0 // indirect | ||
) | ||
|
||
go 1.22.0 | ||
|
||
toolchain go1.22.5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么会会修改 client?我理解整体的框架应该是没有变化。
只是提供一个新的插件,通过文档告诉用户有这个插件可以选择。
我理解只需要按下方实现方式实现即可:
https://github.sheincorp.cn/zouyx/agollo_demo/tree/master/custom/file
如果是现在这种改法,可能会在用户升级的时候出现不兼容状态。
出现这种状态,可能会导致用户出现测试成本增加,或者生产故障。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我最初是在client文件的init里,作为插件初始化的。
但是那个位置无法获取用户的配置信息(*config.AppConfig)来判断是否初始化这个插件。如果盲目初始化插件会调用GetK8sManager方法,连接不到k8s的话会直接报错。所以挪到StartWithConfig这个方法里来了。
这样会有什么问题吗,如果用户没设置IsBackupConfigToConfigMap,就不进行这个插件的初始化