Skip to content

Commit 9445a83

Browse files
refactor out 'io/ioutil' (#224)
Signed-off-by: Michael Valdron <[email protected]>
1 parent e51ee89 commit 9445a83

File tree

10 files changed

+121
-118
lines changed

10 files changed

+121
-118
lines changed

index/generator/vendor/github.com/hashicorp/hcl/.gitignore

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index/server/pkg/server/endpoint.go

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ package server
1818
import (
1919
"encoding/json"
2020
"fmt"
21-
"io/ioutil"
2221
"log"
2322
"net/http"
2423
"net/http/httputil"
@@ -121,15 +120,15 @@ func (*Server) ServeDevfileIndexV1WithType(c *gin.Context, indexType string, par
121120
buildIndexAPIResponse(c, indexType, true, IndexParams(params))
122121
}
123122

124-
func (*Server) PostDevfileIndexV1WithType(c *gin.Context, indexType string, params PostDevfileIndexV1WithTypeParams){
123+
func (*Server) PostDevfileIndexV1WithType(c *gin.Context, indexType string, params PostDevfileIndexV1WithTypeParams) {
125124
SetMethodNotAllowedJSONResponse(c)
126125
}
127126

128-
func (*Server) PutDevfileIndexV1WithType(c *gin.Context, indexType string, params PutDevfileIndexV1WithTypeParams){
127+
func (*Server) PutDevfileIndexV1WithType(c *gin.Context, indexType string, params PutDevfileIndexV1WithTypeParams) {
129128
SetMethodNotAllowedJSONResponse(c)
130129
}
131130

132-
func (*Server) DeleteDevfileIndexV1WithType(c *gin.Context, indexType string, params DeleteDevfileIndexV1WithTypeParams){
131+
func (*Server) DeleteDevfileIndexV1WithType(c *gin.Context, indexType string, params DeleteDevfileIndexV1WithTypeParams) {
133132
SetMethodNotAllowedJSONResponse(c)
134133
}
135134

@@ -157,14 +156,17 @@ func (*Server) ServeHealthCheck(c *gin.Context) {
157156
Message: "the server is up and running",
158157
})
159158
}
159+
160160
// PostHealthCheck serves endpoint `/health` for registry health check with POST request
161161
func (*Server) PostHealthCheck(c *gin.Context) {
162162
SetMethodNotAllowedJSONResponse(c)
163163
}
164+
164165
// PutHealthCheck serves endpoint `/health` for registry health check with PUT request
165166
func (*Server) PutHealthCheck(c *gin.Context) {
166167
SetMethodNotAllowedJSONResponse(c)
167168
}
169+
168170
// DeleteHealthCheck serves endpoint `/health` for registry health check with DELETE request
169171
func (*Server) DeleteHealthCheck(c *gin.Context) {
170172
SetMethodNotAllowedJSONResponse(c)
@@ -198,15 +200,15 @@ func (*Server) ServeDevfileWithVersion(c *gin.Context, name string, version stri
198200
}
199201
}
200202

201-
func (*Server) PostDevfileWithVersion(c *gin.Context, name string, version string){
203+
func (*Server) PostDevfileWithVersion(c *gin.Context, name string, version string) {
202204
SetMethodNotAllowedJSONResponse(c)
203205
}
204206

205-
func (*Server) PutDevfileWithVersion(c *gin.Context, name string, version string){
207+
func (*Server) PutDevfileWithVersion(c *gin.Context, name string, version string) {
206208
SetMethodNotAllowedJSONResponse(c)
207209
}
208210

209-
func (*Server) DeleteDevfileWithVersion(c *gin.Context, name string, version string){
211+
func (*Server) DeleteDevfileWithVersion(c *gin.Context, name string, version string) {
210212
SetMethodNotAllowedJSONResponse(c)
211213
}
212214

@@ -378,7 +380,7 @@ func (*Server) ServeDevfileStarterProjectWithVersion(c *gin.Context, name string
378380
localLoc = downloadFilePath
379381
}
380382

381-
downloadBytes, err = ioutil.ReadFile(filepath.Clean(localLoc))
383+
downloadBytes, err = os.ReadFile(filepath.Clean(localLoc))
382384
if err != nil {
383385
log.Print(err.Error())
384386
c.JSON(http.StatusInternalServerError, gin.H{
@@ -431,15 +433,15 @@ func (*Server) ServeDevfileStarterProjectWithVersion(c *gin.Context, name string
431433
}
432434
}
433435

434-
func (*Server) PostDevfileStarterProjectWithVersion(c *gin.Context, name string, version string, starterProject string){
436+
func (*Server) PostDevfileStarterProjectWithVersion(c *gin.Context, name string, version string, starterProject string) {
435437
SetMethodNotAllowedJSONResponse(c)
436438
}
437439

438-
func (*Server) PutDevfileStarterProjectWithVersion(c *gin.Context, name string, version string, starterProject string){
440+
func (*Server) PutDevfileStarterProjectWithVersion(c *gin.Context, name string, version string, starterProject string) {
439441
SetMethodNotAllowedJSONResponse(c)
440442
}
441443

442-
func (*Server) DeleteDevfileStarterProjectWithVersion(c *gin.Context, name string, version string, starterProject string){
444+
func (*Server) DeleteDevfileStarterProjectWithVersion(c *gin.Context, name string, version string, starterProject string) {
443445
SetMethodNotAllowedJSONResponse(c)
444446
}
445447

@@ -634,7 +636,7 @@ func buildProxyErrorResponse(w http.ResponseWriter, r *http.Request, err error,
634636
// schema from `indexPath` given by server.
635637
func fetchDevfile(c *gin.Context, name string, version string) ([]byte, indexSchema.Schema) {
636638
var index []indexSchema.Schema
637-
bytes, err := ioutil.ReadFile(indexPath)
639+
bytes, err := os.ReadFile(indexPath)
638640
if err != nil {
639641
log.Print(err.Error())
640642
c.JSON(http.StatusInternalServerError, gin.H{
@@ -730,7 +732,7 @@ func fetchDevfile(c *gin.Context, name string, version string) ([]byte, indexSch
730732
if sampleDevfilePath != "" {
731733
if _, err = os.Stat(sampleDevfilePath); err == nil {
732734
/* #nosec G304 -- sampleDevfilePath is constructed from path.Join which cleans the input paths */
733-
bytes, err = ioutil.ReadFile(sampleDevfilePath)
735+
bytes, err = os.ReadFile(sampleDevfilePath)
734736
}
735737
if err != nil {
736738
log.Print(err.Error())
@@ -803,8 +805,8 @@ func ServeOciProxy(c *gin.Context) {
803805
proxy.ServeHTTP(c.Writer, c.Request)
804806
}
805807

806-
func SetMethodNotAllowedJSONResponse(c *gin.Context){
808+
func SetMethodNotAllowedJSONResponse(c *gin.Context) {
807809
c.JSON(http.StatusMethodNotAllowed, MethodNotAllowedResponse{
808810
Message: "Only GET requests are supported.",
809811
})
810-
}
812+
}

0 commit comments

Comments
 (0)