Skip to content

Commit

Permalink
Merge pull request #148 from vijeyash1/main
Browse files Browse the repository at this point in the history
azure container repository webhook support
  • Loading branch information
vijeyash1 authored Aug 4, 2023
2 parents 1daf6cb + 39f11fe commit b5c199d
Show file tree
Hide file tree
Showing 19 changed files with 408 additions and 187 deletions.
205 changes: 58 additions & 147 deletions agent/container/api/agent.gen.go

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

2 changes: 1 addition & 1 deletion agent/container/cfg.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package: api
generate:
chi-server: true
gin-server: true
models: true
embedded-spec: true
output: agent/container/api/agent.gen.go
9 changes: 8 additions & 1 deletion agent/container/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ paths:
responses:
'200':
description: OK

/event/azure/container:
post:
tags:
- public
summary: Post Azure Container Registry webhook events
responses:
'200':
description: OK

# oapi-codegen -config ./cfg.yaml ./openapi.yaml
17 changes: 5 additions & 12 deletions agent/container/pkg/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"log"
"net/http"

"github.com/go-chi/chi/v5"
"github.com/gin-gonic/gin"
"github.com/intelops/kubviz/agent/container/pkg/clients"
"github.com/intelops/kubviz/agent/container/pkg/config"
"github.com/intelops/kubviz/agent/container/pkg/handler"
Expand Down Expand Up @@ -42,17 +42,12 @@ func New() *Application {
log.Fatalf("API Handler initialisation failed: %v", err)
}

mux := chi.NewMux()
apiServer.BindRequest(mux)
chi.Walk(mux, func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error {
fmt.Printf("[%s]: '%s' has %d middlewares.\n", method, route, len(middlewares))
return nil
})
r := gin.Default()
apiServer.BindRequest(r)

httpServer := &http.Server{
// TODO: remove hardcoding
// Addr: fmt.Sprintf("0.0.0.0:%d", cfg.Port),
Addr: fmt.Sprintf(":%d", 8082),
Handler: mux,
Handler: r,
}

return &Application{
Expand All @@ -65,8 +60,6 @@ func New() *Application {
}

func (app *Application) Start() {
// TODO: remove hard coding
// log.Printf("Starting server at %v", app.httpServer.Addr)
log.Printf("Starting server at %v", 8082)
var err error
if err = app.httpServer.ListenAndServe(); err != nil && errors.Is(err, http.ErrServerClosed) {
Expand Down
5 changes: 2 additions & 3 deletions agent/container/pkg/application/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"log"

"github.com/intelops/kubviz/model"
v1 "github.com/vijeyash1/go-github-container/v1"
)

// GithubContainerWatch monitors and publishes container image details from a specified GitHub organization's repositories.
Expand All @@ -24,7 +23,7 @@ func (app *Application) GithubContainerWatch() {
}

// Create a new GitHub client with the provided organization and token.
client := v1.NewGithubClient(app.GithubConfig.Org, app.GithubConfig.Token)
client := NewGithubClient(app.GithubConfig.Org, app.GithubConfig.Token)

// Fetch the list of packages (repositories) from the GitHub organization.
packages, err := client.FetchPackages()
Expand Down Expand Up @@ -61,7 +60,7 @@ func (app *Application) GithubContainerWatch() {
}

// BuildImageDetails constructs a model.GithubImage from the given v1.Package and v1.Version.
func BuildImageDetails(pkg v1.Package, version v1.Version) model.GithubImage {
func BuildImageDetails(pkg Package, version Version) model.GithubImage {
// Create and return a new GithubImage object using the provided package and version information.
return model.GithubImage{
PackageId: fmt.Sprint(pkg.ID), // Convert the package ID to a string and set it as PackageId.
Expand Down
Loading

0 comments on commit b5c199d

Please sign in to comment.