github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/integration/testutil/util.go (about)

     1  // Copyright (c) 2022, R.I. Pienaar and the Choria Project contributors
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  
     5  package testutil
     6  
     7  import (
     8  	"fmt"
     9  	"path/filepath"
    10  
    11  	"github.com/onsi/gomega/gbytes"
    12  	"github.com/sirupsen/logrus"
    13  )
    14  
    15  func GbytesLogger(level logrus.Level) (*gbytes.Buffer, *logrus.Logger) {
    16  	logger := logrus.New()
    17  	logger.SetLevel(level)
    18  	buffer := gbytes.NewBuffer()
    19  	logger.SetOutput(buffer)
    20  
    21  	return buffer, logger
    22  }
    23  
    24  func CertPath(ca string, certname string) string {
    25  	path, _ := filepath.Abs(filepath.Join("../../ca", ca, fmt.Sprintf("certs/%s.pem", certname)))
    26  	return path
    27  }
    28  
    29  func KeyPath(ca string, certname string) string {
    30  	path, _ := filepath.Abs(filepath.Join("../../ca", ca, fmt.Sprintf("%s-key.pem", certname)))
    31  	return path
    32  }