docr.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. package connect
  2. import (
  3. "context"
  4. "fmt"
  5. "github.com/porter-dev/porter/cli/cmd/api"
  6. )
  7. // DOCR creates a DOCR integration
  8. func DOCR(
  9. client *api.Client,
  10. projectID uint,
  11. ) (uint, error) {
  12. // if project ID is 0, ask the user to set the project ID or create a project
  13. if projectID == 0 {
  14. return 0, fmt.Errorf("no project set, please run porter project set [id]")
  15. }
  16. // list oauth integrations and make sure DO exists
  17. oauthInts, err := client.ListOAuthIntegrations(context.TODO(), projectID)
  18. if err != nil {
  19. return 0, err
  20. }
  21. fmt.Println(oauthInts)
  22. // userResp, err := utils.PromptPlaintext(
  23. // fmt.Sprintf(`Porter can set up an IAM user in your AWS account to connect to this ECR instance automatically.
  24. // Would you like to proceed? %s `,
  25. // color.New(color.FgCyan).Sprintf("[y/n]"),
  26. // ),
  27. // )
  28. // if err != nil {
  29. // return 0, err
  30. // }
  31. // if userResp := strings.ToLower(userResp); userResp == "y" || userResp == "yes" {
  32. // agent := awsLocal.NewDefaultAgent()
  33. // creds, err := agent.CreateIAMECRUser(region)
  34. // if err != nil {
  35. // color.New(color.FgRed).Printf("Automatic creation failed, manual input required. Error was: %v\n", err)
  36. // return ecrManual(client, projectID, region)
  37. // }
  38. // waitForAuthorizationToken(region, creds)
  39. // integration, err := client.CreateAWSIntegration(
  40. // context.Background(),
  41. // projectID,
  42. // &api.CreateAWSIntegrationRequest{
  43. // AWSAccessKeyID: creds.AWSAccessKeyID,
  44. // AWSSecretAccessKey: creds.AWSSecretAccessKey,
  45. // AWSRegion: region,
  46. // },
  47. // )
  48. // if err != nil {
  49. // return 0, err
  50. // }
  51. // color.New(color.FgGreen).Printf("created aws integration with id %d\n", integration.ID)
  52. // return linkRegistry(client, projectID, integration.ID)
  53. // }
  54. // return ecrManual(client, projectID, region)
  55. return 0, nil
  56. }