Documentation ¶
Overview ¶
Package hashicorpdocs contains helpers for working with HashiCorp's document templates.
Index ¶
- Constants
- Variables
- func IsLocked(fileID string, db *gorm.DB, goog *googleworkspace.Service, log hclog.Logger) (bool, error)
- type BaseDoc
- func (d *BaseDoc) DeleteFileRevision(revisionID string)
- func (d BaseDoc) GetApprovedBy() []string
- func (d BaseDoc) GetApprovers() []string
- func (d BaseDoc) GetChangesRequestedBy() []string
- func (d BaseDoc) GetContributors() []string
- func (d BaseDoc) GetCreatedTime() int64
- func (d BaseDoc) GetDocNumber() string
- func (d BaseDoc) GetDocType() string
- func (d BaseDoc) GetMetaTags() []string
- func (d BaseDoc) GetModifiedTime() int64
- func (d BaseDoc) GetObjectID() string
- func (d BaseDoc) GetOwners() []string
- func (d BaseDoc) GetProduct() string
- func (d BaseDoc) GetStatus() string
- func (d BaseDoc) GetSummary() string
- func (d BaseDoc) GetTitle() string
- func (d *BaseDoc) SetApprovedBy(s []string)
- func (d *BaseDoc) SetChangesRequestedBy(s []string)
- func (d *BaseDoc) SetContent(s string)
- func (d *BaseDoc) SetDocNumber(s string)
- func (d *BaseDoc) SetFileRevision(revisionID, revisionName string)
- func (d *BaseDoc) SetLocked(l bool)
- func (d *BaseDoc) SetModifiedTime(i int64)
- func (d *BaseDoc) SetStatus(s string)
- type CustomDocTypeField
- type Doc
- type FRD
- type MissingFields
- type PRD
- type RFC
Constants ¶
const ( // MaxDocSize is the maximum size of a doc's content in bytes. If the doc is // larger than this, its content will be trimmed to this length. // Algolia has a hard limit of 100000 bytes total per record. MaxDocSize = 85000 )
Variables ¶
var ValidCustomDocTypeFieldTypes = []string{
"PEOPLE",
"STRING",
}
Functions ¶
Types ¶
type BaseDoc ¶
type BaseDoc struct { // ObjectID is the Google Drive file ID for the document. ObjectID string `json:"objectID,omitempty"` // Title is the title of the document. It does not contain the document number // (e.g., "TF-123"). Title string `json:"title,omitempty"` // DocType is the type of document (e.g., "RFC", "PRD"). DocType string `json:"docType,omitempty"` // DocNumber is a unique document identifier containing a product/area // abbreviation and a unique number (e.g., "TF-123"). DocNumber string `json:"docNumber,omitempty"` // AppCreated should be set to true if the document was created through this // application, and false if created directly in Google Docs and indexed // afterwards. AppCreated bool `json:"appCreated,omitempty"` // ApprovedBy is a slice of email address strings for users that have approved // the document. ApprovedBy []string `json:"approvedBy,omitempty"` // Approvers is a slice of email address strings for users whose approvals // are requested for the document. Approvers []string `json:"approvers,omitempty"` // ChangesRequestedBy is a slice of email address strings for users that have // requested changes for the document. ChangesRequestedBy []string `json:"changesRequestedBy,omitempty"` // Contributors is a slice of email address strings for users who have // contributed to the document. Contributors []string `json:"contributors,omitempty"` // Content is the plaintext content of the document. Content string `json:"content,omitempty"` // Created is the UTC time of document creation, in a RFC 3339 string format. Created string `json:"created,omitempty"` // CreatedTime is the time of document creation, in Unix time. CreatedTime int64 `json:"createdTime,omitempty"` // CustomEditableFields are all document-type-specific fields that are // editable. CustomEditableFields map[string]CustomDocTypeField `json:"customEditableFields,omitempty"` // FileRevisions is a map of file revision IDs to custom names. FileRevisions map[string]string `json:"fileRevisions,omitempty"` // TODO: LinkedDocs is not used yet. LinkedDocs []string `json:"linkedDocs,omitempty"` // Locked is true if the document is locked for editing. Locked bool `json:"locked,omitempty"` // MetaTags contains metadata tags that can be used for filtering in Algolia. MetaTags []string `json:"_tags,omitempty"` // Created is the time that the document was last modified, in Unix time. ModifiedTime int64 `json:"modifiedTime,omitempty"` // Owners is a slice of email address strings for document owners. Hermes // generally only uses the first element as the document owner, but this is a // slice for historical reasons as some HashiCorp documents have had multiple // owners in the past. Owners []string `json:"owners,omitempty"` // OwnerPhotos is a slice of URL strings for the profile photos of the // document owners (in the same order as the Owners field). OwnerPhotos []string `json:"ownerPhotos,omitempty"` // Product is the product or area that the document relates to. Product string `json:"product,omitempty"` // Summary is a summary of the document. Summary string `json:"summary,omitempty"` // Status is the status of the document (e.g., "WIP", "In-Review", "Approved", // "Obsolete"). Status string `json:"status,omitempty"` // Tags is a slice of tags to help users discover the document based on their // interests. Tags []string `json:"tags,omitempty"` // ThumbnailLink is a URL string for the document thumbnail image. ThumbnailLink string `json:"thumbnailLink,omitempty"` }
BaseDoc contains common document metadata fields used by Hermes.
func (*BaseDoc) DeleteFileRevision ¶
func (BaseDoc) GetApprovedBy ¶
func (BaseDoc) GetApprovers ¶
func (BaseDoc) GetChangesRequestedBy ¶
func (BaseDoc) GetContributors ¶
func (BaseDoc) GetCreatedTime ¶
func (BaseDoc) GetDocNumber ¶
func (BaseDoc) GetDocType ¶
func (BaseDoc) GetMetaTags ¶
func (BaseDoc) GetModifiedTime ¶
func (BaseDoc) GetObjectID ¶
func (BaseDoc) GetProduct ¶
func (BaseDoc) GetSummary ¶
func (*BaseDoc) SetApprovedBy ¶
func (*BaseDoc) SetChangesRequestedBy ¶
func (*BaseDoc) SetContent ¶
func (*BaseDoc) SetDocNumber ¶
func (*BaseDoc) SetFileRevision ¶
func (*BaseDoc) SetModifiedTime ¶
type CustomDocTypeField ¶
type CustomDocTypeField struct { // DisplayName is the display name of the custom document-type field. DisplayName string `json:"displayName"` // Type is the type of the custom document-type field. It is used by the // frontend to display the proper input component. // Valid values: "PEOPLE", "STRING". Type string `json:"type"` }
type Doc ¶
type Doc interface { DeleteFileRevision(string) // Getters for fields common to all document types. GetApprovedBy() []string GetApprovers() []string GetChangesRequestedBy() []string GetContributors() []string GetCreatedTime() int64 GetDocNumber() string GetDocType() string GetMetaTags() []string GetModifiedTime() int64 GetObjectID() string GetOwners() []string GetProduct() string GetStatus() string GetSummary() string GetTitle() string MissingFields() []string ReplaceHeader(fileID, baseURL string, isDraft bool, s *gw.Service) error // Setters for fields common to all document types. SetApprovedBy([]string) SetChangesRequestedBy([]string) SetContent(s string) SetDocNumber(string) SetFileRevision(string, string) SetLocked(bool) SetModifiedTime(int64) SetStatus(string) GetCustomEditableFields() map[string]CustomDocTypeField SetCustomEditableFields() }
func NewEmptyDoc ¶
NewEmptyDoc returns an empty doc struct for the provided doc type.
type FRD ¶
type FRD struct { BaseDoc `mapstructure:",squash"` // PRD is the associated PRD. PRD string `json:"prd,omitempty"` // PRFAQ is the associated PRFAQ. PRFAQ string `json:"prfaq,omitempty"` }
FRD contains metadata for documents based off of the HashiCorp FRD template.
func NewFRD ¶
NewFRD parses a Google Drive file based on the HashiCorp FRD template and returns the resulting FRD struct.
func (FRD) GetCustomEditableFields ¶
func (d FRD) GetCustomEditableFields() map[string]CustomDocTypeField
func (FRD) MissingFields ¶
MissingFields returns the missing fields of the doc struct.
func (*FRD) ReplaceHeader ¶
func (*FRD) SetCustomEditableFields ¶
func (d *FRD) SetCustomEditableFields()
type MissingFields ¶
type PRD ¶
type PRD struct { BaseDoc `mapstructure:",squash"` // RFC is the associated RFC. RFC string `json:"rfc,omitempty"` // Stakeholders is a slice of email address strings for document stakeholders. Stakeholders []string `json:"stakeholders,omitempty"` }
PRD contains metadata for documents based off of the HashiCorp PRD template.
func NewPRD ¶
NewPRD parses a Google Drive file based on the HashiCorp PRD template and returns the resulting PRD struct.
func (PRD) GetCustomEditableFields ¶
func (d PRD) GetCustomEditableFields() map[string]CustomDocTypeField
func (PRD) MissingFields ¶
MissingFields returns the missing fields of the doc struct.
func (*PRD) ReplaceHeader ¶
func (*PRD) SetCustomEditableFields ¶
func (d *PRD) SetCustomEditableFields()
type RFC ¶
type RFC struct { BaseDoc `mapstructure:",squash"` // CurrentVersion is the current version of the product at the time of // document authoring. CurrentVersion string `json:"currentVersion,omitempty"` // PRD is the associated PRD. PRD string `json:"prd,omitempty"` // Stakeholders is a slice of email address strings for document stakeholders. Stakeholders []string `json:"stakeholders,omitempty"` // TargetVersion is the target version of the product for the changes being // proposed in the document. TargetVersion string `json:"targetVersion,omitempty"` }
RFC contains metadata for documents based off of the HashiCorp RFC template.
func NewRFC ¶
NewRFC parses a Google Drive file based on the HashiCorp RFC template and returns the resulting RFC struct.
func (RFC) GetCustomEditableFields ¶
func (d RFC) GetCustomEditableFields() map[string]CustomDocTypeField
func (RFC) MissingFields ¶
MissingFields returns the missing fields of the doc struct.
func (*RFC) ReplaceHeader ¶
func (*RFC) SetCustomEditableFields ¶
func (d *RFC) SetCustomEditableFields()