小编Joh*_*hee的帖子

什么是规范的YAML命名风格

我正在设计一个新的YAML文件,我想使用最标准的命名方式.这是什么?

复姓?

- job-name:
    ...
Run Code Online (Sandbox Code Playgroud)

lower_case_with_underscores?

- job_name:
    ...
Run Code Online (Sandbox Code Playgroud)

骆驼香烟盒?

- jobName:
    ...
Run Code Online (Sandbox Code Playgroud)

yaml

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

使用`__dict__`或`vars()`?

内置函数vars()对我来说看起来更像Pythonic,但我看到__dict__更频繁地使用.

Python文档表明它们是等效的.

一位博客声称__dict__比这更快vars().

我应该用哪个?

python

40
推荐指数
3
解决办法
6372
查看次数

继续詹金斯管道过去失败的阶段

我有一系列快速检查的阶段.即使有失败,我也想要完成它们.例如:

stage('one') {
    node {
        sh 'exit 0'
    }
}
stage('two') {
    node {
        sh 'exit 1'   // failure
    }
}
stage('three') {
    node {
        sh 'exit 0'
    }
}
Run Code Online (Sandbox Code Playgroud)

阶段two失败,因此默认情况下three不执行阶段.

通常这是一个工作parallel,但我想在舞台视图中显示它们.在下面的模拟中:

  • Build#4显示了正常情况.作业two失败,所以three不运行.
  • 我在Photoshop#6中展示了我想要看到的内容.作业two失败并显示为,但three仍然运行.真正的Jenkins可能会显示整个Build#6略带红色,这当然很好.

模拟所需的舞台视图结果

jenkins jenkins-pipeline

39
推荐指数
5
解决办法
3万
查看次数

如何模拟Python静态方法和类方法

如何模拟具有未绑定方法的类?例如,这个类有一个@classmethod和一个@staticmethod:

class Calculator(object):
    def __init__(self, multiplier):
        self._multiplier = multiplier
    def multiply(self, n):
        return self._multiplier * n
    @classmethod
    def increment(cls, n):
        return n + 1
    @staticmethod
    def decrement(n):
        return n - 1

calculator = Calculator(2)
assert calculator.multiply(3) == 6    
assert calculator.increment(3) == 4
assert calculator.decrement(3) == 2
assert Calculator.increment(3) == 4
assert Calculator.decrement(3) == 2
Run Code Online (Sandbox Code Playgroud)

以上几乎描述了我的问题.以下是一个工作示例,演示了我尝试过的事情.

Machine包含一个实例Calculator.我将Machine用模拟测试Calculator.要演示我的问题,请Machine通过类的实例CalculatorCalculator类来调用未绑定的方法:

class Machine(object):
    def __init__(self, calculator):
        self._calculator …
Run Code Online (Sandbox Code Playgroud)

python unit-testing mocking

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

为什么在 Terraform aws_route53_record 中出现错误“别名目标名称不在目标区域内”?

使用 Terraform 0.12,我在 S3 存储桶中创建了一个静态网站:

...

resource "aws_s3_bucket" "www" {
  bucket = "example.com"
  acl    = "public-read"
  policy = <<-POLICY
    {
      "Version": "2012-10-17",
      "Statement": [{
        "Sid": "AddPerm",
        "Effect": "Allow",
        "Principal": "*",
        "Action": ["s3:GetObject"],
        "Resource": ["arn:aws:s3:::example.com/*"]
      }]
    }
    POLICY
  website {
    index_document = "index.html"
    error_document = "404.html"
  }

  tags = {
    Environment = var.environment
    Terraform = "true"
  }
}

resource "aws_route53_zone" "main" {
  name = "example.com"

  tags = {
    Environment = var.environment
    Terraform = "true"
  }
}

resource "aws_route53_record" "main-ns" {
  zone_id …
Run Code Online (Sandbox Code Playgroud)

amazon-route53 terraform-provider-aws

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

没有Gerrit的Android回购工具`repo update`

我们正在为自己的非Android软件使用Android回购工具。我们使用的是GitLab,而不是Gerrit进行代码审查。使用GitLab,我只需要对主题分支进行普通推送,就像git push在工作区的每个存储库中一样。

如何在多个存储库上repo upload 进行普通git push设置?您可能会说我需要不存在的repo push命令。

我尝试使用<remote review />清单文件中属性的各种值来实现这一点,例如:

<?xml version="1.0" encoding="UTF-8"?>
<manifest>

  <remote  name="wfe"
           alias="origin"
           review="origin"
           fetch=".." />
  <remote  name="wcore"
           alias="origin"
           review="ssh://git@gitlabserver:sw/wcore"
           fetch=".." />
  <default revision="master"
           remote="wfe"
           sync-j="4" />

  <project path="wcore" name="wcore" remote="wcore" groups="sdk" />
  <project path="wfe" name="wfe" groups="sdk" />

</manifest>
Run Code Online (Sandbox Code Playgroud)

但是,我得到如下错误:

repo upload

----------------------------------------------------------------------
[FAILED] wcore/          repo-test      
       (ssh://git@gitlabserver:sw/wcore: <urlopen error [Errno 110] Connection timed out>)
[FAILED] wfe/            repo-test      
       (origin: <urlopen error [Errno -2] Name or service …
Run Code Online (Sandbox Code Playgroud)

git gitlab repo

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

如何登录microk8s Kubernetes仪表板?

我在microk8s中启用了仪表板:

microk8s.enable dns dashboard
Run Code Online (Sandbox Code Playgroud)

我找到了它的IP地址:

microk8s.kubectl get all --all-namespaces
    ...
kube-system   service/kubernetes-dashboard ClusterIP 10.152.183.212 <none> 443/TCP 24h
    ...
Run Code Online (Sandbox Code Playgroud)

我试图使用URL https://10.152.183.212在浏览器中显示它。我的浏览器显示错误“身份验证失败。请重试。”:

Kubernetes仪表板'验证失败。 请再试一遍。'

我还收到了类似的错误,“没有足够的数据来创建身份验证信息结构。”

kubernetes-dashboard microk8s

5
推荐指数
2
解决办法
2839
查看次数

如何使用 Android repo 工具检查现有功能分支

thebranch一位同事使用创建了功能分支repo start。现在我想检查这个分支并对其进行处理。我试试这个:

repo init -u git@gitserver:manifest.git -m all.xml
repo sync
repo branches              # Responds "(no branches)"
repo checkout thebranch    # Responds "error: no project has branch thebranch"
Run Code Online (Sandbox Code Playgroud)

如何查看其他人开始使用的功能分支repo start

repo

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