Skip to content

Commit

Permalink
Change reference to Magistrala
Browse files Browse the repository at this point in the history
Signed-off-by: Dusan Borovcanin <borovcanindusan1@gmail.com>
  • Loading branch information
dborovcanin committed Jan 17, 2024
1 parent 33c5663 commit a7ae27e
Show file tree
Hide file tree
Showing 1,742 changed files with 241 additions and 617,131 deletions.
5 changes: 1 addition & 4 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<!--
The GitHub issue tracker is for bug reports and feature requests. General support can be found at
the following locations:
- Google group - https://groups.google.com/forum/#!forum/mainflux
- Gitter - https://gitter.im/mainflux/mainflux
the https://matrix.to/#/#Mainflux_mainflux:gitter.im.
-->

**FEATURE REQUEST**
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Pull request title should be `MF-XXX - description` or `NOISSUE - description` where XXX is ID of issue that this PR relate to.
Please review the [CONTRIBUTING.md](https://github.com/mainflux/mainflux/blob/master/CONTRIBUTING.md) file for detailed contributing guidelines.
Please review the [CONTRIBUTING.md](https://github.com/absmach/magistrala/blob/master/CONTRIBUTING.md) file for detailed contributing guidelines.

### What does this do?

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/server-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: mainflux/callhome
images: magistrala/callhome

- name: Build and push Docker image
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
Expand Down
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Copyright (c) Abstract Machines

PROGRAM = callhome
MF_DOCKER_IMAGE_NAME_PREFIX ?= mainflux
MG_DOCKER_IMAGE_NAME_PREFIX ?= magistrala
SOURCES = $(wildcard *.go) cmd/main.go
CGO_ENABLED ?= 0
GOARCH ?= amd64
VERSION ?= $(shell git describe --abbrev=0 --tags 2>/dev/null || echo "0.13.0")
COMMIT ?= $(shell git rev-parse HEAD)
TIME ?= $(shell date +%F_%T)
DOMAIN ?= callhome.mainflux.com
DOMAIN ?= callhome.magistrala.com

all: $(PROGRAM)

Expand All @@ -21,7 +23,7 @@ define make_docker
--build-arg VERSION=$(VERSION) \
--build-arg COMMIT=$(COMMIT) \
--build-arg TIME=$(TIME) \
--tag=$(MF_DOCKER_IMAGE_NAME_PREFIX)/$(PROGRAM) \
--tag=$(MG_DOCKER_IMAGE_NAME_PREFIX)/$(PROGRAM) \
-f docker/Dockerfile .
endef

Expand All @@ -34,10 +36,10 @@ endef

$(PROGRAM): $(SOURCES)
CGO_ENABLED=$(CGO_ENABLED) GOOS=$(GOOS) GOARCH=$(GOARCH) GOARM=$(GOARM) \
go build -mod=vendor -ldflags "-s -w \
-X 'github.com/mainflux/mainflux.BuildTime=$(TIME)' \
-X 'github.com/mainflux/mainflux.Version=$(VERSION)' \
-X 'github.com/mainflux/mainflux.Commit=$(COMMIT)'" \
go build -ldflags "-s -w \
-X 'github.com/absmach/magistrala.BuildTime=$(TIME)' \
-X 'github.com/absmach/magistrala.Version=$(VERSION)' \
-X 'github.com/absmach/magistrala.Commit=$(COMMIT)'" \
-o ./build/$(PROGRAM)-$(PROGRAM) cmd/main.go

clean:
Expand Down
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Mainflux Callhome Service
# Magistrala Callhome Service
[![website][preview]][website]

![build][build]
![Go Report Card][grc]
[![License][LIC-BADGE]][LIC]

This is a server to receive and store information regarding Mainflux deployments.
This is a server to receive and store information regarding Magistrala deployments.

The summary is located on our [Website][website].

Expand All @@ -21,25 +21,25 @@ make run
### Requirements
- [IP to Location database](https://lite.ip2location.com/)

## Data Collection for Mainflux
Mainflux is committed to continuously improving its services and ensuring a seamless experience for its users. To achieve this, we collect certain data from your deployments. Rest assured, this data is collected solely for the purpose of enhancing Mainflux and is not used with any malicious intent. The deployment summary can be found on our [website][website].
## Data Collection for Magistrala
Magistrala is committed to continuously improving its services and ensuring a seamless experience for its users. To achieve this, we collect certain data from your deployments. Rest assured, this data is collected solely for the purpose of enhancing Magistrala and is not used with any malicious intent. The deployment summary can be found on our [website][website].

The collected data includes:
- **IP Address** - Used for approximate location information on deployments.
- **Services Used** - To understand which features are popular and prioritize future developments.
- **Last Seen Time** - To ensure the stability and availability of Mainflux.
- **Mainflux Version** - To track the software version and deliver relevant updates.
- **Last Seen Time** - To ensure the stability and availability of Magistrala.
- **Magistrala Version** - To track the software version and deliver relevant updates.

We take your privacy and data security seriously. All data collected is handled in accordance with our stringent privacy policies and industry best practices.

Data collection is on by default and can be disabled by setting the env variable:
`MF_SEND_TELEMETRY=false`

By utilizing Mainflux, you actively contribute to its improvement. Together, we can build a more robust and efficient IoT platform. Thank you for your trust in Mainflux!
By utilizing Magistrala, you actively contribute to its improvement. Together, we can build a more robust and efficient IoT platform. Thank you for your trust in Magistrala!

[grc]: https://goreportcard.com/badge/github.com/mainflux/callhome
[build]: https://github.com/mainflux/callhome/actions/workflows/ci.yml/badge.svg
[grc]: https://goreportcard.com/badge/github.com/absmach/callhome
[build]: https://github.com/absmach/callhome/actions/workflows/ci.yml/badge.svg
[LIC]: LICENCE
[LIC-BADGE]: https://img.shields.io/badge/License-Apache_2.0-blue.svg
[website]: https://deployments.mainflux.io
[website]: https://deployments.magistrala.io
[preview]: /assets/images/website.png
2 changes: 1 addition & 1 deletion api/doc.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Mainflux
// Copyright (c) Abstract Machines
// SPDX-License-Identifier: Apache-2.0

// Package api contains API-related concerns: endpoint definitions, middlewares
Expand Down
2 changes: 1 addition & 1 deletion api/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package api
import (
"context"

"github.com/absmach/callhome"
"github.com/go-kit/kit/endpoint"
"github.com/mainflux/callhome"
)

func saveEndpoint(svc callhome.Service) endpoint.Endpoint {
Expand Down
8 changes: 4 additions & 4 deletions api/endpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"strings"
"testing"

"github.com/mainflux/callhome"
"github.com/mainflux/callhome/mocks"
"github.com/mainflux/mainflux/logger"
"github.com/absmach/callhome"
"github.com/absmach/callhome/mocks"
"github.com/absmach/magistrala/logger"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -46,7 +46,7 @@ func TestEndpointsRetrieve(t *testing.T) {
func TestEndpointSave(t *testing.T) {
body := `{
"service": "ty",
"mainflux_version": "1.0",
"magistrala_version": "1.0",
"ip_address": "41.90.185.50",
"last_seen":"2023-03-27T17:40:50.356401087+03:00"
}`
Expand Down
8 changes: 2 additions & 6 deletions api/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"fmt"
"time"

"github.com/mainflux/callhome"
"github.com/mainflux/mainflux/logger"
"github.com/absmach/callhome"
"github.com/absmach/magistrala/logger"
)

var _ callhome.Service = (*loggingMiddleware)(nil)
Expand All @@ -30,7 +30,6 @@ func (lm *loggingMiddleware) Retrieve(ctx context.Context, pm callhome.PageMetad
return
}
lm.hommingLogger.Info(fmt.Sprintf("%s without errors.", message))

}(time.Now())

return lm.svc.Retrieve(ctx, pm, filters)
Expand All @@ -45,7 +44,6 @@ func (lm *loggingMiddleware) Save(ctx context.Context, t callhome.Telemetry) (er
return
}
lm.hommingLogger.Info(fmt.Sprintf("%s without errors.", message))

}(time.Now())

return lm.svc.Save(ctx, t)
Expand All @@ -59,7 +57,6 @@ func (lm *loggingMiddleware) RetrieveSummary(ctx context.Context, filters callho
return
}
lm.hommingLogger.Info(fmt.Sprintf("%s without errors.", message))

}(time.Now())

return lm.svc.RetrieveSummary(ctx, filters)
Expand All @@ -74,7 +71,6 @@ func (lm *loggingMiddleware) ServeUI(ctx context.Context, filters callhome.Telem
return
}
lm.hommingLogger.Info(fmt.Sprintf("%s without errors.", message))

}(time.Now())

return lm.svc.ServeUI(ctx, filters)
Expand Down
2 changes: 1 addition & 1 deletion api/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import (
"context"
"time"

"github.com/absmach/callhome"
"github.com/go-kit/kit/metrics"
"github.com/mainflux/callhome"
)

var _ callhome.Service = (*metricsMiddleware)(nil)
Expand Down
4 changes: 2 additions & 2 deletions api/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package api
import (
"time"

"github.com/mainflux/mainflux/pkg/errors"
"github.com/absmach/magistrala/pkg/errors"
)

var (
Expand All @@ -20,7 +20,7 @@ const maxLimitSize = 100
type saveTelemetryReq struct {
Service string `json:"service"`
IpAddress string `json:"ip_address"`
Version string `json:"mainflux_version"`
Version string `json:"magistrala_version"`
LastSeen time.Time `json:"last_seen"`
}

Expand Down
26 changes: 14 additions & 12 deletions api/responses.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@ package api
import (
"net/http"

"github.com/mainflux/callhome"
"github.com/mainflux/mainflux"
"github.com/absmach/callhome"
"github.com/absmach/magistrala"
)

var _ mainflux.Response = (*uiRes)(nil)
var _ mainflux.Response = (*saveTelemetryRes)(nil)
var _ mainflux.Response = (*telemetryPageRes)(nil)
var _ mainflux.Response = (*telemetrySummaryRes)(nil)
var (
_ magistrala.Response = (*uiRes)(nil)
_ magistrala.Response = (*saveTelemetryRes)(nil)
_ magistrala.Response = (*telemetryPageRes)(nil)
_ magistrala.Response = (*telemetrySummaryRes)(nil)
)

type saveTelemetryRes struct {
created bool
Expand Down Expand Up @@ -65,7 +67,7 @@ type uiRes struct {
html []byte
}

// Code implements mainflux.Response
// Code implements magistrala.Response
func (res uiRes) Code() int {
if res.code == 0 {
return http.StatusCreated
Expand All @@ -74,12 +76,12 @@ func (res uiRes) Code() int {
return res.code
}

// Empty implements mainflux.Response
// Empty implements magistrala.Response
func (res uiRes) Empty() bool {
return res.html == nil
}

// Headers implements mainflux.Response
// Headers implements magistrala.Response
func (res uiRes) Headers() map[string]string {
if res.headers == nil {
return map[string]string{}
Expand All @@ -95,17 +97,17 @@ type telemetrySummaryRes struct {
TotalDeployments int `json:"total_deployments,omitempty"`
}

// Code implements mainflux.Response
// Code implements magistrala.Response
func (*telemetrySummaryRes) Code() int {
return http.StatusOK
}

// Empty implements mainflux.Response
// Empty implements magistrala.Response
func (*telemetrySummaryRes) Empty() bool {
return false
}

// Headers implements mainflux.Response
// Headers implements magistrala.Response
func (res *telemetrySummaryRes) Headers() map[string]string {
return map[string]string{}
}
20 changes: 11 additions & 9 deletions api/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import (
"strings"
"time"

"github.com/absmach/callhome"
"github.com/absmach/callhome/timescale"
"github.com/absmach/magistrala"
"github.com/absmach/magistrala/logger"
"github.com/absmach/magistrala/pkg/errors"
"github.com/absmach/magistrala/pkg/uuid"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/go-zoo/bone"
"github.com/mainflux/callhome"
"github.com/mainflux/callhome/timescale"
"github.com/mainflux/mainflux"
"github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/pkg/errors"
"github.com/mainflux/mainflux/pkg/uuid"

"github.com/prometheus/client_golang/prometheus/promhttp"
"go.opentelemetry.io/contrib/instrumentation/github.com/go-kit/kit/otelkit"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -71,7 +72,7 @@ func MakeHandler(svc callhome.Service, tp trace.TracerProvider, logger logger.Lo
opts...,
))

mux.GetFunc("/health", mainflux.Health("telemetry"))
mux.GetFunc("/health", magistrala.Health("home", "telemetry"))
mux.Handle("/metrics", promhttp.Handler())

// Static file handler
Expand Down Expand Up @@ -105,7 +106,7 @@ func encodeStaticResponse(_ context.Context, w http.ResponseWriter, response int
}

func encodeResponse(_ context.Context, w http.ResponseWriter, response interface{}) error {
if ar, ok := response.(mainflux.Response); ok {
if ar, ok := response.(magistrala.Response); ok {
for k, v := range ar.Headers() {
w.Header().Set(k, v)
}
Expand All @@ -122,7 +123,8 @@ func encodeResponse(_ context.Context, w http.ResponseWriter, response interface

func encodeError(_ context.Context, err error, w http.ResponseWriter) {
switch {
case errors.Contains(err, errors.ErrInvalidQueryParams),
case
errors.Contains(err, ErrInvalidQueryParams),
errors.Contains(err, errors.ErrMalformedEntity),
err == ErrLimitSize,
err == ErrOffsetSize:
Expand Down
15 changes: 8 additions & 7 deletions api/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ import (
"net/http"
"strconv"

"github.com/absmach/magistrala/logger"
"github.com/absmach/magistrala/pkg/errors"
kithttp "github.com/go-kit/kit/transport/http"
"github.com/go-zoo/bone"
"github.com/mainflux/mainflux/logger"
"github.com/mainflux/mainflux/pkg/errors"
)

// ErrorRes represents the HTTP error response body.
type ErrorRes struct {
Err string `json:"error"`
}

var ErrInvalidQueryParams = errors.New("invalid query params")

// LoggingErrorEncoder is a go-kit error encoder logging decorator.
func LoggingErrorEncoder(logger logger.Logger, enc kithttp.ErrorEncoder) kithttp.ErrorEncoder {
return func(ctx context.Context, err error, w http.ResponseWriter) {
switch err {
case ErrLimitSize,
ErrOffsetSize:
case ErrLimitSize, ErrOffsetSize:
logger.Error(err.Error())
}
enc(ctx, err, w)
Expand All @@ -32,15 +33,15 @@ func LoggingErrorEncoder(logger logger.Logger, enc kithttp.ErrorEncoder) kithttp
func ReadUintQuery(r *http.Request, key string, def uint64) (uint64, error) {
vals := bone.GetQuery(r, key)
if len(vals) > 1 {
return 0, errors.ErrInvalidQueryParams
return 0, ErrInvalidQueryParams
}
if len(vals) == 0 {
return def, nil
}
strval := vals[0]
val, err := strconv.ParseUint(strval, 10, 64)
if err != nil {
return 0, errors.ErrInvalidQueryParams
return 0, ErrInvalidQueryParams
}
return val, nil
}
Expand All @@ -49,7 +50,7 @@ func ReadUintQuery(r *http.Request, key string, def uint64) (uint64, error) {
func ReadStringQuery(r *http.Request, key string, def string) (string, error) {
vals := bone.GetQuery(r, key)
if len(vals) > 1 {
return "", errors.ErrInvalidQueryParams
return "", ErrInvalidQueryParams
}
if len(vals) == 0 {
return def, nil
Expand Down
Loading

0 comments on commit a7ae27e

Please sign in to comment.