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

Rename Go module to allow installing with go install #734

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build:
go build ./cmd/rpc
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Remote Provisioning Client (RPC)

![CodeQL](https://img.shields.io/github/actions/workflow/status/open-amt-cloud-toolkit/rpc-go/codeql-analysis.yml?style=for-the-badge&label=CodeQL&logo=github)
![Build](https://img.shields.io/github/actions/workflow/status/open-amt-cloud-toolkit/rpc-go/main.yml?style=for-the-badge&logo=github)
![Codecov](https://img.shields.io/codecov/c/github/open-amt-cloud-toolkit/rpc-go?style=for-the-badge&logo=codecov)
Expand All @@ -18,34 +19,40 @@ The Remote Provisioning Client (RPC) is an application that assists with activat
---


## Prerequisites
## Prerequisites

- [Golang](https://go.dev/dl/)

## Build

### Windows

#### As executable:
#### As executable:

```
go build -o rpc.exe ./cmd/main.go
go build -o rpc.exe ./cmd/rpc/main.go
```
#### As Library:

#### As Library:

```
go build -buildmode=c-shared -o rpc.dll ./cmd
go build -buildmode=c-shared -o rpc.dll ./cmd/rpc
```

### Linux

#### As executable:
#### As executable:

```
go build -o rpc ./cmd/main.go
go build -o rpc ./cmd/rpc/main.go
```

#### As Library:
#### As Library:

```
go build -buildmode=c-shared -o librpc.so ./cmd
CGO_ENABLED=1 go build -buildmode=c-shared -o librpc.so ./cmd/rpc
```

### Docker image

```bash
Expand All @@ -55,21 +62,24 @@ docker build -t rpc-go:latest .
## Run

Install the executable on a target device and then run from a terminal/shell
command line with <b>adminstrator privileges</b>.
command line with <b>adminstrator privileges</b>.

For usage, call the executable with no additional parameters.
For usage, call the executable with no additional parameters.

### Windows

```shell
.\rpc
```

### Linux

```bash
sudo ./rpc
```

### Docker

```bash
$ docker run --rm -it --device /dev/mei0 rpc-go:latest
```
Expand All @@ -78,7 +88,7 @@ $ docker run --rm -it --device /dev/mei0 rpc-go:latest

# Dev tips for passing CI Checks

- Ensure code is formatted correctly with `gofmt -s -w ./`
- Ensure code is formatted correctly with `gofmt -s -w ./`
- Ensure all unit tests pass with `go test ./...`
- Ensure code has been linted with `docker run --rm -v ${pwd}:/app -w /app golangci/golangci-lint:v1.52.2 golangci-lint run -v`

Expand All @@ -92,4 +102,4 @@ $ docker run --rm -it --device /dev/mei0 rpc-go:latest

- Need additional support or want to get the latest news and events about Open AMT? Connect with the team directly through Discord.

[![Discord Banner 1](https://discordapp.com/api/guilds/1063200098680582154/widget.png?style=banner2)](https://discord.gg/DKHeUNEWVH)
[![Discord Banner 1](https://discordapp.com/api/guilds/1063200098680582154/widget.png?style=banner2)](https://discord.gg/DKHeUNEWVH)
3 changes: 2 additions & 1 deletion cmd/lib.go → cmd/rpc/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
"encoding/csv"
"io"
"os"
"rpc/pkg/utils"
"strings"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

log "github.com/sirupsen/logrus"
)

Expand Down
11 changes: 6 additions & 5 deletions cmd/main.go → cmd/rpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ package main

import (
"os"
"rpc/internal/amt"
"rpc/internal/flags"
"rpc/internal/local"
"rpc/internal/rps"
"rpc/pkg/utils"

log "github.com/sirupsen/logrus"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/amt"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/flags"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/local"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/rps"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"
)

const AccessErrMsg = "Failed to execute due to access issues. " +
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module rpc
module github.com/open-amt-cloud-toolkit/rpc-go/v2

go 1.20

Expand Down
5 changes: 3 additions & 2 deletions internal/amt/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ package amt
import (
"errors"
"fmt"
"rpc/pkg/pthi"
"rpc/pkg/utils"
"strconv"
"strings"
"time"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/pthi"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"
)

//TODO: Ensure pointers are freed properly throughout this file
Expand Down
5 changes: 3 additions & 2 deletions internal/amt/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ package amt
import (
"errors"
"fmt"
"rpc/pkg/pthi"
"rpc/pkg/utils"
"testing"
"time"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/pthi"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/stretchr/testify/assert"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/certs/certs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import (
"encoding/hex"
"encoding/pem"
"fmt"
log "github.com/sirupsen/logrus"
"math/big"
"net"
"software.sslmate.com/src/go-pkcs12"
"strings"
"time"

log "github.com/sirupsen/logrus"
"software.sslmate.com/src/go-pkcs12"
)

type Composite struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/certs/certs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
package certs

import (
"github.com/stretchr/testify/assert"
"strings"
"testing"

"github.com/stretchr/testify/assert"
)

func RunNewSignedCompositeTest(t *testing.T, testDer string) {
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/activate.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import (
"fmt"
"reflect"
"regexp"
"rpc/pkg/utils"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

log "github.com/sirupsen/logrus"
)
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/activate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ package flags

import (
"os"
"rpc/pkg/utils"
"strings"
"testing"
"time"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/stretchr/testify/assert"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/flags/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
"fmt"
"os"
"path/filepath"
"rpc/internal/config"
"rpc/pkg/utils"
"strings"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/config"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/wifi"
"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/ips/ieee8021x"

Expand Down
5 changes: 3 additions & 2 deletions internal/flags/configure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ package flags
import (
"fmt"
"os"
"rpc/internal/config"
"rpc/pkg/utils"
"strings"
"testing"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/config"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/cim/wifi"
"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/wsman/ips/ieee8021x"

Expand Down
3 changes: 2 additions & 1 deletion internal/flags/deactivate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ package flags

import (
"fmt"
"rpc/pkg/utils"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"
)

func (f *Flags) handleDeactivateCommand() error {
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/deactivate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
package flags

import (
"rpc/pkg/utils"
"testing"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/stretchr/testify/assert"
)

Expand Down
9 changes: 5 additions & 4 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import (
"net"
"os"
"path/filepath"
"rpc/internal/amt"
"rpc/internal/config"
"rpc/internal/smb"
"rpc/pkg/utils"
"strconv"
"strings"
"time"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/amt"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/config"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/smb"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

configv2 "github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/config"
"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/security"

Expand Down
9 changes: 5 additions & 4 deletions internal/flags/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import (
"net"
"os"
"path/filepath"
"rpc/internal/config"
"rpc/internal/smb"
"rpc/pkg/pthi"
"rpc/pkg/utils"
"testing"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/config"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/smb"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/pthi"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"gopkg.in/yaml.v3"

"github.com/stretchr/testify/assert"
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ package flags

import (
"flag"
"rpc/pkg/utils"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"
)

type AmtInfoFlags struct {
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
package flags

import (
"rpc/pkg/utils"
"strings"
"testing"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/stretchr/testify/assert"
)

Expand Down
5 changes: 3 additions & 2 deletions internal/flags/maintenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import (
"os"
"path/filepath"
"regexp"
"rpc/internal/amt"
"rpc/pkg/utils"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/internal/amt"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

log "github.com/sirupsen/logrus"
)
Expand Down
3 changes: 2 additions & 1 deletion internal/flags/maintenance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ package flags
import (
"os"
"path/filepath"
"rpc/pkg/utils"
"strings"
"testing"

"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"

"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion internal/flags/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
package flags

import (
"rpc/pkg/utils"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/utils"
)

func (f *Flags) handleVersionCommand() error {
Expand Down
6 changes: 4 additions & 2 deletions internal/lm/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ package lm
import (
"bytes"
"encoding/binary"
"rpc/pkg/pthi"
"sync"
"time"

"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/apf"
"github.com/open-amt-cloud-toolkit/rpc-go/v2/pkg/pthi"

log "github.com/sirupsen/logrus"

"github.com/open-amt-cloud-toolkit/go-wsman-messages/v2/pkg/apf"
)

// LMConnection is struct for managing connection to LMS
Expand Down
Loading