Преглед изворни кода

add dockerhub as integration service, customize connect dockerhub command

Alexander Belanger пре 5 година
родитељ
комит
fb0d2f20bc
3 измењених фајлова са 24 додато и 16 уклоњено
  1. 7 4
      cli/cmd/connect/dockerhub.go
  2. 13 12
      internal/models/integrations/integration.go
  3. 4 0
      internal/models/registry.go

+ 7 - 4
cli/cmd/connect/dockerhub.go

@@ -18,20 +18,23 @@ func Dockerhub(
 		return 0, fmt.Errorf("no project set, please run porter project set [id]")
 	}
 
-	// query for helm repo name
-	repoName, err := utils.PromptPlaintext(fmt.Sprintf(`Provide the image path: `))
+	// query for dockerhub name
+
+	repoName, err := utils.PromptPlaintext(fmt.Sprintf(`Provide the Docker Hub image path, in the form of ${org_name}/${repo_name}. For example, porter1/porter.
+Image path: `))
 
 	if err != nil {
 		return 0, err
 	}
 
-	username, err := utils.PromptPlaintext(fmt.Sprintf(`Username: `))
+	username, err := utils.PromptPlaintext(fmt.Sprintf(`Docker Hub username: `))
 
 	if err != nil {
 		return 0, err
 	}
 
-	password, err := utils.PromptPasswordWithConfirmation()
+	password, err := utils.PromptPassword(`Provide the Docker Hub personal access token.
+Token:`)
 
 	if err != nil {
 		return 0, err

+ 13 - 12
internal/models/integrations/integration.go

@@ -5,18 +5,19 @@ type IntegrationService string
 
 // The list of supported third-party services
 const (
-	GKE      IntegrationService = "gke"
-	DOKS     IntegrationService = "doks"
-	GCS      IntegrationService = "gcs"
-	S3       IntegrationService = "s3"
-	HelmRepo IntegrationService = "helm"
-	EKS      IntegrationService = "eks"
-	Kube     IntegrationService = "kube"
-	GCR      IntegrationService = "gcr"
-	ECR      IntegrationService = "ecr"
-	DOCR     IntegrationService = "docr"
-	Github   IntegrationService = "github"
-	Docker   IntegrationService = "docker"
+	GKE       IntegrationService = "gke"
+	DOKS      IntegrationService = "doks"
+	GCS       IntegrationService = "gcs"
+	S3        IntegrationService = "s3"
+	HelmRepo  IntegrationService = "helm"
+	EKS       IntegrationService = "eks"
+	Kube      IntegrationService = "kube"
+	GCR       IntegrationService = "gcr"
+	ECR       IntegrationService = "ecr"
+	DOCR      IntegrationService = "docr"
+	Github    IntegrationService = "github"
+	DockerHub IntegrationService = "dockerhub"
+	Docker    IntegrationService = "docker"
 )
 
 // PorterIntegration is a supported integration service, specifying an auth

+ 4 - 0
internal/models/registry.go

@@ -1,6 +1,8 @@
 package models
 
 import (
+	"strings"
+
 	"github.com/porter-dev/porter/internal/models/integrations"
 	"gorm.io/gorm"
 )
@@ -65,6 +67,8 @@ func (r *Registry) Externalize() *RegistryExternal {
 		serv = integrations.GCR
 	} else if r.DOIntegrationID != 0 {
 		serv = integrations.DOCR
+	} else if strings.Contains(r.URL, "index.docker.io") {
+		serv = integrations.DockerHub
 	}
 
 	return &RegistryExternal{