github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/cd-service/pkg/sqlitestore/sqlitestore.go (about) 1 /*This file is part of kuberpult. 2 3 Kuberpult is free software: you can redistribute it and/or modify 4 it under the terms of the Expat(MIT) License as published by 5 the Free Software Foundation. 6 7 Kuberpult is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 MIT License for more details. 11 12 You should have received a copy of the MIT License 13 along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>. 14 15 Copyright 2023 freiheit.com*/ 16 17 package sqlitestore 18 19 // #cgo pkg-config: sqlite3 libgit2 20 /* 21 #include <git2.h> 22 #include <sqlite3.h> 23 #include "sqlite.h" 24 */ 25 import "C" 26 import ( 27 "fmt" 28 "unsafe" 29 30 git "github.com/libgit2/git2go/v34" 31 ) 32 33 func NewOdbBackend(name string) (*git.OdbBackend, error) { 34 var ( 35 result *C.git_odb_backend 36 err_out *C.char 37 ) 38 err := C.kp_backend_sqlite(&result, C.CString(name), &err_out) 39 if err != C.SQLITE_OK { 40 str := C.GoString(C.sqlite3_errstr(err)) 41 return nil, fmt.Errorf("sqlitestore: %d %s %s", err, str, C.GoString(err_out)) 42 } 43 return git.NewOdbBackendFromC(unsafe.Pointer(result)), nil 44 }