Git Integrator

Platform:

Ubuntu
24.04
Channel Revision Published Runs on
1.0/edge 7 Yesterday
Ubuntu 24.04
juju deploy git-integrator --channel 1.0/edge

charms.git_integrator.v0.git

Library to manage the relation provided by the Git Integrator charm.

This library contains the Requires and Provides classes for handling the relation between provider of the git relation interface (Git Integrator) and also the requirers. Both the Requires and Provides classes supports multiple relations over the git interfaces (the Git Integrator charm can share data with multiple downstream requirer apps, and similarly, a requirer app can receive data from multiple upstream Git Integrator charms.)

Requirer Charm

The following presents an example usage of the GitIntegratorRequires class:

import charms.git_integrator.v0.git as git


class CharmThatNeedsGit(ops.CharmBase):
    def __init__(self, *args) -> None:
        super().__init__(*args)

        self.git_requirer = git.GitRequires(
            self,
            "git", # relation endpoint
            callback=self.reconcile,
        )

        self.framework.observe(
            self.git_requirer.on.git_connection_information_update,
            self.print_git_connection_information,
        )

    def reconcile(self, event) -> None:
        # Reconciler method for this charm

        self.git_requirer.get_git_connection_information() # dict with git connection details

        # git connection details of a specific relation
        git_relations = self.model.relations["git"]
        for relation in git_relations:
            self.git_requirer.get_git_connection_information_for_relation(relation.id)


    def print_git_connection_information(self) -> None:
        # Print the git connection information
        print(f"New git connection info: {self.git_requirer.get_git_connection_information()}")
Provider Charm

The following presents an example usage of the GitProvides class:

import charms.git_integrator.v0.git as git


class GitIntegrator(ops.CharmBase):
    def __init__(self, *args) -> None:
        super().__init__(*args)

        self.git_provider = git.GitProvides(
            self,
            "git", # relation endpoint
            self.reconcile,
        )

    def reconcile(self, event) -> None:
        # Reconciler method for this charm

        self.git_provider.update_git_connection_information({
            "repository_url": "https://github.com/my/repo",
            "path": "custom/sub/directory",
        })

class AuthenticationMethodEnum

Description

Enum to encapsulate the possible Git authentication method options. None

class GitProviderModel

Description

Provider side of the git relation interface. None

class GitConnectionInformationUpdatedEvent

Description

Git connection information updated event. None

Methods

GitConnectionInformationUpdatedEvent. __init__( self , handle , relation , app , unit , content: TGitProviderModel )

GitConnectionInformationUpdatedEvent. snapshot( self )

Description

Save event information. None

GitConnectionInformationUpdatedEvent. restore( self , snapshot )

Description

Restore event information. None

class GitProvidesEvents

Description

Events that Git provider can emit. None

class GitRequirerEventHandler

Description

Event Handler for Git requirer. None

Methods

GitRequirerEventHandler. __init__( self , charm , relation_name: str , request_model , unique_key: str )

Description

Builds a Git requirer event handler. None

GitRequirerEventHandler. provider_content( self )

Data from valid related git integrator charms.

Description

Only returns pydantic models for relations that have valid relation data. If issues occur while building pydantic models from relation data, the relation is not included in the returned models.

class GitProviderEventHandler

Description

Event Handler for Git provider. None

Methods

GitProviderEventHandler. __init__( self , charm , relation_name: str , unique_key: str )

Description

Builds an Git provider event handler. None

GitProviderEventHandler. update_git_connection_info( self , connection_info , fields_to_reset )

Update data to send to related charms.

Description

Do nothing if no relations present, unit is not leader, or no connection info provided. Otherwise, build pydantic model from existing relation data or a new model if no data set yet in relation, and write the model to the relation with provided updates in connection_info. Assumes inputted connection_info is well formatted.

class GitRequires

Description

A requirer handler encapsulating the git relation. None

Methods

GitRequires. __init__( self , charm , relation_name: str , callback )

GitRequires. on( self )

Description

ops.CharmEvents containing custom events for this relation. None

GitRequires. relations( self )

Description

Relations for the git interface. None

GitRequires. is_ready( self , relation )

Description

Readiness of a relation's git connection information. None

GitRequires. get_git_connection_information_for_relation( self , relation_id: int )

Description

The git connection information for a relation. None

GitRequires. get_git_connection_information( self )

Description

Git connection information for all relations. None

class GitProvides

Description

A provider handler encapsulating the git relation. None

Methods

GitProvides. __init__( self , charm , relation_name: str , callback )

GitProvides. relations_exists( self )

Description

Indicates if git relations present. None

GitProvides. set_git_connection_info( self , connection_info )

Set git connection info appropriately in all relations.

Arguments

connection_info (dict[str, str])

fields to update in the pydantic model Valid keys:

  • repository_url
  • path
  • tracking_ref
  • authentication_method
  • credentials_username (if authentication_method == "credentials")
  • credentials_personal_access_token (if authentication_method == "credentials")
  • ssh_private_key (if authentication_method == "ssh")
  • ssh_passphrase (optional if authentication_method == "ssh")
  • ssh_strict_host_key_checking (optional if authentication_method == "ssh")
  • ssh_port (optional if authentication_method == "ssh")