Jelajahi Sumber

remove comments

Alexander Belanger 4 tahun lalu
induk
melakukan
7946555ae4
1 mengubah file dengan 0 tambahan dan 101 penghapusan
  1. 0 101
      api/server/handlers/registry/get_token.go

+ 0 - 101
api/server/handlers/registry/get_token.go

@@ -271,104 +271,3 @@ func (c *RegistryGetDockerhubTokenHandler) ServeHTTP(w http.ResponseWriter, r *h
 
 	c.WriteResult(w, r, resp)
 }
-
-// // HandleGetProjectRegistryDockerhubToken gets a Dockerhub token for a registry
-// func (app *App) HandleGetProjectRegistryDockerhubToken(w http.ResponseWriter, r *http.Request) {
-// 	projID, err := strconv.ParseUint(chi.URLParam(r, "project_id"), 0, 64)
-
-// 	if err != nil || projID == 0 {
-// 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
-// 		return
-// 	}
-
-// 	// list registries and find one that matches the region
-// 	regs, err := app.Repo.Registry().ListRegistriesByProjectID(uint(projID))
-// 	var token string
-// 	var expiresAt *time.Time
-
-// 	for _, reg := range regs {
-// 		if reg.BasicIntegrationID != 0 && strings.Contains(reg.URL, "index.docker.io") {
-// 			basic, err := app.Repo.BasicIntegration().ReadBasicIntegration(reg.BasicIntegrationID)
-
-// 			if err != nil {
-// 				app.handleErrorDataRead(err, w)
-// 				return
-// 			}
-
-// 			token = base64.StdEncoding.EncodeToString([]byte(string(basic.Username) + ":" + string(basic.Password)))
-
-// 			// we'll just set an arbitrary 30-day expiry time (this is not enforced)
-// 			timeExpires := time.Now().Add(30 * 24 * 3600 * time.Second)
-// 			expiresAt = &timeExpires
-// 		}
-// 	}
-
-// 	resp := &RegTokenResponse{
-// 		Token:     token,
-// 		ExpiresAt: expiresAt,
-// 	}
-
-// 	w.WriteHeader(http.StatusOK)
-
-// 	if err := json.NewEncoder(w).Encode(resp); err != nil {
-// 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
-// 		return
-// 	}
-// }
-
-// // HandleGetProjectRegistryDOCRToken gets a DOCR token for a registry
-// func (app *App) HandleGetProjectRegistryDOCRToken(w http.ResponseWriter, r *http.Request) {
-// 	projID, err := strconv.ParseUint(chi.URLParam(r, "project_id"), 0, 64)
-
-// 	if err != nil || projID == 0 {
-// 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
-// 		return
-// 	}
-
-// 	reqBody := &GCRTokenRequestBody{}
-
-// 	// decode from JSON to form value
-// 	if err := json.NewDecoder(r.Body).Decode(reqBody); err != nil {
-// 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
-// 		return
-// 	}
-
-// 	// list registries and find one that matches the region
-// 	regs, err := app.Repo.Registry().ListRegistriesByProjectID(uint(projID))
-// 	var token string
-// 	var expiresAt *time.Time
-
-// 	for _, reg := range regs {
-// 		if reg.DOIntegrationID != 0 && strings.Contains(reg.URL, reqBody.ServerURL) {
-// 			oauthInt, err := app.Repo.OAuthIntegration().ReadOAuthIntegration(reg.DOIntegrationID)
-
-// 			if err != nil {
-// 				app.handleErrorDataRead(err, w)
-// 				return
-// 			}
-
-// 			tok, expiry, err := oauth.GetAccessToken(oauthInt.SharedOAuthModel, app.DOConf, oauth.MakeUpdateOAuthIntegrationTokenFunction(oauthInt, app.Repo))
-
-// 			if err != nil {
-// 				app.handleErrorDataRead(err, w)
-// 				return
-// 			}
-
-// 			token = tok
-// 			expiresAt = expiry
-// 			break
-// 		}
-// 	}
-
-// 	resp := &RegTokenResponse{
-// 		Token:     token,
-// 		ExpiresAt: expiresAt,
-// 	}
-
-// 	w.WriteHeader(http.StatusOK)
-
-// 	if err := json.NewEncoder(w).Encode(resp); err != nil {
-// 		app.handleErrorFormDecoding(err, ErrProjectDecode, w)
-// 		return
-// 	}
-// }