Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
linters-settings:
dupl:
threshold: 100
threshold: 150
exhaustive:
default-signifies-exhaustive: false
funlen:
Expand Down Expand Up @@ -154,4 +154,7 @@ issues:
linters:
- gomnd
- dupl
- goconst
- goconst
- path: provider/gcp/.*\.go
linters:
- dupl
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ Zop is a comprehensive tool for managing cloud infrastructure. It consists of th
Run the following command to pull and start the Docker image for the zop-api:

```bash
docker run -d -p 8000:8000 --name zop-api zopdev/zop-api:v0.0.2
docker run -d -p 8000:8000 --name zop-api zopdev/zop-api:v0.0.3
```

#### zop-ui
Run the following command to pull and start the Docker image for the zop-ui:
```bash
docker run -d -p 3000:3000 -e NEXT_PUBLIC_API_BASE_URL='http://localhost:8000' --name zop-ui zopdev/zop-ui:v0.0.2
docker run -d -p 3000:3000 -e NEXT_PUBLIC_API_BASE_URL='http://localhost:8000' --name zop-ui zopdev/zop-ui:v0.0.3
```

> **Note:** The environment variable `NEXT_PUBLIC_API_BASE_URL` is used by zop-ui to connect to the zop-api. Ensure that the value matches the API's running base URL.
Expand Down
1 change: 1 addition & 0 deletions cloudaccounts/service/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ type CloudAccountService interface {
FetchDeploymentSpace(ctx *gofr.Context, cloudAccountID int) (interface{}, error)
ListNamespaces(ctx *gofr.Context, id int, clusterName, clusterRegion string) (interface{}, error)
FetchDeploymentSpaceOptions(ctx *gofr.Context, id int) ([]DeploymentSpaceOptions, error)
FetchCredentials(ctx *gofr.Context, cloudAccountID int64) (interface{}, error)
}
39 changes: 27 additions & 12 deletions cloudaccounts/service/mock_interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions cloudaccounts/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,12 @@ func (*Service) FetchDeploymentSpaceOptions(_ *gofr.Context, id int) ([]Deployme

return options, nil
}

func (s *Service) FetchCredentials(ctx *gofr.Context, cloudAccountID int64) (interface{}, error) {
credentials, err := s.store.GetCredentials(ctx, cloudAccountID)
if err != nil {
return nil, err
}

return credentials, nil
}
168 changes: 168 additions & 0 deletions deploymentspace/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,171 @@ func validate(deploymentSpace *service.DeploymentSpace) error {

return nil
}

func (h *Handler) ListServices(ctx *gofr.Context) (interface{}, error) {
id := ctx.PathParam("id")
id = strings.TrimSpace(id)

environmentID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

resp, err := h.service.GetServices(ctx, environmentID)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) ListDeployments(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
id = strings.TrimSpace(id)

environmentID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

resp, err := h.service.GetDeployments(ctx, environmentID)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) ListPods(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
id = strings.TrimSpace(id)

environmentID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

resp, err := h.service.GetPods(ctx, environmentID)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) ListCronJobs(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
id = strings.TrimSpace(id)

environmentID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

resp, err := h.service.GetCronJobs(ctx, environmentID)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) GetService(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
name := ctx.PathParam("name")

envID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

if name == "" {
return nil, http.ErrorMissingParam{Params: []string{"name"}}
}

resp, err := h.service.GetServiceByName(ctx, envID, name)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) GetDeployment(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
name := ctx.PathParam("name")

envID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

if name == "" {
return nil, http.ErrorMissingParam{Params: []string{"name"}}
}

resp, err := h.service.GetDeploymentByName(ctx, envID, name)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) GetPod(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
name := ctx.PathParam("name")

envID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

if name == "" {
return nil, http.ErrorMissingParam{Params: []string{"name"}}
}

resp, err := h.service.GetPodByName(ctx, envID, name)
if err != nil {
return nil, err
}

return resp, nil
}

func (h *Handler) GetCronJob(ctx *gofr.Context) (any, error) {
id := ctx.PathParam("id")
name := ctx.PathParam("name")

envID, err := strconv.Atoi(id)
if err != nil {
ctx.Logger.Error(err, "failed to convert environment id to int")

return nil, http.ErrorInvalidParam{Params: []string{"id"}}
}

if name == "" {
return nil, http.ErrorMissingParam{Params: []string{"name"}}
}

resp, err := h.service.GetCronJobByName(ctx, envID, name)
if err != nil {
return nil, err
}

return resp, nil
}
8 changes: 8 additions & 0 deletions deploymentspace/service/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,12 @@ type DeploymentSpaceService interface {
// *DeploymentSpaceResp - The deployment space response object that includes the deployment space and cluster.
// error - Any error encountered during the fetch operation.
Fetch(ctx *gofr.Context, environmentID int) (*DeploymentSpaceResp, error)
GetServices(ctx *gofr.Context, environmentID int) (any, error)
GetDeployments(ctx *gofr.Context, environmentID int) (any, error)
GetPods(ctx *gofr.Context, environmentID int) (any, error)
GetCronJobs(ctx *gofr.Context, environmentID int) (any, error)
GetServiceByName(ctx *gofr.Context, envID int, serviceName string) (any, error)
GetDeploymentByName(ctx *gofr.Context, envID int, deploymentName string) (any, error)
GetPodByName(ctx *gofr.Context, environmentID int, deploymentName string) (any, error)
GetCronJobByName(ctx *gofr.Context, environmentID int, deploymentName string) (any, error)
}
Loading
Loading