Skip to content

Commit

Permalink
[CI] Add yaml linter (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tankilevitch authored Aug 20, 2023
1 parent 1e4bbc5 commit f61343c
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/integration-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ body:
description: >
The version of the integration, can be extracted via the spec.yml file in the .port folder, or the docker container image tag
validations:
required: true
required: true
- type: textarea
attributes:
label: Steps to reproduce
Expand Down
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/integration-enhancement.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Integration Feature Request/Enhancement
description: Request a new feature or ask for an improvement of existing functionality in an integration powered by the Ocean framework
title: "[Enhancement/Feature] [Framework]"
labels: [ "enhancement", "framework" ]
labels: ["enhancement", "framework"]
body:
- type: textarea
attributes:
Expand All @@ -17,4 +17,4 @@ body:
attributes:
label: Are you willing to submit a PR?
options:
- label: I'm willing to submit a PR!
- label: I'm willing to submit a PR!
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/ocean-framework-enhancement.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Ocean Framework Feature Request/Enhancement
description: Request a new feature or ask for an improvement of existing functionality in the Ocean framework
title: "[Enhancement/Feature] [Integration] [<Integration Name Here i.e PagerDuty, Jira...>]"
labels: [ "enhancement", "integration" ]
labels: ["enhancement", "integration"]
body:
- type: textarea
attributes:
Expand All @@ -17,4 +17,4 @@ body:
attributes:
label: Are you willing to submit a PR?
options:
- label: I'm willing to submit a PR!
- label: I'm willing to submit a PR!
2 changes: 1 addition & 1 deletion .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ tests:
- any: ['**/tests/**']

infra:
- any: ['.github/**']
- any: ['.github/**']
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ jobs:
- name: Lint
run: |
make install/all
make lint/all
2 changes: 1 addition & 1 deletion .github/workflows/release-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Make install and build
run: |
run: |
make install
make build
- name: Publish package to PyPI
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Build and push Docker image
run: |
GHCR_TOKEN=$(echo ${{ secrets.GITHUB_TOKEN }} | base64)
files=$(find integrations/*/.port -name "spec.yaml")
for file in $files; do
# Get the type from ocean-spec.yaml
Expand All @@ -37,7 +37,7 @@ jobs:
MANIFEST=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${GHCR_TOKEN}" "https://ghcr.io/v2/port-labs/port-ocean-$type/manifests/$version")
if [ "$MANIFEST" = "200" ]; then
if [ "$MANIFEST" = "200" ]; then
echo "Image already exists in $repository: port-ocean-$type:$version"
else
# Check if the 'version' variable contains any character other than digits and "."
Expand Down Expand Up @@ -80,4 +80,4 @@ jobs:
done < file_list.txt
yq -j . < "$temp_file" > "$output_file"
aws s3 cp "$output_file" "s3://$aws_s3_bucket/$output_file"
aws s3 cp "$output_file" "s3://$aws_s3_bucket/$output_file"
1 change: 1 addition & 0 deletions .yamlignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*cookiecutter
16 changes: 16 additions & 0 deletions .yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends: default

ignore-from-file: [.gitignore, .yamlignore]

rules:
# ignore line length
line-length: disable

# ignore truthy checks
truthy: disable

# ignore document start marker
document-start: disable

# don't bother me with this rule
indentation: disable
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ define run_checks
mypy . --exclude '/\.venv/' || exit_code=$$?; \
ruff . || exit_code=$$?; \
black --check . || exit_code=$$?; \
yamllint . || exit_code=$$?; \
if [ $$exit_code -eq 1 ]; then \
echo "\033[0;31mOne or more checks failed with exit code $$exit_code\033[0m"; \
else \
Expand Down
1 change: 1 addition & 0 deletions changelog/1.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added yaml linter
6 changes: 3 additions & 3 deletions integrations/azure/.port/spec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: v0.1.0
version: v0.1.1
type: azure
description: azure integration for Port Ocean
icon: Azure
Expand All @@ -19,8 +19,8 @@ configurations:
sensitive: true
deploymentMethod:
- type: terraform
module: ocean-containerapp
module: port-labs/ocean-containerapp/azure
example: azure-integration
title: Azure Container App
version: ">=0.0.4"
extraVars: []
extraVars: []
7 changes: 7 additions & 0 deletions integrations/azure/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

<!-- towncrier release notes start -->

# 0.1.1 (2023-08-20)

### Bug Fixes

- Removed capability to remove port entity on received event of resource deletion
- Changed deployment method to point to full terraform module path

# 0.1.0 (2023-08-13)

### Features
Expand Down
16 changes: 2 additions & 14 deletions integrations/azure/azure_integration/ocean.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from loguru import logger
from starlette import responses
from port_ocean.context.ocean import ocean
from port_ocean.core.models import Entity
from port_ocean.core.ocean_types import ASYNC_GENERATOR_RESYNC_TYPE
from azure.identity.aio import DefaultAzureCredential
from azure.core.exceptions import ResourceNotFoundError
Expand Down Expand Up @@ -217,25 +216,14 @@ async def handle_events(cloud_event: CloudEvent) -> fastapi.Response:
resource_id=resource_uri,
api_version=resource_config.selector.api_version,
)
await ocean.register_raw(resource_type, [resource.as_dict()]) # type: ignore
except ResourceNotFoundError:
logger.info(
"Resource not found in azure, unregistering from port",
"Resource not found in azure, skipping",
id=resource_uri,
kind=resource_type,
api_version=resource_config.selector.api_version,
)
await ocean.unregister(
[
Entity(
# remove the quotes from the blueprint name
# TODO: remove this once the port client handles it
blueprint=resource_config.port.entity.mappings.blueprint.strip('"'), # type: ignore
identifier=resource_uri,
)
]
)
return fastapi.Response(status_code=http.HTTPStatus.OK)
await ocean.register_raw(resource_type, [resource.as_dict()]) # type: ignore
return fastapi.Response(status_code=http.HTTPStatus.OK)


Expand Down
6 changes: 3 additions & 3 deletions integrations/azure/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Please copy this file to config.yaml file in the integration folder and edit it to your needs.
initializePortResources: true
port:
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID, if both are set, the environment variable will be used.
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET, if both are set, the environment variable will be used.
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID, if both are set, the environment variable will be used.
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET, if both are set, the environment variable will be used.
# The event listener to use for the integration service.
eventListener:
type: POLLING
Expand All @@ -13,4 +13,4 @@ integration:
# The type of the integration.
type: "azure"
config:
subscriptionId: "{{ from env AZURE_SUBSCRIPTION_ID }}"
subscriptionId: "{{ from env AZURE_SUBSCRIPTION_ID }}"
4 changes: 2 additions & 2 deletions integrations/gitlab/config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
initializePortResources: true
port:
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID, if both are set, the environment variable will be used.
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET, if both are set, the environment variable will be used.
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID, if both are set, the environment variable will be used.
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET, if both are set, the environment variable will be used.
# The event listener to use for the integration service.
eventListener:
type: POLLING
Expand Down
4 changes: 2 additions & 2 deletions integrations/jira/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

initializePortResources: true
port:
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID, if both are set, the environment variable will be used.
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET, if both are set, the environment variable will be used.
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID, if both are set, the environment variable will be used.
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET, if both are set, the environment variable will be used.
# The event listener to use for the integration service.
eventListener:
type: POLLING
Expand Down
1 change: 0 additions & 1 deletion integrations/newrelic/.port/resources/port-app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,3 @@ resources:
error_rate: .apmSummary.errorRate
response_time_avg: .apmSummary.responseTimeAverage
instance_count: .apmSummary.instanceCount

8 changes: 4 additions & 4 deletions integrations/newrelic/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Please copy this file to config.yaml file in the integration folder and edit it to your needs.
initializePortResources: true
port:
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET
baseUrl: "{{ from env PORT_BASE_URL }}" # Can be loaded via environment variable: PORT_BASE_URL
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET
baseUrl: "{{ from env PORT_BASE_URL }}" # Can be loaded via environment variable: PORT_BASE_URL
# The event listener to use for the integration service.
eventListener:
type: POLLING
Expand All @@ -16,4 +16,4 @@ integration:
config:
newRelicAPIKey: "{{ from env NEWRELIC_API_KEY }}"
newRelicGraphqlURL: "{{ from env NEWRELIC_GRAPHQL_URL }}"
newRelicAccountID: "{{ from env NEWRELIC_ACCOUNT_ID }}"
newRelicAccountID: "{{ from env NEWRELIC_ACCOUNT_ID }}"
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ resources:
created_at: .created_at
updated_at: .updated_at
relations:
pagerdutyService: .service.id
pagerdutyService: .service.id
2 changes: 1 addition & 1 deletion integrations/pagerduty/.port/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ configurations:
- name: appHost
description: Pagerduty app host (https://app.pagerduty.com)
required: true
type: string
type: string
6 changes: 3 additions & 3 deletions integrations/pagerduty/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Please copy this file to config.yaml file in the integration folder and edit it to your needs.
initializePortResources: true
port:
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET
clientId: "{{ from env PORT_CLIENT_ID }}" # Can be loaded via environment variable: PORT_CLIENT_ID
clientSecret: "{{ from env PORT_CLIENT_SECRET }}" # Can be loaded via environment variable: PORT_CLIENT_SECRET
# The event listener to use for the integration service.
eventListener:
type: POLLING
Expand All @@ -15,4 +15,4 @@ integration:
config:
token: "{{ from env PAGERDUTY_TOKEN }}"
appHost: "{{ from env APP_HOST }}"
apiUrl: "{{ from env API_URL }}"
apiUrl: "{{ from env API_URL }}"
20 changes: 19 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ configurations:
type: string
sensitive: true
- name: someApplicationUrl
type: url
type: url
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ types-pyyaml = "^6.0.12.10"
ruff = "^0.0.278"
types-toml = "^0.10.8.6"
towncrier = "^23.6.0"
yamllint = "^1.32.0"

[tool.towncrier]
directory = "changelog"
Expand Down

0 comments on commit f61343c

Please sign in to comment.