Skip to content

Commit

Permalink
Add cred support
Browse files Browse the repository at this point in the history
  • Loading branch information
vkumbha committed Dec 7, 2023
1 parent 5d20547 commit 4640290
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 33 deletions.
4 changes: 2 additions & 2 deletions notify_teams_gitlab_project_visibility/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Notify a Teams channel with GitLab Public Projects of a group. Optionally, updat

## Usage

- Add your Slack API token and channel name to `flowpipe.pvars`
- Add your GitLab API token to `flowpipe.pvars`
- Add your Microsoft Teams channel ID to `flowpipe.pvars`
- Add your GitLab and Microsoft Teams API tokens to `credential` resource in any `.fpc` file in the config directory (~/.flowpipe/config/*.fpc).
- Start your Flowpipe server
- Run the pipeline and specify `group_id` e.g., `flowpipe pipeline run notify_teams_gitlab_project_visibility --arg group_id=77637670 --arg teams_channel_id="19:P7fSYEJGuWSTHTfYAMAZEzIc1Uk8BTS-abcdnSV2H-A1@thread.tacv2"`

Expand Down
10 changes: 3 additions & 7 deletions notify_teams_gitlab_project_visibility/mod.fp
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ mod "notify_teams_gitlab_project_visibility" {

require {
mod "github.com/turbot/flowpipe-mod-gitlab" {
version = "v0.0.1-rc-3"
args = {
access_token = var.gitlab_access_token
}
version = "v0.0.1-rc.4"
}
mod "github.com/turbot/flowpipe-mod-teams" {
version = "v0.0.1-rc.4"
version = "v0.0.1-rc.13"
args = {
access_token = var.teams_access_token
team_id = var.team_id
team_id = var.team_id
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ pipeline "notify_teams_gitlab_project_visibility" {
title = "Notify GitLab Project Visibility Changes"
description = "Notify a Slack channel when a GitLab's project visibility is changed."

param "gitlab_access_token" {
param "gitlab_credentials" {
type = string
description = "GitLab personal, project, or group access token to authenticate to the API. Example: glpat-ABC123_456-789."
default = var.gitlab_access_token
description = "Name for GitLab credentials to use. If not provided, the default credentials will be used."
default = "default"
}

param "group_id" {
type = string
description = "GitLab Group ID"
description = "GitLab Group ID."
}

param "action_public_to_private" {
Expand All @@ -19,10 +19,10 @@ pipeline "notify_teams_gitlab_project_visibility" {
default = false
}

param "teams_access_token" {
param "teams_credentials" {
type = string
description = "The MS Team access token to use for the API request."
default = var.teams_access_token
description = "Name for Microsoft Teams credentials to use. If not provided, the default credentials will be used."
default = "default"
}

param "team_id" {
Expand All @@ -40,9 +40,9 @@ pipeline "notify_teams_gitlab_project_visibility" {
pipeline = gitlab.pipeline.list_group_projects

args = {
access_token = param.gitlab_access_token
group_id = param.group_id
visibility = "public"
cred = param.gitlab_credentials
group_id = param.group_id
visibility = "public"
}
}

Expand All @@ -55,16 +55,16 @@ pipeline "notify_teams_gitlab_project_visibility" {
pipeline = gitlab.pipeline.update_project

args = {
access_token = param.gitlab_access_token
visibility = "private"
project_id = tostring(each.value.id)
cred = param.gitlab_credentials
visibility = "private"
project_id = tostring(each.value.id)
}
}

step "pipeline" "send_message" {
pipeline = teams.pipeline.send_channel_message
args = {
access_token = param.teams_access_token
cred = param.teams_credentials
team_id = param.team_id
channel_id = param.teams_channel_id
message_content_type = "html"
Expand Down
10 changes: 0 additions & 10 deletions notify_teams_gitlab_project_visibility/variables.fp
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
variable "gitlab_access_token" {
type = string
description = "GitLab personal, project, or group access token to authenticate to the API. Example: glpat-ABC123_456-789."
}

variable "teams_access_token" {
description = "The Microsoft personal security access_token to authenticate to the Microsoft graph APIs."
type = string
}

variable "team_id" {
description = "The unique identifier of the Team."
type = string
Expand Down

0 comments on commit 4640290

Please sign in to comment.