Просмотр исходного кода

Merge branch 'master' into sms/helm-convert

Stefan McShane 2 лет назад
Родитель
Сommit
03181a0a29

+ 39 - 0
.github/actions/build-go/action.yml

@@ -0,0 +1,39 @@
+---
+name: 'build-go'
+description: builds the go binaries for the app
+
+runs:
+  using: "composite"
+  steps:
+    - name: Setup Go Cache
+      uses: actions/cache@v3
+      with:
+        path: |
+          ~/.cache/go-build
+          ~/go/pkg/mod
+        key: porter-go-${{ hashFiles('**/go.sum') }}
+        restore-keys: porter-go-`
+    - name: Setup Go
+      uses: actions/setup-go@v4
+      with:
+        cache: false
+        go-version-file: go.mod
+    - name: Download Go Modules
+      shell: bash
+      run: go mod download
+    - name: Build Server Binary
+      shell: bash
+      run: go build -ldflags="-w -s -X 'main.Version=production'" -tags ee -o ./bin/app ./cmd/app
+    - name: Build Migration Binary
+      shell: bash
+      run: go build -ldflags '-w -s' -tags ee -o ./bin/migrate ./cmd/migrate
+    - name: Compress binaries
+      shell: bash
+      run: |
+        upx bin/* --best --lzma
+    - name: Store Binaries
+      uses: actions/upload-artifact@v3
+      with:
+        name: go-binaries
+        path: bin/
+        retention-days: 1

+ 27 - 0
.github/actions/build-npm/action.yml

@@ -0,0 +1,27 @@
+---
+name: 'build-npm'
+description: builds the static dashboard files for the app
+
+runs:
+  using: "composite"
+  steps:
+    - name: Setup Node
+      uses: actions/setup-node@v3
+      with:
+        node-version: 16
+    - name: Install NPM Dependencies
+      shell: bash
+      run: |
+        cd dashboard
+        npm i --legacy-peer-deps
+    - name: Run NPM Build
+      shell: bash
+      run: |
+        cd dashboard
+        npm run build
+    - name: Store NPM Static Files
+      uses: actions/upload-artifact@v3
+      with:
+        name: npm-static-files
+        path: dashboard/build/
+        retention-days: 1

+ 49 - 0
.github/actions/porter-deploy/action.yml

@@ -0,0 +1,49 @@
+---
+name: 'porter-deploy'
+description: deploys porter
+
+inputs:
+  app:
+    description: 'app to deploy'
+    required: true
+  cluster:
+    description: 'cluster to deploy to'
+    required: true
+  host:
+    description: 'project to deploy to'
+    required: true
+  project:
+    description: 'project to deploy to'
+    required: true
+  token:
+    description: 'porter deploy api token'
+    required: true
+
+runs:
+  using: "composite"
+  steps:
+    - name: Get Go Binaries
+      uses: actions/download-artifact@v3
+      with:
+        name: go-binaries
+        path: bin/
+    - name: Get NPM static files
+      uses: actions/download-artifact@v3
+      with:
+        name: npm-static-files
+        path: build/
+    - name: Set Github tag
+      shell: bash
+      id: vars
+      run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
+    - name: Deploy stack
+      uses: porter-dev/porter-cli-action@v0.1.0
+      with:
+        command: apply
+      env:
+        PORTER_CLUSTER: "${{ inputs.cluster }}"
+        PORTER_HOST: "${{ inputs.host }}"
+        PORTER_PROJECT: "${{ inputs.project }}"
+        PORTER_STACK_NAME: "${{ inputs.app }}"
+        PORTER_TAG: ${{ steps.vars.outputs.sha_short }}
+        PORTER_TOKEN: "${{ inputs.token }}"

+ 13 - 70
.github/workflows/porter_stack_porter-ui.yml

@@ -9,86 +9,29 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v3
-      - name: Setup Go Cache
-        uses: actions/cache@v3
-        with:
-          path: |
-            ~/.cache/go-build
-            ~/go/pkg/mod
-          key: porter-go-${{ hashFiles('**/go.sum') }}
-          restore-keys: porter-go-`
-      - name: Setup Go
-        uses: actions/setup-go@v4
-        with:
-          cache: false
-          go-version: '1.20.5'
-          go-version-file: go.mod
-      - name: Download Go Modules
-        run: go mod download
-      - name: Build Server Binary
-        run: go build -ldflags="-w -s -X 'main.Version=production'" -tags ee -o ./bin/app ./cmd/app
-      - name: Build Migration Binary
-        run: go build -ldflags '-w -s' -tags ee -o ./bin/migrate ./cmd/migrate
-      - name: Compress binaries
-        run: |
-          upx bin/* --best --lzma
-      - name: Store Binaries
-        uses: actions/upload-artifact@v3
-        with:
-          name: go-binaries
-          path: bin/
-          retention-days: 1
+      - name: build-go
+        uses: ./.github/actions/build-go
+
   build-npm:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout code
         uses: actions/checkout@v3
-      - name: Setup Node
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16
-      - name: Install NPM Dependencies
-        run: |
-          cd dashboard
-          npm i --legacy-peer-deps
-      - name: Run NPM Build
-        run: |
-          cd dashboard
-          npm run build
-      - name: Store NPM Static Files
-        uses: actions/upload-artifact@v3
-        with:
-          name: npm-static-files
-          path: dashboard/build/
-          retention-days: 1
+      - name: build-npm
+        uses: ./.github/actions/build-npm
+
   porter-deploy:
     runs-on: ubuntu-latest
     needs: [build-go, build-npm]
     steps:
       - name: Checkout code
         uses: actions/checkout@v3
-      - name: Get Go Binaries
-        uses: actions/download-artifact@v3
-        with:
-          name: go-binaries
-          path: bin/
-      - name: Get NPM static files
-        uses: actions/download-artifact@v3
-        with:
-          name: npm-static-files
-          path: build/
-      - name: Set Github tag
-        id: vars
-        run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
-      - name: Deploy stack
+      - name: porter-deploy
         timeout-minutes: 30
-        uses: porter-dev/porter-cli-action@v0.1.0
+        uses: ./.github/actions/porter-deploy
         with:
-          command: apply
-        env:
-          PORTER_CLUSTER: "11"
-          PORTER_HOST: https://dashboard.internal-tools.porter.run
-          PORTER_PROJECT: "8"
-          PORTER_STACK_NAME: porter-ui
-          PORTER_TAG: ${{ steps.vars.outputs.sha_short }}
-          PORTER_TOKEN: ${{ secrets.PORTER_STACK_8_11 }}
+          app: porter-ui
+          cluster: "11"
+          host: https://dashboard.internal-tools.porter.run
+          project: "8"
+          token: ${{ secrets.PORTER_STACK_8_11 }}

+ 4 - 46
.github/workflows/production.yml

@@ -9,57 +9,15 @@ jobs:
     steps:
       - name: Checkout code
         uses: actions/checkout@v3
-      - name: Setup Go Cache
-        uses: actions/cache@v3
-        with:
-          path: |
-            ~/.cache/go-build
-            ~/go/pkg/mod
-          key: porter-go-${{ hashFiles('**/go.sum') }}
-          restore-keys: porter-go-`
-      - name: Setup Go
-        uses: actions/setup-go@v4
-        with:
-          cache: false
-          go-version-file: go.mod
-      - name: Download Go Modules
-        run: go mod download
-      - name: Build Server Binary
-        run: go build -ldflags="-w -s -X 'main.Version=production'" -tags ee -o ./bin/app ./cmd/app
-      - name: Build Migration Binary
-        run: go build -ldflags '-w -s' -tags ee -o ./bin/migrate ./cmd/migrate
-      - name: Compress binaries
-        run: |
-          upx bin/* --best --lzma
-      - name: Store Binaries
-        uses: actions/upload-artifact@v3
-        with:
-          name: go-binaries
-          path: bin/
-          retention-days: 1
+      - name: build-go
+        uses: ./.github/actions/build-go
   build-npm:
     runs-on: ubuntu-latest
     steps:
       - name: Checkout code
         uses: actions/checkout@v3
-      - name: Setup Node
-        uses: actions/setup-node@v3
-        with:
-          node-version: 16
-      - name: Install NPM Dependencies
-        run: |
-          cd dashboard
-          npm i --legacy-peer-deps
-      - name: Run NPM Build
-        run: |
-          cd dashboard
-          npm run build
-      - name: Store NPM Static Files
-        uses: actions/upload-artifact@v3
-        with:
-          name: npm-static-files
-          path: dashboard/build/
-          retention-days: 1
+      - name: build-npm
+        uses: ./.github/actions/build-npm
   porter-deploy:
     runs-on: ubuntu-latest
     needs: [build-go, build-npm]

+ 2 - 0
api/client/porter_app.go

@@ -154,11 +154,13 @@ func (c *Client) ParseYAML(
 	ctx context.Context,
 	projectID, clusterID uint,
 	b64Yaml string,
+	appName string,
 ) (*porter_app.ParsePorterYAMLToProtoResponse, error) {
 	resp := &porter_app.ParsePorterYAMLToProtoResponse{}
 
 	req := &porter_app.ParsePorterYAMLToProtoRequest{
 		B64Yaml: b64Yaml,
+		AppName: appName,
 	}
 
 	err := c.postRequest(

+ 2 - 1
cli/cmd/v2/apply.go

@@ -35,7 +35,8 @@ func Apply(ctx context.Context, cliConf config.CLIConfig, client api.Client, por
 
 	b64YAML := base64.StdEncoding.EncodeToString(porterYaml)
 
-	parseResp, err := client.ParseYAML(ctx, cliConf.Project, cliConf.Cluster, b64YAML)
+	// last argument is passed to accommodate users with v1 porter yamls
+	parseResp, err := client.ParseYAML(ctx, cliConf.Project, cliConf.Cluster, b64YAML, os.Getenv("PORTER_STACK_NAME"))
 	if err != nil {
 		return fmt.Errorf("error calling parse yaml endpoint: %w", err)
 	}

+ 16 - 2
dashboard/src/components/porter/Text.tsx

@@ -7,6 +7,7 @@ type Props = {
   weight?: number;
   children: any;
   additionalStyles?: string;
+  truncate?: boolean;
 };
 
 const Text: React.FC<Props> = ({
@@ -14,7 +15,8 @@ const Text: React.FC<Props> = ({
   weight,
   color,
   children,
-  additionalStyles
+  additionalStyles,
+  truncate // added this
 }) => {
   const getColor = () => {
     switch (color) {
@@ -31,6 +33,7 @@ const Text: React.FC<Props> = ({
       color={getColor()}
       weight={weight}
       additionalStyles={additionalStyles}
+      truncate={truncate}
     >
       {children}
     </StyledText>
@@ -44,6 +47,7 @@ const StyledText = styled.div<{
   color?: string;
   weight?: number;
   additionalStyles?: string;
+  truncate?: boolean;
 }>`
   line-height: 1.5;
   font-weight: ${props => props.weight || 400};
@@ -53,4 +57,14 @@ const StyledText = styled.div<{
   align-items: center;
   user-select: text;
   ${props => props.additionalStyles ? props.additionalStyles : ""}
-`;
+
+  ${props =>
+    props.truncate
+      ? `
+        white-space: nowrap;
+        overflow: hidden;
+        text-overflow: ellipsis;
+        max-width: 90%; 
+      `
+      : ""}
+`;

+ 1 - 2
dashboard/src/main/home/app-dashboard/AppDashboard.tsx

@@ -153,7 +153,7 @@ const AppDashboard: React.FC<Props> = ({ }) => {
               height="18px"
               src="https://cdn4.iconfinder.com/data/icons/logos-and-brands/512/97_Docker_logo_logos-512.png"
             />
-            <Text size={13} color="#ffffff44">{app.image_repo_uri}</Text>
+            <Text truncate={true} size={13} color="#ffffff44">{app.image_repo_uri}</Text>
           </Container>
         )}
       </>
@@ -420,7 +420,6 @@ const Block = styled.div`
   :hover {
     border: 1px solid #7a7b80;
   }
-
   animation: fadeIn 0.3s 0s;
   @keyframes fadeIn {
     from {