gitlabhandler

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 15, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package gitlabhandler provides helper types and methods for interacting with GitLab resources in the context of Crossplane compositions. It includes handlers for GitLab groups and projects, enabling extraction of key resource attributes and validation of resource existence.

The package offers:

  • GroupHandler: Retrieves GitLab group properties such as namespace ID and path, and checks if a group already exists based on observed conditions.
  • ProjectHandler: Retrieves GitLab project properties such as namespace ID and path, and checks if a project already exists based on observed conditions.

These handlers work with Crossplane's DesiredComposed and ObservedComposed resources, using the function-sdk-go for resource access and error handling.

Typical usage:

groupHandler := &gitlabhandler.GroupHandler{}
namespaceID, err := groupHandler.GetNamespaceID(desired)
if err != nil {
    // handle error
}

existsMsg, exists := groupHandler.CheckResourceExists(observed)
if exists {
    // resource already exists
}

This package is intended for Crossplane Composition Function implementations that manage GitLab resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GroupHandler

type GroupHandler struct{}

GroupHandler provides helper methods for working with GitLab group resources in the context of Crossplane compositions. It enables extracting key attributes from desired resources and checking if a group already exists based on observed conditions.

The handler offers:

  • GetNamespaceID: Retrieves the parent group ID (namespaceID) from the desired resource.
  • GetPath: Retrieves the path of the GitLab group from the desired resource.
  • CheckResourceExists: Determines if a GitLab group already exists by inspecting the "Synced" condition message for duplication errors.

This type is intended for use in Crossplane functions that manage GitLab groups.

func (*GroupHandler) CheckResourceExists

func (g *GroupHandler) CheckResourceExists(obs resource.ObservedComposed) (string, bool)

CheckResourceExists determines if a GitLab group already exists based on the observed resource. It inspects the "Synced" condition message and checks if it contains the phrase "has already been taken". Returns:

  • The condition message.
  • A boolean indicating whether the resource already exists.

func (*GroupHandler) GetNamespaceID

func (g *GroupHandler) GetNamespaceID(des *resource.DesiredComposed) (int, error)

GetNamespaceID retrieves the parent group ID (namespaceID) from the desired resource. It looks up the value at the path "spec.forProvider.parentId" in the resource. Returns:

  • The namespace ID as an int if successful.
  • An error if the value cannot be retrieved or converted.

func (*GroupHandler) GetPath

func (g *GroupHandler) GetPath(des *resource.DesiredComposed) (string, error)

GetPath retrieves the path of the GitLab group from the desired resource. It looks up the value at the path "spec.forProvider.path" in the resource. Returns:

  • The path as a string if successful.
  • An error if the value cannot be retrieved.

type ProjectHandler

type ProjectHandler struct {
	Name string
}

ProjectHandler provides helper methods for working with GitLab project resources in the context of Crossplane compositions. It enables extracting key attributes from desired resources and checking if a project already exists based on observed conditions.

The handler offers:

  • GetNamespaceID: Retrieves the namespace ID of the GitLab project from the desired resource.
  • GetPath: Retrieves the path of the GitLab project from the desired resource.
  • CheckResourceExists: Determines if a GitLab project already exists by inspecting the "Synced" condition message for duplication errors.

This type is intended for use in Crossplane function implementations that manage GitLab projects.

func (*ProjectHandler) CheckResourceExists

func (p *ProjectHandler) CheckResourceExists(obs resource.ObservedComposed) (string, bool)

CheckResourceExists determines if a GitLab project already exists based on the observed resource. It inspects the "Synced" condition message and checks if it contains the phrase "has already been taken". Returns:

  • The condition message.
  • A boolean indicating whether the resource already exists.

func (*ProjectHandler) GetNamespaceID

func (p *ProjectHandler) GetNamespaceID(des *resource.DesiredComposed) (int, error)

GetNamespaceID retrieves the namespace ID of the GitLab project from the desired resource. It looks up the value at the path "spec.forProvider.namespaceId" in the resource. Returns:

  • The namespace ID as an int if successful.
  • An error if the value cannot be retrieved or converted.

func (*ProjectHandler) GetPath

func (p *ProjectHandler) GetPath(des *resource.DesiredComposed) (string, error)

GetPath retrieves the path of the GitLab project from the desired resource. It looks up the value at the path "spec.forProvider.path" in the resource. Returns:

  • The path as a string if successful.
  • An error if the value cannot be retrieved.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL