Skip to content

Commit

Permalink
Merge branch 'main' into release/v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-samfira committed Jul 6, 2023
2 parents 481ce34 + 9e849ed commit a0a5611
Show file tree
Hide file tree
Showing 941 changed files with 113,392 additions and 5,707 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ Once you've configured your database, providers and github credentials, you'll n
At this point, you should be done. Have a look at the [running garm document](/doc/running_garm.md) for usage instructions and available features.
If you would like to use ```garm``` with a different IaaS than the ones already available, have a loot at the [writing an external provider](/doc/external_provider.md) page.
If you would like to use ```garm``` with a different IaaS than the ones already available, have a look at the [writing an external provider](/doc/external_provider.md) page.
If you like to optimize the startup time of new instance, take a look at the [performance considerations](/doc/performance_considerations.md) page.
## Security considerations
Expand Down
14 changes: 14 additions & 0 deletions apiserver/controllers/controllers.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,3 +306,17 @@ func (a *APIController) ListProviders(w http.ResponseWriter, r *http.Request) {
log.Printf("failed to encode response: %q", err)
}
}

func (a *APIController) ListAllJobs(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
jobs, err := a.r.ListAllJobs(ctx)
if err != nil {
handleError(w, err)
return
}

w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(jobs); err != nil {
log.Printf("failed to encode response: %q", err)
}
}
2 changes: 1 addition & 1 deletion apiserver/controllers/enterprises.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (a *APIController) UpdateEnterpriseHandler(w http.ResponseWriter, r *http.R
return
}

var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return
Expand Down
48 changes: 48 additions & 0 deletions apiserver/controllers/instances.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ func (a *APIController) ListPoolInstancesHandler(w http.ResponseWriter, r *http.
}
}

// swagger:route GET /instances/{instanceName} instances GetInstance
//
// Get runner instance by name.
//
// Parameters:
// + name: instanceName
// description: Runner instance name.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Instance
// default: APIErrorResponse
func (a *APIController) GetInstanceHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
Expand Down Expand Up @@ -82,6 +96,19 @@ func (a *APIController) GetInstanceHandler(w http.ResponseWriter, r *http.Reques
}
}

// swagger:route DELETE /instances/{instanceName} instances DeleteInstance
//
// Delete runner instance by name.
//
// Parameters:
// + name: instanceName
// description: Runner instance name.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteInstanceHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
Expand All @@ -107,6 +134,20 @@ func (a *APIController) DeleteInstanceHandler(w http.ResponseWriter, r *http.Req
w.WriteHeader(http.StatusOK)
}

// swagger:route GET /repositories/{repoID}/instances repositories instances ListRepoInstances
//
// List repository instances.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Instances
// default: APIErrorResponse
func (a *APIController) ListRepoInstancesHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
Expand Down Expand Up @@ -191,6 +232,13 @@ func (a *APIController) ListEnterpriseInstancesHandler(w http.ResponseWriter, r
}
}

// swagger:route GET /instances instances ListInstances
//
// Get all runners' instances.
//
// Responses:
// 200: Instances
// default: APIErrorResponse
func (a *APIController) ListAllInstancesHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down
2 changes: 1 addition & 1 deletion apiserver/controllers/organizations.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (a *APIController) UpdateOrgHandler(w http.ResponseWriter, r *http.Request)
return
}

var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return
Expand Down
169 changes: 168 additions & 1 deletion apiserver/controllers/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ import (
"github.com/gorilla/mux"
)

// swagger:route POST /repositories repositories CreateRepo
//
// Create repository with the parameters given.
//
// Parameters:
// + name: Body
// description: Parameters used when creating the repository.
// type: CreateRepoParams
// in: body
// required: true
//
// Responses:
// 200: Repository
// default: APIErrorResponse
func (a *APIController) CreateRepoHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand All @@ -48,6 +62,13 @@ func (a *APIController) CreateRepoHandler(w http.ResponseWriter, r *http.Request
}
}

// swagger:route GET /repositories repositories ListRepos
//
// List repositories.
//
// Responses:
// 200: Repositories
// default: APIErrorResponse
func (a *APIController) ListReposHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand All @@ -64,6 +85,20 @@ func (a *APIController) ListReposHandler(w http.ResponseWriter, r *http.Request)
}
}

// swagger:route GET /repositories/{repoID} repositories GetRepo
//
// Get repository by ID.
//
// Parameters:
// + name: repoID
// description: ID of the repository to fetch.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Repository
// default: APIErrorResponse
func (a *APIController) GetRepoByIDHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down Expand Up @@ -93,6 +128,19 @@ func (a *APIController) GetRepoByIDHandler(w http.ResponseWriter, r *http.Reques
}
}

// swagger:route DELETE /repositories/{repoID} repositories DeleteRepo
//
// Delete repository by ID.
//
// Parameters:
// + name: repoID
// description: ID of the repository to delete.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteRepoHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down Expand Up @@ -120,6 +168,26 @@ func (a *APIController) DeleteRepoHandler(w http.ResponseWriter, r *http.Request

}

// swagger:route PUT /repositories/{repoID} repositories UpdateRepo
//
// Update repository with the parameters given.
//
// Parameters:
// + name: repoID
// description: ID of the repository to update.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when updating the repository.
// type: UpdateEntityParams
// in: body
// required: true
//
// Responses:
// 200: Repository
// default: APIErrorResponse
func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand All @@ -136,7 +204,7 @@ func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request
return
}

var updatePayload runnerParams.UpdateRepositoryParams
var updatePayload runnerParams.UpdateEntityParams
if err := json.NewDecoder(r.Body).Decode(&updatePayload); err != nil {
handleError(w, gErrors.ErrBadRequest)
return
Expand All @@ -155,6 +223,26 @@ func (a *APIController) UpdateRepoHandler(w http.ResponseWriter, r *http.Request
}
}

// swagger:route POST /repositories/{repoID}/pools repositories pools CreateRepoPool
//
// Create repository pool with the parameters given.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when creating the repository pool.
// type: CreatePoolParams
// in: body
// required: true
//
// Responses:
// 200: Pool
// default: APIErrorResponse
func (a *APIController) CreateRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down Expand Up @@ -191,6 +279,20 @@ func (a *APIController) CreateRepoPoolHandler(w http.ResponseWriter, r *http.Req
}
}

// swagger:route GET /repositories/{repoID}/pools repositories pools ListRepoPools
//
// List repository pools.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Pools
// default: APIErrorResponse
func (a *APIController) ListRepoPoolsHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
Expand Down Expand Up @@ -219,6 +321,26 @@ func (a *APIController) ListRepoPoolsHandler(w http.ResponseWriter, r *http.Requ
}
}

// swagger:route GET /repositories/{repoID}/pools/{poolID} repositories pools GetRepoPool
//
// Get repository pool by ID.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: poolID
// description: Pool ID.
// type: string
// in: path
// required: true
//
// Responses:
// 200: Pool
// default: APIErrorResponse
func (a *APIController) GetRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
vars := mux.Vars(r)
Expand Down Expand Up @@ -248,6 +370,25 @@ func (a *APIController) GetRepoPoolHandler(w http.ResponseWriter, r *http.Reques
}
}

// swagger:route DELETE /repositories/{repoID}/pools/{poolID} repositories pools DeleteRepoPool
//
// Delete repository pool by ID.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: poolID
// description: ID of the repository pool to delete.
// type: string
// in: path
// required: true
//
// Responses:
// default: APIErrorResponse
func (a *APIController) DeleteRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down Expand Up @@ -276,6 +417,32 @@ func (a *APIController) DeleteRepoPoolHandler(w http.ResponseWriter, r *http.Req

}

// swagger:route PUT /repositories/{repoID}/pools/{poolID} repositories pools UpdateRepoPool
//
// Update repository pool with the parameters given.
//
// Parameters:
// + name: repoID
// description: Repository ID.
// type: string
// in: path
// required: true
//
// + name: poolID
// description: ID of the repository pool to update.
// type: string
// in: path
// required: true
//
// + name: Body
// description: Parameters used when updating the repository pool.
// type: UpdatePoolParams
// in: body
// required: true
//
// Responses:
// 200: Pool
// default: APIErrorResponse
func (a *APIController) UpdateRepoPoolHandler(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

Expand Down
Loading

0 comments on commit a0a5611

Please sign in to comment.