You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/07/28 13:57:00 UTC
[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2616: feat: project_mapping for org plugin
klesh commented on code in PR #2616:
URL: https://github.com/apache/incubator-devlake/pull/2616#discussion_r932251722
##########
plugins/org/api/project_mapping.go:
##########
@@ -0,0 +1,90 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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 api
+
+import (
+ "github.com/apache/incubator-devlake/plugins/core"
+ "net/http"
+
+ "github.com/gocarina/gocsv"
+)
+
+// GetProjectMapping godoc
+// @Summary Get project_mapping.csv file
+// @Description get project_mapping.csv file
+// @Tags plugins/org
+// @Produce text/csv
+// @Param fake_data query bool false "return fake data or not"
+// @Success 200
+// @Failure 400 {object} shared.ApiBody "Bad Request"
+// @Failure 500 {object} shared.ApiBody "Internal Error"
+// @Router /plugins/org/project_mapping.csv [get]
+func (h *Handlers) GetProjectMapping(input *core.ApiResourceInput) (*core.ApiResourceOutput, error) {
+ input.Query.Get("fake_data")
+ var mapping []projectMapping
+ var err error
+ if input.Query.Get("fake_data") == "true" {
+ mapping = fakeProjectMapping
+ } else {
+ mapping, err = h.store.findAllProjectMapping()
+ if err != nil {
+ return nil, err
+ }
+ }
+ blob, err := gocsv.MarshalBytes(mapping)
+ if err != nil {
+ return nil, err
+ }
+ return &core.ApiResourceOutput{
+ Body: nil,
+ Status: http.StatusOK,
+ File: &core.OutputFile{
+ ContentType: "text/csv",
+ Data: blob,
+ },
+ }, nil
+}
+
+// CreateProjectMapping godoc
Review Comment:
Same as above
##########
plugins/org/api/project_mapping.go:
##########
@@ -0,0 +1,90 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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 api
+
+import (
+ "github.com/apache/incubator-devlake/plugins/core"
+ "net/http"
+
+ "github.com/gocarina/gocsv"
+)
+
+// GetProjectMapping godoc
Review Comment:
Please finish the documentation, i.e:
GetProjectMapping returns all project mapping in csv format
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@devlake.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org