-
Notifications
You must be signed in to change notification settings - Fork 514
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f97440a
Showing
8,624 changed files
with
4,231,374 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
devtron |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* | ||
* Copyright (c) 2020 Devtron Labs | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"github.com/devtron-labs/devtron/api/router" | ||
"github.com/devtron-labs/devtron/api/sse" | ||
"github.com/devtron-labs/devtron/client/argocdServer" | ||
"github.com/devtron-labs/devtron/client/pubsub" | ||
"github.com/devtron-labs/devtron/internal/middleware" | ||
"github.com/devtron-labs/devtron/pkg/user" | ||
"fmt" | ||
"github.com/argoproj/argo-cd/util/session" | ||
"github.com/casbin/casbin" | ||
"github.com/go-pg/pg" | ||
_ "github.com/lib/pq" | ||
"go.uber.org/zap" | ||
"log" | ||
"net/http" | ||
"os" | ||
"time" | ||
) | ||
|
||
type App struct { | ||
MuxRouter *router.MuxRouter | ||
Logger *zap.SugaredLogger | ||
SSE *sse.SSE | ||
Enforcer *casbin.Enforcer | ||
sessionManager *session.SessionManager | ||
server *http.Server | ||
db *pg.DB | ||
pubsubClient *pubsub.PubSubClient | ||
} | ||
|
||
func NewApp(router *router.MuxRouter, | ||
Logger *zap.SugaredLogger, | ||
sse *sse.SSE, | ||
manager *session.SessionManager, | ||
versionService argocdServer.VersionService, | ||
enforcer *casbin.Enforcer, | ||
db *pg.DB, | ||
pubsubClient *pubsub.PubSubClient) *App { | ||
//check argo connection | ||
err := versionService.CheckVersion() | ||
if err != nil { | ||
log.Panic(err) | ||
} | ||
app := &App{MuxRouter: router, Logger: Logger, SSE: sse, Enforcer: enforcer, sessionManager: manager, db: db, pubsubClient: pubsubClient} | ||
return app | ||
} | ||
|
||
func (app *App) Start() { | ||
|
||
/* RequestDuration := prometheus.NewHistogramVec(prometheus.HistogramOpts{ | ||
Name: "request_duration_seconds", | ||
Help: "Time (in seconds) spent serving HTTP requests.", | ||
Buckets: prometheus.DefBuckets, | ||
}, []string{"method", "route", "status_code", "ws"}) | ||
prometheus.MustRegister(RequestDuration) | ||
prometheus.Ins*/ | ||
//instrument:=middleware.Instrument{ | ||
// Duration: RequestDuration, | ||
//} | ||
port := 8080 //TODO: extract from environment variable | ||
app.Logger.Debugw("starting server") | ||
app.Logger.Infow("starting server on ", "port", port) | ||
app.MuxRouter.Init() | ||
//authEnforcer := casbin2.Create() | ||
|
||
server := &http.Server{Addr: fmt.Sprintf(":%d", port), Handler: user.Authorizer(app.Enforcer, app.sessionManager)(app.MuxRouter.Router)} | ||
|
||
app.MuxRouter.Router.Use(middleware.PrometheusMiddleware) | ||
app.server = server | ||
err := server.ListenAndServe() | ||
//err := http.ListenAndServe(fmt.Sprintf(":%d", port), auth.Authorizer(app.Enforcer, app.sessionManager)(app.MuxRouter.Router)) | ||
if err != nil { | ||
app.Logger.Errorw("error in startup", "err", err) | ||
os.Exit(2) | ||
} | ||
} | ||
|
||
func (app *App) Stop() { | ||
app.Logger.Infow("orchestrator shutdown initiating") | ||
timeoutContext, _ := context.WithTimeout(context.Background(), 5*time.Second) | ||
app.Logger.Infow("closing router") | ||
err := app.server.Shutdown(timeoutContext) | ||
if err != nil { | ||
app.Logger.Errorw("error in mux router shutdown", "err", err) | ||
} | ||
app.Logger.Infow("closing db connection") | ||
err = app.db.Close() | ||
if err != nil { | ||
app.Logger.Errorw("error in closing db connection", "err", err) | ||
} | ||
nc := app.pubsubClient.Conn.NatsConn() | ||
//closing nats | ||
err = app.pubsubClient.Conn.Close() | ||
if err != nil { | ||
app.Logger.Errorw("error in closing stan", "err", err) | ||
} | ||
err = nc.Drain() | ||
if err != nil { | ||
app.Logger.Errorw("error in draining nats", "err", err) | ||
} | ||
nc.Close() | ||
app.Logger.Infow("housekeeping done. exiting now") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# How to Contribute | ||
|
||
Devtron is [Apache 2.0 licensed](LICENSE) and accepts contributions via GitHub | ||
pull requests. This document outlines some of the conventions on development | ||
workflow, commit message formatting, contact points and other resources to make | ||
it easier to get your contribution accepted. | ||
|
||
We gratefully welcome improvements to issues and documentation as well as to code. | ||
|
||
## Certificate of Origin | ||
|
||
By contributing to this project you agree to the Developer Certificate of | ||
Origin (DCO). This document was created by the Linux Kernel community and is a | ||
simple statement that you, as a contributor, have the legal right to make the | ||
contribution. No action from you is required, but it's a good idea to see the | ||
[DCO](DCO) file for details before you start contributing code to Devtron. | ||
|
||
## Communications | ||
|
||
The project uses discord for communication: | ||
|
||
To join the conversation, simply join the **[discord](https://discord.gg/wRspyec)** and use the __#contrib__ channel. | ||
|
||
## Code Structure | ||
|
||
Devtron has following components | ||
|
||
- [devtron](https://github.com/devtron-labs/devtron.git) main co-ordinating engine | ||
- [git sensor](https://github.com/devtron-labs/git-sensor.git) microservice for watching and interacting with git | ||
- [ci runner](https://github.com/devtron-labs/ci-runner.git) Devtron runner for executing jobs | ||
- [guard](https://github.com/devtron-labs/guard.git) A kubernetes validating webhook for policy inforcement | ||
- [imge-scanner](https://github.com/devtron-labs/image-scanner.git) microservice for docker image vulnerability scanning | ||
- [kubewatch](https://github.com/devtron-labs/kubewatch.git) microservice for k8s event filtering and recording | ||
- [lens](https://github.com/devtron-labs/lens.git) microservice for performing analytical task | ||
- [dashboard](https://github.com/devtron-labs/dashboard.git) Ui for devtron written in react js | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Developer Certificate of Origin | ||
Version 1.1 | ||
|
||
Copyright (C) 2004, 2006 The Linux Foundation and its contributors. | ||
1 Letterman Drive | ||
Suite D4700 | ||
San Francisco, CA, 94129 | ||
|
||
Everyone is permitted to copy and distribute verbatim copies of this | ||
license document, but changing it is not allowed. | ||
|
||
|
||
Developer's Certificate of Origin 1.1 | ||
|
||
By making a contribution to this project, I certify that: | ||
|
||
(a) The contribution was created in whole or in part by me and I | ||
have the right to submit it under the open source license | ||
indicated in the file; or | ||
|
||
(b) The contribution is based upon previous work that, to the best | ||
of my knowledge, is covered under an appropriate open source | ||
license and I have the right under that license to submit that | ||
work with modifications, whether created in whole or in part | ||
by me, under the same open source license (unless I am | ||
permitted to submit under a different license), as indicated | ||
in the file; or | ||
|
||
(c) The contribution was provided directly to me by some other | ||
person who certified (a), (b) or (c) and I have not modified | ||
it. | ||
|
||
(d) I understand and agree that this project and the contribution | ||
are public and that a record of the contribution (including all | ||
personal information I submit with it, including my sign-off) is | ||
maintained indefinitely and may be redistributed consistent with | ||
this project or the open source license(s) involved. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FROM golang:1.12.9-alpine3.9 AS build-env | ||
RUN echo $GOPATH | ||
|
||
RUN apk add --no-cache git gcc musl-dev | ||
RUN apk add --update make | ||
RUN go get github.com/google/wire/cmd/wire | ||
WORKDIR /go/src/github.com/devtron-labs/devtron | ||
ADD . /go/src/github.com/devtron-labs/devtron/ | ||
RUN GOOS=linux make | ||
|
||
FROM alpine:3.9 | ||
RUN apk add --no-cache ca-certificates | ||
RUN echo pwd | ||
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/devtron . | ||
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/auth_model.conf . | ||
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/vendor/github.com/argoproj/argo-cd/assets/ /go/src/github.com/devtron-labs/devtron/vendor/github.com/argoproj/argo-cd/assets | ||
COPY --from=build-env /go/src/github.com/devtron-labs/devtron/scripts/devtron-reference-helm-charts scripts/devtron-reference-helm-charts | ||
CMD ["./devtron"] |
Oops, something went wrong.