diff --git a/pkg/api/models/create_project.go b/pkg/api/models/create_project.go index 522ddbea..593f6686 100644 --- a/pkg/api/models/create_project.go +++ b/pkg/api/models/create_project.go @@ -4,40 +4,6 @@ import "encoding/json" // CreateProject create project type CreateProject struct { - - // git remote URL - GitRemoteURL string `json:"gitRemoteURL,omitempty"` - - // git token - GitToken string `json:"gitToken,omitempty"` - - // git private key - GitPrivateKey string `json:"gitPrivateKey,omitempty"` - - // git private key passphrase - GitPrivateKeyPass string `json:"gitPrivateKeyPass,omitempty"` - - // git proxy URL - GitProxyURL string `json:"gitProxyUrl,omitempty"` - - // git proxy scheme - GitProxyScheme string `json:"gitProxyScheme,omitempty"` - - // git proxy user - GitProxyUser string `json:"gitProxyUser,omitempty"` - - // insecure skip tls - InsecureSkipTLS bool `json:"insecureSkipTLS"` - - // git proxy password - GitProxyPassword string `json:"gitProxyPassword,omitempty"` - - //git PEM Certificate - GitPemCertificate string `json:"gitPemCertificate,omitempty"` - - // git user - GitUser string `json:"gitUser,omitempty"` - // name // Required: true Name *string `json:"name"` @@ -45,6 +11,9 @@ type CreateProject struct { // shipyard // Required: true Shipyard *string `json:"shipyard"` + + // git auth credentials + GitCredentials *GitAuthCredentials `json:"gitCredentials,omitempty"` } // ToJSON converts object to JSON string diff --git a/pkg/api/models/expanded_project.go b/pkg/api/models/expanded_project.go index 2a43c3ac..56caf2b1 100644 --- a/pkg/api/models/expanded_project.go +++ b/pkg/api/models/expanded_project.go @@ -1,5 +1,7 @@ package models +import "encoding/json" + // ExpandedProject expanded project // // swagger:model ExpandedProject @@ -8,12 +10,6 @@ type ExpandedProject struct { // Creation date of the project CreationDate string `json:"creationDate,omitempty"` - // Git remote URI - GitRemoteURI string `json:"gitRemoteURI,omitempty"` - - // Git User - GitUser string `json:"gitUser,omitempty"` - // last event context LastEventContext *EventContextInfo `json:"lastEventContext,omitempty"` @@ -26,18 +22,24 @@ type ExpandedProject struct { // Version of the shipyard file ShipyardVersion string `json:"shipyardVersion,omitempty"` - // git proxy URL - GitProxyURL string `json:"gitProxyUrl,omitempty"` - - // git proxy scheme - GitProxyScheme string `json:"gitProxyScheme,omitempty"` + // stages + Stages []*ExpandedStage `json:"stages"` - // git proxy user - GitProxyUser string `json:"gitProxyUser,omitempty"` + // git auth credentials + GitCredentials *GitAuthCredentialsSecure `json:"gitCredentials,omitempty"` +} - // insecure skip tls - InsecureSkipTLS bool `json:"insecureSkipTLS"` +// ToJSON converts object to JSON string +func (a *ExpandedProject) ToJSON() ([]byte, error) { + return json.Marshal(a) +} - // stages - Stages []*ExpandedStage `json:"stages"` +// FromJSON converts JSON string to object +func (a *ExpandedProject) FromJSON(b []byte) error { + var res ExpandedProject + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *a = res + return nil } diff --git a/pkg/api/models/git_credentials.go b/pkg/api/models/git_credentials.go new file mode 100644 index 00000000..a8ce1809 --- /dev/null +++ b/pkg/api/models/git_credentials.go @@ -0,0 +1,199 @@ +package models + +import "encoding/json" + +// GitAuthCredentials stores git credentials +type GitAuthCredentials struct { + + // git remote URL + RemoteURL string `json:"remoteURL" bson:"remoteURL"` + + // git user + User string `json:"user,omitempty" bson:"user"` + + // https git credentials + HttpsAuth *HttpsGitAuth `json:"https,omitempty" bson:"https"` + + //ssh git credentials + SshAuth *SshGitAuth `json:"ssh,omitempty" bson:"ssh"` +} + +// ToJSON converts object to JSON string +func (p *GitAuthCredentials) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *GitAuthCredentials) FromJSON(b []byte) error { + var res GitAuthCredentials + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} + +// HttpsGitAuth stores HTTPS git credentials +type HttpsGitAuth struct { + // Git token + Token string `json:"token" bson:"token"` + + //git PEM Certificate + Certificate string `json:"certificate,omitempty" bson:"certificate"` + + // insecure skip tls + InsecureSkipTLS bool `json:"insecureSkipTLS" bson:"insecureSkipTLS"` + + // git proxy credentials + Proxy *ProxyGitAuth `json:"proxy,omitempty" bson:"proxy"` +} + +// ToJSON converts object to JSON string +func (p *HttpsGitAuth) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *HttpsGitAuth) FromJSON(b []byte) error { + var res HttpsGitAuth + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} + +// SshGitAuth stores SSH git credentials +type SshGitAuth struct { + // git private key + PrivateKey string `json:"privateKey" bson:"privateKey"` + + // git private key passphrase + PrivateKeyPass string `json:"privateKeyPass,omitempty" bson:"privateKeyPass"` +} + +// ToJSON converts object to JSON string +func (p *SshGitAuth) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *SshGitAuth) FromJSON(b []byte) error { + var res SshGitAuth + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} + +// ProxyGitAuth stores proxy git credentials +type ProxyGitAuth struct { + // git proxy URL + URL string `json:"url" bson:"url"` + + // git proxy scheme + Scheme string `json:"scheme" bson:"scheme"` + + // git proxy user + User string `json:"user,omitempty" bson:"user"` + + // git proxy password + Password string `json:"password,omitempty" bson:"password"` +} + +// ToJSON converts object to JSON string +func (p *ProxyGitAuth) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *ProxyGitAuth) FromJSON(b []byte) error { + var res ProxyGitAuth + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} + +// GitAuthCredentialsSecure stores git credentials without secure information +// model for retrieving credentials data with GET request +type GitAuthCredentialsSecure struct { + // git remote URL + RemoteURL string `json:"remoteURL" bson:"remoteURL"` + + // git user + User string `json:"user,omitempty" bson:"user"` + + // https git credentials + HttpsAuth *HttpsGitAuthSecure `json:"https,omitempty" bson:"https"` +} + +// ToJSON converts object to JSON string +func (p *GitAuthCredentialsSecure) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *GitAuthCredentialsSecure) FromJSON(b []byte) error { + var res GitAuthCredentialsSecure + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} + +// HttpsGitAuthSecure stores HTTPS git credentials without secure information +// model for retrieving credentials data with GET request +type HttpsGitAuthSecure struct { + // insecure skip tls + InsecureSkipTLS bool `json:"insecureSkipTLS" bson:"insecureSkipTLS"` + + // git proxy credentials + Proxy *ProxyGitAuthSecure `json:"proxy,omitempty" bson:"proxy"` +} + +// ToJSON converts object to JSON string +func (p *HttpsGitAuthSecure) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *HttpsGitAuthSecure) FromJSON(b []byte) error { + var res HttpsGitAuthSecure + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} + +// ProxyGitAuthSecure stores proxy git credentials without secure information +// model for retrieving credentials data with GET request +type ProxyGitAuthSecure struct { + // git proxy URL + URL string `json:"url" bson:"url"` + + // git proxy scheme + Scheme string `json:"scheme" bson:"scheme"` + + // git proxy user + User string `json:"user,omitempty" bson:"user"` +} + +// ToJSON converts object to JSON string +func (p *ProxyGitAuthSecure) ToJSON() ([]byte, error) { + return json.Marshal(p) +} + +// FromJSON converts JSON string to object +func (p *ProxyGitAuthSecure) FromJSON(b []byte) error { + var res ProxyGitAuthSecure + if err := json.Unmarshal(b, &res); err != nil { + return err + } + *p = res + return nil +} diff --git a/pkg/api/models/project.go b/pkg/api/models/project.go index 454c4b5d..006b6d7a 100644 --- a/pkg/api/models/project.go +++ b/pkg/api/models/project.go @@ -8,39 +8,6 @@ type Project struct { // Creation date of the service CreationDate string `json:"creationDate,omitempty"` - // Git remote URI - GitRemoteURI string `json:"gitRemoteURI,omitempty"` - - // Git token - GitToken string `json:"gitToken,omitempty"` - - // git private key - GitPrivateKey string `json:"gitPrivateKey,omitempty"` - - // git private key passphrase - GitPrivateKeyPass string `json:"gitPrivateKeyPass,omitempty"` - - // git proxy URL - GitProxyURL string `json:"gitProxyUrl,omitempty"` - - // git proxy scheme - GitProxyScheme string `json:"gitProxyScheme,omitempty"` - - // git proxy user - GitProxyUser string `json:"gitProxyUser,omitempty"` - - // insecure skip tls - InsecureSkipTLS bool `json:"insecureSkipTLS"` - - // git proxy password - GitProxyPassword string `json:"gitProxyPassword,omitempty"` - - //git PEM Certificate - GitPemCertificate string `json:"gitPemCertificate,omitempty"` - - // Git User - GitUser string `json:"gitUser,omitempty"` - // Project name ProjectName string `json:"projectName,omitempty"` @@ -49,6 +16,9 @@ type Project struct { // stages Stages []*Stage `json:"stages"` + + // git auth credentials + GitCredentials *GitAuthCredentials `json:"gitCredentials,omitempty"` } // ToJSON converts object to JSON string