Skip to content

Commit

Permalink
technical debt
Browse files Browse the repository at this point in the history
  • Loading branch information
e154 committed Jan 3, 2024
1 parent 607d244 commit 58afb36
Show file tree
Hide file tree
Showing 122 changed files with 714 additions and 172 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.0
go-version: 1.21.0

- name: Set up Node
uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.0
go-version: 1.21.0

- name: Install linter
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.20.0
go-version: 1.21.0

- name: Set up Node
uses: actions/setup-node@v2
Expand Down
2 changes: 1 addition & 1 deletion Makefile.local
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test:
go test -race $(go list ./... | grep -v /tests/)

install_linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.45.0
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.55.2

lint-todo:
@echo MARK: make lint todo
Expand Down
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ func (a *Api) registerHandlers() {
v1.PUT("/plugin/:name/settings", a.echoFilter.Auth(wrapper.PluginServiceUpdatePluginSettings))
v1.GET("/plugins", a.echoFilter.Auth(wrapper.PluginServiceGetPluginList))
v1.GET("/plugins/search", a.echoFilter.Auth(wrapper.PluginServiceSearchPlugin))
v1.GET("/plugin/:name/readme", a.echoFilter.Auth(wrapper.PluginServiceGetPluginReadme))
v1.POST("/role", a.echoFilter.Auth(wrapper.RoleServiceAddRole))
v1.DELETE("/role/:name", a.echoFilter.Auth(wrapper.RoleServiceDeleteRoleByName))
v1.GET("/role/:name", a.echoFilter.Auth(wrapper.RoleServiceGetRoleByName))
Expand Down
33 changes: 33 additions & 0 deletions api/api.swagger3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2433,6 +2433,39 @@ paths:
$ref: '#/components/responses/HTTP-409'
security:
- ApiKeyAuth: [ ]
/v1/plugin/{name}/readme:
get:
tags:
- PluginService
summary: get plugin readme
operationId: PluginService_GetPluginReadme
parameters:
- name: name
in: path
required: true
schema:
type: string
- name: lang
in: query
required: false
schema:
type: string
- $ref: '#/components/parameters/Accept-JSON'
responses:
200:
description: A successful response.
content:
text/plain:
schema:
type: string
'400':
$ref: '#/components/responses/HTTP-400'
'401':
$ref: '#/components/responses/HTTP-401'
'404':
$ref: '#/components/responses/HTTP-404'
security:
- ApiKeyAuth: [ ]
/v1/plugins:
get:
tags:
Expand Down
11 changes: 11 additions & 0 deletions api/controllers/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,14 @@ func (c ControllerPlugin) PluginServiceUpdatePluginSettings(ctx echo.Context, na

return c.HTTP200(ctx, ResponseWithObj(ctx, struct{}{}))
}

// PluginServiceGetPluginReadme ...
func (c ControllerPlugin) PluginServiceGetPluginReadme(ctx echo.Context, name string, params stub.PluginServiceGetPluginReadmeParams) error {

html, err := c.endpoint.Plugin.Readme(ctx.Request().Context(), name, params.Lang)
if err != nil {
return c.ERROR(ctx, err)
}

return ctx.HTMLBlob(200, html)
}
48 changes: 48 additions & 0 deletions api/stub/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/stub/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion doc/content/en/docs/plugins/weather/met.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

---
title: "Met"
title: "MET"
linkTitle: "met"
date: 2021-10-20
description: >
Expand Down
2 changes: 1 addition & 1 deletion doc/content/en/docs/plugins/weather/owm.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

---
title: "Met"
title: "OWM"
linkTitle: "met"
date: 2021-10-20
description: >
Expand Down
2 changes: 1 addition & 1 deletion doc/content/ru/docs/plugins/weather/met.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

---
title: "Met"
title: "MET"
linkTitle: "met"
date: 2021-10-20
description: >
Expand Down
2 changes: 1 addition & 1 deletion doc/content/ru/docs/plugins/weather/owm.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

---
title: "Met"
title: "OWM"
linkTitle: "met"
date: 2021-10-20
description: >
Expand Down
22 changes: 14 additions & 8 deletions endpoint/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ package endpoint

import (
"context"

"github.com/pkg/errors"

"github.com/e154/smart-home/common"
Expand Down Expand Up @@ -92,34 +91,41 @@ func (p *PluginEndpoint) GetByName(ctx context.Context, pluginName string) (plug
}

// Search ...
func (n *PluginEndpoint) Search(ctx context.Context, query string, limit, offset int64) (result []*m.Plugin, total int64, err error) {
func (p *PluginEndpoint) Search(ctx context.Context, query string, limit, offset int64) (result []*m.Plugin, total int64, err error) {

result, total, err = n.adaptors.Plugin.Search(ctx, query, limit, offset)
result, total, err = p.adaptors.Plugin.Search(ctx, query, limit, offset)
if err != nil {
err = errors.Wrap(apperr.ErrInternal, err.Error())
}
return
}

// UpdateSettings ...
func (n *PluginEndpoint) UpdateSettings(ctx context.Context, name string, settings m.Attributes) (err error) {
func (p *PluginEndpoint) UpdateSettings(ctx context.Context, name string, settings m.Attributes) (err error) {

var plugin *m.Plugin
if plugin, err = n.adaptors.Plugin.GetByName(ctx, name); err != nil {
if plugin, err = p.adaptors.Plugin.GetByName(ctx, name); err != nil {
return
}

plugin.Settings = settings.Serialize()

if err = n.adaptors.Plugin.Update(ctx, plugin); err != nil {
if err = p.adaptors.Plugin.Update(ctx, plugin); err != nil {
return
}

if err = n.supervisor.DisablePlugin(ctx, name); err != nil {
if err = p.supervisor.DisablePlugin(ctx, name); err != nil {
return
}

err = n.supervisor.EnablePlugin(ctx, name)
err = p.supervisor.EnablePlugin(ctx, name)

return
}

func (p *PluginEndpoint) Readme(ctx context.Context, name string, lang *string) (result []byte, err error) {

result, err = p.supervisor.GetPluginReadme(ctx, name, lang)

return
}
28 changes: 3 additions & 25 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/e154/smart-home

go 1.20
go 1.21

toolchain go1.21.1

require (
github.com/DrmagicE/gmqtt v0.5.0
Expand Down Expand Up @@ -92,38 +94,26 @@ require (
github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 // indirect
github.com/CloudyKit/jet/v6 v6.2.0 // indirect
github.com/Joker/jade v1.1.3 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.2.0 // indirect
github.com/Masterminds/sprig/v3 v3.2.3 // indirect
github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 // indirect
github.com/andybalholm/brotli v1.0.5 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/armon/go-radix v1.0.0 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bgentry/speakeasy v0.1.0 // indirect
github.com/bytedance/sonic v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/denisenkom/go-mssqldb v0.9.0 // indirect
github.com/elgs/gostrgen v0.0.0-20220325073726-0c3e00d082f6 // indirect
github.com/eyetowers/gowsdl v0.0.0-20230602114649-7e912399d91a // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/flosch/pongo2/v4 v4.0.2 // indirect
github.com/gabriel-vasile/mimetype v1.4.2 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-gorp/gorp/v3 v3.1.0 // indirect
github.com/go-logfmt/logfmt v0.6.0 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-sql-driver/mysql v1.6.0 // indirect
github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/godror/godror v0.40.4 // indirect
github.com/godror/knownpb v0.1.1 // indirect
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12 // indirect
Expand All @@ -133,7 +123,6 @@ require (
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-version v1.6.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/iris-contrib/schema v0.0.6 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
Expand All @@ -157,32 +146,22 @@ require (
github.com/mailgun/raymond/v2 v2.0.48 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-oci8 v0.1.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/microcosm-cc/bluemonday v1.0.25 // indirect
github.com/mitchellh/cli v1.1.5 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/motemen/go-loghttp v0.0.0-20170804080138-974ac5ceac27 // indirect
github.com/motemen/go-nuts v0.0.0-20220604134737-2658d0104f31 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/posener/complete v1.2.3 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
github.com/shoenig/go-m1cpu v0.1.6 // indirect
github.com/shopspring/decimal v1.3.1 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tdewolff/minify/v2 v2.12.9 // indirect
github.com/tdewolff/parse/v2 v2.6.8 // indirect
Expand All @@ -198,7 +177,6 @@ require (
github.com/yosssi/ace v0.0.5 // indirect
github.com/yusufpapurcu/wmi v1.2.3 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231212172506-995d672761c0 // indirect
Expand Down
Loading

0 comments on commit 58afb36

Please sign in to comment.