View Source Lightning.VersionControl (Lightning v2.10.4)

Boundary module for handling Version control activities for project, jobs workflows etc Use this module to create, modify and delete connections as well as running any associated sync jobs

Summary

Functions

Creates a connection between a project and a github repo

Deletes the authorization for the github app and updates the user details accordingly

Fecthes the access token for the given User. If the access token has expired, it refreshes the token and updates the User column accordingly

Checks if the given token has expired. Github supports access tokens that expire and those that don't. If the access token expires, then a refresh token is also availed. This function simply checks if the token has a refresh_token, if yes, it proceeds to check the expiry date

Functions

Link to this function

create_github_connection(attrs, user)

View Source

Creates a connection between a project and a github repo

Link to this function

delete_github_oauth_grant(user)

View Source
@spec delete_github_oauth_grant(Lightning.Accounts.User.t()) ::
  {:ok, Lightning.Accounts.User.t()} | {:error, map()}

Deletes the authorization for the github app and updates the user details accordingly

Link to this function

exchange_code_for_oauth_token(code)

View Source
@spec exchange_code_for_oauth_token(code :: String.t()) ::
  {:ok, map()} | {:error, map()}

Fetches the oauth access token using the code received from the callback url For more info: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/generating-a-user-access-token-for-a-github-app

Link to this function

fetch_installation_repos(installation_id)

View Source
Link to this function

fetch_repo_branches(installation_id, repo_name)

View Source
Link to this function

fetch_user_access_token(user)

View Source
@spec fetch_user_access_token(Lightning.Accounts.User.t()) ::
  {:ok, String.t()} | {:error, map()}

Fecthes the access token for the given User. If the access token has expired, it refreshes the token and updates the User column accordingly

Link to this function

fetch_user_installations(user)

View Source
Link to this function

get_repo_connection_for_project(project_id)

View Source
Link to this function

get_repo_connection_for_token(token)

View Source
Link to this function

initiate_sync(repo_connection, user_email)

View Source
@spec initiate_sync(
  repo_connection :: Lightning.VersionControl.ProjectRepoConnection.t(),
  user_email :: String.t()
) :: :ok | {:error, Lightning.Extensions.UsageLimiting.message() | map()}
Link to this function

oauth_token_valid?(token)

View Source
@spec oauth_token_valid?(token :: map()) :: boolean()

Checks if the given token has expired. Github supports access tokens that expire and those that don't. If the access token expires, then a refresh token is also availed. This function simply checks if the token has a refresh_token, if yes, it proceeds to check the expiry date

Link to this function

reconfigure_github_connection(repo_connection, params, user)

View Source
Link to this function

refresh_oauth_token(refresh_token)

View Source
@spec refresh_oauth_token(refresh_token :: String.t()) ::
  {:ok, map()} | {:error, map()}

Fetches a new access token using the given refresh token For more info: https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-access-tokens

Link to this function

remove_github_connection(repo_connection, user)

View Source

Deletes a github connection

Link to this function

save_oauth_token(user, token, opts \\ [notify: true])

View Source
@spec save_oauth_token(Lightning.Accounts.User.t(), map(), [{:notify, boolean()}]) ::
  {:ok, Lightning.Accounts.User.t()} | {:error, Ecto.Changeset.t()}

See Lightning.VersionControl.Events.subscribe/1.

Link to this function

verify_github_connection(repo_connection)

View Source
@spec verify_github_connection(
  repo_connection :: Lightning.VersionControl.ProjectRepoConnection.t()
) ::
  :ok | {:error, Lightning.VersionControl.GithubError.t() | map()}