我使用 Terraform 来管理 Google Cloud Functions 的资源。但是,虽然云函数的初始部署有效,但当sourcecode.zip我在更新源存档后使用时,未重新部署更改后的云函数源代码(源存档)的进一步部署terraform apply。
存储桶对象被更新,但这不会触发云函数资源的更新/重新部署。
这是提供商的错误吗?当代码更改时,有没有办法在 terraform 中重新部署函数?
我正在使用的简化源代码:
resource "google_storage_bucket" "cloud_function_source_bucket" {
name = "${local.project}-function-bucket"
location = local.region
uniform_bucket_level_access = true
}
resource "google_storage_bucket_object" "function_source_archive" {
name = "sourcecode.zip"
bucket = google_storage_bucket.cloud_function_source_bucket.name
source = "./../../../sourcecode.zip"
}
resource "google_cloudfunctions_function" "test_function" {
name = "test_func"
runtime = "python39"
region = local.region
project = local.project
available_memory_mb = 256
source_archive_bucket = google_storage_bucket.cloud_function_source_bucket.name
source_archive_object = google_storage_bucket_object.function_source_archive.name
trigger_http = true
entry_point = "trigger_endpoint"
service_account_email = google_service_account.function_service_account.email
vpc_connector …Run Code Online (Sandbox Code Playgroud) google-cloud-platform terraform google-cloud-functions terraform-provider-gcp
我正在寻找一种在 GitLab 中取消作业后清理运行程序的方法。原因是我们经常不得不取消正在运行的作业,因为运行程序有时会卡在测试管道中,我可以想象一些其他场景,您希望取消作业并在之后运行清理脚本。我正在寻找类似的东西after_script,但只是在工作被取消的情况下。我检查了GitLab 关键字参考,但找不到我需要的内容。
我的以下部分gitlab-ci.yaml显示了测试阶段,我想docker-compose down在取消作业时通过调用来优雅地取消该阶段。
我使用的是单个 gitlab-runner。另外,我不使用dind。
test_stage:
stage: test
only:
- master
- tags
- merge_requests
image: registry.gitlab.com/xxxxxxxxxxxxxxxxxxx
variables:
HEADLESS: "true"
script:
- docker login -u="xxxx" -p="${QUAY_IO_PASSWORD}" quay.io
- npm install
- npm run test
- npm install wait-on
- cd example
- docker-compose up --force-recreate --abort-on-container-exit --build traefik frontend &
- cd ..
- apt install -y iproute2
- export DOCKER_HOST_IP=$( /sbin/ip route|awk '/default/ { print $3 }' ) …Run Code Online (Sandbox Code Playgroud) 我曾经使用 IconButton 的onpressed从我的 AppBar 导航到设置页面,这是有效的。现在我试图从 PopupMenuItem 的onTap触发导航,但页面不导航。两个小部件都位于同一层次结构中,我无法找出不同行为的原因。不会抛出任何错误。
这是我的 appBar 的代码,其中包含操作:
Widget build(BuildContext ctx) {
return Container(
child: Scaffold(
appBar: AppBar(
title: const Text('MyApp'),
actions: [
PopupMenuButton(
itemBuilder: (context) => [
// THE NAVIGATION IN onTap DOES NOT WORK
PopupMenuItem(
child: Text(AppLocalizations.of(context).settings),
onTap: () => _openSettings(ctx),
),
],
icon: Icon(
Icons.settings,
),
),
// THIS WORKS
IconButton(onPressed: () => _openSettings(ctx),
icon: Icon(Icons.settings))
],
),
body: Text("")
),
);
}
Run Code Online (Sandbox Code Playgroud)
这里的导航调用只能在 IconButton 的onpressed内部工作。我可以确认该函数在这两种情况下都被触发:
Future<void> _openSettings(BuildContext ctx) …Run Code Online (Sandbox Code Playgroud)