Documentation
¶
Overview ¶
Package codegurureviewer emulates Amazon CodeGuru Reviewer: repository associations, code reviews that run a deterministic static rule set over the repository's real source, recommendations and feedback.
Index ¶
- Variables
- type AssociateRepositoryInput
- type AssociationOutput
- type CodeArtifacts
- type CodeCommitRepository
- type CodeReview
- type CodeReviewOutput
- type CodeReviewSummary
- type CodeReviewType
- type CreateCodeReviewInput
- type DescribeFeedbackInput
- type DescribeFeedbackOutput
- type Handler
- func (h *Handler) ChaosOperations() []string
- func (h *Handler) ChaosRegions() []string
- func (h *Handler) ChaosServiceName() string
- func (h *Handler) ExtractOperation(c *echo.Context) string
- func (h *Handler) ExtractResource(c *echo.Context) string
- func (h *Handler) GetSupportedOperations() []string
- func (h *Handler) Handler() echo.HandlerFunc
- func (h *Handler) MatchPriority() int
- func (h *Handler) Name() string
- func (h *Handler) Reset()
- func (h *Handler) Restore(ctx context.Context, data []byte) error
- func (h *Handler) RouteMatcher() service.Matcher
- func (h *Handler) Snapshot(ctx context.Context) []byte
- type InMemoryBackend
- func (b *InMemoryBackend) AssociateRepository(ctx context.Context, in *AssociateRepositoryInput) (*associationRecord, error)
- func (b *InMemoryBackend) CreateCodeReview(ctx context.Context, in *CreateCodeReviewInput) (*reviewRecord, error)
- func (b *InMemoryBackend) DescribeRecommendationFeedback(ctx context.Context, in *DescribeFeedbackInput) (*RecommendationFeedback, error)
- func (b *InMemoryBackend) DescribeRepositoryAssociation(arn string) (*associationRecord, error)
- func (b *InMemoryBackend) DisassociateRepository(arn string) (*associationRecord, error)
- func (b *InMemoryBackend) GetCodeReview(arn string) (*reviewRecord, error)
- func (b *InMemoryBackend) ListCodeReviews(in *ListCodeReviewsInput) ([]CodeReviewSummary, string, error)
- func (b *InMemoryBackend) ListRecommendationFeedback(in *ListFeedbackInput) ([]RecommendationFeedbackSummary, string, error)
- func (b *InMemoryBackend) ListRecommendations(arn, token string, maxResults int32) ([]Recommendation, string, error)
- func (b *InMemoryBackend) ListRepositoryAssociations(in *ListAssociationsInput) ([]RepositoryAssociationSummary, string, error)
- func (b *InMemoryBackend) ListTagsForResource(arn string) (map[string]string, error)
- func (b *InMemoryBackend) PutRecommendationFeedback(ctx context.Context, in *PutFeedbackInput) error
- func (b *InMemoryBackend) Reset()
- func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
- func (b *InMemoryBackend) SetAppConfig(cfg any)
- func (b *InMemoryBackend) SetClock(now func() time.Time)
- func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
- func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
- func (b *InMemoryBackend) TagResource(arn string, add map[string]string) error
- func (b *InMemoryBackend) UntagResource(arn string, keys []string) error
- type KMSKeyDetails
- type ListAssociationsInput
- type ListAssociationsOutput
- type ListCodeReviewsInput
- type ListCodeReviewsOutput
- type ListFeedbackInput
- type ListFeedbackOutput
- type Metrics
- type MetricsSummary
- type Provider
- type PutFeedbackInput
- type Recommendation
- type RecommendationFeedback
- type RecommendationFeedbackSummary
- type Repository
- type RepositoryAnalysis
- type RepositoryAssociation
- type RepositoryAssociationSummary
- type RepositoryHead
- type RuleMetadata
- type S3BucketRepository
- type S3Repository
- type S3RepositoryDetails
- type SourceCodeType
- type ThirdPartySourceRepository
Constants ¶
This section is empty.
Variables ¶
var ErrNilAppContext = errors.New("codegurureviewer: AppContext must not be nil")
ErrNilAppContext is returned by Init when no AppContext is supplied.
Functions ¶
This section is empty.
Types ¶
type AssociateRepositoryInput ¶
type AssociateRepositoryInput struct {
Repository *Repository `json:"Repository"`
KMSKeyDetails *KMSKeyDetails `json:"KMSKeyDetails,omitempty"`
Tags map[string]string `json:"Tags,omitempty"`
ClientRequestToken string `json:"ClientRequestToken,omitempty"`
}
AssociateRepositoryInput is the AssociateRepository request.
type AssociationOutput ¶
type AssociationOutput struct {
RepositoryAssociation *RepositoryAssociation `json:"RepositoryAssociation"`
Tags map[string]string `json:"Tags,omitempty"`
}
AssociationOutput is the Associate/Describe/DisassociateRepository response.
type CodeArtifacts ¶
type CodeArtifacts struct {
BuildArtifactsObjectKey string `json:"BuildArtifactsObjectKey,omitempty"`
SourceCodeArtifactsObjectKey string `json:"SourceCodeArtifactsObjectKey,omitempty"`
}
CodeArtifacts holds the S3 keys of the source and build archives.
type CodeCommitRepository ¶
type CodeCommitRepository struct {
Name string `json:"Name"`
}
CodeCommitRepository names a CodeCommit repository.
type CodeReview ¶
type CodeReview struct {
CreatedTimeStamp awstime.EpochTime `json:"CreatedTimeStamp"`
LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
Metrics *Metrics `json:"Metrics,omitempty"`
SourceCodeType *SourceCodeType `json:"SourceCodeType,omitempty"`
RepositoryName string `json:"RepositoryName"`
AssociationArn string `json:"AssociationArn"`
CodeReviewArn string `json:"CodeReviewArn"`
ConfigFileState string `json:"ConfigFileState,omitempty"`
Name string `json:"Name"`
Owner string `json:"Owner"`
ProviderType string `json:"ProviderType"`
PullRequestID string `json:"PullRequestId,omitempty"`
State string `json:"State"`
StateReason string `json:"StateReason,omitempty"`
Type string `json:"Type"`
AnalysisTypes []string `json:"AnalysisTypes,omitempty"`
}
CodeReview is the wire shape of a review.
type CodeReviewOutput ¶
type CodeReviewOutput struct {
CodeReview *CodeReview `json:"CodeReview"`
}
CodeReviewOutput is the Create/DescribeCodeReview response.
type CodeReviewSummary ¶
type CodeReviewSummary struct {
CreatedTimeStamp awstime.EpochTime `json:"CreatedTimeStamp"`
LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
MetricsSummary *MetricsSummary `json:"MetricsSummary,omitempty"`
SourceCodeType *SourceCodeType `json:"SourceCodeType,omitempty"`
CodeReviewArn string `json:"CodeReviewArn"`
Name string `json:"Name"`
Owner string `json:"Owner"`
ProviderType string `json:"ProviderType"`
PullRequestID string `json:"PullRequestId,omitempty"`
RepositoryName string `json:"RepositoryName"`
State string `json:"State"`
Type string `json:"Type"`
}
CodeReviewSummary is the list shape of a review.
type CodeReviewType ¶
type CodeReviewType struct {
RepositoryAnalysis *RepositoryAnalysis `json:"RepositoryAnalysis,omitempty"`
AnalysisTypes []string `json:"AnalysisTypes,omitempty"`
}
CodeReviewType is the CreateCodeReview type; only RepositoryAnalysis can be created.
type CreateCodeReviewInput ¶
type CreateCodeReviewInput struct {
Type *CodeReviewType `json:"Type"`
Name string `json:"Name"`
RepositoryAssociationArn string `json:"RepositoryAssociationArn"`
ClientRequestToken string `json:"ClientRequestToken,omitempty"`
}
CreateCodeReviewInput is the CreateCodeReview request.
type DescribeFeedbackInput ¶
type DescribeFeedbackInput struct {
CodeReviewArn string `json:"-" path:"CodeReviewArn"`
RecommendationID string `json:"-" query:"RecommendationId"`
UserID string `json:"-" query:"UserId"`
}
DescribeFeedbackInput is the DescribeRecommendationFeedback request.
type DescribeFeedbackOutput ¶
type DescribeFeedbackOutput struct {
RecommendationFeedback *RecommendationFeedback `json:"RecommendationFeedback"`
}
DescribeFeedbackOutput is the DescribeRecommendationFeedback response.
type Handler ¶
type Handler struct {
Backend *InMemoryBackend
DefaultRegion string
// contains filtered or unexported fields
}
Handler serves the CodeGuru Reviewer REST-JSON API.
func (*Handler) ChaosOperations ¶
ChaosOperations lists the fault-injectable operations.
func (*Handler) ChaosRegions ¶
ChaosRegions lists the regions served.
func (*Handler) ChaosServiceName ¶
ChaosServiceName returns the lowercase service name for fault rules.
func (*Handler) ExtractOperation ¶
ExtractOperation returns the operation name for metrics.
func (*Handler) ExtractResource ¶
ExtractResource returns the first path label for metrics.
func (*Handler) GetSupportedOperations ¶
GetSupportedOperations lists every routed operation.
func (*Handler) Handler ¶
func (h *Handler) Handler() echo.HandlerFunc
Handler returns the Echo handler.
func (*Handler) MatchPriority ¶
MatchPriority returns the routing priority.
func (*Handler) RouteMatcher ¶
RouteMatcher matches by SigV4 signing name (or SDK user agent) plus a known path shape.
type InMemoryBackend ¶
type InMemoryBackend struct {
// contains filtered or unexported fields
}
InMemoryBackend holds associations, reviews and feedback behind one coarse lock.
func NewInMemoryBackend ¶
func NewInMemoryBackend(accountID, region string) *InMemoryBackend
NewInMemoryBackend creates an empty backend.
func (*InMemoryBackend) AssociateRepository ¶
func (b *InMemoryBackend) AssociateRepository( ctx context.Context, in *AssociateRepositoryInput, ) (*associationRecord, error)
AssociateRepository starts associating a repository; it reads Associated once the lifecycle window passes.
func (*InMemoryBackend) CreateCodeReview ¶
func (b *InMemoryBackend) CreateCodeReview(ctx context.Context, in *CreateCodeReviewInput) (*reviewRecord, error)
CreateCodeReview analyzes the associated repository's source with the static rule set and records the findings. The review reads Pending until the lifecycle window passes, then Completed (or Failed when the source is unreadable).
func (*InMemoryBackend) DescribeRecommendationFeedback ¶
func (b *InMemoryBackend) DescribeRecommendationFeedback( ctx context.Context, in *DescribeFeedbackInput, ) (*RecommendationFeedback, error)
DescribeRecommendationFeedback returns one user's feedback; the caller's when UserId is omitted.
func (*InMemoryBackend) DescribeRepositoryAssociation ¶
func (b *InMemoryBackend) DescribeRepositoryAssociation(arn string) (*associationRecord, error)
DescribeRepositoryAssociation returns an association with its current state.
func (*InMemoryBackend) DisassociateRepository ¶
func (b *InMemoryBackend) DisassociateRepository(arn string) (*associationRecord, error)
DisassociateRepository starts disassociating; it reads Disassociated once the lifecycle window passes.
func (*InMemoryBackend) GetCodeReview ¶
func (b *InMemoryBackend) GetCodeReview(arn string) (*reviewRecord, error)
GetCodeReview returns a review by ARN.
func (*InMemoryBackend) ListCodeReviews ¶
func (b *InMemoryBackend) ListCodeReviews(in *ListCodeReviewsInput) ([]CodeReviewSummary, string, error)
ListCodeReviews lists reviews of one type, newest first.
func (*InMemoryBackend) ListRecommendationFeedback ¶
func (b *InMemoryBackend) ListRecommendationFeedback( in *ListFeedbackInput, ) ([]RecommendationFeedbackSummary, string, error)
ListRecommendationFeedback lists the feedback given on a review, filtered by user and recommendation.
func (*InMemoryBackend) ListRecommendations ¶
func (b *InMemoryBackend) ListRecommendations(arn, token string, maxResults int32) ([]Recommendation, string, error)
ListRecommendations pages through a completed review's findings; a review still running has none yet.
func (*InMemoryBackend) ListRepositoryAssociations ¶
func (b *InMemoryBackend) ListRepositoryAssociations( in *ListAssociationsInput, ) ([]RepositoryAssociationSummary, string, error)
ListRepositoryAssociations lists associations, filtered by provider, state, name and owner.
func (*InMemoryBackend) ListTagsForResource ¶
func (b *InMemoryBackend) ListTagsForResource(arn string) (map[string]string, error)
ListTagsForResource returns a copy of the association's tags.
func (*InMemoryBackend) PutRecommendationFeedback ¶
func (b *InMemoryBackend) PutRecommendationFeedback(ctx context.Context, in *PutFeedbackInput) error
PutRecommendationFeedback records the caller's reactions to a recommendation; an empty list clears them.
func (*InMemoryBackend) Restore ¶
func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error
Restore loads a snapshot; an incompatible version is discarded.
func (*InMemoryBackend) SetAppConfig ¶
func (b *InMemoryBackend) SetAppConfig(cfg any)
SetAppConfig records the service.AppContext.Config for lazy CodeCommit and S3 lookups.
func (*InMemoryBackend) SetClock ¶
func (b *InMemoryBackend) SetClock(now func() time.Time)
SetClock replaces the time source.
func (*InMemoryBackend) SetLifecycleDelay ¶
func (b *InMemoryBackend) SetLifecycleDelay(d time.Duration)
SetLifecycleDelay overrides how long associations and reviews stay in a transitional state.
func (*InMemoryBackend) Snapshot ¶
func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte
Snapshot serialises the backend state.
func (*InMemoryBackend) TagResource ¶
func (b *InMemoryBackend) TagResource(arn string, add map[string]string) error
TagResource adds or replaces tags on a repository association.
func (*InMemoryBackend) UntagResource ¶
func (b *InMemoryBackend) UntagResource(arn string, keys []string) error
UntagResource removes tags by key.
type KMSKeyDetails ¶
type KMSKeyDetails struct {
EncryptionOption string `json:"EncryptionOption,omitempty"`
KMSKeyID string `json:"KMSKeyId,omitempty"`
}
KMSKeyDetails is the repository encryption setting.
type ListAssociationsInput ¶
type ListAssociationsInput struct {
NextToken string `json:"-" query:"NextToken"`
ProviderTypes []string `json:"-" query:"ProviderType"`
States []string `json:"-" query:"State"`
Names []string `json:"-" query:"Name"`
Owners []string `json:"-" query:"Owner"`
MaxResults int32 `json:"-" query:"MaxResults"`
}
ListAssociationsInput is the ListRepositoryAssociations request.
type ListAssociationsOutput ¶
type ListAssociationsOutput struct {
NextToken string `json:",omitempty"`
RepositoryAssociationSummaries []RepositoryAssociationSummary
}
ListAssociationsOutput is the ListRepositoryAssociations response.
type ListCodeReviewsInput ¶
type ListCodeReviewsInput struct {
Type string `json:"-" query:"Type"`
NextToken string `json:"-" query:"NextToken"`
ProviderTypes []string `json:"-" query:"ProviderTypes"`
States []string `json:"-" query:"States"`
RepositoryNames []string `json:"-" query:"RepositoryNames"`
MaxResults int32 `json:"-" query:"MaxResults"`
}
ListCodeReviewsInput is the ListCodeReviews request.
type ListCodeReviewsOutput ¶
type ListCodeReviewsOutput struct {
NextToken string `json:",omitempty"`
CodeReviewSummaries []CodeReviewSummary
}
ListCodeReviewsOutput is the ListCodeReviews response.
type ListFeedbackInput ¶
type ListFeedbackInput struct {
CodeReviewArn string `json:"-" path:"CodeReviewArn"`
NextToken string `json:"-" query:"NextToken"`
UserIDs []string `json:"-" query:"UserIds"`
RecommendationIDs []string `json:"-" query:"RecommendationIds"`
MaxResults int32 `json:"-" query:"MaxResults"`
}
ListFeedbackInput is the ListRecommendationFeedback request.
type ListFeedbackOutput ¶
type ListFeedbackOutput struct {
NextToken string `json:",omitempty"`
RecommendationFeedbackSummaries []RecommendationFeedbackSummary
}
ListFeedbackOutput is the ListRecommendationFeedback response.
type Metrics ¶
type Metrics struct {
FindingsCount int64 `json:"FindingsCount"`
MeteredLinesOfCodeCount int64 `json:"MeteredLinesOfCodeCount"`
SuppressedLinesOfCodeCount int64 `json:"SuppressedLinesOfCodeCount"`
}
Metrics are the totals of a completed review.
type Provider ¶
type Provider struct{}
Provider implements service.Provider.
func (*Provider) Init ¶
func (p *Provider) Init(ctx *service.AppContext) (service.Registerable, error)
Init builds the backend and handler.
type PutFeedbackInput ¶
type PutFeedbackInput struct {
CodeReviewArn string `json:"CodeReviewArn"`
RecommendationID string `json:"RecommendationId"`
Reactions []string `json:"Reactions"`
}
PutFeedbackInput is the PutRecommendationFeedback request.
type Recommendation ¶
type Recommendation struct {
RuleMetadata *RuleMetadata `json:"RuleMetadata,omitempty"`
Description string `json:"Description"`
FilePath string `json:"FilePath"`
RecommendationCategory string `json:"RecommendationCategory"`
RecommendationID string `json:"RecommendationId"`
Severity string `json:"Severity"`
StartLine int32 `json:"StartLine"`
EndLine int32 `json:"EndLine"`
}
Recommendation is one finding of a review (wire RecommendationSummary).
type RecommendationFeedback ¶
type RecommendationFeedback struct {
CreatedTimeStamp awstime.EpochTime `json:"CreatedTimeStamp"`
LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
CodeReviewArn string `json:"CodeReviewArn"`
RecommendationID string `json:"RecommendationId"`
UserID string `json:"UserId"`
Reactions []string `json:"Reactions"`
}
RecommendationFeedback is one user's reactions to one recommendation.
type RecommendationFeedbackSummary ¶
type RecommendationFeedbackSummary struct {
RecommendationID string `json:"RecommendationId"`
UserID string `json:"UserId"`
Reactions []string `json:"Reactions"`
}
RecommendationFeedbackSummary is the list shape of feedback.
type Repository ¶
type Repository struct {
Bitbucket *ThirdPartySourceRepository `json:"Bitbucket,omitempty"`
CodeCommit *CodeCommitRepository `json:"CodeCommit,omitempty"`
GitHubEnterpriseServer *ThirdPartySourceRepository `json:"GitHubEnterpriseServer,omitempty"`
S3Bucket *S3Repository `json:"S3Bucket,omitempty"`
}
Repository is the AssociateRepository union.
type RepositoryAnalysis ¶
type RepositoryAnalysis struct {
RepositoryHead *RepositoryHead `json:"RepositoryHead,omitempty"`
SourceCodeType *SourceCodeType `json:"SourceCodeType,omitempty"`
}
RepositoryAnalysis is the CreateCodeReview repository-analysis request.
type RepositoryAssociation ¶
type RepositoryAssociation struct {
CreatedTimeStamp awstime.EpochTime `json:"CreatedTimeStamp"`
LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
KMSKeyDetails *KMSKeyDetails `json:"KMSKeyDetails,omitempty"`
S3RepositoryDetails *S3RepositoryDetails `json:"S3RepositoryDetails,omitempty"`
AssociationArn string `json:"AssociationArn"`
AssociationID string `json:"AssociationId"`
ConnectionArn string `json:"ConnectionArn,omitempty"`
Name string `json:"Name"`
Owner string `json:"Owner"`
ProviderType string `json:"ProviderType"`
State string `json:"State"`
StateReason string `json:"StateReason,omitempty"`
}
RepositoryAssociation is the wire shape of an association.
type RepositoryAssociationSummary ¶
type RepositoryAssociationSummary struct {
LastUpdatedTimeStamp awstime.EpochTime `json:"LastUpdatedTimeStamp"`
AssociationArn string `json:"AssociationArn"`
AssociationID string `json:"AssociationId"`
ConnectionArn string `json:"ConnectionArn,omitempty"`
Name string `json:"Name"`
Owner string `json:"Owner"`
ProviderType string `json:"ProviderType"`
State string `json:"State"`
}
RepositoryAssociationSummary is the list shape of an association.
type RepositoryHead ¶
type RepositoryHead struct {
BranchName string `json:"BranchName"`
}
RepositoryHead selects a branch.
type RuleMetadata ¶
type RuleMetadata struct {
LongDescription string `json:"LongDescription,omitempty"`
RuleID string `json:"RuleId,omitempty"`
RuleName string `json:"RuleName,omitempty"`
ShortDescription string `json:"ShortDescription,omitempty"`
RuleTags []string `json:"RuleTags,omitempty"`
}
RuleMetadata describes the rule behind a recommendation.
type S3BucketRepository ¶
type S3BucketRepository struct {
Details *S3RepositoryDetails `json:"Details,omitempty"`
Name string `json:"Name"`
}
S3BucketRepository is the S3 member of SourceCodeType.
type S3Repository ¶
S3Repository names an S3 repository to associate.
type S3RepositoryDetails ¶
type S3RepositoryDetails struct {
CodeArtifacts *CodeArtifacts `json:"CodeArtifacts,omitempty"`
BucketName string `json:"BucketName,omitempty"`
}
S3RepositoryDetails locates an S3 repository's archives.
type SourceCodeType ¶
type SourceCodeType struct {
RepositoryHead *RepositoryHead `json:"RepositoryHead,omitempty"`
S3BucketRepository *S3BucketRepository `json:"S3BucketRepository,omitempty"`
}
SourceCodeType says which code a review analyzes.
type ThirdPartySourceRepository ¶
type ThirdPartySourceRepository struct {
ConnectionArn string `json:"ConnectionArn"`
Name string `json:"Name"`
Owner string `json:"Owner"`
}
ThirdPartySourceRepository names a Bitbucket or GitHub Enterprise Server repository.