Apache License 2.0

项目介绍

cloud66-oss/copper 是一个托管在 GitHub 上的开源项目,主要使用 JavaScript 编写,采用 Apache License 2.0 许可证,目前获得 275 个 Star、14 次 Fork。

仓库全名
cloud66-oss/copper
开源许可证
Apache License 2.0
Star 数
275
Fork 数
14
未关闭 Issue
5

README 摘要

Copper Copper is a simple tool for validate your configuration files. This is specifically useful with Kubernetes configuration files to enforce best practices, apply policies and compliance requirements. NOTE: This is Copper v2.0 which is a rewrite of Copper v1.0 (and not an in-place upgrade). Copper v2.0 uses Javascript as it's scripting language instead of Copper v1.0's custom DSL. At the moment, we don't offer…

完整内容见 GitHub 原始 README 或本页 。

常见问题

copper 用什么语言开发?

主要使用 JavaScript 编写,采用 Apache License 2.0 许可证,目前有 275 个 Star。

copper 可以免费商用吗?

仓库采用 Apache License 2.0 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 copper 的源码?

可以直接克隆仓库:git clone https://github.com/cloud66-oss/copper.git;安装与运行步骤见仓库 README。

copper 最近还在维护吗?

仓库最近一次更新为 2022年6月11日,当前有 5 个未关闭 Issue;Star 数为 275,可作为社区活跃度的参考。

关于

A configuration file validator for Kubernetes.

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
578
价值分
196
活跃状态
活跃

语言占比

Go
JavaScript
Shell

Release

README

Copper

Copper is a simple tool for validate your configuration files. This is specifically useful with Kubernetes configuration files to enforce best practices, apply policies and compliance requirements.

NOTE: This is Copper v2.0 which is a rewrite of Copper v1.0 (and not an in-place upgrade). Copper v2.0 uses Javascript as it’s scripting language instead of Copper v1.0’s custom DSL. At the moment, we don’t offer any upgrades for old Copper v1 scripts to Copper v2.

Copper Logo

Installation

Head to the releases section of this repository and download the latest version of Copper. You can update Copper using copper update command at any time. By default, you will be running the stable releases. To change the channel, you can use the --channel argument in copper update.

Usage

copper validate --in samples/sample.yml --validator samples/no_latest.js

This will run no_latest.js script to validate sample.yml (both available in this repository).

Copper supports YAML configuration files. By default, it loads the entire input YAML file into the $$ variable that’s available to your scripts. Each section of your YAML file is one item in the $$ array.

Here is an example on how to stop using latest as the image tag.

$$.forEach(function($){
    if ($.kind === 'Deployment') {
        $.spec.template.spec.containers.forEach(function(container) {
            var image = new DockerImage(container.image);
            if (image.tag === 'latest') {
                errors.add_error('no_latest',"latest is used in " + $.metadata.name, 1)
            }
        });
    }
});

As you can see, for each section in the YAML, we check if the item is a Deployment, if it is use one of Copper’s internal helper classes DocerkImage to load the image name and parse it. DockerImage understands the intricacies of Docker image names (default tag names, default repos, etc). If the tag is latest we push an error into the errors list.

Once our script has run, Copper will check errors for any errors.

Each validation error should have 3 attributes: check_name: The name of the check we just performed title: Some explanation about this error severity: A numerical representation of the severity of this error.

You can set the maximum allowed severity when running Copper using the --threshold argument.

Helpers

To see what helpers are available for you to use in your scripts, see the files in the libjs folder in the repository. All these files are loaded before your script is run and therefore are available to use within your scripts.

评论

暂无评论