Skip to content

Commit

Permalink
Added support for github credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
mcasperson committed Jan 6, 2025
1 parent 812a34d commit cf8b041
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
25 changes: 25 additions & 0 deletions pkg/credentials/github.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package credentials

// GitHub defines a reference GitHub connection.
type GitHub struct {
ID string `json:"Id"`

gitCredential
}

// NewReference creates and initializes a reference Git credential.
func NewGitHub(id string) *Reference {
return &Reference{
ID: id,
gitCredential: gitCredential{
CredentialType: GitCredentialTypeGitHub,
},
}
}

// Type returns the type for this Git credential.
func (u *GitHub) Type() Type {
return u.CredentialType
}

var _ GitCredential = &GitHub{}
1 change: 1 addition & 0 deletions pkg/credentials/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ const (
GitCredentialTypeAnonymous = Type("Anonymous")
GitCredentialTypeReference = Type("Reference")
GitCredentialTypeUsernamePassword = Type("UsernamePassword")
GitCredentialTypeGitHub = Type("GitHub")
)
7 changes: 7 additions & 0 deletions pkg/projects/git_persistence_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ func (p *gitPersistenceSettings) UnmarshalJSON(b []byte) error {
return err
}
p.credential = usernamePasswordGitCredential
case credentials.GitCredentialTypeGitHub:
var githubGitCredential *credentials.GitHub
err := json.Unmarshal(*gitCredentials, &githubGitCredential)
if err != nil {
return err
}
p.credential = githubGitCredential
}

var conversionState *json.RawMessage
Expand Down
1 change: 0 additions & 1 deletion pkg/projects/persistence_settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ type PersistenceSettings interface {
// persistenceSettings represents persistence settings associated with a project.
type persistenceSettings struct {
SettingsType PersistenceSettingsType `json:"Type"`
SettingsId *string `json:"Id"`
}

0 comments on commit cf8b041

Please sign in to comment.