-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release v1.8.1 - Bug fix for pinned items. (#410)
- Loading branch information
1 parent
5391c38
commit 34ed128
Showing
11 changed files
with
270 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
from iblog import logger | ||
from kubernetes import client, config | ||
from typing import Dict, List | ||
|
||
""" | ||
WIP | ||
""" | ||
|
||
config.load_kube_config() | ||
# config.load_incluster_config() | ||
|
||
crd_group = "extensions.incidentbot.io" | ||
crd_namespace = "incident-bot" | ||
crd_plural = "incidents" | ||
crd_version = "v1alpha1" | ||
|
||
api = client.CustomObjectsApi() | ||
|
||
|
||
def get_incident(name: str) -> Dict: | ||
"""Return an incident stored via the CustomResourceDefinition for Kubernetes | ||
Keyword arguments: | ||
name -- string containing the name of the Incident CRD | ||
""" | ||
try: | ||
resource = api.get_namespaced_custom_object( | ||
group=crd_group, | ||
version=crd_version, | ||
name=name, | ||
namespace=crd_namespace, | ||
plural=crd_plural, | ||
) | ||
except client.exceptions.ApiException as error: | ||
logger.Error( | ||
f"Error looking for incident {name} in Kubernetes cluster: {error}" | ||
) | ||
|
||
return resource | ||
|
||
|
||
def get_incidents() -> List[Dict]: | ||
"""Return a list of incidents stored via the CustomResourceDefinition for Kubernetes""" | ||
try: | ||
resources = api.list_namespaced_custom_object( | ||
group=crd_group, | ||
version=crd_version, | ||
namespace=crd_namespace, | ||
plural=crd_plural, | ||
) | ||
|
||
return resources.get("items") | ||
except client.exceptions.ApiException as error: | ||
logger.Error( | ||
f"Error looking for incidents in Kubernetes cluster: {error}" | ||
) | ||
|
||
|
||
def patch_incident(name: str, body: Dict): | ||
"""Patch an incident stored via the CustomResourceDefinition for Kubernetes | ||
Keyword arguments: | ||
name -- string containing the name of the Incident CRD | ||
body -- the body for the patch operation | ||
""" | ||
try: | ||
api.patch_namespaced_custom_object( | ||
group=crd_group, | ||
version=crd_version, | ||
name=name, | ||
namespace=crd_namespace, | ||
plural=crd_plural, | ||
body=body, | ||
) | ||
except client.exceptions.ApiException as error: | ||
logger.Error( | ||
f"Error patching incident {name} in Kubernetes cluster: {error}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
creationTimestamp: null | ||
name: incidents.extensions.incidentbot.io | ||
spec: | ||
group: extensions.incidentbot.io | ||
names: | ||
kind: Incident | ||
listKind: IncidentList | ||
plural: incidents | ||
shortNames: | ||
- inc | ||
singular: incident | ||
scope: Namespaced | ||
versions: | ||
- additionalPrinterColumns: | ||
- description: Creation timestamp | ||
jsonPath: .metadata.creationTimestamp | ||
name: Created | ||
type: date | ||
- description: Severity | ||
jsonPath: .spec.severity | ||
name: Severity | ||
type: string | ||
- description: Status | ||
jsonPath: .spec.status | ||
name: Status | ||
type: string | ||
name: v1alpha1 | ||
schema: | ||
openAPIV3Schema: | ||
required: | ||
- spec | ||
type: object | ||
properties: | ||
spec: | ||
required: | ||
- id | ||
- created_at | ||
- channel_description | ||
- channel_id | ||
- channel_name | ||
- is_security_incident | ||
- severity | ||
- status | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
created_at: | ||
type: string | ||
updated_at: | ||
type: string | ||
channel_description: | ||
type: string | ||
channel_id: | ||
type: string | ||
channel_name: | ||
type: string | ||
conference_bridge: | ||
type: string | ||
is_security_incident: | ||
type: boolean | ||
last_update_sent: | ||
type: string | ||
rca: | ||
type: string | ||
roles: | ||
type: object | ||
severity: | ||
type: string | ||
status: | ||
type: string | ||
tags: | ||
items: | ||
type: string | ||
type: array | ||
bp_message_ts: | ||
type: string | ||
dig_message_ts: | ||
type: string | ||
sp_message_ts: | ||
type: string | ||
sp_incident_id: | ||
type: string | ||
sp_incident_data: | ||
type: object | ||
jira_issues: | ||
items: | ||
type: string | ||
type: array | ||
pagerduty_incidents: | ||
items: | ||
type: string | ||
type: array | ||
served: true | ||
storage: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: extensions.incidentbot.io/v1alpha1 | ||
kind: Incident | ||
metadata: | ||
name: foo | ||
spec: | ||
id: '2024-01-01-1234' | ||
created_at: '2024-01-01-1234' | ||
channel_description: 'placeholder' | ||
channel_id: 'placeholder' | ||
channel_name: 'placeholder' | ||
is_security_incident: false | ||
severity: 'sev4' | ||
status: 'investigating' |
Oops, something went wrong.