From e2991d59e448036be063f36cf15c3349774e4a3d Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sat, 15 Jan 2022 13:12:49 -0500 Subject: [PATCH] lint: lint yaml files --- .github/FUNDING.yml | 4 +- .github/dependabot.yml | 37 ++++++------- .github/workflows/build.yaml | 94 ++++++++++++++++----------------- .yamllint | 11 ++++ dist/example_config.yaml | 81 ++++++++++++++-------------- dist/prometheus/prometheus.yaml | 11 ++-- 6 files changed, 127 insertions(+), 111 deletions(-) create mode 100644 .yamllint diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index c427c9e..d8a644f 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1,3 @@ -github: [ jzelinskie ] +--- +github: + - "jzelinskie" diff --git a/.github/dependabot.yml b/.github/dependabot.yml index afe2123..fab91a5 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -1,22 +1,23 @@ +--- version: 2 updates: -- package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: "monthly" - labels: - - "component/dependencies" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" + labels: + - "component/dependencies" -- package-ecosystem: "gomod" - directory: "/" - schedule: - interval: "monthly" - labels: - - "component/dependencies" + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "monthly" + labels: + - "component/dependencies" -- package-ecosystem: "docker" - directory: "/" - schedule: - interval: "monthly" - labels: - - "component/dependencies" + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "monthly" + labels: + - "component/dependencies" diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index d437900..c0d785c 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -34,21 +34,21 @@ jobs: name: "E2E Memory Tests" runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v2" - - uses: "actions/setup-go@v2" - with: - go-version: ^1.17 - - name: "Install and configure chihaya" - run: | - go install ./cmd/chihaya - cat ./dist/example_config.yaml - - name: "Run end-to-end tests" - run: | - chihaya --config=./dist/example_config.yaml --debug & - pid=$! - sleep 2 - chihaya e2e --debug - kill $pid + - uses: "actions/checkout@v2" + - uses: "actions/setup-go@v2" + with: + go-version: "^1.17" + - name: "Install and configure chihaya" + run: | + go install ./cmd/chihaya + cat ./dist/example_config.yaml + - name: "Run end-to-end tests" + run: | + chihaya --config=./dist/example_config.yaml --debug & + pid=$! + sleep 2 + chihaya e2e --debug + kill $pid e2e-redis: name: "E2E Redis Tests" @@ -59,24 +59,24 @@ jobs: ports: ["6379:6379"] options: "--entrypoint redis-server" steps: - - uses: "actions/checkout@v2" - - uses: "actions/setup-go@v2" - with: - go-version: ^1.17 - - name: "Install and configure chihaya" - run: | - go install ./cmd/chihaya - curl -LO https://github.com/jzelinskie/faq/releases/download/0.0.6/faq-linux-amd64 - chmod +x faq-linux-amd64 - ./faq-linux-amd64 '.chihaya.storage = {"config":{"gc_interval":"3m","peer_lifetime":"31m","prometheus_reporting_interval":"1s","redis_broker":"redis://127.0.0.1:6379/0","redis_connect_timeout":"15s","redis_read_timeout":"15s","redis_write_timeout":"15s"},"name":"redis"}' ./dist/example_config.yaml > ./dist/example_redis_config.yaml - cat ./dist/example_redis_config.yaml - - name: "Run end-to-end tests" - run: | - chihaya --config=./dist/example_redis_config.yaml --debug & - pid=$! - sleep 2 - chihaya e2e --debug - kill $pid + - uses: "actions/checkout@v2" + - uses: "actions/setup-go@v2" + with: + go-version: "^1.17" + - name: "Install and configure chihaya" + run: | + go install ./cmd/chihaya + curl -LO https://github.com/jzelinskie/faq/releases/download/0.0.6/faq-linux-amd64 + chmod +x faq-linux-amd64 + ./faq-linux-amd64 '.chihaya.storage = {"config":{"gc_interval":"3m","peer_lifetime":"31m","prometheus_reporting_interval":"1s","redis_broker":"redis://127.0.0.1:6379/0","redis_connect_timeout":"15s","redis_read_timeout":"15s","redis_write_timeout":"15s"},"name":"redis"}' ./dist/example_config.yaml > ./dist/example_redis_config.yaml + cat ./dist/example_redis_config.yaml + - name: "Run end-to-end tests" + run: | + chihaya --config=./dist/example_redis_config.yaml --debug & + pid=$! + sleep 2 + chihaya e2e --debug + kill $pid image-build: name: "Docker Build" @@ -96,17 +96,17 @@ jobs: name: "Helm Template" runs-on: "ubuntu-latest" steps: - - uses: "actions/checkout@v2" - - name: "Install Helm" - uses: "engineerd/configurator@v0.0.5" - with: - name: "helm" - pathInArchive: "linux-amd64/helm" - fromGitHubReleases: true - repo: "helm/helm" - version: "^v3" - urlTemplate: "https://get.helm.sh/helm-{{version}}-linux-amd64.tar.gz" - token: "${{ secrets.GITHUB_TOKEN }}" - - name: "Run `helm template`" - working-directory: "./dist/helm/chihaya" - run: "helm template . --debug" + - uses: "actions/checkout@v2" + - name: "Install Helm" + uses: "engineerd/configurator@v0.0.5" + with: + name: "helm" + pathInArchive: "linux-amd64/helm" + fromGitHubReleases: true + repo: "helm/helm" + version: "^v3" + urlTemplate: "https://get.helm.sh/helm-{{version}}-linux-amd64.tar.gz" + token: "${{ secrets.GITHUB_TOKEN }}" + - name: "Run `helm template`" + working-directory: "./dist/helm/chihaya" + run: "helm template . --debug" diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..7db2cb6 --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +# vim: ft=yaml +--- +yaml-files: + - "*.yaml" + - "*.yml" + - ".yamllint" +ignore: "dist/helm/" +extends: "default" +rules: + quoted-strings: "enable" + line-length: "disable" diff --git a/dist/example_config.yaml b/dist/example_config.yaml index c1afcc7..aff5fa1 100644 --- a/dist/example_config.yaml +++ b/dist/example_config.yaml @@ -1,15 +1,16 @@ +--- chihaya: # The interval communicated with BitTorrent clients informing them how # frequently they should announce in between client events. - announce_interval: 30m + announce_interval: "30m" # The interval communicated with BitTorrent clients informing them of the # minimal duration between announces. - min_announce_interval: 15m + min_announce_interval: "15m" # The network interface that will bind to an HTTP endpoint that can be # scraped by programs collecting metrics. - # + # # /metrics serves metrics in the Prometheus format # /debug/pprof/{cmdline,profile,symbol,trace} serves profiles in the pprof format metrics_addr: "0.0.0.0:6880" @@ -30,14 +31,14 @@ chihaya: tls_key_path: "" # The timeout durations for HTTP requests. - read_timeout: 5s - write_timeout: 5s + read_timeout: "5s" + write_timeout: "5s" # When true, persistent connections will be allowed. Generally this is not # useful for a public tracker, but helps performance in some cases (use of # a reverse proxy, or when there are few clients issuing many requests). enable_keepalive: false - idle_timeout: 30s + idle_timeout: "30s" # Whether to time requests. # Disabling this should increase performance/decrease load. @@ -88,7 +89,7 @@ chihaya: addr: "0.0.0.0:6969" # The leeway for a timestamp on a connection ID. - max_clock_skew: 10s + max_clock_skew: "10s" # The key used to encrypt connection IDs. private_key: "paste a random string here that will be used to hmac connection IDs" @@ -113,17 +114,17 @@ chihaya: # This block defines configuration used for the storage of peer data. storage: - name: memory + name: "memory" config: # The frequency which stale peers are removed. # This balances between # - collecting garbage more often, potentially using more CPU time, but potentially using less memory (lower value) # - collecting garbage less frequently, saving CPU time, but keeping old peers long, thus using more memory (higher value). - gc_interval: 3m + gc_interval: "3m" # The amount of time until a peer is considered stale. # To avoid churn, keep this slightly larger than `announce_interval` - peer_lifetime: 31m + peer_lifetime: "31m" # The number of partitions data will be divided into in order to provide a # higher degree of parallelism. @@ -131,7 +132,7 @@ chihaya: # The interval at which metrics about the number of infohashes and peers # are collected and posted to Prometheus. - prometheus_reporting_interval: 1s + prometheus_reporting_interval: "1s" # This block defines configuration used for redis storage. # storage: @@ -141,56 +142,56 @@ chihaya: # # This balances between # # - collecting garbage more often, potentially using more CPU time, but potentially using less memory (lower value) # # - collecting garbage less frequently, saving CPU time, but keeping old peers long, thus using more memory (higher value). - # gc_interval: 3m + # gc_interval: "3m" # # The interval at which metrics about the number of infohashes and peers # # are collected and posted to Prometheus. - # prometheus_reporting_interval: 1s + # prometheus_reporting_interval: "1s" # # The amount of time until a peer is considered stale. # # To avoid churn, keep this slightly larger than `announce_interval` - # peer_lifetime: 31m + # peer_lifetime: "31m" # # The address of redis storage. # redis_broker: "redis://pwd@127.0.0.1:6379/0" # # The timeout for reading a command reply from redis. - # redis_read_timeout: 15s + # redis_read_timeout: "15s" # # The timeout for writing a command to redis. - # redis_write_timeout: 15s + # redis_write_timeout: "15s" # # The timeout for connecting to redis server. - # redis_connect_timeout: 15s + # redis_connect_timeout: "15s" # This block defines configuration used for middleware executed before a # response has been returned to a BitTorrent client. prehooks: - #- name: jwt - # options: - # issuer: "https://issuer.com" - # audience: "https://chihaya.issuer.com" - # jwk_set_url: "https://issuer.com/keys" - # jwk_set_update_interval: 5m + # - name: "jwt" + # options: + # issuer: "https://issuer.com" + # audience: "https://chihaya.issuer.com" + # jwk_set_url: "https://issuer.com/keys" + # jwk_set_update_interval: "5m" - #- name: client approval - # options: - # whitelist: - # - "OP1011" - # blacklist: - # - "OP1012" + # - name: "client approval" + # options: + # whitelist: + # - "OP1011" + # blacklist: + # - "OP1012" - #- name: interval variation - # options: - # modify_response_probability: 0.2 - # max_increase_delta: 60 - # modify_min_interval: true + # - name: "interval variation" + # options: + # modify_response_probability: 0.2 + # max_increase_delta: 60 + # modify_min_interval: true # This block defines configuration used for torrent approval, it requires to be given # hashes for whitelist or for blacklist. Hashes are hexadecimal-encoaded. - #- name: torrent approval - # options: - # whitelist: - # - "a1b2c3d4e5a1b2c3d4e5a1b2c3d4e5a1b2c3d4e5" - # blacklist: - # - "e1d2c3b4a5e1b2c3b4a5e1d2c3b4e5e1d2c3b4a5" + # - name: "torrent approval" + # options: + # whitelist: + # - "a1b2c3d4e5a1b2c3d4e5a1b2c3d4e5a1b2c3d4e5" + # blacklist: + # - "e1d2c3b4a5e1b2c3b4a5e1d2c3b4e5e1d2c3b4a5" diff --git a/dist/prometheus/prometheus.yaml b/dist/prometheus/prometheus.yaml index 818ef08..a19cae8 100644 --- a/dist/prometheus/prometheus.yaml +++ b/dist/prometheus/prometheus.yaml @@ -1,11 +1,12 @@ +--- global: - scrape_interval: 5s - evaluation_interval: 5s + scrape_interval: "5s" + evaluation_interval: "5s" # A scrape configuration containing exactly one endpoint to scrape: scrape_configs: # The job name is added as a label `job=` to any timeseries scraped from this config. - - job_name: 'local-chihaya' # you can name this however you want - scrape_interval: 5s # optionally override the global scrape_interval + - job_name: "local-chihaya" # you can name this however you want + scrape_interval: "5s" # optionally override the global scrape_interval static_configs: - - targets: ['localhost:6881'] # provide the address of chihaya's prometheus endpoint + - targets: ["localhost:6881"] # provide the address of chihaya's prometheus endpoint