rpcdef

package
v3.1.12+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnboardExportTypeUsers      OnboardExportType = "users"
	OnboardExportTypeRepos                        = "repos"
	OnboardExportTypeProjects                     = "projects"
	OnboardExportTypeWorkConfig                   = "workconfig"
	OnboardExportTypeCalendar                     = "calendars"
)

Variables

View Source
var ErrOnboardExportNotSupported = errors.New("onboard for integration does not support requested object type")
View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "PLUGIN",
	MagicCookieValue: "pinpoint-agent-plugin",
}

handshakeConfigs are used to just do a basic handshake between a plugin and host. If the handshake fails, a user friendly error is shown. This prevents users from executing bad plugins or executing a plugin directory. It is a UX feature, not a security feature.

View Source
var PluginMap = map[string]plugin.Plugin{
	"integration": &IntegrationPlugin{},
}

Functions

This section is empty.

Types

type Agent

type Agent interface {
	// ExportStarted should be called when starting export for each modelType.
	// It returns session id to be used later when sending objects.
	ExportStarted(modelType string) (sessionID string, lastProcessed interface{})

	// ExportDone should be called when export of a certain modelType is complete.
	// TODO: rename to SessionDone
	ExportDone(sessionID string, lastProcessed interface{})

	// SendExported forwards the exported objects from intergration to agent,
	// which then uploads the data (or queues for uploading).
	// TODO: rename to SessionSend
	SendExported(
		sessionID string,
		objs []ExportObj)

	// SessionStart creates a new export session with optional parent.
	// isTracking is a bool to create a tracking session instead of normal session. Tracking sessions do not allow sending data, they are only used for organizing progress events.
	// name - For normal sessions use model name. For tracking sessions any string is allows, it will be shown in the progress log.
	// parentSessionID - parent session. Can be 0 for root sessions.
	// parentObjectID - id of the parent object. To show in progress logs.
	// parentObjectName - name of the parent object
	SessionStart(isTracking bool, name string, parentSessionID int, parentObjectID, parentObjectName string) (sessionID int, lastProcessed interface{}, _ error)

	// SessionProgress updates progress for a session
	SessionProgress(id int, current, total int) error

	// SessionRollback does not update lastProcessed, and deletes temp session file
	SessionRollback(id int) error

	// Integration can ask agent to download and process git repo using ripsrc.
	ExportGitRepo(fetch GitRepoFetch) error

	// OAuthNewAccessToken returns a new access token for integrations with UseOAuth: true. It askes agent to retrieve a new token from backend based on refresh token agent has.
	OAuthNewAccessToken() (token string, _ error)

	SendPauseEvent(msg string, resumeDate time.Time) error

	SendResumeEvent(msg string) error
}

keep in sync with readme.md

type AgentClient

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

func (*AgentClient) ExportDone

func (s *AgentClient) ExportDone(sessionID string, lastProcessed interface{})

func (*AgentClient) ExportGitRepo

func (s *AgentClient) ExportGitRepo(fetch GitRepoFetch) error

func (*AgentClient) ExportStarted

func (s *AgentClient) ExportStarted(modelType string) (sessionID string, lastProcessed interface{})

func (*AgentClient) OAuthNewAccessToken

func (s *AgentClient) OAuthNewAccessToken() (token string, _ error)

func (*AgentClient) SendExported

func (s *AgentClient) SendExported(sessionID string, objs []ExportObj)

func (*AgentClient) SendPauseEvent

func (s *AgentClient) SendPauseEvent(msg string, resumeDate time.Time) error

func (*AgentClient) SendResumeEvent

func (s *AgentClient) SendResumeEvent(msg string) error

func (*AgentClient) SessionProgress

func (s *AgentClient) SessionProgress(id int, current, total int) error

func (*AgentClient) SessionRollback

func (s *AgentClient) SessionRollback(id int) error

func (*AgentClient) SessionStart

func (s *AgentClient) SessionStart(isTracking bool, name string, parentSessionID int, parentObjectID, parentObjectName string) (sessionID int, lastProcessed interface{}, _ error)

type AgentServer

type AgentServer struct {
	Impl Agent
}

func (*AgentServer) ExportDone

func (s *AgentServer) ExportDone(ctx context.Context, req *proto.ExportDoneReq) (*proto.Empty, error)

func (*AgentServer) ExportGitRepo

func (s *AgentServer) ExportGitRepo(ctx context.Context, req *proto.ExportGitRepoReq) (resp *proto.Empty, _ error)

func (*AgentServer) ExportStarted

func (*AgentServer) OAuthNewAccessToken

func (s *AgentServer) OAuthNewAccessToken(ctx context.Context, req *proto.Empty) (*proto.OAuthNewAccessTokenResp, error)

func (*AgentServer) SendExported

func (s *AgentServer) SendExported(ctx context.Context, req *proto.SendExportedReq) (*proto.Empty, error)

func (*AgentServer) SendPauseEvent

func (s *AgentServer) SendPauseEvent(ctx context.Context, req *proto.SendPauseEventReq) (resp *proto.Empty, rerr error)

func (*AgentServer) SendResumeEvent

func (s *AgentServer) SendResumeEvent(ctx context.Context, req *proto.SendResumeEventReq) (resp *proto.Empty, err error)

func (*AgentServer) SessionProgress

func (s *AgentServer) SessionProgress(ctx context.Context, req *proto.SessionProgressReq) (resp *proto.Empty, _ error)

func (*AgentServer) SessionRollback

func (s *AgentServer) SessionRollback(ctx context.Context, req *proto.SessionRollbackReq) (resp *proto.Empty, _ error)

func (*AgentServer) SessionStart

func (s *AgentServer) SessionStart(ctx context.Context, req *proto.SessionStartReq) (resp *proto.SessionStartResp, _ error)

type ExportConfig

type ExportConfig struct {
	Pinpoint    ExportConfigPinpoint
	Integration IntegrationConfig
	UseOAuth    bool
}

type ExportConfigPinpoint

type ExportConfigPinpoint struct {
	CustomerID string
}

type ExportObj

type ExportObj struct {
	Data interface{}
}

type ExportProject

type ExportProject struct {
	ID         string `json:"id"`
	RefID      string `json:"ref_id"`
	ReadableID string `json:"name"`
	Error      string `json:"error"`
}

type ExportResult

type ExportResult struct {
	Projects []ExportProject
}

type GitRepoFetch

type GitRepoFetch struct {
	RepoID            string
	UniqueName        string
	RefType           string
	URL               string
	CommitURLTemplate string
	BranchURLTemplate string
	PRs               []GitRepoFetchPR
}

func (GitRepoFetch) Validate

func (s GitRepoFetch) Validate() error

type GitRepoFetchPR

type GitRepoFetchPR struct {
	ID            string
	RefID         string
	URL           string
	BranchName    string
	LastCommitSHA string
}

func (GitRepoFetchPR) Validate

func (s GitRepoFetchPR) Validate() error

type Integration

type Integration interface {
	// Init provides the connection details for connecting back to agent.
	Init(agent Agent) error
	// Export starts export of all data types for this integration.
	// Config contains typed config common for all integrations and map[string]interface{} for custom fields.
	Export(context.Context, ExportConfig) (ExportResult, error)
	ValidateConfig(context.Context, ExportConfig) (ValidationResult, error)
	// OnboardExport returns the data used in onboard. Kind is one of users, repos, projects.
	OnboardExport(ctx context.Context, objectType OnboardExportType, config ExportConfig) (OnboardExportResult, error)

	// Mutate changes integration data
	Mutate(ctx context.Context, fn string, data string, config ExportConfig) (MutateResult, error)

	// Webhook takes the objects provided by integration webhooks and queries for additional fields if needed
	Webhook(ctx context.Context, headers map[string]string, body string, config ExportConfig) (WebhookResult, error)
}

type IntegrationClient

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

func NewIntegrationClient

func NewIntegrationClient(protoClient proto.IntegrationClient, broker *plugin.GRPCBroker) *IntegrationClient

func (*IntegrationClient) Destroy

func (s *IntegrationClient) Destroy()

func (*IntegrationClient) Export

func (s *IntegrationClient) Export(ctx context.Context, exportConfig ExportConfig) (res ExportResult, _ error)

func (*IntegrationClient) Init

func (s *IntegrationClient) Init(agent Agent) error

func (*IntegrationClient) Mutate

func (s *IntegrationClient) Mutate(ctx context.Context, mutateFn string, mutateData string, exportConfig ExportConfig) (res MutateResult, rerr error)

func (*IntegrationClient) OnboardExport

func (s *IntegrationClient) OnboardExport(ctx context.Context, objectType OnboardExportType, exportConfig ExportConfig) (res OnboardExportResult, _ error)

func (*IntegrationClient) ValidateConfig

func (s *IntegrationClient) ValidateConfig(ctx context.Context, exportConfig ExportConfig) (res ValidationResult, _ error)

func (*IntegrationClient) Webhook

func (s *IntegrationClient) Webhook(ctx context.Context, headers map[string]string, body string, exportConfig ExportConfig) (res WebhookResult, rerr error)

type IntegrationConfig

type IntegrationConfig inconfig.Integration

type IntegrationPlugin

type IntegrationPlugin struct {
	plugin.Plugin
	Impl Integration
}

func (*IntegrationPlugin) GRPCClient

func (s *IntegrationPlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

func (*IntegrationPlugin) GRPCServer

func (s *IntegrationPlugin) GRPCServer(broker *plugin.GRPCBroker, server *grpc.Server) error

type IntegrationServer

type IntegrationServer struct {
	Impl Integration
	// contains filtered or unexported fields
}

func NewIntegrationServer

func NewIntegrationServer(impl Integration, broker *plugin.GRPCBroker) *IntegrationServer

func (*IntegrationServer) Destroy

func (s *IntegrationServer) Destroy() error

func (*IntegrationServer) Export

func (*IntegrationServer) Init

func (*IntegrationServer) Mutate

func (*IntegrationServer) OnboardExport

func (*IntegrationServer) ValidateConfig

func (*IntegrationServer) Webhook

type MutateResult

type MutateResult struct {
	MutatedObjects MutatedObjects
	WebappResponse interface{}
	Error          string
	ErrorCode      string
}

type MutatedObjects

type MutatedObjects map[string][]interface{}

type OnboardExportResult

type OnboardExportResult struct {
	Error error
	Data  interface{}
}

OnboardExportResult is the result of the onboard call. If the particular data type is not supported by integration, return Error will be equal to OnboardExportErrNotSupported.

type OnboardExportType

type OnboardExportType string

type ValidationResult

type ValidationResult struct {
	Errors        []string `json:"errors"`
	RepoURL       string   `json:"repo"`
	ServerVersion string   `json:"server_version"`
}

type WebhookResult

type WebhookResult struct {
	MutatedObjects MutatedObjects
	Error          string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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