Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 006 outputs api #2763

Merged
merged 33 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2488fb1
parent 8ff74f4fdff39b83db963f23e64500d4ebf823cb
Jan 10, 2023
2c02d1f
chore: update arhive test shasum to account for containerregistry man…
bdegeeter May 16, 2023
dc1480e
chore: address lint issues
bdegeeter May 17, 2023
9e4c1c0
Bump github.com/docker/cli
dependabot[bot] May 14, 2023
caf1e76
Bump go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp
dependabot[bot] May 7, 2023
9a451ff
Update CODEOWNERS
schristoff May 17, 2023
d1f94de
Bump github.com/docker/distribution
dependabot[bot] May 11, 2023
63c65dd
Adds custom section to output
tompaana May 22, 2023
8d1623a
Restores mixins in table output
tompaana May 23, 2023
8984cee
Removes commented out line
tompaana May 23, 2023
d4974ae
Minor fix
tompaana May 23, 2023
8085119
Done it the proper way this time I think
tompaana May 23, 2023
529fa18
Modifies test data to support custom output
tompaana May 23, 2023
b08a1f5
Fixes order in expected output as it is sorted
tompaana May 23, 2023
79afd0f
Updates porter explain documentation
tompaana May 23, 2023
109a73f
Adding my name to the list of contributors
tompaana May 23, 2023
f1446e8
Fixes based in review
tompaana May 24, 2023
05d34f2
Grammar fix
tompaana May 24, 2023
8763ddd
update hugo to v0.112.7
Arhell Jun 5, 2023
c26ca16
Bump github.com/docker/docker
dependabot[bot] May 14, 2023
9b89b32
update helm3 mixin link and changed client version in docs
troy0820 Jun 8, 2023
1b79fa2
add troy0820 to contributors
troy0820 Jun 8, 2023
311f2dd
chore: basic repo structure for grpc api
Jan 10, 2023
7ab9361
chore: go mod tidy
bdegeeter Jun 8, 2023
ff220e2
chore: fixes for integration tests
bdegeeter Jun 8, 2023
c5834b1
chore: fix mage imports
bdegeeter Jun 8, 2023
6b2b29c
Merge branch 'main' into pep-006-outputs-api
bdegeeter Jun 8, 2023
ba15bfd
chore: build flags for grpc service and other PR feedback
bdegeeter Jun 11, 2023
a3d0462
chore: rename grpc-server to api-server
bdegeeter Jun 11, 2023
16277ac
Merge branch 'main' into pep-006-outputs-api
bdegeeter Jun 11, 2023
f6595ea
chore: address lint issues
bdegeeter Jun 11, 2023
450a4b7
docs: Added docstring to porter server struct and middleware
sgettys Jun 11, 2023
6d5fd72
chore: cleanup signals based on pr feedback
bdegeeter Jun 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
*

!bin/dev/porter-linux-amd64
!bin/dev/porter-linux-arm64
!bin/dev/agent-linux-amd64
!bin/dev/agent-linux-arm64
!bin/mixins/exec/dev/exec-linux-amd64
!bin/mixins/exec/dev/exec-linux-arm64
36 changes: 36 additions & 0 deletions .github/workflows/build-publish-from-fork.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: build-publish-from-fork
on:
workflow_dispatch: {}
push: {}
pull_request: {}

jobs:
build:
runs-on: ubuntu-latest
if: github.repository != 'getporter/porter'
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- uses: actions/setup-go@v3
with:
go-version-file: go.mod
cache: true
cache-dependency-path: go.sum
- name: Set up Mage
run: go run mage.go EnsureMage
- name: Publish
if: ${{ github.event_name != 'pull_request' }}
env:
PORTER_REGISTRY: ghcr.io/${{ github.repository }}
run: |
mage -v XBuildAll
mage -v PublishServerMultiArchImages
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@ examples/**/Dockerfile
workshop/**/Dockerfile

.vscode
*.code-workspace
.idea
kind.config
grpc-porter-tls.crt
grpc-porter-tls.key
grpc-porter.csr
.grpcurl/
config.yaml
29 changes: 29 additions & 0 deletions build/images/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM alpine:3 as builder
WORKDIR /app/.porter
ARG TARGETARCH

RUN mkdir runtimes && \
mkdir -p mixins/exec/runtimes

# Install porter, agent, and the exec mixin, everything else
# must be mounted into the container
COPY bin/dev/porter-linux-${TARGETARCH} porter
COPY bin/dev/agent-linux-${TARGETARCH} agent
COPY bin/mixins/exec/dev/exec-linux-${TARGETARCH} mixins/exec/exec
RUN ln -s /app/.porter/porter runtimes/porter-runtime && \
ln -s /app/.porter/mixins/exec/exec mixins/exec/runtimes/exec-runtime

# Copy the porter installation into a distroless container
# Explicitly not using the nonroot tag because we don't want the user to exist so it is placed in the root group
# This allows us to run with a random UID, and access a mounted docker socket (which is only accessible via the root group)
FROM gcr.io/distroless/static
WORKDIR /app
COPY --from=builder --chown=65532:0 --chmod=770 /app/.porter /app/.porter
ENV PATH "$PATH:/app/.porter"
# This is where files that need to be copied into /app/.porter/ should be mounted
VOLUME /porter-config
ENV PORTER_HOME /app/.porter

# Run as a nonroot user
USER 65532
ENTRYPOINT ["/app/.porter/agent"]
5 changes: 5 additions & 0 deletions build/protoc.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM golang:1.19.0
RUN apt-get update && apt-get -y install protobuf-compiler
RUN go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
RUN go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
WORKDIR /proto
1 change: 1 addition & 0 deletions cmd/porter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ Try our QuickStart https://getporter.org/quickstart to learn how to use Porter.
cmd.AddCommand(buildCredentialsCommands(p))
cmd.AddCommand(buildParametersCommands(p))
cmd.AddCommand(buildCompletionCommand(p))
cmd.AddCommand(buildServerCommands(p))

for _, alias := range buildAliasCommands(p) {
cmd.AddCommand(alias)
Expand Down
58 changes: 58 additions & 0 deletions cmd/porter/server.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package main

import (
"time"

grpc "get.porter.sh/porter/pkg/grpc"
"get.porter.sh/porter/pkg/porter"
"get.porter.sh/porter/pkg/signals"
"github.com/spf13/cobra"
)

func buildServerCommands(p *porter.Porter) *cobra.Command {
bdegeeter marked this conversation as resolved.
Show resolved Hide resolved
cmd := &cobra.Command{
Use: "server",
Short: "Server commands",
Long: "Command for working with the gRPC server for porter",
Hidden: true, // This is a hidden command and is currently only meant to be used by the porter operator
}
cmd.Annotations = map[string]string{
"group": "server",
}
cmd.AddCommand(buildServerRunCommand(p))
return cmd
}

func buildServerRunCommand(p *porter.Porter) *cobra.Command {
opts := porter.ServiceOptions{}
cmd := &cobra.Command{
Use: "run",
Short: "Run the gRPC server",
Long: `Run the gRPC server for porter.

This command starts the gRPC server for porter which is able to expose limited porter functionality via RPC.
Currently only data operations are supported, creation of resources such as installations, credential sets, or parameter sets is not supported.

A list of the supported RPCs can be found at <link?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

porter -> Porter (it is the nittiest of nits, but I only included it because I'm going to point out....) -> and <link?> ?

`,
PreRunE: func(cmd *cobra.Command, args []string) error {
return opts.Validate()
},
RunE: func(cmd *cobra.Command, args []string) error {
srv, err := grpc.NewServer(cmd.Context(), &opts)
if err != nil {
return err
}
grpcServer, err := srv.ListenAndServe()
stopCh := signals.SetupSignalHandler()
serverShutdownTimeout := time.Duration(time.Second * 30)
sd, _ := signals.NewShutdown(serverShutdownTimeout, cmd.Context())
sd.Graceful(stopCh, grpcServer, cmd.Context())
return err
},
}
f := cmd.Flags()
f.Int64VarP(&opts.Port, "port", "p", 3001, "Port to run the server on")
f.StringVarP(&opts.ServiceName, "service-name", "s", "grpc-server", "Server service name")
return cmd
}
19 changes: 19 additions & 0 deletions docker-bake.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"group": {
"default": {
"targets": [
"server"
]
}
},
"target": {
"server": {
"platforms": [
"linux/amd64",
"linux/arm64"
],
"dockerfile": "build/images/server/Dockerfile",
"context": "./"
}
}
}
Loading
Loading