Skip to content

Commit

Permalink
Add initial pipelines and mod files (#1)
Browse files Browse the repository at this point in the history
Co-authored-by: RahulLah19 <[email protected]>
  • Loading branch information
bigdatasourav and RahulLah19 authored Nov 20, 2023
1 parent eb86257 commit da4dc05
Show file tree
Hide file tree
Showing 23 changed files with 836 additions and 133 deletions.
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,4 @@
.DS_Store

# Flowpipe variable files
*.pvars

# Flowpipe mod dependencies
.flowpipe
*.pvars
70 changes: 49 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# GitHub Mod for PagerDuty
# PagerDuty Mod for Flowpipe

Run pipelines and use triggers for GitHub resources.
A collection of [Flowpipe](https://flowpipe.io) pipelines that can be used to:

- List Incidents
- List Users
- List Incident Log Entries
- And more!

## Documentation

- **[Pipelines →](https://hub.flowpipe.io/mods/turbot/pagerduty/pipelines)**
- **[Triggers →](https://hub.flowpipe.io/mods/turbot/pagerduty/triggers)**

## Getting started

Expand All @@ -16,13 +26,30 @@ brew install flowpipe
Clone:

```sh
git clone https://github.com/turbot/flowpipe-mod-github.git
cd flowpipe-mod-github
git clone https://github.com/turbot/flowpipe-mod-pagerduty.git
cd flowpipe-mod-pagerduty
```

### Configuration

Configure your credentials:

```sh
cp flowpipe.pvars.example flowpipe.pvars
vi flowpipe.pvars
```

It's recommended to configure credentials through [input variables](https://flowpipe.io/docs/using-flowpipe/mod-variables) by setting them in the `flowpipe.pvars` file.

**Note:** Credentials can also be passed in each pipeline run with `--pipeline-arg api_key=u+gLkyUh9sGsEGH3nmtw`.

Additional input variables may be defined in the mod's `variables.hcl` file that can be configured to better match your environment and requirements.

Variables with defaults set do not need to be explicitly set, but it may be helpful to override them.

### Usage

Start your server to get started:
Start the Flowpipe server to get started:

```sh
flowpipe service start
Expand All @@ -31,35 +58,36 @@ flowpipe service start
Run a pipeline:

```sh
flowpipe pipeline run user_get_current
flowpipe pipeline run list_incidents
```

### Credentials

This mod uses the credentials configured in `flowpipe.pvars` or passed through `--pipeline-args token`.

### Configuration
## Passing pipeline arguments

Pipelines have [input variables](https://flowpipe.io/docs/using-flowpipe/mod-variables) that can be configured to better match your environment and requirements. Some variables have defaults defined in its source file, e.g., `variables.hcl`, but these can be overwritten in several ways:
To pass values into pipeline [parameters](https://flowpipe.io/docs/using-flowpipe/pipeline-parameters), use the following syntax:

- Copy and rename the `flowpipe.pvars.example` file to `flowpipe.pvars`, and then modify the variable values inside that file
- Pass in a value on the command line:
```sh
flowpipe pipeline run list_incidents --pipeline-arg api_key=u+gLkyUh9sGsEGH3nmtw
```

```shell
flowpipe pipeline run user_get_current --pipeline-arg token="ghp_Abc123"
```
Multiple pipeline args can be passed in with separate `--pipeline-arg` flags.

These are only some of the ways you can set variables. For a full list, please see [Passing Input Variables](https://flowpipe.io/docs/using-flowpipe/mod-variables#passing-input-variables).
For more information on passing arguments, please see [Pipeline Args](https://flowpipe.io/docs/using-flowpipe/pipeline-arguments).

## Contributing

If you have an idea for additional controls or just want to help maintain and extend this mod ([or others](https://github.com/topics/flowpipe-mod)) we would love you to join the community and start contributing.

- **[Join our Slack community ](https://flowpipe.io/community/join)** and hang out with other Mod developers.
- **[Join #flowpipe in our Slack community ](https://flowpipe.io/community/join)**

Please see the [contribution guidelines](https://github.com/turbot/flowpipe/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/turbot/flowpipe/blob/main/CODE_OF_CONDUCT.md). All contributions are subject to the [Apache 2.0 open source license](https://github.com/turbot/flowpipe-mod-github/blob/main/LICENSE).
Please see the [contribution guidelines](https://github.com/turbot/flowpipe/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/turbot/flowpipe/blob/main/CODE_OF_CONDUCT.md).

Want to help but not sure where to start? Pick up one of the `help wanted` issues:

- [Flowpipe](https://github.com/turbot/flowpipe/labels/help%20wanted)
- [GitHub Mod](https://github.com/turbot/flowpipe-mod-github/labels/help%20wanted)
- [PagerDuty Mod](https://github.com/turbot/flowpipe-mod-pagerduty/labels/help%20wanted)

## License

This mod is licensed under the [Apache License 2.0](https://github.com/turbot/flowpipe-mod-pagerduty/blob/main/LICENSE).

Flowpipe is licensed under the [AGPLv3](https://github.com/turbot/flowpipe/blob/main/LICENSE).
77 changes: 46 additions & 31 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
---
repository: "https://github.com/turbot/flowpipe-mod-github"
repository: "https://github.com/turbot/flowpipe-mod-pagerduty"
---

# Flowpipe GitHub Mod
# PagerDuty Mod for Flowpipe

Run pipelines and use triggers for GitHub resources.
A collection of [Flowpipe](https://flowpipe.io) pipelines that can be used to:

## References

[GitHub](https://github.com/) is a provider of Internet hosting for software development and version control using Git.

[Flowpipe](https://flowpipe.io) is an open source workflow tool.

[Flowpipe Mods](https://flowpipe.io/docs/reference/mod-resources#mod) are collections of `pipelines` and `triggers`.
- List Incidents
- List Users
- List Incident Log Entries
- And more!

## Documentation

- **[Pipelines →](https://hub.flowpipe.io/mods/turbot/github/pipelines)**
- **[Triggers →](https://hub.flowpipe.io/mods/turbot/github/triggers)**
- **[Pipelines →](https://hub.flowpipe.io/mods/turbot/pagerduty/pipelines)**
- **[Triggers →](https://hub.flowpipe.io/mods/turbot/pagerduty/triggers)**

## Getting started

Expand All @@ -33,13 +30,30 @@ brew install flowpipe
Clone:

```sh
git clone https://github.com/turbot/flowpipe-mod-github.git
cd flowpipe-mod-github
git clone https://github.com/turbot/flowpipe-mod-pagerduty.git
cd flowpipe-mod-pagerduty
```

### Configuration

Configure your credentials:

```sh
cp flowpipe.pvars.example flowpipe.pvars
vi flowpipe.pvars
```

It's recommended to configure credentials through [input variables](https://flowpipe.io/docs/using-flowpipe/mod-variables) by setting them in the `flowpipe.pvars` file.

**Note:** Credentials can also be passed in each pipeline run with `--pipeline-arg api_key=u+gLkyUh9sGsEGH3nmtw`.

Additional input variables may be defined in the mod's `variables.hcl` file that can be configured to better match your environment and requirements.

Variables with defaults set do not need to be explicitly set, but it may be helpful to override them.

### Usage

Start your server to get started:
Start the Flowpipe server to get started:

```sh
flowpipe service start
Expand All @@ -48,35 +62,36 @@ flowpipe service start
Run a pipeline:

```sh
flowpipe pipeline run user_get_current
flowpipe pipeline run list_incidents
```

### Credentials

This mod uses the credentials configured in `flowpipe.pvars` or passed through `--pipeline-args token`.

### Configuration
## Passing pipeline arguments

Pipelines have [input variables](https://flowpipe.io/docs/using-flowpipe/mod-variables) that can be configured to better match your environment and requirements. Some variables have defaults defined in its source file, e.g., `variables.hcl`, but these can be overwritten in several ways:
To pass values into pipeline [parameters](https://flowpipe.io/docs/using-flowpipe/pipeline-parameters), use the following syntax:

- Copy and rename the `flowpipe.pvars.example` file to `flowpipe.pvars`, and then modify the variable values inside that file
- Pass in a value on the command line:
```sh
flowpipe pipeline run list_incidents --pipeline-arg api_key=u+gLkyUh9sGsEGH3nmtw
```

```shell
flowpipe pipeline run user_get_current --pipeline-arg token="ghp_Abc123"
```
Multiple pipeline args can be passed in with separate `--pipeline-arg` flags.

These are only some of the ways you can set variables. For a full list, please see [Passing Input Variables](https://flowpipe.io/docs/using-flowpipe/mod-variables#passing-input-variables).
For more information on passing arguments, please see [Pipeline Args](https://flowpipe.io/docs/using-flowpipe/pipeline-arguments).

## Contributing

If you have an idea for additional controls or just want to help maintain and extend this mod ([or others](https://github.com/topics/flowpipe-mod)) we would love you to join the community and start contributing.

- **[Join our Slack community ](https://flowpipe.io/community/join)** and hang out with other Mod developers.
- **[Join #flowpipe in our Slack community ](https://flowpipe.io/community/join)**

Please see the [contribution guidelines](https://github.com/turbot/flowpipe/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/turbot/flowpipe/blob/main/CODE_OF_CONDUCT.md). All contributions are subject to the [Apache 2.0 open source license](https://github.com/turbot/flowpipe-mod-github/blob/main/LICENSE).
Please see the [contribution guidelines](https://github.com/turbot/flowpipe/blob/main/CONTRIBUTING.md) and our [code of conduct](https://github.com/turbot/flowpipe/blob/main/CODE_OF_CONDUCT.md).

Want to help but not sure where to start? Pick up one of the `help wanted` issues:

- [Flowpipe](https://github.com/turbot/flowpipe/labels/help%20wanted)
- [GitHub Mod](https://github.com/turbot/flowpipe-mod-github/labels/help%20wanted)
- [PagerDuty Mod](https://github.com/turbot/flowpipe-mod-pagerduty/labels/help%20wanted)

## License

This mod is licensed under the [Apache License 2.0](https://github.com/turbot/flowpipe-mod-pagerduty/blob/main/LICENSE).

Flowpipe is licensed under the [AGPLv3](https://github.com/turbot/flowpipe/blob/main/LICENSE).
9 changes: 6 additions & 3 deletions locals.hcl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Common descriptions
locals {
repository_owner = split("/", var.repository_full_name)[0]
repository_name = split("/", var.repository_full_name)[1]
}
api_key_param_description = "The API token to authenticate to the PagerDuty APIs."
email_param_description = "The email address of a valid user associated with the account making the request."
incident_id_param_description = "The ID of the incident."
user_id_param_description = "The ID of the user."
}
18 changes: 9 additions & 9 deletions mod.hcl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
mod "pageduty" {
title = "PageDuty"
description = "Run pipelines and triggers that interact with PageDuty."
color = "#191717"
mod "pagerduty" {
title = "PagerDuty"
description = "Run pipelines and triggers that interact with PagerDuty."
color = "#06AC38"
documentation = file("./docs/index.md")
icon = "/images/flowpipe/mods/turbot/github.svg"
categories = ["pageduty"]
icon = "/images/flowpipe/mods/turbot/pagerduty.svg"
categories = ["pagerduty", "library"]

opengraph {
title = "PageDuty"
description = "Run pipelines and triggers that interact with PageDuty."
image = "/images/flowpipe/mods/turbot/github-social-graphic.png"
title = "PagerDuty"
description = "Run pipelines and triggers that interact with PagerDuty."
image = "/images/flowpipe/mods/turbot/pagerduty-social-graphic.png"
}
}
100 changes: 100 additions & 0 deletions pipelines/incident/create_incident.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
pipeline "create_incident" {
title = "Create Incident"
description = "Create an incident."

param "body" {
type = object({
type = string
details = string
})
description = "Additional incident details."
optional = true
}

param "conference_bridge" {
type = object({
conference_number = string
conference_url = string
})
description = "Central channel for collaboration."
optional = true
}

param "escalation_policy" {
type = object({
id = string
type = string
})
description = "The escalation policy for the incident."
optional = true
}

param "from" {
type = string
description = local.email_param_description
}

param "incident_key" {
type = string
description = "A string which identifies the incident. Sending subsequent requests referencing the same service and with the same incident_key will result in those requests being rejected if an open incident matches that incident_key."
optional = true
}

param "priority" {
type = object({
id = string
type = string
})
description = "The priority of the incident."
optional = true
}

param "service" {
type = object({
id = string
type = string
})
description = "The service detail for the incident."
}

param "api_key" {
type = string
description = local.api_key_param_description
default = var.api_key
}

param "title" {
type = string
description = "A succinct description of the nature, symptoms, cause, or effect of the incident."
}

param "type" {
type = string
description = "The type of the incident."
}

param "urgency" {
type = string
description = "The urgency of the incident."
optional = true
}

step "http" "create_incident" {
method = "POST"
url = "https://api.pagerduty.com/incidents"
request_headers = {
Content-Type = "application/json"
Authorization = "Token token=${param.api_key}"
From = "${param.from}"
}
request_body = jsonencode({
incident = {
for name, value in param : name => value if value != null
}
})
}

output "incident" {
value = step.http.create_incident.response_body
}
}
Loading

0 comments on commit da4dc05

Please sign in to comment.