utils

package
v0.55.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ServiceFileContentTemplate = `` /* 942-byte string literal not displayed */

	AppFileContentTemplate = `` /* 183-byte string literal not displayed */

	AppFileContentTemplateWithHotfixVersion = AppFileContentTemplate + `  hotfixVersions:
  - @hotfixVersion@
`
	AppFileContentTemplateWithHotfixVersions = AppFileContentTemplate + `  hotfixVersions:
  - @hotfixVersion1@
  - @hotfixVersion2@
`
)
View Source
const CommitTemplate = `commit %s
Author: John Doe <john.doe@company.com>
Date:   Thu Jan 01 00:00:00 1970 +0000

    Commit #%d
`
View Source
const (
	DefaultProdNamespaceRef = "hivep"
)

Variables

View Source
var DefaultSignature = object.Signature{
	Name:  "John Doe",
	Email: "john.doe@company.com",
}

Functions

func CleanupAllTestDataResources

func CleanupAllTestDataResources()

func FilterTargetsContainingNamespaceRef

func FilterTargetsContainingNamespaceRef(targetNodes []*kyaml.RNode, namespaceRef string) ([]*kyaml.RNode, error)

func GetFileContent

func GetFileContent(template string, name string, properties map[string]string) string

func InitProperties

func InitProperties(repoUrl, gitHash string) map[string]string

func ReadYamlDocFromFile

func ReadYamlDocFromFile(filePath string) (*yamlDoc, error)

Types

type AppInterfaceClone

type AppInterfaceClone struct {
	// contains filtered or unexported fields
}

func FindAppInterfaceClone

func FindAppInterfaceClone(providedPath string) (*AppInterfaceClone, error)

func (*AppInterfaceClone) CheckoutNewBranch

func (a *AppInterfaceClone) CheckoutNewBranch(branchName string) error

func (*AppInterfaceClone) Commit

func (a *AppInterfaceClone) Commit(commitMessage string) error

func (*AppInterfaceClone) GetPath

func (a *AppInterfaceClone) GetPath() string

func (*AppInterfaceClone) IsClean

func (a *AppInterfaceClone) IsClean() (bool, error)

type Application

type Application struct {
	// contains filtered or unexported fields
}

func (*Application) GetComponent

func (a *Application) GetComponent(componentUrl string) (*CodeComponent, error)

func (*Application) GetFilePath

func (d *Application) GetFilePath() string

func (*Application) GetName

func (s *Application) GetName() string

func (*Application) Save

func (d *Application) Save() error

type CodeComponent

type CodeComponent struct {
	// contains filtered or unexported fields
}

func (*CodeComponent) GetName

func (c *CodeComponent) GetName() string

func (*CodeComponent) SetHotfixVersion

func (c *CodeComponent) SetHotfixVersion(hotfixVersion string) error

type CommitMessage

type CommitMessage struct {
	Title      string
	TestsList  string
	ChangesURL string
	ChangeLog  string
}

type DefaultPromoteCallbacks

type DefaultPromoteCallbacks struct {
	Service *Service
}

func (*DefaultPromoteCallbacks) ComputeCommitMessage

func (c *DefaultPromoteCallbacks) ComputeCommitMessage(resourceTemplateRepo *Repo, resourceTemplatePath, oldHash, newHash string) (*CommitMessage, error)

func (*DefaultPromoteCallbacks) FilterTargets

func (*DefaultPromoteCallbacks) FilterTargets(targetNodes []*kyaml.RNode) ([]*kyaml.RNode, error)

func (*DefaultPromoteCallbacks) GetResourceTemplateRelPath

func (c *DefaultPromoteCallbacks) GetResourceTemplateRelPath(resourceTemplateNode *kyaml.RNode) (string, error)

func (*DefaultPromoteCallbacks) GetResourceTemplateRepoUrl

func (c *DefaultPromoteCallbacks) GetResourceTemplateRepoUrl(resourceTemplateNode *kyaml.RNode) (string, error)

func (*DefaultPromoteCallbacks) GetTargetHash

func (c *DefaultPromoteCallbacks) GetTargetHash(targetNode *kyaml.RNode) (string, error)

func (*DefaultPromoteCallbacks) SetTargetHash

func (c *DefaultPromoteCallbacks) SetTargetHash(targetNode *kyaml.RNode, newHash string) error

type PromoteCallbacks

type PromoteCallbacks interface {
	GetResourceTemplateRepoUrl(resourceTemplateNode *kyaml.RNode) (string, error)
	GetResourceTemplateRelPath(resourceTemplateNode *kyaml.RNode) (string, error)
	FilterTargets(targetNodes []*kyaml.RNode) ([]*kyaml.RNode, error)
	GetTargetHash(targetNode *kyaml.RNode) (string, error)
	SetTargetHash(targetNode *kyaml.RNode, newHash string) error
	ComputeCommitMessage(resourceTemplateRepo *Repo, resourceTemplatePath, currentHash, newHash string) (*CommitMessage, error)
}

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

func GetRepo

func GetRepo(repoUrl string) (*Repo, error)

func (*Repo) Cleanup

func (r *Repo) Cleanup()

func (*Repo) FormattedLog

func (r *Repo) FormattedLog(fileRelPath, commonAncestorHash, targetHash string) (string, error)

func (*Repo) GetHeadHash

func (r *Repo) GetHeadHash() (string, error)

func (*Repo) GetUrl

func (r *Repo) GetUrl() string

func (*Repo) ResolveHash

func (r *Repo) ResolveHash(hashOrBranchName string) string

type Service

type Service struct {
	// contains filtered or unexported fields
}

func ReadServiceFromFile

func ReadServiceFromFile(appInterfaceClone *AppInterfaceClone, filePath string) (*Service, error)

func (*Service) GetApplication

func (s *Service) GetApplication() *Application

func (*Service) GetFilePath

func (d *Service) GetFilePath() string

func (*Service) GetName

func (s *Service) GetName() string

func (*Service) GetResourceTemplatesSequenceNode

func (s *Service) GetResourceTemplatesSequenceNode() *kyaml.RNode

func (*Service) GetRootNode

func (s *Service) GetRootNode() *kyaml.RNode

func (*Service) Promote

func (s *Service) Promote(callbacks PromoteCallbacks, newHash string) error

func (*Service) Save

func (d *Service) Save() error

type ServicesRegistry

type ServicesRegistry struct {
	// contains filtered or unexported fields
}

func CreateDefaultServiceRegistry

func CreateDefaultServiceRegistry(data *TestData) *ServicesRegistry

func CreateServiceRegistry

func CreateServiceRegistry(data *TestData, validateServiceFilePathCallback ValidateServiceFilePathCallback, servicesDirsRelPaths ...string) *ServicesRegistry

func NewServicesRegistry

func NewServicesRegistry(appInterfaceClone *AppInterfaceClone, validateServiceFilePathCallback ValidateServiceFilePathCallback, servicesDirsRelPaths ...string) (*ServicesRegistry, error)

func (*ServicesRegistry) GetService

func (r *ServicesRegistry) GetService(serviceId string) (*Service, error)

func (*ServicesRegistry) GetServicesIds

func (r *ServicesRegistry) GetServicesIds() []string

type TestData

type TestData struct {
	TestRepoPath     string
	TestRepoHashes   [10]string
	AppInterfacePath string
}

func CreateDefaultTestData

func CreateDefaultTestData() *TestData

func CreateTestData

func CreateTestData(getAppInterfaceContent func(data *TestData) map[string]string) *TestData

func (*TestData) CheckAppInterfaceBranchName

func (d *TestData) CheckAppInterfaceBranchName(expectedBranchName string)

func (*TestData) CheckAppInterfaceCommitMessage

func (d *TestData) CheckAppInterfaceCommitMessage(commitIndex int, expectedSubString string)

func (*TestData) CheckAppInterfaceCommitStats

func (d *TestData) CheckAppInterfaceCommitStats(commitIndex, filesCount int, fileRelPath string, addChangesCount, delChangesCount int)

func (*TestData) CheckAppInterfaceFileContent

func (d *TestData) CheckAppInterfaceFileContent(fileRelPath, expectedTemplate, expectedName string, expectedProperties map[string]string)

func (*TestData) CheckAppInterfaceIsClean

func (d *TestData) CheckAppInterfaceIsClean()

func (*TestData) CheckAppInterfaceService1Content

func (d *TestData) CheckAppInterfaceService1Content(expectedTemplate string, expectedProperties map[string]string)

func (*TestData) CommitAppInterfaceChanges

func (d *TestData) CommitAppInterfaceChanges(commitMessage string)

func (*TestData) GetAppInterfaceCommit

func (d *TestData) GetAppInterfaceCommit(index int) *object.Commit

func (*TestData) GetAppInterfaceCommitsCount

func (d *TestData) GetAppInterfaceCommitsCount() int

func (*TestData) GetTestRepoFormattedLog

func (d *TestData) GetTestRepoFormattedLog(hashIndexes ...int) string

func (*TestData) ReadAppInterfaceFile

func (d *TestData) ReadAppInterfaceFile(fileRelPath string) string

func (*TestData) WriteAppInterfaceFile

func (d *TestData) WriteAppInterfaceFile(fileRelPath string, fileContent string)

type ValidateServiceFilePathCallback

type ValidateServiceFilePathCallback func(filePath string) string

Jump to

Keyboard shortcuts

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