小编wiw*_*978的帖子

Terraform:模块 + for_each 的输出

我有一个使用模块的 Terraform 脚本。我想创建多个资源,所以我使用了 for_each 方法。

下面是我的变量配置:

variable bridge_domains {
  description = "Bridge Domain"
  type     = map
  default  = {
    bd1 = {
      name  = "BD1",
    },
    bd2 = {
      name    = "BD2"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

在根main.tf文件中,我使用for_each以下命令遍历该变量:

module "schema_template_bd" {
  source = "./modules/schema_template_bd"
  for_each     =    var.bridge_domains
  
  schema       =    module.tenant.mso_schema.id 
  template     =    var.template

  bd           =    each.value.name
}
Run Code Online (Sandbox Code Playgroud)

然后在modules/schema_template_bd文件中我有以下内容:

resource "mso_schema_template_bd" "bd" {
  schema_id              =      var.schema
  template_name          =      var.template
  name                   =      var.bd
}
Run Code Online (Sandbox Code Playgroud)

该模块有一个输出,我在其中定义了以下内容:

output "mso_bd" { …
Run Code Online (Sandbox Code Playgroud)

terraform terraform0.12+

20
推荐指数
2
解决办法
2万
查看次数

Celery and Flower:经纪商标签中没有任何内容

我正在尝试配置Flower,Celery的监控工具.这总体上可行,但我在代理选项卡下看不到任何内容.我可以看到"工人","任务"和"监视器"下的内容,图表正在更新.我正在使用以下开始花:

celery flower --broker=amqp://<username>:<password>@<ipaddress>:5672/vhost_ubuntu --broker_api=http://<username>:<password>@<ipaddress>:15672/api
Run Code Online (Sandbox Code Playgroud)

我收到的相关错误消息是:无法获取经纪人信息:401客户端错误:未经授权

我可以通过http://:15672 /用户名guest和密码来登录RabbitMQ管理

关于为什么我看不到代理选项卡下的消息的任何想法?

rabbitmq celery flower

7
推荐指数
2
解决办法
2683
查看次数

Meteor更新用户配置文件

我不知道我的应用程序出了什么问题.我正在尝试更新用户个人资料.如果用户已有配置文件,则应显示配置文件的当前值.我有一个附加到用户集合的SimpleSchema.

<template name="updateCustomerProfile">
  <div class="container">
    <h1>Edit User</h1>
    {{#if isReady 'updateCustomerProfile'}}
      {{#autoForm collection="Users" doc=getUsers id="profileForm" type="update"}}
        <fieldset>
          {{> afQuickField name='username'}}
          {{> afObjectField name='profile'}}
        </fieldset>
        <button type="submit" class="btn btn-primary">Update User</button>
        <a class="btn btn-link" role="button" href="{{pathFor 'adminDocuments'}}">Back</a>
      {{/autoForm}}
    {{else}}
      Nothing
    {{/if}}
   </div>
</template>
Run Code Online (Sandbox Code Playgroud)

我有一个模板助手:

Template.updateCustomerProfile.events({
getUsers: function () {
    //return Users.findOne();
    return Meteor.user();
  }
});
Run Code Online (Sandbox Code Playgroud)

我有一个Autoform钩子

AutoForm.addHooks(['profileForm'], { 
    before: {
      insert: function(error, result) {
        if (error) {
          console.log("Insert Error:", error);
          AutoForm.debug();
        } else {
          console.log("Insert Result:", result);
          AutoForm.debug();
        }
      },
      update: function(error) { …
Run Code Online (Sandbox Code Playgroud)

javascript meteor

7
推荐指数
1
解决办法
578
查看次数

Gitlab CICD:使用 gitlab-ci.yml 中的函数

我有一个 .gitlab-ci.yml 文件,它允许需要为每个步骤执行相同的函数。我有以下内容并且有效。

image:
  name: hashicorp/terraform

before_script: 
  - export MYDATE=$(date "+%d/%m/%y - %H:%M:%S")

stages:
  - validate
  - plan

validate:
  stage: validate
  script:
    - terraform validate
    - 'curl --request POST --header "Authorization: Bearer $bearer"  --form "text=$MYDATE $msg" https://api.teams.com/v1/messages'
  variables:
    msg: "Example1"

plan:
  stage: plan
  script:
    - terraform validate
    - 'curl --request POST --header "Authorization: Bearer $bearer"  --form "text=$MYDATE $msg" https://api.teams.com/v1/messages'
  variables:
    msg: "Example2"
Run Code Online (Sandbox Code Playgroud)

鉴于它始终是相同的curl命令,我想使用一个我声明一次并且可以在每个步骤中使用的函数。类似于下面代码片段的内容。

image:
  name: hashicorp/terraform

before_script: 
  - export MYDATE=$(date "+%d/%m/%y - %H:%M:%S")

.send_message: &send_message
  script:  
  - 'curl --request POST …
Run Code Online (Sandbox Code Playgroud)

gitlab gitlab-ci

6
推荐指数
2
解决办法
2万
查看次数

Twilio:此电话号码无法使用消息

我现在有一个Twilio测试帐户.我收到了一个比利时电话号码,我验证了自己的手机号码.我正在尝试从我指定的Twilio号码向我的手机号码发送简单的短信,但这不起作用.

仪表板显示"此电话号码的消息不可用".但是在消息传递FAQ中(https://www.twilio.com/help/faq/phone-numbers/which-countries-does-twilio-have-phone-numbers-in-and-what-are-their-capabilities) ,提到比利时启用了国内和全球短信.

1)如果我的国家/地区被列为启用短信,为什么我不能发送短信?2)是因为我有一个试用帐户,一旦升级它会起作用吗?

sms twilio

4
推荐指数
1
解决办法
2988
查看次数

Laravel 路由模型绑定:找不到模型 id 时返回 json 响应

我正在 Laravel 中开发 REST API。我正在使用路由模型绑定来更新项目。当在数据库中找不到 id 时,我想返回 JSON 未找到响应。

这是路由文件中的条目api.php

   Route::get('product/{product}', 'ProductController@show')->name('products.show');
Run Code Online (Sandbox Code Playgroud)

控制器更新函数如下所示:

   public function update(Request $request, Product $product)
    {
        $request->validate([
            'user_id'       =>  'required',
            'name'          =>  'nullable',
            'description'   =>  'nullable',
            'price'         =>  'nullable'
        ]);

        // check if currently authenticated user is the owner of the listing

        if (auth::user()->id !== $product->user_id) {
            return response()->json(['error' => 'You can only edit your own products.'], 403);
        }

        $product->update($request->only(['name', 'description', 'price']));

        return new ProductResource($product);
    }
Run Code Online (Sandbox Code Playgroud)

使用此代码,Laravel 自动返回一个404 Not found视图,但我希望它是一个 JSON 响应。 …

laravel

4
推荐指数
1
解决办法
2494
查看次数

Terraform for-each 包含对象列表

我在 Variables.tf 文件中有以下变量:

variable tenants {
  description = "Map of project names to configuration."
  type = list(object({
    name  = string
    dname = string
    desc  = string
    site  = list(string)
  }))
  default = [{
      name  = "Tenant-1",
      dname = "Tenant-1",
      desc  = "Test Tenant 1",
      site  = ["site1", "site2"]
    },
    {
      name  = "Tenant-2",
      dname = "Tenant-2",
      desc  = "Test Tenant 2",
      site  = ["site1"]
    }]
}
Run Code Online (Sandbox Code Playgroud)

在我的 main.tf 文件中,我想循环遍历这个列表。我在 main.tf 文件中有以下代码:

resource "mso_tenant" "restenant" {
  for_each = {for i, v …
Run Code Online (Sandbox Code Playgroud)

terraform

4
推荐指数
1
解决办法
4万
查看次数

Laravel Spatie Medialibrary:通过 REST API 上传多个图像

我在 Laravel 应用程序中使用Spatie MediaLibrary库。我想通过 REST API 将 0 张或多张照片上传到我的应用程序。

photo当属性包含 1 个文件时我可以让它工作

public function store(Request $request)
{
    $request->validate([
        'name'          =>      'required',
        'slug'          =>      'required',
        'description'   =>      'required',
        'price'         =>      'required|integer',
        'photo'         =>      'nullable|file'
    ]);
    $listing =  Listing::Create([
        'user_id'       =>      auth('api')->user()->id,
        'name'          =>      $request->name,
        'slug'          =>      $request->slug,
        'description'   =>      $request->description,
        'price'         =>      $request->price,
    ]);
    // stores the photo
    if ($request->hasFile('photo')) {
        $listing->addMediaFromRequest('photo')->toMediaCollection('photos');
    }
    return new ListingResource($listing);
}
Run Code Online (Sandbox Code Playgroud)

邮递员请求如下所示: 在此输入图像描述

我知道想要更改代码,以便它可以处理请求中的多张照片。我在上面的控制器中使用以下代码来执行此操作:

if ($request->hasFile('photo')) {
   foreach ($request->input('photo', []) as $photo) { …
Run Code Online (Sandbox Code Playgroud)

laravel

3
推荐指数
1
解决办法
9316
查看次数

Heroku和Rails 4:一些javascript无法正常工作

我正在尝试在Heroku Rails 4应用程序上显示一个javascript项目.在我的本地开发机器上,一切都运行得很好.无法让它在Heroku上运行.

在我的application.html.erb文件中,我添加了:

<%= javascript_include_tag "application" %>
Run Code Online (Sandbox Code Playgroud)

在另一个视图文件(events.html.erb)我有:

<script type="text/javascript">
   $(document).ready(function()
   ...code to add data to a timeline using getjson()...
</script>`
Run Code Online (Sandbox Code Playgroud)

它指的是assets> javascripts文件夹中的timeline.js文件.添加事件时(使用Rails CRUD操作,javascript代码调用getJson()方法并将事件添加到时间轴.这在本地计算机上按预期工作.

当我推送到Heroku时,我可以通过rails添加事件,但不显示时间轴.

我最初的想法是没有在Heroku上加载Javascript,所以我添加了一个简单的:

<script type="text/javascript">
   alert('Displays OK')
</script>
Run Code Online (Sandbox Code Playgroud)

调用,这在Heroku(以及我的本地机器)上显示正常.

在Heroku上查看页面源代码时,我可以看到:

<script src="/assets/application-6da332d35efc3706e98f87ead9900f20.js">
Run Code Online (Sandbox Code Playgroud)

所以似乎timeline.js文件是预编译的(它似乎是时间轴js的最小化版本).

在我的本地机器上,我没有看到预编译的js文件,但我看到:

<script src="/assets/timeline.js?body=1"></script>
<script src="/assets/timeline.min.js?body=1"></script>
Run Code Online (Sandbox Code Playgroud)

事实上,在Heroku上,它显示了javascript警报,但没有显示时间轴,似乎表明某些内容与预编译中的javascript代码混淆了.

我在heroku日志中看不到任何明显的东西.它说slug编译成功完成,我看不到错误消息.

有没有办法可以强制Heroku不使用预编译的js文件,所以我可以使用Heroku:

   <script src="/assets/timeline.js?body=1"></script>
   <script src="/assets/timeline.min.js?body=1"></script>
Run Code Online (Sandbox Code Playgroud)

我在production.rb文件中有以下内容:

config.serve_static_assets = false
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.compress = true
config.assets.digest = true
config.assets.debug = false
Run Code Online (Sandbox Code Playgroud)

希望有人可以帮助我.这已经困扰了我几天了.任何帮助赞赏.谢谢!

javascript ruby-on-rails heroku ruby-on-rails-4

2
推荐指数
1
解决办法
1713
查看次数

Meteor Flow Router问题与更新

我有一个Meteor应用程序,我正在从IronRouter转换到FlowRouter.到目前为止一直很好,但有些方面我还不了解.

我的路线如下:

FlowRouter.route('/documents/:docId/edit', {
  name: 'documentEdit',
  subscriptions: function (params, queryParams) {
    this.register('documentEdit', Meteor.subscribe('documentSingle', params.docId));
  },
  action: function (params, queryParams) {
    BlazeLayout.render('layout', { top: 'header', main: 'documentEdit' });
  },    
});
Run Code Online (Sandbox Code Playgroud)

第一种选择:

然后我还有一个模板:

<template name="documentEdit">
  <div class="container">
    <h1>Edit document</h1>
    {{#if isReady 'documentEdit'}}
      {{#autoForm collection="Documents" doc=this id="documentForm" type="update" meteormethod="documentUpdateMethod"}}
        <fieldset>
          {{> afQuickField name='title'}}
          {{> afQuickField name='content' rows=6}}
        </fieldset>
        <button type="submit" class="btn btn-primary">Update</button>
        <a class="btn btn-link" role="button" href="{{pathFor 'documentsList'}}">Back</a>
      {{/autoForm}}
      {{/if}}
   </div>
</template>
Run Code Online (Sandbox Code Playgroud)

使用模板助手如下:

Template.documentEdit.helpers({
 isReady: function(sub) {
    if(sub) {
      return FlowRouter.subsReady(sub);
    } else …
Run Code Online (Sandbox Code Playgroud)

meteor

1
推荐指数
1
解决办法
519
查看次数

当输出多个模型时如何制作Laravel资源

我正在构建一个 Laravel API。我有两个模型:列表和预订。

class Listing extends Model
{
    public function reservations()
    {
        return $this->hasMany(Reservation::class);
    }
Run Code Online (Sandbox Code Playgroud)

class Reservation extends Model
{
    public function listing()
    {
        return $this->belongsTo(Listing::class);
    }
Run Code Online (Sandbox Code Playgroud)

我还创建了两个 Laravel 资源:

class ListingResource extends JsonResource
    {
        public function toArray($request)
        {
            return [
                'id'            =>  $this->id,
                'user_id'       =>  $this->user->id,
                'name'          =>  $this->name,
                'description'   =>  $this->description,
                'price'         =>  $this->price,
            ];
        }
    }
Run Code Online (Sandbox Code Playgroud)

我还定义了 Laravel 资源:

class ReservationResource extends JsonResource
{
    public function toArray($request)
    {
        return [
            'id'            =>  $this->id,
            'listing_id'    =>  $this->listing->id, …
Run Code Online (Sandbox Code Playgroud)

laravel

1
推荐指数
1
解决办法
4258
查看次数

Rancher:Rancher UI中未显示EC2主机

我使用docker-machine创建了一个在Virtualbox上运行的Rancher设置.然后我在virtualbox上添加了两个主机.现在,我正在尝试将EC2主机添加到该设置中(这只是为了试验Rancher).

我已经看过这个教程,但是我想用Docker-machine代替.

在这方面,我做了以下工作:

 MAC-OSX:~ wauterw$ docker-machine create -d amazonec2 --amazonec2-vpc-id vpc-84fd6de0 --amazonec2-region eu-west-1 --amazonec2-ami ami-c5f1beb6 --amazonec2-ssh-user rancher Rancher-node-aws-01
Running pre-create checks...
Creating machine...
(Rancher-node-aws-01) Launching instance...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with rancheros...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection …
Run Code Online (Sandbox Code Playgroud)

rancher

0
推荐指数
1
解决办法
286
查看次数

在Laravel搜索

我有以下查询

$objects = Object::where('user_id', auth()->user()->id)
                ->where('object_name','LIKE','%'.$request->search."%")
                ->get();
Run Code Online (Sandbox Code Playgroud)

这将返回包含关键字的当前用户的所有对象.这仅搜索object_name列中的关键字.

因为我想内同时进行搜索object_nameobject_description,我增加了一个orWhere条款如下:

 $objects = Object::where('user_id', auth()->user()->id)
            ->where('object_name','LIKE','%'.$request->search."%")
            ->orWhere('object_description','LIKE','%'.$request->search."%")
            ->get();
Run Code Online (Sandbox Code Playgroud)

现在,这会返回一个包含关键字的所有对象object_nameobject_description,但它搜索整个用户群内.

我想要的是更改此查询,以便我可以在object_name或中搜索关键字object_description,但搜索范围必须限制为当前登录用户.

laravel eloquent

0
推荐指数
1
解决办法
58
查看次数