store

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

README

01cloud-store

01cloud-store is a Go library that provides a single storage-facing API for platform metadata, workflow records, events, services, and related operational data across Firestore and MongoDB backends.

Build License Go Version

Why this project exists

Applications that need to persist CI/CD workflow data, cluster activity, service records, or environment state often end up tightly coupled to a single database implementation. This package keeps that persistence layer behind a consistent interface so consumers can switch between Firestore and MongoDB with environment-driven configuration.

Features

  • Unified StoreInterface for Firestore and MongoDB backends
  • Domain collections for CI workflows, cluster workflows, events, services, storage, cron jobs, release metadata, and more
  • fake package for tests and local development
  • Environment-based backend selection
  • Apache 2.0 licensed and ready for community contributions

Installation

Prerequisites
  • Go 1.13 or later
  • One configured backend:
    • Firestore with access to a Google Cloud project
    • MongoDB with a reachable connection URI
Add the dependency
go get github.com/berrybytes/01cloud-store@latest

Quick start

The package loads configuration from environment variables using .env support out of the box. Copy the example file and set values for the backend you want to use.

cp .env.example .env
Firestore configuration
export STORE_TYPE=firestore
export GCLOUD_PROJECT="your-gcp-project-id"
export GCLOUD_NAMESPACE="your-namespace"
MongoDB configuration
export STORE_TYPE=mongo
export MONGO_URL="mongodb://localhost:27017"
export MONGO_DB="cloud_store"
Example usage
package main

import (
	"log"

	store "github.com/berrybytes/01cloud-store"
)

func main() {
	s := store.NewStore()

	workflow, err := s.CIWOrkflow().GetWorkflow("example-workflow")
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("workflow: %#v", workflow)
}

Note: the current public API includes legacy method names such as CIWOrkflow() and ClusterWOrkflow(). They are documented here as-is to reflect the current exported surface.

Configuration

Variable Required Description
STORE_TYPE No Backend selector: firestore by default, or mongo
GCLOUD_PROJECT Firestore only Google Cloud project ID used to initialize the Firestore client
GCLOUD_NAMESPACE Firestore only Namespace or tenant scope used by Firestore queries
MONGO_URL Mongo only MongoDB connection URI
MONGO_DB Mongo only MongoDB database name

See .env.example for a working template.

Package layout

  • firestore/: Firestore-backed implementations
  • mongodb/: MongoDB-backed implementations
  • fake/: in-memory and fake helpers for tests
  • model/: shared domain models
  • constant/: collection names and constants

Development

Run tests
go test ./...
Run pre-commit checks
pip install pre-commit
pre-commit install
pre-commit run --all-files

To run a single hook:

pre-commit run gitleaks --all-files

Community

License

This project is licensed under the Apache License 2.0. See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActivityCollectionInterface

type ActivityCollectionInterface interface {
	Activity() ActivityInterface
}

type ActivityInterface

type ActivityInterface interface {
	GetActivityLog(namespace, objectName string, offset uint64, limit uint64) ([]map[string]interface{}, error)
}

type CIMetricCollectionInterface

type CIMetricCollectionInterface interface {
	CIMetric() CIMetricInterface
}

type CIMetricInterface

type CIMetricInterface interface {
	GetCiMetrics(namespace string) (map[string]interface{}, error)
	UpdateMetrics(namespace string, metric string) error
	DeleteMetrics(namespace string) error
}

type CIWorkflowCollectionInterface

type CIWorkflowCollectionInterface interface {
	CIWOrkflow() CIWorkflowInterface
}

type CIWorkflowInterface

type CIWorkflowInterface interface {
	GetWorkflowDetail(namespace string, offset int, limit int) ([]*model.WorkflowMetadata, error)
	GetWorkflowLog(name string) (map[string]interface{}, error)
	GetLatestWorkflow(namespace string) (*model.WorkflowMetadata, error)
	GetWorkflowCount(namespace, startdate, enddate string) (int, error)
	GetWorkflow(name string) (map[string]interface{}, error)
	GetBuildImages(namespace string, offset int, limit int) ([]map[string]string, error)
	DeleteWorkflow(namespace string, workflowId string) error
	DeleteCIWorkflow(namespace string) error
	DeleteCIPodData(namespace string) error
	StoreWorkflow(data model.PublishDataCi) error
	UpdateWorkflow(data model.PublishDataCi) error
	StorePodData(data model.PodLogsData) error
}

type CertificateCollectionInterface

type CertificateCollectionInterface interface {
	Certificate() CertificateInterface
}

type CertificateInterface

type CertificateInterface interface {
	StoreCertificateDetail(data map[string]interface{}) error
	GetCertificateDetail(namespace string) ([]map[string]interface{}, error)
	DeleteCertificateDetail(namespace string) error
}

type ClusterWorkflowCollectionInterface

type ClusterWorkflowCollectionInterface interface {
	ClusterWOrkflow() ClusterWorkflowInterface
}

type ClusterWorkflowInterface

type ClusterWorkflowInterface interface {
	GetCreateClusterWorkflow(name string) (*model.ClusterWorkflowMetadata, error)
	GetClusterWorkflowDetail(namespace string, offset int, limit int) ([]*model.ClusterWorkflowMetadata, error)
	GetCreateClusterWorkflowLog(name string) (map[string]interface{}, error)
	StoreWorkflow(data model.PublishData)
	UpdateWorkflow(data model.PublishData)
	DeleteWorkflowByNamespace(namespace string) error
	DeleteWorkflowLogsByNamespace(namespace string) error
}

type CronJobCollectionInterface

type CronJobCollectionInterface interface {
	CronJob() CronJobInterface
}

type CronJobInterface

type CronJobInterface interface {
	StoreCronJob(job model.CronJobPublish) error
	StoreJob(job model.JobPublish) error
	GetCronJobStatus(namespace string) ([]map[string]interface{}, error)
	GetCronJobLogs(namespace string, name string, page int, limit int) ([]map[string]interface{}, error)
	StoreCronJobLogs(data model.JobLog) error
	DeleteCronJob(namespace string, id uint) error
	DeleteCronJobByNamespace(namespace string) error
	DeleteCronJobLogs(namespace string, name string) error
	DeleteCronJobLogsByNamespace(namespace string) error
}

type EnvironmentLogCollection

type EnvironmentLogCollection interface {
	EnvironmentLog() EnvironmentLogInterface
}

type EnvironmentLogInterface

type EnvironmentLogInterface interface {
	StoreEnvironmentLogs(data model.EnvironmentLog) error
	DeleteEnvironmentLogs(namespace string) error
}

type EventCollectionInterface

type EventCollectionInterface interface {
	Event() EventInterface
}

type EventInterface

type EventInterface interface {
	StoreEventError(data *metav1.Status) error
	StoreEventData(data *corev1.Event) error
	DeleteEventData(namespace string) error
}

type LoadbalancerCollectionInterface

type LoadbalancerCollectionInterface interface {
	Loadbalancer() LoadbalancerInterface
}

type LoadbalancerInterface

type LoadbalancerInterface interface {
	StoreLoadBalancerStatus(ns string, data map[string]interface{}) error
	GetLoadbalancerStatus(namespace string) (map[string]interface{}, error)
	DeleteLoadbalancer(namespace string) error
}

type PodStateCollectionInterface

type PodStateCollectionInterface interface {
	PodState() PodStateInterface
}

type PodStateInterface

type PodStateInterface interface {
	GetAddOnState(namespace string) ([]map[string]interface{}, error)
	GetEnvironmentState(namespace string) ([]map[string]interface{}, string, bool, error)
	GetPodStatus(namespace string) ([]map[string]interface{}, error)
	StorePodData(data model.PodLogsData)
	DeletePodState(namespace string) []map[string]interface{}
	DeletePodData(namespace string) error
	StorePodState(i int, data *model.EnvironmentState) error
	StorePodEventData(i int, data *model.PodEvent) error
}

type ReleaseInfoCollectionInterface

type ReleaseInfoCollectionInterface interface {
	ReleaseInfo() ReleaseInfoInterface
}

type ReleaseInfoInterface

type ReleaseInfoInterface interface {
	GetData(releaseId string) (*model.K8sRelease, error)
	GetRevisonData(namespace string) (*model.RevisionHistory, error)
	DeleteReleaseMeta(releaseId string) error
	StoreRelease(releaseId string, data *model.HelmRelease, valuesString string, cname string) error
	StoreRevison(tag string, result *model.HelmRelease) error
	DeleteRevison(namespace string) error
}

type ServiceCollectionInterface

type ServiceCollectionInterface interface {
	Service() ServiceInterface
}

type ServiceInterface

type ServiceInterface interface {
	StoreServiceData(data *corev1.ServiceList, namespace string) error
	DeleteServiceData(namespace string) error
}

type StorageCollectionInterface

type StorageCollectionInterface interface {
	Storage() StorageInterface
}

type StorageInterface

type StorageInterface interface {
	GetStorageState(namespace string) ([]map[string]interface{}, error)
	StorageData(data model.StoragePublish) error
	SetStorageData(namespace string, data *corev1.PersistentVolumeClaimList)
	DeleteStorageData(namespace string) error
	DeleteStorageDataAll(namespace string) error
	DeleteStorageDataById(namespace string, id uint) error
}

type Store

type Store struct {
}

func (*Store) Activity

func (c *Store) Activity() ActivityInterface

func (*Store) CIMetric

func (c *Store) CIMetric() CIMetricInterface

func (*Store) CIWOrkflow

func (c *Store) CIWOrkflow() CIWorkflowInterface

func (*Store) Certificate

func (c *Store) Certificate() CertificateInterface

func (*Store) ClusterWOrkflow

func (c *Store) ClusterWOrkflow() ClusterWorkflowInterface

func (*Store) CronJob

func (c *Store) CronJob() CronJobInterface

func (*Store) EnvironmentLog

func (c *Store) EnvironmentLog() EnvironmentLogInterface

func (*Store) Event

func (c *Store) Event() EventInterface

func (*Store) Loadbalancer

func (c *Store) Loadbalancer() LoadbalancerInterface

func (*Store) PodState

func (c *Store) PodState() PodStateInterface

func (*Store) ReleaseInfo

func (c *Store) ReleaseInfo() ReleaseInfoInterface

func (*Store) Service

func (c *Store) Service() ServiceInterface

func (*Store) Storage

func (c *Store) Storage() StorageInterface

Directories

Path Synopsis
test command

Jump to

Keyboard shortcuts

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