我想使用 hashcorp-vault 动态生成 postgres 凭证/令牌。为此,我指的是https://www.vaultproject.io/docs/secrets/databases/postgresql.html。
这是配置插件的命令:
vault write database/config/my-postgresql-database \
plugin_name=postgresql-database-plugin \
allowed_roles="my-role" \
connection_url="postgresql://{{username}}:{{password}}@localhost:5432/" \
username="root" \
password="root"
Run Code Online (Sandbox Code Playgroud)
但是抛出以下错误
* error creating database object: error verifying connection: pq: SSL is not enabled on the server
Run Code Online (Sandbox Code Playgroud)
你们能帮我解决这个错误吗?
注意:我的是开发服务器,因此未启用 SSL。我不知道如何启用它。
我有以下测试:
org.springframework.test.web.client.MockRestServiceServer mockServer
Run Code Online (Sandbox Code Playgroud)
当我使用any(String.class)或确切的 URL运行时,它们运行良好:
mockServer.expect(requestTo(any(String.class)))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)
或者:
mockServer.expect(requestTo("https://exact-example-url.com/path"))
.andExpect(method(HttpMethod.GET))
.andRespond(withSuccess("response", MediaType.APPLICATION_JSON));
Run Code Online (Sandbox Code Playgroud)
我希望通过字符串模式请求避免检查确切的 URL。我可以在Spring MockRestServiceServer上编写自定义匹配器来处理对同一 URI 的多个请求(自动发现)
有没有其他方法可以mockServer.expect(requestTo(".*example.*"))通过 String 模式制作?
我想使用Dataflow将数据从发布/订阅移到GCS。因此,基本上我希望Dataflow在固定的时间量(例如15分钟)中累积一些消息,然后在经过该时间量后将这些数据作为文本文件写入GCS。
我的最终目标是创建一个自定义管道,因此“ Pub / Sub to Cloud Storage”模板对我来说还不够,而且我完全不了解Java,这使我开始使用Python进行调整。
这是到目前为止我所获得的(Apache Beam Python SDK 2.10.0):
import apache_beam as beam
TOPIC_PATH="projects/<my-project>/topics/<my-topic>"
def CombineFn(e):
return "\n".join(e)
o = beam.options.pipeline_options.PipelineOptions()
p = beam.Pipeline(options=o)
data = ( p | "Read From Pub/Sub" >> beam.io.ReadFromPubSub(topic=TOPIC_PATH)
| "Window" >> beam.WindowInto(beam.window.FixedWindows(30))
| "Combine" >> beam.transforms.core.CombineGlobally(CombineFn).without_defaults()
| "Output" >> beam.io.WriteToText("<GCS path or local path>"))
res = p.run()
res.wait_until_finish()
Run Code Online (Sandbox Code Playgroud)
我在本地环境中运行该程序没有问题。
python main.py
Run Code Online (Sandbox Code Playgroud)
它在本地运行,但可以从指定的Pub / Sub主题读取,并且每隔30秒就会按预期写入指定的GCS路径。
但是现在的问题是,当我在Google Cloud Platform(即Cloud Dataflow)上运行它时,它不断发出神秘的异常。
java.util.concurrent.ExecutionException: java.lang.RuntimeException: Error received from SDK harness for instruction -1096: Traceback (most …Run Code Online (Sandbox Code Playgroud) python google-cloud-pubsub google-cloud-dataflow apache-beam
考虑 x64 Intel 程序集中的以下变量引用,其中变量a在.data节中声明:
mov eax, dword ptr [rip + _a]
Run Code Online (Sandbox Code Playgroud)
我很难理解这个变量引用是如何工作的。既然a是对应于变量运行时地址的符号(带重定位),如何[rip + _a]解引用正确的内存位置a?事实上,rip保存当前指令的地址,它是一个大的正整数,所以加法会导致错误的地址a?
相反,如果我使用 x86 语法(非常直观):
mov eax, dword ptr [_a]
Run Code Online (Sandbox Code Playgroud)
,我收到以下错误:64 位模式不支持 32 位绝对寻址。
有什么解释吗?
1 int a = 5;
2
3 int main() {
4 int b = a;
5 return b;
6 }
Run Code Online (Sandbox Code Playgroud)
编译gcc -S -masm=intel abs_ref.c -o abs_ref::
1 .section __TEXT,__text,regular,pure_instructions
2 .build_version macos, 10, 14
3 …Run Code Online (Sandbox Code Playgroud) 我正在尝试将一些多媒体文件(图像、音频和视频)上传到我的服务器,并且我只想在互联网连接稳定的情况下上传这些文件。有没有具体的方法来实现这一目标?
如果用户拒绝相机访问,我将显示一个带有取消和设置按钮的警报以显示它。但代码不起作用。
@IBAction func ProfileImageButton(_ sender: UIButton) {
print("profile image Button is pressed")
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
profileimgbool = true
let actionSheet = UIAlertController(title: "Photo Source", message: "choose a Source", preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .camera
self.present(imagePickerController, animated: true, completion: nil)
}))
actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary
self.present(imagePickerController, animated: true, completion: nil)}))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(actionSheet, animated: true, completion: nil)
}
func checkCameraPermission() …Run Code Online (Sandbox Code Playgroud) 我在更新时遇到错误.当我添加数据时,它会成功添加.这个错误只是为了UpdateAPIView
{
"detail": "Method \"POST\" not allowed."
}
Run Code Online (Sandbox Code Playgroud)
urls.py
path('groups/update/<int:pk>', views.GroupsUpdateAPIView.as_view(), name='api_groups_update'),
Run Code Online (Sandbox Code Playgroud)
Views.py
class GroupsUpdateAPIView(generics.UpdateAPIView):
queryset = Groups.objects.all()
serializer_class = GroupsAddSerialzer
permission_classes = [UserIsAuthenticated]
def perform_update(self, serializer):
serializer.save(
group_updated_by = self.request.auth.application.user,
)
Run Code Online (Sandbox Code Playgroud)
Serializer.py
class GroupsAddSerialzer(serializers.ModelSerializer):
class Meta:
model = Groups
fields = ['group_name', 'group_description', 'group_status']
Run Code Online (Sandbox Code Playgroud) 我想了解变量范围如何在 Jupyter 笔记本中工作。
当我创建一个包含两个单元格的bash笔记本时,导出的环境变量跨单元格边界可见:
在 [1]:
export PATH=$PATH:~/samplepath
Run Code Online (Sandbox Code Playgroud)
在 [2]:
echo $PATH
Run Code Online (Sandbox Code Playgroud)
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/myuser/samplepath
但是如果我创建一个Python笔记本并使用单元格魔法来实现相同的结果,变量似乎不再跨单元格边界可见:
在 [1]:
%%script bash
export PATH=$PATH:~/samplepath
Run Code Online (Sandbox Code Playgroud)
在 [2]:
%%script bash
echo $PATH
Run Code Online (Sandbox Code Playgroud)
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
对于不同的魔法,这种行为保持相同(即,在 echo 前面使用感叹号而不是脚本魔法给出相同的结果)。
所以,我想了解在这种情况下的范围规则是什么,以及如何制作export真正的导出变量,以便它们在整个笔记本中可见。
任何人都可以向我解释我在这里做错了什么吗?
struct X {
int x{};
explicit X(int x) : x(x) {}
virtual X &operator++() = 0;
};
struct OK : X {
int ok{};
explicit OK(int ok) : X(ok), ok(ok) {}
X &operator++() override {
ok += 10;
return *this;
}
};
struct MU : X {
int mu{};
explicit MU(int mu) : X(mu), mu(mu) {}
X &operator++() override {
mu *= 5;
return *this;
}
};
int main() {
X *x_base = new OK(0);
++x_base;
std::cout << x_base->x; …Run Code Online (Sandbox Code Playgroud) 我在连接使用SSL配置的MongoDB时遇到问题.我在Azure虚拟机中有MongoDB企业服务器,它具有以下配置.
net:
bindIp: 0.0.0.0
port: 27017
ssl:
CAFile: 'C:\openssl-0.9.8h-1-bin\bin\rCA.pem'
PEMKeyFile: 'C:\openssl-0.9.8h-1-bin\bin\rser.pem'
allowConnectionsWithoutCertificates: false
allowInvalidHostnames: true
mode: requireSSL
storage:
dbPath: 'C:\data\db'
Run Code Online (Sandbox Code Playgroud)
我有一个C#示例连接mongodb和作为字节数组传递的证书数据.
MongoClientSettings settings = new MongoClientSettings
{
Server = new MongoServerAddress("mongo_azure_host", 27017),
UseSsl = true,
RetryWrites = true
};
settings.VerifySslCertificate = false;
var SslCertificateData = FilePathHelper.ReadFile(Server, mySslClientCertificate);
var certificate = new X509Certificate2(SslCertificateData, "pwd");
settings.SslSettings = new SslSettings()
{
ClientCertificates = new[] { certificate }
};
}
MongoClient mongoClient = new MongoClient(settings);
mongoClient.GetServer().Connect();
Run Code Online (Sandbox Code Playgroud)
如果样本在我的本地环境中,这可以正常工作.但是,如果我在Azure Web应用程序中发布相同内容并尝试连接,则会引发以下异常
system.componentmodel.win32exception:无法识别提供给包的凭据
alert ×1
apache-beam ×1
assembly ×1
azure ×1
c++ ×1
django ×1
django-views ×1
flutter ×1
intel-syntax ×1
ios ×1
iphone ×1
java ×1
junit ×1
mockito ×1
mockserver ×1
mongodb ×1
objective-c ×1
openssl ×1
operators ×1
polymorphism ×1
postgresql ×1
python ×1
scope ×1
spring-boot ×1
ssl ×1
x86-64 ×1
xcode ×1