Documentation ¶
Overview ¶
this package contains the different datastructures used to model data setting and getting in the got system. It has structs to model the following: repositories, branches, commits, access to repository
Index ¶
- func UnmarashalKeyAnnouncements(objectString string) (map[string]KeyAnnouncement, error)
- type AccessLog
- type CommitLog
- type KeyAnnouncement
- type PushLog
- type Repo
- func (repo *Repo) AddBranch(branch RepoBranch) (bool, error)
- func (repo *Repo) AddCommitHash(commitLog CommitLog) bool
- func (repo *Repo) AddCommitHashes(commitLogs []CommitLog) bool
- func (repo *Repo) AddCommitLog(commitLog CommitLog, branchName string, passValidation bool) (bool, error)
- func (repo *Repo) AddCommitLogs(commitLogs []CommitLog, branchName string, passValidation bool) (bool, error)
- func (repo *Repo) CanAuthorize(userName string) bool
- func (repo *Repo) CanAuthorizeCollaborator(userName string) bool
- func (repo *Repo) CanEdit(userName string) bool
- func (repo *Repo) GetBranches() []string
- func (repo *Repo) GetUserAccess(userName string) UserAccess
- func (repo *Repo) IsBranch(branchName string) bool
- func (repo *Repo) IsCommitHash(hashName string) bool
- func (repo *Repo) UpdateAccess(authorized string, userAccess UserAccess, authorizer string, ...) bool
- func (repo *Repo) UpdateCommitsForUser(userName string) bool
- func (repo *Repo) ValidBranch(Branch RepoBranch) (bool, error)
- func (repo *Repo) ValidCommitLog(commitLog CommitLog, branchName string) (bool, error)
- func (repo *Repo) ValidCommitLogs(commitLogs []CommitLog, branchName string) (bool, error)
- func (repo *Repo) ValidUpdateAccess(authorized string, userAccess UserAccess, authorizer string) bool
- type RepoBranch
- type UserAccess
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarashalKeyAnnouncements ¶
func UnmarashalKeyAnnouncements(objectString string) (map[string]KeyAnnouncement, error)
This function takes a json string that represents the marshalling of map that has an encryption key's hash as its key and a KeyAnnouncement as its value. It returns this specified map. The returned data is valid and consistent
Types ¶
type AccessLog ¶
type AccessLog struct { Authorizer string `json:"authorizer"` Authorized string `json:"authorized"` UserAccess `json:"userAccess"` }
A struct that contains the required data to keep track about who is responsible of another user's access in the repository.
type CommitLog ¶
type CommitLog struct { Message string `json:"message"` Author string `json:"author"` Committer string `json:"committer"` CommitterTimestamp int `json:"CommitterTimestamp"` Hash string `json:"hash"` Parenthashes []string `json:"parentHashes"` Signature []byte `json:"signature"` EncryptionKey string `json:"encryptionKey"` StorageHashes map[string]string `json:"storageHashes"` }
This structure is modeling the necessary data to be stored for each commit including data nomrally stored through git and data required to get the git objects through the GoT IPFS Cluster. The EncryptionKey stored inside this object represents the hash of the symmetric encryption key used to encrypt the git objects. However, when a query is done in the block chain, this field is filled with the encrypted form of the EncryptionKey instead of its hash.
func CreateNewCommitLog ¶
func CreateNewCommitLog(message string, author string, commiter string, timestamp int, hash string, parenthashes []string, signature []byte, encryptionKey string, storageHashes map[string]string) (CommitLog, error)
this is a helper function to initialize a new CommitLog object instance
type KeyAnnouncement ¶
type KeyAnnouncement struct { KeyHash string `json:"keyHash"` EncryptedKeys map[string]string `json:"encryptedKeys"` }
KeyAnnouncement is struct that is used to keep information about the avaiable symmetric encryption keys. it maps the has of the symmetric encryption key to the encrypted version of the key that a user can then decrypt using their private key.
func UnmarashalKeyAnnouncement ¶
func UnmarashalKeyAnnouncement(objectString string) (KeyAnnouncement, error)
This function takes a json string that represents the marshalling of KeyAnnouncement and returns a KeyAnnouncement. The returned data is valid and consistent
type PushLog ¶
type PushLog struct { BranchName string `json:"branchName"` DirectoryCID string `json:"directoryCID"` Logs []CommitLog `json:"logs"` }
This struct is used to model the required data to add a push to a got project
func CreateNewPushLog ¶
Helper function that creates a new object instance of a PushLog
func UnmarashalPushLog ¶
This function takes a json string that represents the marshalling of PushLog and returns a PushLog. The returned data is valid and consistent
type Repo ¶
type Repo struct { Name string `json:"repoName"` Author string `json:"author"` DirectoryCID string `json:"directoryCID"` Timestamp int `json:"timeStamp"` CommitHashes map[string]struct{} `json:"hashes"` Branches map[string]RepoBranch `json:"branches"` EncryptionKey KeyAnnouncement `json:"encryptionKey"` Users map[string]UserAccess `json:"users"` AccessLogs []AccessLog `json:"accessLogs"` KeyAnnouncements map[string]KeyAnnouncement `json:"keyAnnouncements"` }
This structis the entry point to store all the needed data for repo to ensure that it's working smoothly whether it's metadata or data required for access control or storage access.
func CreateNewRepo ¶
func CreateNewRepo(name string, author string, directoryCID string, timestamp int, branches map[string]RepoBranch, encryptionKey KeyAnnouncement, users map[string]UserAccess) (Repo, error)
helper function that is needed to create a new Repo instance
func UnmarashalRepo ¶
This function takes a json string that represents the marshalling of Repo and returns a Repo. The returned data is valid and consistent
func (*Repo) AddBranch ¶
func (repo *Repo) AddBranch(branch RepoBranch) (bool, error)
Adds a new beanch to the repo if it creates a new valid state a new branch must have a new unique name and it must be consistent and builds on the current repo state
func (*Repo) AddCommitHash ¶
func (*Repo) AddCommitHashes ¶
func (*Repo) AddCommitLog ¶
func (repo *Repo) AddCommitLog(commitLog CommitLog, branchName string, passValidation bool) (bool, error)
Adds a commitLog to a branch if it creates a new valid state
func (*Repo) AddCommitLogs ¶
func (repo *Repo) AddCommitLogs(commitLogs []CommitLog, branchName string, passValidation bool) (bool, error)
Adds a list of commitLogs to a branch if it creates a new valid state
func (*Repo) CanAuthorize ¶
checks if the mentioned userName belongs to user that is authorized to authorize or revoke ReadWriteAccess for the repository. Only collaborators and owners CanAuthorize
func (*Repo) CanAuthorizeCollaborator ¶
checks if the mentioned userName belongs to user that is authorized to authorize or revoke CollaboratorAccess for the repository. Only owners CanAuthorizeCollaborator
func (*Repo) CanEdit ¶
checks if the mentioned userName belongs to user that is authorized to do read/write for the repository. anyone included in the repo can read / write
func (*Repo) GetBranches ¶
returns a list that contains the names of branches in a project
func (*Repo) GetUserAccess ¶
func (repo *Repo) GetUserAccess(userName string) UserAccess
returns the current access type of the specified user's userName
func (*Repo) IsCommitHash ¶
checks if the provided hash has belonged to one of the repo's branches
func (*Repo) UpdateAccess ¶
func (repo *Repo) UpdateAccess(authorized string, userAccess UserAccess, authorizer string, keyAnnouncement KeyAnnouncement) bool
It does the required data writing work to update a user's access type in case, the user access update is valid.
func (*Repo) UpdateCommitsForUser ¶
Originally the encryptedKey inside each CommitLog contains the hash of the encrytion key this functions replaces each hash with a user's encryted version of the key.
func (*Repo) ValidBranch ¶
func (repo *Repo) ValidBranch(Branch RepoBranch) (bool, error)
need to check commits in the branch
func (*Repo) ValidCommitLog ¶
checks that all hash parents are hashes in the repository
func (*Repo) ValidCommitLogs ¶
Check that all parents hashes are current hashes or previous ones in the new hashes list
func (*Repo) ValidUpdateAccess ¶
func (repo *Repo) ValidUpdateAccess(authorized string, userAccess UserAccess, authorizer string) bool
check if the authorized has enough permissions to update the authorized's current access type to the mentioned value.
type RepoBranch ¶
type RepoBranch struct { Name string `json:"branchName"` Author string `json:"author"` Timestamp int `json:"timeStamp"` Logs map[string]CommitLog `json:"logs"` }
func CreateNewRepoBranch ¶
func UnmarashalRepoBranch ¶
func UnmarashalRepoBranch(objectString string) (RepoBranch, error)
This function takes a json string that represents the marshalling of RepoBranch and returns a RepoBranch. The returned data is valid and consistent
func (*RepoBranch) AddCommitLog ¶
func (branch *RepoBranch) AddCommitLog(commitLog CommitLog, passValidation bool) (bool, error)
Adds a CommitLog to the branch if it can be added according to the info avaiable to the branch.
func (*RepoBranch) IsCommitHash ¶
func (branch *RepoBranch) IsCommitHash(hashName string) bool
Check if the hash has been added to the branch before.
type UserAccess ¶
type UserAccess int
This enum represents the type of access a user has for a repo
const ( ReadWriteAccess UserAccess = 1 CollaboratorAccess UserAccess = 2 OwnerAccess UserAccess = 3 ReovkedAccess UserAccess = 4 NeverSetAccess UserAccess = 5 )