1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-03-29 20:39:48 +02:00

Fix Skaffold pipelines for client projects (#2244)

* Update greeter references to helloworld

* Add new client command

With this change, Gomu users will be able to generate template projects
for clients to services. Additionally vendor support has been built in
so Gomu users can now generate projects using fully qualified package
names, for example:

```bash
gomu new service github.com/auditemarlow/helloworld
```

This will create a new service project `helloworld` with its module name
already set to `github.com/auditemarlow/helloworld`. Likewise, Gomu
users can then generate client projects in the same manner:

```bash
gomu new client github.com/auditemarlow/helloworld
```

This will create a `helloworld-client` project that uses the protobufs
found in the `github.com/auditemarlow/helloworld` service. This removes
at least some strain in configuring these module dependencies yourself;
you can just scaffold them outright from the start.

Although the default client project is highly opinionated, it works
straight out of the box and has Skaffold in mind. Gomu users should be
able to get going in a matter of seconds.

* Update README

* Fix Skaffold pipeline for generated client projects
This commit is contained in:
Niek den Breeje 2021-09-03 14:26:34 +02:00 committed by GitHub
parent 86de031adc
commit c45073a308
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 13 deletions

View File

@ -29,6 +29,7 @@ type config struct {
Comments []string
Dir string
Vendor string
Client bool
Jaeger bool
Skaffold bool
}
@ -148,6 +149,7 @@ func createProject(ctx *cli.Context, pt string) error {
Alias: name,
Dir: dir,
Vendor: vendor,
Client: pt == "client",
Jaeger: ctx.Bool("jaeger"),
Skaffold: ctx.Bool("skaffold"),
}

View File

@ -6,7 +6,7 @@ ENV CGO_ENABLED=0 GOOS=linux
WORKDIR /go/src/{{.Alias}}
RUN apk --update --no-cache add ca-certificates gcc libtool make musl-dev protoc
COPY . /go/src/{{.Alias}}
RUN make init proto tidy build
RUN make {{if not .Client}}init proto {{end}}tidy build
FROM scratch
COPY --from=builder /etc/ssl/certs /etc/ssl/certs

View File

@ -7,7 +7,7 @@ var KubernetesEnv = `---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{.Alias}}-env
name: {{.Dir}}-env
data:
MICRO_REGISTRY: kubernetes
`
@ -56,23 +56,23 @@ var KubernetesDeployment = `---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{.Alias}}
name: {{.Dir}}
labels:
app: {{.Alias}}
app: {{.Dir}}
spec:
replicas: 1
selector:
matchLabels:
app: {{.Alias}}
app: {{.Dir}}
template:
metadata:
labels:
app: {{.Alias}}
app: {{.Dir}}
spec:
containers:
- name: {{.Alias}}
image: {{.Alias}}:latest
- name: {{.Dir}}
image: {{.Dir}}:latest
envFrom:
- configMapRef:
name: {{.Alias}}-env
name: {{.Dir}}-env
`

View File

@ -11,7 +11,7 @@ require (
// This can be removed once etcd becomes go gettable, version 3.4 and 3.5 is not,
// see https://github.com/etcd-io/etcd/issues/11154 and https://github.com/etcd-io/etcd/issues/11931.
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0{{if .Vendor}}
replace google.golang.org/grpc => google.golang.org/grpc v1.26.0{{if .Vendor}}{{if not .Skaffold}}
replace {{.Vendor}}{{lower .Alias}} => ../{{lower .Alias}}{{end}}
replace {{.Vendor}}{{lower .Alias}} => ../{{lower .Alias}}{{end}}{{end}}
`

View File

@ -6,10 +6,10 @@ var SkaffoldCFG = `---
apiVersion: skaffold/v2beta21
kind: Config
metadata:
name: {{.Alias}}
name: {{.Dir}}
build:
artifacts:
- image: {{.Alias}}
- image: {{.Dir}}
deploy:
kubectl:
manifests: