gitSensor

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 21 Imported by: 17

Documentation

Index

Constants

View Source
const (
	POST = "POST"
	GET  = "GET"
	PUT  = "PUT"
)
View Source
const (
	ContextTimeoutInSeconds = 10
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiClient added in v0.6.17

type ApiClient interface {
	SaveGitProvider(ctx context.Context, provider *GitProvider) error
	AddRepo(ctx context.Context, materials []*GitMaterial) error
	UpdateRepo(ctx context.Context, material *GitMaterial) error
	SavePipelineMaterial(ctx context.Context, ciPipelineMaterials []*CiPipelineMaterial) error

	FetchChanges(ctx context.Context, req *FetchScmChangesRequest) (*MaterialChangeResp, error)
	GetHeadForPipelineMaterials(ctx context.Context, req *HeadRequest) ([]*CiPipelineMaterial, error)
	GetCommitMetadata(ctx context.Context, req *CommitMetadataRequest) (*GitCommit, error)
	GetCommitMetadataForPipelineMaterial(ctx context.Context, req *CommitMetadataRequest) (*GitCommit, error)
	RefreshGitMaterial(ctx context.Context, req *RefreshGitMaterialRequest) (*RefreshGitMaterialResponse, error)

	GetWebhookData(ctx context.Context, req *WebhookDataRequest) (*WebhookAndCiData, error)
	GetAllWebhookEventConfigForHost(ctx context.Context, req *WebhookEventConfigRequest) ([]*WebhookEventConfig, error)
	GetWebhookEventConfig(ctx context.Context, req *WebhookEventConfigRequest) (*WebhookEventConfig, error)
	GetWebhookPayloadDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadDataRequest) (*WebhookPayloadDataResponse, error)
	GetWebhookPayloadFilterDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadFilterDataRequest) (*WebhookPayloadFilterDataResponse, error)
}

type CiPipelineMaterial

type CiPipelineMaterial struct {
	Id                        int
	GitMaterialId             int
	Type                      SourceType
	Value                     string
	Active                    bool
	GitCommit                 GitCommit
	ExtraEnvironmentVariables map[string]string // extra env variables which will be used for CI
}

type Client added in v0.6.17

type Client interface {
	SaveGitProvider(ctx context.Context, provider *GitProvider) error
	AddRepo(ctx context.Context, materials []*GitMaterial) error
	UpdateRepo(ctx context.Context, material *GitMaterial) error
	SavePipelineMaterial(ctx context.Context, ciPipelineMaterials []*CiPipelineMaterial) error

	FetchChanges(ctx context.Context, req *FetchScmChangesRequest) (*MaterialChangeResp, error)
	GetHeadForPipelineMaterials(ctx context.Context, req *HeadRequest) ([]*CiPipelineMaterial, error)
	GetCommitMetadata(ctx context.Context, req *CommitMetadataRequest) (*GitCommit, error)
	GetCommitMetadataForPipelineMaterial(ctx context.Context, req *CommitMetadataRequest) (*GitCommit, error)
	RefreshGitMaterial(ctx context.Context, req *RefreshGitMaterialRequest) (*RefreshGitMaterialResponse, error)

	GetWebhookData(ctx context.Context, req *WebhookDataRequest) (*WebhookAndCiData, error)
	GetAllWebhookEventConfigForHost(ctx context.Context, req *WebhookEventConfigRequest) ([]*WebhookEventConfig, error)
	GetWebhookEventConfig(ctx context.Context, req *WebhookEventConfigRequest) (*WebhookEventConfig, error)
	GetWebhookPayloadDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadDataRequest) (*WebhookPayloadDataResponse, error)
	GetWebhookPayloadFilterDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadFilterDataRequest) (*WebhookPayloadFilterDataResponse, error)
}

type ClientConfig added in v0.6.17

type ClientConfig struct {
	Url      string `env:"GIT_SENSOR_URL" envDefault:"127.0.0.1:7070"`
	Protocol string `env:"GIT_SENSOR_PROTOCOL" envDefault:"REST"`
	Timeout  int    `env:"GIT_SENSOR_TIMEOUT" envDefault:"0"` // in seconds
}

func GetConfig added in v0.6.17

func GetConfig() (*ClientConfig, error)

type ClientImpl added in v0.6.17

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

func NewGitSensorClient added in v0.6.17

func NewGitSensorClient(logger *zap.SugaredLogger, config *ClientConfig) (*ClientImpl, error)

func (*ClientImpl) AddRepo added in v0.6.17

func (c *ClientImpl) AddRepo(ctx context.Context, materials []*GitMaterial) error

func (*ClientImpl) FetchChanges added in v0.6.17

func (*ClientImpl) GetAllWebhookEventConfigForHost added in v0.6.17

func (c *ClientImpl) GetAllWebhookEventConfigForHost(ctx context.Context, req *WebhookEventConfigRequest) ([]*WebhookEventConfig, error)

func (*ClientImpl) GetCommitMetadata added in v0.6.17

func (c *ClientImpl) GetCommitMetadata(ctx context.Context, req *CommitMetadataRequest) (*GitCommit, error)

func (*ClientImpl) GetCommitMetadataForPipelineMaterial added in v0.6.17

func (c *ClientImpl) GetCommitMetadataForPipelineMaterial(ctx context.Context, req *CommitMetadataRequest) (*GitCommit, error)

func (*ClientImpl) GetHeadForPipelineMaterials added in v0.6.17

func (c *ClientImpl) GetHeadForPipelineMaterials(ctx context.Context, req *HeadRequest) ([]*CiPipelineMaterial, error)

func (*ClientImpl) GetWebhookData added in v0.6.17

func (c *ClientImpl) GetWebhookData(ctx context.Context, req *WebhookDataRequest) (*WebhookAndCiData, error)

func (*ClientImpl) GetWebhookEventConfig added in v0.6.17

func (c *ClientImpl) GetWebhookEventConfig(ctx context.Context, req *WebhookEventConfigRequest) (*WebhookEventConfig, error)

func (*ClientImpl) GetWebhookPayloadDataForPipelineMaterialId added in v0.6.17

func (c *ClientImpl) GetWebhookPayloadDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadDataRequest) (*WebhookPayloadDataResponse, error)

func (*ClientImpl) GetWebhookPayloadFilterDataForPipelineMaterialId added in v0.6.17

func (c *ClientImpl) GetWebhookPayloadFilterDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadFilterDataRequest) (*WebhookPayloadFilterDataResponse, error)

func (*ClientImpl) RefreshGitMaterial added in v0.6.17

func (*ClientImpl) SaveGitProvider added in v0.6.17

func (c *ClientImpl) SaveGitProvider(ctx context.Context, provider *GitProvider) error

func (*ClientImpl) SavePipelineMaterial added in v0.6.17

func (c *ClientImpl) SavePipelineMaterial(ctx context.Context, ciPipelineMaterials []*CiPipelineMaterial) error

func (*ClientImpl) UpdateRepo added in v0.6.17

func (c *ClientImpl) UpdateRepo(ctx context.Context, material *GitMaterial) error

type ClientRequest

type ClientRequest struct {
	Method       string
	Path         string
	RequestBody  interface{}
	ResponseBody interface{}
}

type CommitMetadataRequest

type CommitMetadataRequest struct {
	PipelineMaterialId int    `json:"pipelineMaterialId"`
	GitHash            string `json:"gitHash"`
	GitTag             string `json:"gitTag"`
	BranchName         string `json:"branchName"`
}

type FetchScmChangesRequest

type FetchScmChangesRequest struct {
	PipelineMaterialId int    `json:"pipelineMaterialId"`
	From               string `json:"from"`
	To                 string `json:"to"`
	ShowAll            bool   `json:"showAll"`
}

---------------

type GitCommit

type GitCommit struct {
	Commit      string //git hash
	Author      string
	Date        time.Time
	Message     string
	Changes     []string
	WebhookData *WebhookData
	Excluded    bool
}

type GitMaterial

type GitMaterial struct {
	Id               int
	GitProviderId    int
	Url              string
	Name             string
	CheckoutLocation string
	CheckoutStatus   bool
	CheckoutMsgAny   string
	Deleted          bool
	FetchSubmodules  bool
	FilterPattern    []string
}

type GitProvider

type GitProvider struct {
	Id            int
	Name          string
	Url           string
	UserName      string
	Password      string
	SshPrivateKey string
	AccessToken   string
	Active        bool
	AuthMode      repository.AuthMode
}

type GitSensorApiError

type GitSensorApiError struct {
	HttpStatusCode    int    `json:"-"`
	Code              string `json:"code,omitempty"`
	InternalMessage   string `json:"internalMessage,omitempty"`
	UserMessage       string `json:"userMessage,omitempty"`
	UserDetailMessage string `json:"userDetailMessage,omitempty"`
}

type GitSensorResponse

type GitSensorResponse struct {
	Code   int                  `json:"code,omitempty"`
	Status string               `json:"status,omitempty"`
	Result json.RawMessage      `json:"result,omitempty"`
	Errors []*GitSensorApiError `json:"errors,omitempty"`
}

-----------

type GrpcApiClientImpl added in v0.6.17

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

func NewGitSensorGrpcClientImpl added in v0.6.17

func NewGitSensorGrpcClientImpl(logger *zap.SugaredLogger, config *ClientConfig) (*GrpcApiClientImpl, error)

func (*GrpcApiClientImpl) AddRepo added in v0.6.17

func (client *GrpcApiClientImpl) AddRepo(ctx context.Context, materials []*GitMaterial) error

AddRepo adds git materials

func (*GrpcApiClientImpl) FetchChanges added in v0.6.17

func (client *GrpcApiClientImpl) FetchChanges(ctx context.Context, req *FetchScmChangesRequest) (
	*MaterialChangeResp, error)

func (*GrpcApiClientImpl) GetAllWebhookEventConfigForHost added in v0.6.17

func (client *GrpcApiClientImpl) GetAllWebhookEventConfigForHost(ctx context.Context, req *WebhookEventConfigRequest) (
	[]*WebhookEventConfig, error)

func (*GrpcApiClientImpl) GetChangesInRelease added in v0.6.17

func (client *GrpcApiClientImpl) GetChangesInRelease(ctx context.Context, req *pb.ReleaseChangeRequest) (
	*pb.GitChanges, error)

func (*GrpcApiClientImpl) GetCommitInfoForTag added in v0.6.17

func (client *GrpcApiClientImpl) GetCommitInfoForTag(ctx context.Context, req *CommitMetadataRequest) (
	*GitCommit, error)

func (*GrpcApiClientImpl) GetCommitMetadata added in v0.6.17

func (client *GrpcApiClientImpl) GetCommitMetadata(ctx context.Context, req *CommitMetadataRequest) (
	*GitCommit, error)

func (*GrpcApiClientImpl) GetCommitMetadataForPipelineMaterial added in v0.6.17

func (client *GrpcApiClientImpl) GetCommitMetadataForPipelineMaterial(ctx context.Context, req *CommitMetadataRequest) (
	*GitCommit, error)

func (*GrpcApiClientImpl) GetHeadForPipelineMaterials added in v0.6.17

func (client *GrpcApiClientImpl) GetHeadForPipelineMaterials(ctx context.Context, req *HeadRequest) (
	[]*CiPipelineMaterial, error)

func (*GrpcApiClientImpl) GetWebhookData added in v0.6.17

func (client *GrpcApiClientImpl) GetWebhookData(ctx context.Context, req *WebhookDataRequest) (
	*WebhookAndCiData, error)

func (*GrpcApiClientImpl) GetWebhookEventConfig added in v0.6.17

func (client *GrpcApiClientImpl) GetWebhookEventConfig(ctx context.Context, req *WebhookEventConfigRequest) (
	*WebhookEventConfig, error)

func (*GrpcApiClientImpl) GetWebhookPayloadDataForPipelineMaterialId added in v0.6.17

func (client *GrpcApiClientImpl) GetWebhookPayloadDataForPipelineMaterialId(ctx context.Context,
	req *WebhookPayloadDataRequest) (*WebhookPayloadDataResponse, error)

func (*GrpcApiClientImpl) GetWebhookPayloadFilterDataForPipelineMaterialId added in v0.6.17

func (client *GrpcApiClientImpl) GetWebhookPayloadFilterDataForPipelineMaterialId(ctx context.Context,
	req *WebhookPayloadFilterDataRequest) (*WebhookPayloadFilterDataResponse, error)

func (*GrpcApiClientImpl) RefreshGitMaterial added in v0.6.17

func (*GrpcApiClientImpl) ReloadAllMaterial added in v0.6.17

func (client *GrpcApiClientImpl) ReloadAllMaterial(ctx context.Context, req *pb.Empty) (*pb.Empty, error)

func (*GrpcApiClientImpl) ReloadMaterial added in v0.6.17

func (client *GrpcApiClientImpl) ReloadMaterial(ctx context.Context, materialId int64) (
	*pb.GenericResponse, error)

func (*GrpcApiClientImpl) SaveGitProvider added in v0.6.17

func (client *GrpcApiClientImpl) SaveGitProvider(ctx context.Context, provider *GitProvider) error

SaveGitProvider saves Git provider

func (*GrpcApiClientImpl) SavePipelineMaterial added in v0.6.17

func (client *GrpcApiClientImpl) SavePipelineMaterial(ctx context.Context, ciPipelineMaterials []*CiPipelineMaterial) error

SavePipelineMaterial saves ci pipeline material info

func (*GrpcApiClientImpl) UpdateRepo added in v0.6.17

func (client *GrpcApiClientImpl) UpdateRepo(ctx context.Context, material *GitMaterial) error

UpdateRepo updates the git material

type HeadRequest

type HeadRequest struct {
	MaterialIds []int `json:"materialIds"`
}

type MaterialChangeResp

type MaterialChangeResp struct {
	Commits        []*GitCommit `json:"commits"`
	LastFetchTime  time.Time    `json:"lastFetchTime"`
	IsRepoError    bool         `json:"isRepoError"`
	RepoErrorMsg   string       `json:"repoErrorMsg"`
	IsBranchError  bool         `json:"isBranchError"`
	BranchErrorMsg string       `json:"branchErrorMsg"`
}

type RefreshGitMaterialRequest

type RefreshGitMaterialRequest struct {
	GitMaterialId int `json:"gitMaterialId"`
}

type RefreshGitMaterialResponse

type RefreshGitMaterialResponse struct {
	Message       string    `json:"message"`
	ErrorMsg      string    `json:"errorMsg"`
	LastFetchTime time.Time `json:"lastFetchTime"`
}

type RestClientImpl added in v0.6.17

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

func NewGitSensorSession

func NewGitSensorSession(config *ClientConfig, logger *zap.SugaredLogger) (session *RestClientImpl, err error)

func (RestClientImpl) AddRepo added in v0.6.17

func (session RestClientImpl) AddRepo(ctx context.Context, material []*GitMaterial) error

func (RestClientImpl) FetchChanges added in v0.6.17

func (session RestClientImpl) FetchChanges(ctx context.Context, changeRequest *FetchScmChangesRequest) (materialChangeResp *MaterialChangeResp, err error)

func (RestClientImpl) GetAllWebhookEventConfigForHost added in v0.6.17

func (session RestClientImpl) GetAllWebhookEventConfigForHost(ctx context.Context, req *WebhookEventConfigRequest) (webhookEvents []*WebhookEventConfig, err error)

func (RestClientImpl) GetCommitMetadata added in v0.6.17

func (session RestClientImpl) GetCommitMetadata(ctx context.Context, commitMetadataRequest *CommitMetadataRequest) (*GitCommit, error)

func (RestClientImpl) GetCommitMetadataForPipelineMaterial added in v0.6.17

func (session RestClientImpl) GetCommitMetadataForPipelineMaterial(ctx context.Context, commitMetadataRequest *CommitMetadataRequest) (commit *GitCommit, err error)

func (RestClientImpl) GetHeadForPipelineMaterials added in v0.6.17

func (session RestClientImpl) GetHeadForPipelineMaterials(ctx context.Context, req *HeadRequest) (material []*CiPipelineMaterial, err error)

func (RestClientImpl) GetWebhookData added in v0.6.17

func (session RestClientImpl) GetWebhookData(ctx context.Context, req *WebhookDataRequest) (*WebhookAndCiData, error)

func (RestClientImpl) GetWebhookEventConfig added in v0.6.17

func (session RestClientImpl) GetWebhookEventConfig(ctx context.Context, req *WebhookEventConfigRequest) (webhookEvent *WebhookEventConfig, err error)

func (RestClientImpl) GetWebhookPayloadDataForPipelineMaterialId added in v0.6.17

func (session RestClientImpl) GetWebhookPayloadDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadDataRequest) (response *WebhookPayloadDataResponse, err error)

func (RestClientImpl) GetWebhookPayloadFilterDataForPipelineMaterialId added in v0.6.17

func (session RestClientImpl) GetWebhookPayloadFilterDataForPipelineMaterialId(ctx context.Context, req *WebhookPayloadFilterDataRequest) (response *WebhookPayloadFilterDataResponse, err error)

func (RestClientImpl) RefreshGitMaterial added in v0.6.17

func (session RestClientImpl) RefreshGitMaterial(ctx context.Context, req *RefreshGitMaterialRequest) (refreshRes *RefreshGitMaterialResponse, err error)

func (RestClientImpl) SaveGitProvider added in v0.6.17

func (session RestClientImpl) SaveGitProvider(ctx context.Context, provider *GitProvider) error

func (RestClientImpl) SavePipelineMaterial added in v0.6.17

func (session RestClientImpl) SavePipelineMaterial(ctx context.Context, material []*CiPipelineMaterial) error

func (RestClientImpl) UpdateRepo added in v0.6.17

func (session RestClientImpl) UpdateRepo(ctx context.Context, material *GitMaterial) error

type SourceType

type SourceType string

type StatusCode

type StatusCode int

func (StatusCode) IsSuccess

func (code StatusCode) IsSuccess() bool

type WebhookAndCiData added in v0.6.13

type WebhookAndCiData struct {
	ExtraEnvironmentVariables map[string]string `json:"extraEnvironmentVariables"` // extra env variables which will be used for CI
	WebhookData               *WebhookData      `json:"webhookData"`
}

type WebhookData added in v0.2.22

type WebhookData struct {
	Id              int               `json:"id"`
	EventActionType string            `json:"eventActionType"`
	Data            map[string]string `json:"data"`
}

type WebhookDataRequest added in v0.2.22

type WebhookDataRequest struct {
	Id                   int `json:"id"`
	CiPipelineMaterialId int `json:"ciPipelineMaterialId"`
}

type WebhookEventConfig added in v0.2.22

type WebhookEventConfig struct {
	Id            int       `json:"id"`
	GitHostId     int       `json:"gitHostId"`
	Name          string    `json:"name"`
	EventTypesCsv string    `json:"eventTypesCsv"`
	ActionType    string    `json:"actionType"`
	IsActive      bool      `json:"isActive"`
	CreatedOn     time.Time `json:"createdOn"`
	UpdatedOn     time.Time `json:"updatedOn"`

	Selectors []*WebhookEventSelectors `json:"selectors"`
}

type WebhookEventConfigRequest added in v0.2.22

type WebhookEventConfigRequest struct {
	GitHostId int `json:"gitHostId"`
	EventId   int `json:"eventId"`
}

type WebhookEventSelectors added in v0.2.22

type WebhookEventSelectors struct {
	Id               int       `json:"id"`
	EventId          int       `json:"eventId"`
	Name             string    `json:"name"`
	Selector         string    `json:"selector"`
	ToShow           bool      `json:"toShow"`
	ToShowInCiFilter bool      `json:"toShowInCiFilter"`
	FixValue         string    `json:"fixValue"`
	PossibleValues   string    `json:"possibleValues"`
	IsActive         bool      `json:"isActive"`
	CreatedOn        time.Time `json:"createdOn"`
	UpdatedOn        time.Time `json:"updatedOn"`
}

type WebhookPayloadDataPayloadsResponse added in v0.2.27

type WebhookPayloadDataPayloadsResponse struct {
	ParsedDataId        int       `json:"parsedDataId"`
	EventTime           time.Time `json:"eventTime"`
	MatchedFiltersCount int       `json:"matchedFiltersCount"`
	FailedFiltersCount  int       `json:"failedFiltersCount"`
	MatchedFilters      bool      `json:"matchedFilters"`
}

type WebhookPayloadDataRequest added in v0.2.27

type WebhookPayloadDataRequest struct {
	CiPipelineMaterialId int    `json:"ciPipelineMaterialId"`
	Limit                int    `json:"limit"`
	Offset               int    `json:"offset"`
	EventTimeSortOrder   string `json:"eventTimeSortOrder"`
}

type WebhookPayloadDataResponse added in v0.2.27

type WebhookPayloadDataResponse struct {
	Filters       map[string]string                     `json:"filters"`
	RepositoryUrl string                                `json:"repositoryUrl"`
	Payloads      []*WebhookPayloadDataPayloadsResponse `json:"payloads"`
}

type WebhookPayloadFilterDataRequest added in v0.2.27

type WebhookPayloadFilterDataRequest struct {
	CiPipelineMaterialId int `json:"ciPipelineMaterialId"`
	ParsedDataId         int `json:"parsedDataId"`
}

type WebhookPayloadFilterDataResponse added in v0.2.27

type WebhookPayloadFilterDataResponse struct {
	PayloadId     int                                         `json:"payloadId"`
	PayloadJson   string                                      `json:"payloadJson"`
	SelectorsData []*WebhookPayloadFilterDataSelectorResponse `json:"selectorsData"`
}

type WebhookPayloadFilterDataSelectorResponse added in v0.2.27

type WebhookPayloadFilterDataSelectorResponse struct {
	SelectorName      string `json:"selectorName"`
	SelectorCondition string `json:"selectorCondition"`
	SelectorValue     string `json:"selectorValue"`
	Match             bool   `json:"match"`
}

Directories

Path Synopsis
Package mock_gitSensor is a generated GoMock package.
Package mock_gitSensor is a generated GoMock package.

Jump to

Keyboard shortcuts

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