Explorar el Código

Merge branch 'master' into belanger/add-swagger-docs

Mohammed Nafees hace 3 años
padre
commit
6adbaba229

+ 1 - 1
api/server/handlers/handler.go

@@ -21,7 +21,7 @@ type PorterHandler interface {
 		w http.ResponseWriter,
 		r *http.Request,
 		state string,
-		isUser, isProject bool,
+		isProject, isUser bool,
 		integrationClient types.OAuthIntegrationClient,
 		integrationID uint,
 	) error

+ 1 - 1
api/server/handlers/project_oauth/digitalocean.go

@@ -29,7 +29,7 @@ func NewProjectOAuthDOHandler(
 func (p *ProjectOAuthDOHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	state := oauth.CreateRandomState()
 
-	if err := p.PopulateOAuthSession(w, r, state, false, true, "", 0); err != nil {
+	if err := p.PopulateOAuthSession(w, r, state, true, false, "", 0); err != nil {
 		p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
 		return
 	}

+ 1 - 1
api/server/handlers/project_oauth/slack.go

@@ -29,7 +29,7 @@ func NewProjectOAuthSlackHandler(
 func (p *ProjectOAuthSlackHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
 	state := oauth.CreateRandomState()
 
-	if err := p.PopulateOAuthSession(w, r, state, false, true, "", 0); err != nil {
+	if err := p.PopulateOAuthSession(w, r, state, true, false, "", 0); err != nil {
 		p.HandleAPIError(w, r, apierrors.NewErrInternal(err))
 		return
 	}

+ 1 - 0
api/types/user.go

@@ -66,4 +66,5 @@ type WelcomeWebhookRequest struct {
 	IsCompany bool   `json:"isCompany" schema:"isCompany"`
 	Company   string `json:"company" schema:"company"`
 	Role      string `json:"role" schema:"role"`
+	Name      string `json:"name" schema:"name"`
 }

+ 60 - 64
dashboard/src/main/home/WelcomeForm.tsx

@@ -16,9 +16,10 @@ type StateType = {
 const WelcomeForm: React.FunctionComponent<Props> = ({}) => {
   const context = useContext(Context);
   const [active, setActive] = useState(true);
-  const [isCompany, setIsCompany] = useState(false);
-  const [role, setRole] = useState("unspecified");
+  const [isCompany, setIsCompany] = useState(true);
+  const [name, setName] = useState("");
   const [company, setCompany] = useState("");
+  const [role, setRole] = useState("unspecified");
 
   const submitForm = () => {
     api
@@ -26,6 +27,7 @@ const WelcomeForm: React.FunctionComponent<Props> = ({}) => {
         "<token>",
         {
           email: context.user && context.user.email,
+          name,
           isCompany,
           company,
           role,
@@ -40,70 +42,64 @@ const WelcomeForm: React.FunctionComponent<Props> = ({}) => {
   };
 
   const renderContents = () => {
-    if (isCompany) {
-      return (
-        <FadeWrapper>
-          <Title>Welcome to Porter</Title>
-          <Subtitle>Just two things before getting started.</Subtitle>
-          <SubtitleAlt>
-            <Num>1</Num> What is your company website? *
-          </SubtitleAlt>
-          <Input
-            placeholder="ex: https://porter.run"
-            value={company}
-            onChange={(e: any) => setCompany(e.target.value)}
-          />
-          <SubtitleAlt>
-            <Num>2</Num> What is your role? *
-          </SubtitleAlt>
-          <RadioButton
-            onClick={() => setRole("founder")}
-            selected={role === "founder"}
-          >
-            <i className="material-icons-round">
-              {role === "founder" ? "check_box" : "check_box_outline_blank"}
-            </i>{" "}
-            Founder
-          </RadioButton>
-          <RadioButton
-            onClick={() => setRole("developer")}
-            selected={role === "developer"}
-          >
-            <i className="material-icons-round">
-              {role === "developer" ? "check_box" : "check_box_outline_blank"}
-            </i>{" "}
-            Developer
-          </RadioButton>
-          <RadioButton
-            onClick={() => setRole("devops")}
-            selected={role === "devops"}
-          >
-            <i className="material-icons-round">
-              {role === "devops" ? "check_box" : "check_box_outline_blank"}
-            </i>{" "}
-            DevOps
-          </RadioButton>
-
-          <Submit
-            isDisabled={!company || role === "unspecified"}
-            onClick={() => company && role !== "unspecified" && submitForm()}
-          >
-            <i className="material-icons-round">check</i> Done
-          </Submit>
-        </FadeWrapper>
-      );
-    }
     return (
-      <>
+      <FadeWrapper>
         <Title>Welcome to Porter</Title>
-        <Subtitle delay="0.7s">I am interested in using Porter as:</Subtitle>
-        <Option onClick={() => setIsCompany(true)}>
-          <i className="material-icons-round">people</i> A Company
-        </Option>
-        <Option onClick={() => submitForm()}>
-          <i className="material-icons-round">person</i> An Individual
-        </Option>
-      </>
+        <Subtitle>Just a few things before getting started.</Subtitle>
+        <SubtitleAlt>
+          <Num>1</Num> What is your name? *
+        </SubtitleAlt>
+        <Input
+          placeholder="John Doe"
+          value={name}
+          onChange={(e: any) => setName(e.target.value)}
+        />
+        <SubtitleAlt>
+          <Num>2</Num> What is your company website? *
+        </SubtitleAlt>
+        <Input
+          placeholder="ex: https://porter.run"
+          value={company}
+          onChange={(e: any) => setCompany(e.target.value)}
+        />
+        <SubtitleAlt>
+          <Num>3</Num> What is your role? *
+        </SubtitleAlt>
+        <RadioButton
+          onClick={() => setRole("founder")}
+          selected={role === "founder"}
+        >
+          <i className="material-icons-round">
+            {role === "founder" ? "check_box" : "check_box_outline_blank"}
+          </i>{" "}
+          Founder
+        </RadioButton>
+        <RadioButton
+          onClick={() => setRole("developer")}
+          selected={role === "developer"}
+        >
+          <i className="material-icons-round">
+            {role === "developer" ? "check_box" : "check_box_outline_blank"}
+          </i>{" "}
+          Developer
+        </RadioButton>
+        <RadioButton
+          onClick={() => setRole("devops")}
+          selected={role === "devops"}
+        >
+          <i className="material-icons-round">
+            {role === "devops" ? "check_box" : "check_box_outline_blank"}
+          </i>{" "}
+          DevOps
+        </RadioButton>
+
+        <Submit
+          isDisabled={!company || role === "unspecified"}
+          onClick={() => company && role !== "unspecified" && submitForm()}
+        >
+          <i className="material-icons-round">check</i> Done
+        </Submit>
+      </FadeWrapper>
     );
   };
 

+ 1 - 0
dashboard/src/shared/api.tsx

@@ -1188,6 +1188,7 @@ const getMetadata = baseApi<{}, {}>("GET", () => {
 const postWelcome = baseApi<{
   email: string;
   isCompany: boolean;
+  name: string;
   company: string;
   role: string;
 }>("POST", () => {

+ 52 - 6
internal/registry/registry.go

@@ -682,8 +682,13 @@ func (r *Registry) listECRImages(repoName string, repo repository.Repository) ([
 
 	svc := ecr.New(sess)
 
+	maxResults := int64(1000)
+
+	var imageIDs []*ecr.ImageIdentifier
+
 	resp, err := svc.ListImages(&ecr.ListImagesInput{
 		RepositoryName: &repoName,
+		MaxResults:     &maxResults,
 	})
 
 	if err != nil {
@@ -694,9 +699,28 @@ func (r *Registry) listECRImages(repoName string, repo repository.Repository) ([
 		return []*ptypes.Image{}, nil
 	}
 
+	imageIDs = append(imageIDs, resp.ImageIds...)
+
+	nextToken := resp.NextToken
+
+	for nextToken != nil {
+		resp, err := svc.ListImages(&ecr.ListImagesInput{
+			RepositoryName: &repoName,
+			MaxResults:     &maxResults,
+		})
+
+		if err != nil {
+			return nil, err
+		}
+
+		imageIDs = append(imageIDs, resp.ImageIds...)
+		nextToken = resp.NextToken
+	}
+
 	describeResp, err := svc.DescribeImages(&ecr.DescribeImagesInput{
 		RepositoryName: &repoName,
-		ImageIds:       resp.ImageIds,
+		// MaxResults:     &maxResults,
+		ImageIds: imageIDs,
 	})
 
 	if err != nil {
@@ -705,12 +729,13 @@ func (r *Registry) listECRImages(repoName string, repo repository.Repository) ([
 
 	imageDetails := describeResp.ImageDetails
 
-	nextToken := describeResp.NextToken
+	nextToken = describeResp.NextToken
 
 	for nextToken != nil {
 		describeResp, err := svc.DescribeImages(&ecr.DescribeImagesInput{
 			RepositoryName: &repoName,
-			ImageIds:       resp.ImageIds,
+			// MaxResults:     &maxResults,
+			ImageIds: resp.ImageIds,
 		})
 
 		if err != nil {
@@ -877,10 +902,31 @@ func (r *Registry) listDOCRImages(
 
 	name := urlArr[1]
 
-	tags, _, err := client.Registry.ListRepositoryTags(context.TODO(), name, repoName, &godo.ListOptions{})
+	var tags []*godo.RepositoryTag
+	opt := &godo.ListOptions{
+		PerPage: 200,
+	}
+
+	for {
+		nextTags, resp, err := client.Registry.ListRepositoryTags(context.TODO(), name, repoName, opt)
 
-	if err != nil {
-		return nil, err
+		if err != nil {
+			return nil, err
+		}
+
+		tags = append(tags, nextTags...)
+
+		if resp.Links == nil || resp.Links.IsLastPage() {
+			break
+		}
+
+		page, err := resp.Links.CurrentPage()
+
+		if err != nil {
+			return nil, err
+		}
+
+		opt.Page = page + 1
 	}
 
 	res := make([]*ptypes.Image, 0)