Skip to content

Commit

Permalink
refactor(providers): Review code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Porsh33 committed Apr 14, 2022
1 parent af4b6f8 commit ef60297
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions server/api/provider/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func HandleCreate(providers core.ProviderStore) http.HandlerFunc {
Host string `json:"host" valid:"url,required"`
AccessToken string `json:"accessToken" valid:"stringlength(12|50),required"`
Secret string `json:"secret" valid:"stringlength(5|50),required"`
HttpUser string `json:"HttpUser"`
HttpPass string `json:"HttpPass"`
HttpUser string `json:"httpUser"`
HttpPass string `json:"httpPass"`
}

return func(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions server/api/provider/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ func HandleUpdate(providers core.ProviderStore, users core.UserStore) http.Handl
Host string `json:"host" valid:"url,required"`
AccessToken string `json:"accessToken"`
Secret string `json:"secret" valid:"stringlength(5|50),required"`
HttpUser string `json:"HttpUser"`
HttpPass string `json:"HttpPass"`
HttpUser string `json:"httpUser"`
HttpPass string `json:"httpPass"`
}

return func(w http.ResponseWriter, r *http.Request) {
Expand Down
4 changes: 2 additions & 2 deletions server/core/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ type (
Name string `gorm:"not null" json:"name"`
URL string `gorm:"not null" json:"url"`
AccessToken string `gorm:"not null" json:"-"`
HttpUser string `json:"HttpUser"`
HttpPass string `json:"HttpPass"`
HttpUser string `json:"httpUser"`
HttpPass string `json:"httpPass"`
Secret string `gorm:"not null" json:"secret"`
Host string `gorm:"not null" json:"host"`
LastSync *time.Time `json:"lastSync"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ export class ProvidersModalComponent implements OnInit {
],
accessToken: [(this.provider && this.provider.accessToken) || null],
secret: [(this.provider && this.provider.secret) || null, [Validators.required]],
httpUser: [(this.provider && this.provider.HttpUser) || null],
httpPass: [(this.provider && this.provider.HttpPass) || null]
httpUser: [(this.provider && this.provider.httpUser) || null],
httpPass: [(this.provider && this.provider.httpPass) || null]
});
}
}
8 changes: 4 additions & 4 deletions web/abstruse/src/app/providers/shared/provider.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export class Provider {
public host?: string,
public secret?: string,
public accessToken?: string,
public HttpUser?: string,
public HttpPass?: string,
public httpUser?: string,
public httpPass?: string,
public lastSync?: Date | null,
public userID?: number,
public createdAt?: Date,
Expand Down Expand Up @@ -53,8 +53,8 @@ export const generateProvider = (data: any): Provider => {
data.host,
data.secret,
data.accessToken,
data.HttpUser,
data.HttpPass,
data.httpUser,
data.httpPass,
data.lastSync ? new Date(data.lastSync) : null,
data.userID,
new Date(data.createdAt),
Expand Down
16 changes: 8 additions & 8 deletions worker/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,21 @@ func (s *Server) StartJob(job *pb.Job, stream pb.API_StartJobServer) error {
logch <- []byte(yellow(fmt.Sprintf("==> Cloning repository %s ref: %s sha: %s... ", job.GetSshURL(), job.GetRef(), job.GetCommitSHA())))
}

HttpUser := job.GetProviderHttpUser()
if HttpUser == "" {
HttpUser = "user"
httpUser := job.GetProviderHttpUser()
if httpUser == "" {
httpUser = "user"
}
HttpPass := job.GetProviderHttpPass()
if HttpPass == "" {
HttpPass = job.GetProviderToken()
httpPass := job.GetProviderHttpPass()
if httpPass == "" {
httpPass = job.GetProviderToken()
}

if err := git.CloneRepository(
job.GetUrl(),
job.GetRef(),
job.GetCommitSHA(),
HttpUser,
HttpPass,
httpUser,
httpPass,
dir,
job.GetSshURL(),
[]byte(job.GetSshPrivateKey()),
Expand Down

0 comments on commit ef60297

Please sign in to comment.