3 Commits

Author SHA1 Message Date
7e78b271f4 add opts struct to class logo method
All checks were successful
Build and Publish / check-chart (push) Successful in 14s
Build and Publish / helm-release (push) Successful in 59s
Build and Publish / release (push) Successful in 3m46s
2025-07-08 20:44:24 -04:00
d5abda89a1 update Dockerfile
All checks were successful
Build and Publish / check-chart (push) Successful in 16s
Build and Publish / helm-release (push) Successful in 52s
Build and Publish / release (push) Successful in 3m44s
2025-07-08 17:13:29 -04:00
02dc08fb1e update Dockerfile 2025-07-08 17:13:07 -04:00
4 changed files with 27 additions and 10 deletions

View File

@ -22,6 +22,6 @@ ARG APP_NAME=class-server
WORKDIR /app WORKDIR /app
USER 100:101 USER 100:101
COPY --from=build --chown=100:101 /app/${APP_NAME} /app/ COPY --from=build --chown=100:101 /app/${APP_NAME} /app/app
ENTRYPOINT [ "/app/${APP_NAME}" ] ENTRYPOINT [ "/app/app" ]

View File

@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/) # Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.3 version: 0.1.4
# This is the version number of the application being deployed. This version number should be # This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to # incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using. # follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes. # It is recommended to use it with quotes.
appVersion: "v0.1.1" appVersion: "v0.2.0"
dependencies: dependencies:
- name: hull - name: hull

View File

@ -23,6 +23,7 @@ import (
optsgrpc "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts" optsgrpc "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/grpc/opts"
optshttp "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts" optshttp "gitea.libretechconsulting.com/rmcguire/go-app/pkg/srv/http/opts"
class "gitea.libretechconsulting.com/rmcguire/class-server/api/class/v1alpha1"
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/classgrpc" "gitea.libretechconsulting.com/rmcguire/class-server/pkg/classgrpc"
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/config" "gitea.libretechconsulting.com/rmcguire/class-server/pkg/config"
"gitea.libretechconsulting.com/rmcguire/class-server/pkg/demogrpc" "gitea.libretechconsulting.com/rmcguire/class-server/pkg/demogrpc"
@ -52,7 +53,11 @@ func main() {
demoHTTP := demohttp.NewDemoHTTPServer(ctx, demoApp) demoHTTP := demohttp.NewDemoHTTPServer(ctx, demoApp)
demoGRPC := demogrpc.NewDemoGRPCServer(ctx, demoApp) demoGRPC := demogrpc.NewDemoGRPCServer(ctx, demoApp)
classGRPC := classgrpc.New(ctx) classGRPC := classgrpc.New(&classgrpc.ClassServiceOpts{
Ctx: ctx,
Font: class.Font_FONT_AVATAR,
Text: "Indiana Tech Net 1500",
})
// Prepare app // Prepare app
app := &app.App{ app := &app.App{

View File

@ -1,3 +1,5 @@
// Package classgrpc provides demonstrative rpc implementation for class server
// TODO: Move font and text to ClassServiceOpts in New() and use
package classgrpc package classgrpc
import ( import (
@ -12,16 +14,24 @@ import (
type ClassService struct { type ClassService struct {
class.UnimplementedClassServiceServer class.UnimplementedClassServiceServer
ctx context.Context ctx context.Context
font class.Font
text string
}
type ClassServiceOpts struct {
Ctx context.Context
Font class.Font
Text string
} }
var DefaultFont = class.Font_FONT_BARBWIRE var DefaultFont = class.Font_FONT_BARBWIRE
func (s *ClassService) GetClassLogo(ctx context.Context, req *class.GetClassLogoRequest) (*class.GetClassLogoResponse, error) { func (s *ClassService) GetClassLogo(ctx context.Context, req *class.GetClassLogoRequest) (*class.GetClassLogoResponse, error) {
if req.GetFont() == class.Font_FONT_UNSPECIFIED { if req.GetFont() == class.Font_FONT_UNSPECIFIED {
req.Font = DefaultFont req.Font = s.font
} }
f := figure.NewFigure("Indiana Tech", getFontString(req.GetFont()), false) f := figure.NewFigure(s.text, getFontString(req.GetFont()), false)
resp := &class.GetClassLogoResponse{ resp := &class.GetClassLogoResponse{
LogoBytes: []byte(f.String()), LogoBytes: []byte(f.String()),
@ -38,8 +48,10 @@ func getFontString(font class.Font) string {
return strings.ToLower(strings.ReplaceAll(font.String(), "FONT_", "")) return strings.ToLower(strings.ReplaceAll(font.String(), "FONT_", ""))
} }
func New(ctx context.Context) *ClassService { func New(opts *ClassServiceOpts) *ClassService {
return &ClassService{ return &ClassService{
ctx: ctx, ctx: opts.Ctx,
font: opts.Font,
text: opts.Text,
} }
} }