Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: plugin creation oss #5780

Merged
merged 58 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
93b624e
wip: new plugin creation api and min plugin api with only shared plug…
prakash100198 Aug 7, 2024
da93046
wip: create new plugin version code
prakash100198 Aug 7, 2024
9b88045
wip:plugin type SHARED by default
prakash100198 Aug 7, 2024
6da2832
wip:find plugin either by identifier or by id while creating a new ve…
prakash100198 Aug 7, 2024
7dc5df6
wip: create new plugin tag logic improved
prakash100198 Aug 7, 2024
40e7365
wip: optimize GetAllFilteredPluginParentMetadata query
prakash100198 Aug 7, 2024
638a5e7
wip: create plugin tag new flow
prakash100198 Aug 8, 2024
db878ae
wip: minor fix
prakash100198 Aug 8, 2024
046fb83
wip: minor fix
prakash100198 Aug 8, 2024
309705f
wip: minor fix
prakash100198 Aug 8, 2024
eff0501
wip: newTagsPresent -> areNewTagsPresent
prakash100198 Aug 8, 2024
f43da65
wip: icon is not mandatory code incorporated
prakash100198 Aug 8, 2024
d906333
wip:minor refactoring
prakash100198 Aug 8, 2024
ff188eb
wip: prevent duplicate version from being created and save tags rela…
prakash100198 Aug 8, 2024
19e66a3
wip: minor fix
prakash100198 Aug 8, 2024
c2e7cde
wip: details api, get all plugin data or non
prakash100198 Aug 8, 2024
8dc7386
wip: code review incorp part -1
prakash100198 Aug 9, 2024
47015bc
wip: code review incorp part -2
prakash100198 Aug 9, 2024
27e79d5
wip: code review incorp part -3
prakash100198 Aug 9, 2024
5efc2c5
wip: remove code duplication
prakash100198 Aug 9, 2024
d7f077e
wip: hardcode isExposed to true
prakash100198 Aug 9, 2024
38e2c80
Merge branch 'main' into plugin-creation-oss
prakash100198 Aug 9, 2024
cbfc114
wip: hardcode StepType= inline
prakash100198 Aug 9, 2024
4060ef5
wip: set default VariableStepIndex= 1
prakash100198 Aug 12, 2024
779e913
migration number changes (#5692)
prakash100198 Aug 15, 2024
4f04d6b
refrain from checkin autoscalingCheckBeforeTrigger for virt clus (#5696)
prakash100198 Aug 20, 2024
2e58e77
fix: Decode secret fix on add update oss (#5695)
prakash100198 Aug 20, 2024
bf23515
saving pco concurrency case handled (#5688)
prakash100198 Aug 20, 2024
694831c
fix: script for pipelineStageStepVariable, making input value and def…
prakash100198 Aug 21, 2024
3e31f49
fix: ea fixes for helm app (#5708)
RajeevRanjan27 Aug 21, 2024
8de88d7
Revert "fix: ea fixes for helm app (#5708)" (#5713)
RajeevRanjan27 Aug 22, 2024
378c2d9
fix: SkipCiBuildCachePushPull code incorporated with minor refac in h…
prakash100198 Aug 22, 2024
827608f
migration syn with ent (#5718)
prkhrkat Aug 23, 2024
5f43eb2
doc: Edit Deployment Chart Schema (#5735)
ashokdevtron Aug 23, 2024
16d01d6
doc: Redirection of old entry in gitbook.yaml (#5738)
ashokdevtron Aug 23, 2024
d816dee
docs: added Documentation for Air-Gapped Installation (#5360)
badal773 Aug 23, 2024
26784d5
feat: Env description handling (#5744)
kripanshdevtron Aug 27, 2024
0415cee
Merge branch 'main' into plugin-creation-oss
prakash100198 Aug 28, 2024
e677fbd
misc: Main sync rc - branch update (#5753)
kartik-579 Aug 28, 2024
8a61bac
doc: Update prerequisites of code-scan (#5625)
bhushan-nemade-dt Aug 28, 2024
6da544f
fix: ci patch rbac for branch update (#5759)
Ash-exp Aug 28, 2024
09946c2
feat: Added basic auth support for servicemonitor (#5761)
pawan-mehta-dt Aug 29, 2024
80f0758
fix: Bitnami chart repo tls issue (#5740)
akshatsinha007 Aug 29, 2024
7ee4a32
doc: Cosign plugin doc (#5665)
bhushan-nemade-dt Aug 29, 2024
99d10f5
fix: check rbac on env if envName is present (#5765)
prakash100198 Aug 29, 2024
f1a50b1
doc: CraneCopy plugin doc (#5658)
bhushan-nemade-dt Aug 30, 2024
3ef2b96
doc: Devtron CD Trigger Plugin doc (#5747)
bhushan-nemade-dt Aug 30, 2024
3888a41
doc: DockerSlim plugin doc (#5660)
bhushan-nemade-dt Aug 30, 2024
e619322
Merge branch 'main' into plugin-creation-oss
prakash100198 Aug 30, 2024
a625e7e
doc: Devtron Job Trigger Plugin doc (#5742)
bhushan-nemade-dt Aug 30, 2024
ff89a26
fix: scan tool active check removed (#5771)
kripanshdevtron Aug 30, 2024
5170040
feat: Docker pull env driven (#5767)
prakash100198 Aug 30, 2024
c66ccf5
fix: panic handlings and argocd app delete stuck in partial stage (#5…
Ash-exp Aug 30, 2024
5f84b16
Merge branch 'main' into plugin-creation-oss
prakash100198 Sep 2, 2024
4296366
feat: plugin creation support (#5630)
prakash100198 Sep 2, 2024
47843d9
Revert "feat: plugin creation support (#5630)" (#5778)
prakash100198 Sep 2, 2024
535b879
Merge branch 'main' into plugin-creation-oss
prakash100198 Sep 2, 2024
88f5362
Merge branch 'develop' into plugin-creation-oss
prakash100198 Sep 2, 2024
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
67 changes: 67 additions & 0 deletions api/restHandler/GlobalPluginRestHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (

type GlobalPluginRestHandler interface {
PatchPlugin(w http.ResponseWriter, r *http.Request)
CreatePlugin(w http.ResponseWriter, r *http.Request)

GetAllGlobalVariables(w http.ResponseWriter, r *http.Request)
ListAllPlugins(w http.ResponseWriter, r *http.Request)
Expand All @@ -46,6 +47,7 @@ type GlobalPluginRestHandler interface {
GetPluginDetailByIds(w http.ResponseWriter, r *http.Request)
GetAllUniqueTags(w http.ResponseWriter, r *http.Request)
MigratePluginData(w http.ResponseWriter, r *http.Request)
GetAllPluginMinData(w http.ResponseWriter, r *http.Request)
}

func NewGlobalPluginRestHandler(logger *zap.SugaredLogger, globalPluginService plugin.GlobalPluginService,
Expand Down Expand Up @@ -420,3 +422,68 @@ func (handler *GlobalPluginRestHandlerImpl) MigratePluginData(w http.ResponseWri
}
common.WriteJsonResp(w, nil, nil, http.StatusOK)
}

func (handler *GlobalPluginRestHandlerImpl) CreatePlugin(w http.ResponseWriter, r *http.Request) {
userId, err := handler.userService.GetLoggedInUser(r)
if userId == 0 || err != nil {
common.WriteJsonResp(w, err, "Unauthorized User", http.StatusUnauthorized)
return
}
token := r.Header.Get("token")
appId, err := common.ExtractIntQueryParam(w, r, "appId", 0)
if err != nil {
return
}
ok, err := handler.IsUserAuthorized(token, appId)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}
decoder := json.NewDecoder(r.Body)
var pluginDataDto bean.PluginParentMetadataDto
err = decoder.Decode(&pluginDataDto)
if err != nil {
handler.logger.Errorw("request err, CreatePlugin", "error", err, "payload", pluginDataDto)
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
handler.logger.Infow("request payload received for creating plugins", pluginDataDto, "userId", userId)

pluginVersionId, err := handler.globalPluginService.CreatePluginOrVersions(&pluginDataDto, userId)
if err != nil {
handler.logger.Errorw("service error, error in creating plugin", "pluginCreateRequestDto", pluginDataDto, "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}

common.WriteJsonResp(w, nil, bean.NewPluginMinDto().WithPluginVersionId(pluginVersionId), http.StatusOK)
}

func (handler *GlobalPluginRestHandlerImpl) GetAllPluginMinData(w http.ResponseWriter, r *http.Request) {
token := r.Header.Get("token")
appId, err := common.ExtractIntQueryParam(w, r, "appId", 0)
if err != nil {
return
}
ok, err := handler.IsUserAuthorized(token, appId)
if err != nil {
common.WriteJsonResp(w, err, nil, http.StatusBadRequest)
return
}
if !ok {
common.WriteJsonResp(w, fmt.Errorf("unauthorized user"), "Unauthorized User", http.StatusForbidden)
return
}

pluginDetail, err := handler.globalPluginService.GetAllPluginMinData()
if err != nil {
handler.logger.Errorw("error in getting all unique tags", "err", err)
common.WriteJsonResp(w, err, nil, http.StatusInternalServerError)
return
}
common.WriteJsonResp(w, nil, pluginDetail, http.StatusOK)
}
5 changes: 4 additions & 1 deletion api/router/GlobalPluginRouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ type GlobalPluginRouterImpl struct {
func (impl *GlobalPluginRouterImpl) initGlobalPluginRouter(globalPluginRouter *mux.Router) {
globalPluginRouter.Path("/migrate").
HandlerFunc(impl.globalPluginRestHandler.MigratePluginData).Methods("PUT")

globalPluginRouter.Path("/create").
HandlerFunc(impl.globalPluginRestHandler.CreatePlugin).Methods("POST")
// versioning impact handling to be done for below apis,
globalPluginRouter.Path("").
HandlerFunc(impl.globalPluginRestHandler.PatchPlugin).Methods("POST")
Expand All @@ -68,5 +69,7 @@ func (impl *GlobalPluginRouterImpl) initGlobalPluginRouter(globalPluginRouter *m

globalPluginRouter.Path("/list/tags").
HandlerFunc(impl.globalPluginRestHandler.GetAllUniqueTags).Methods("GET")
globalPluginRouter.Path("/list/v2/min").
HandlerFunc(impl.globalPluginRestHandler.GetAllPluginMinData).Methods("GET")

}
9 changes: 9 additions & 0 deletions internal/util/ErrorUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"net/http"
"strconv"
)

type ApiError struct {
Expand All @@ -36,6 +37,14 @@ type ApiError struct {
UserDetailMessage string `json:"userDetailMessage,omitempty"`
}

func GetApiError(code int, userMessage, internalMessage string) *ApiError {
return &ApiError{
HttpStatusCode: code,
Code: strconv.Itoa(code),
InternalMessage: internalMessage,
UserMessage: userMessage,
}
}
func NewApiError() *ApiError {
return &ApiError{}
}
Expand Down
Loading