Selaa lähdekoodia

remove debug statements and clean up

Alexander Belanger 4 vuotta sitten
vanhempi
sitoutus
6a4a8f52a3
4 muutettua tiedostoa jossa 0 lisäystä ja 155 poistoa
  1. 0 8
      cli/cmd/api/api.go
  2. 0 20
      cli/cmd/connect.go
  3. 0 125
      cli/cmd/connect/actions.go
  4. 0 2
      cli/cmd/deploy/create.go

+ 0 - 8
cli/cmd/api/api.go

@@ -1,7 +1,6 @@
 package api
 
 import (
-	"bytes"
 	"encoding/base64"
 	"encoding/json"
 	"fmt"
@@ -96,13 +95,6 @@ func (c *Client) sendRequest(req *http.Request, v interface{}, useCookie bool) (
 	}
 
 	if v != nil {
-		body, _ := ioutil.ReadAll(res.Body)
-
-		fmt.Println("BODY IS", string(body))
-
-		// need to create a new stream for the body
-		res.Body = ioutil.NopCloser(bytes.NewReader(body))
-
 		if err = json.NewDecoder(res.Body).Decode(v); err != nil {
 			return nil, err
 		}

+ 0 - 20
cli/cmd/connect.go

@@ -67,18 +67,6 @@ var connectRegistryCmd = &cobra.Command{
 	},
 }
 
-// var connectActionsCmd = &cobra.Command{
-// 	Use:   "actions",
-// 	Short: "Adds Github Actions to a project",
-// 	Run: func(cmd *cobra.Command, args []string) {
-// 		err := checkLoginAndRun(args, runConnectActions)
-
-// 		if err != nil {
-// 			os.Exit(1)
-// 		}
-// 	},
-// }
-
 var connectGCRCmd = &cobra.Command{
 	Use:   "gcr",
 	Short: "Adds a GCR instance to a project",
@@ -135,7 +123,6 @@ func init() {
 		"the context to connect (defaults to the current context)",
 	)
 
-	// connectCmd.AddCommand(connectActionsCmd)
 	connectCmd.AddCommand(connectECRCmd)
 	connectCmd.AddCommand(connectRegistryCmd)
 	connectCmd.AddCommand(connectDockerhubCmd)
@@ -243,10 +230,3 @@ func runConnectHelmRepoBasic(_ *api.AuthCheckResponse, client *api.Client, _ []s
 
 	return config.SetHelmRepo(hrID)
 }
-
-// func runConnectActions(_ *api.AuthCheckResponse, client *api.Client, _ []string) error {
-// 	return connect.Actions(
-// 		client,
-// 		config.Project,
-// 	)
-// }

+ 0 - 125
cli/cmd/connect/actions.go

@@ -1,125 +0,0 @@
-package connect
-
-// import (
-// 	"context"
-// 	"fmt"
-// 	"strconv"
-// 	"time"
-
-// 	"github.com/porter-dev/porter/cli/cmd/api"
-// 	"github.com/porter-dev/porter/cli/cmd/utils"
-
-// 	ints "github.com/porter-dev/porter/internal/models/integrations"
-// )
-
-// // Actions creates a github actions integration
-// func Actions(
-// 	client *api.Client,
-// 	projectID uint,
-// ) error {
-// 	// if project ID is 0, ask the user to set the project ID or create a project
-// 	if projectID == 0 {
-// 		return fmt.Errorf("no project set, please run porter project set [id]")
-// 	}
-
-// 	// list oauth integrations and make sure Github exists
-// 	oauthInts, err := client.ListOAuthIntegrations(context.TODO(), projectID)
-
-// 	if err != nil {
-// 		return err
-// 	}
-
-// 	linkedGH := false
-
-// 	// iterate through oauth integrations to find do
-// 	for _, oauthInt := range oauthInts {
-// 		if oauthInt.Client == ints.OAuthGithub {
-// 			linkedGH = true
-// 			break
-// 		}
-// 	}
-
-// 	if !linkedGH {
-// 		_, err = triggerGithubOAuth(client, projectID)
-
-// 		if err != nil {
-// 			return err
-// 		}
-// 	}
-
-// 	gitRepos, err := client.ListGitRepos(context.TODO(), projectID)
-
-// 	gitRepoID := gitRepos[0].ID
-
-// 	// prompts (unfortunately a lot)
-// 	clusterIDStr, _ := utils.PromptPlaintext(fmt.Sprintf(`Please provide the cluster id (can be found with "porter clusters list").
-// Cluster ID: `))
-// 	clusterID, err := strconv.ParseUint(clusterIDStr, 10, 64)
-
-// 	if err != nil {
-// 		return err
-// 	}
-
-// 	releaseName, _ := utils.PromptPlaintext(fmt.Sprintf(`Release name:`))
-// 	releaseNamespace, _ := utils.PromptPlaintext(fmt.Sprintf(`Release namespace:`))
-// 	gitRepo, _ := utils.PromptPlaintext(fmt.Sprintf(`Please enter the Github repo, in the form ${owner}/${repo_name}. For example, porter-dev/porter.
-// Github repo:`))
-
-// 	imageRepo, _ := utils.PromptPlaintext(fmt.Sprintf(`Please enter the image repo url.
-// Image repo:`))
-
-// 	dockerfilePath, _ := utils.PromptPlaintext(fmt.Sprintf(`Please enter the path in the repo to your dockerfile.
-// Dockerfile path:`))
-
-// 	err = client.CreateGithubAction(
-// 		context.Background(),
-// 		projectID,
-// 		uint(clusterID),
-// 		releaseName,
-// 		releaseNamespace,
-// 		&api.CreateGithubActionRequest{
-// 			GitRepo:        gitRepo,
-// 			ImageRepoURI:   imageRepo,
-// 			DockerfilePath: dockerfilePath,
-// 			GitRepoID:      gitRepoID,
-// 		},
-// 	)
-
-// 	return err
-// }
-
-// func triggerGithubOAuth(client *api.Client, projectID uint) (ints.OAuthIntegrationExternal, error) {
-// 	var ghAuth ints.OAuthIntegrationExternal
-
-// 	oauthURL := fmt.Sprintf("%s/oauth/projects/%d/github", client.BaseURL, projectID)
-
-// 	fmt.Printf("Please visit %s in your browser to connect to Github (it should open automatically).", oauthURL)
-// 	utils.OpenBrowser(oauthURL)
-
-// 	for {
-// 		oauthInts, err := client.ListOAuthIntegrations(context.TODO(), projectID)
-
-// 		if err != nil {
-// 			return ghAuth, err
-// 		}
-
-// 		linkedGH := false
-
-// 		// iterate through oauth integrations to find do
-// 		for _, oauthInt := range oauthInts {
-// 			if oauthInt.Client == ints.OAuthGithub {
-// 				linkedGH = true
-// 				ghAuth = oauthInt
-// 				break
-// 			}
-// 		}
-
-// 		if linkedGH {
-// 			break
-// 		}
-
-// 		time.Sleep(2 * time.Second)
-// 	}
-
-// 	return ghAuth, nil
-// }

+ 0 - 2
cli/cmd/deploy/create.go

@@ -49,7 +49,6 @@ func (c *CreateAgent) CreateFromGithub(
 	)
 
 	if err != nil {
-		fmt.Println("could not list git repos")
 		return "", err
 	}
 
@@ -64,7 +63,6 @@ func (c *CreateAgent) CreateFromGithub(
 		)
 
 		if err != nil {
-			fmt.Println("could not list github repos")
 			return "", err
 		}