Skip to content

Commit

Permalink
Merge pull request #148 from MUzairS15/MUzairS15/cilium/upgrade
Browse files Browse the repository at this point in the history
Fix Cilium Registration and working.
  • Loading branch information
Mohd Uzair authored Nov 10, 2023
2 parents 79eee42 + c121cc6 commit 08dab0c
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 690 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- run: GOPROXY=direct GOSUMDB=off GO111MODULE=on go build .
docker:
name: Docker build and push
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ jobs:
name: Check & Review code
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
- uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- uses: actions/checkout@master
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.49
version: v1.54

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand All @@ -40,9 +40,9 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- run: GOPROXY=https://proxy.golang.org,direct GOSUMDB=off GO111MODULE=on go install github.com/kisielk/errcheck@latest; /home/runner/go/bin/errcheck -tags draft ./...
error_code_check:
name: Error code utility check
Expand All @@ -53,9 +53,9 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- run: |
errWillHave="level=error"
GOPROXY=https://proxy.golang.org,direct GOSUMDB=off GO111MODULE=on go install github.com/layer5io/meshkit/cmd/errorutil;
Expand All @@ -75,9 +75,9 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- uses: dominikh/[email protected]
with:
install-go: false
Expand All @@ -91,9 +91,9 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- run: GOPROXY=https://proxy.golang.org,direct GOSUMDB=off GO111MODULE=on go vet -tags draft ./...
sec_check:
name: Security check
Expand Down Expand Up @@ -121,9 +121,9 @@ jobs:
with:
fetch-depth: 1
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- name: Create cluster using KinD
uses: engineerd/[email protected]
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/component-generator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
token: ${{ secrets.GH_ACCESS_TOKEN }}
ref: "master"
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.19
go-version: 1.21
- name: Run adapter to create components
run: |
touch log.txt
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/error-ref-publisher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ jobs:
ref: 'master'

- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: ${{ secrets.GO_VERSION }}
go-version: 1.21

- name: Run utility
run: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.19 as build-env
FROM golang:1.21 as build-env
ARG VERSION
ARG GIT_COMMITSHA

Expand Down
2 changes: 1 addition & 1 deletion build/Makefile.core.mk
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ GIT_VERSION = $(shell git describe --tags `git rev-list --tags --max-count=1`)
GIT_COMMITSHA = $(shell git rev-list -1 HEAD)
GIT_STRIPPED_VERSION=$(shell git describe --tags `git rev-list --tags --max-count=1` | cut -c 2-)

GOVERSION = 1.19
GOVERSION = 1.21
GOPATH = $(shell go env GOPATH)
GOBIN = $(GOPATH)/bin

Expand Down
108 changes: 1 addition & 107 deletions cilium/oam/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import (
"os"
"path/filepath"
"strconv"
"strings"
"sync"

"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshery-cilium/internal/config"
"github.com/layer5io/meshkit/models/meshmodel/core/types"
)

Expand Down Expand Up @@ -56,70 +54,6 @@ func RegisterMeshModelComponents(uuid, runtime, host, port string) error {
Register(uuid)
}

// RegisterWorkloads will register all of the workload definitions
// present in the path oam/workloads
//
// Registration process will send POST request to $runtime/api/oam/workload
func RegisterWorkloads(runtime, host string) error {
oamRDP := []adapter.OAMRegistrantDefinitionPath{}

pathSets, err := load(WorkloadPath)
if err != nil {
return err
}

for _, pathSet := range pathSets {
metadata := map[string]string{
config.OAMAdapterNameMetadataKey: config.CiliumOperation,
}

if strings.HasSuffix(pathSet.name, "addon") {
metadata[config.OAMComponentCategoryMetadataKey] = "addon"
}

oamRDP = append(oamRDP, adapter.OAMRegistrantDefinitionPath{
OAMDefintionPath: pathSet.oamDefinitionPath,
OAMRefSchemaPath: pathSet.jsonSchemaPath,
Host: host,
Metadata: metadata,
})
}

return adapter.
NewOAMRegistrant(oamRDP, fmt.Sprintf("%s/api/oam/workload", runtime)).
Register()
}

// RegisterTraits will register all of the trait definitions
// present in the path oam/traits
//
// Registeration process will send POST request to $runtime/api/oam/trait
func RegisterTraits(runtime, host string) error {
oamRDP := []adapter.OAMRegistrantDefinitionPath{}

pathSets, err := load(traitPath)
if err != nil {
return err
}

for _, pathSet := range pathSets {
metadata := map[string]string{
config.OAMAdapterNameMetadataKey: config.CiliumOperation,
}

oamRDP = append(oamRDP, adapter.OAMRegistrantDefinitionPath{
OAMDefintionPath: pathSet.oamDefinitionPath,
OAMRefSchemaPath: pathSet.jsonSchemaPath,
Host: host,
Metadata: metadata,
})
}

return adapter.
NewOAMRegistrant(oamRDP, fmt.Sprintf("%s/api/oam/trait", runtime)).
Register()
}

func loadMeshmodelComponents(basepath string) ([]meshmodelDefinitionPathSet, error) {
res := []meshmodelDefinitionPathSet{}
if err := filepath.Walk(basepath, func(path string, info os.FileInfo, err error) error {
Expand All @@ -143,44 +77,4 @@ func loadMeshmodelComponents(basepath string) ([]meshmodelDefinitionPathSet, err
}

return res, nil
}

func load(basePath string) ([]schemaDefinitionPathSet, error) {
res := []schemaDefinitionPathSet{}

if err := filepath.Walk(basePath, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}

if info.IsDir() {
return nil
}

if matched, err := filepath.Match("*_definition.json", filepath.Base(path)); err != nil {
return err
} else if matched {
nameWithPath := strings.TrimSuffix(path, "_definition.json")

res = append(res, schemaDefinitionPathSet{
oamDefinitionPath: path,
jsonSchemaPath: fmt.Sprintf("%s.meshery.layer5io.schema.json", nameWithPath),
name: filepath.Base(nameWithPath),
})
availableVersionGlobalMutex.Lock()
AvailableVersions[filepath.Base(filepath.Dir(path))] = true
availableVersionGlobalMutex.Unlock()
}

return nil
}); err != nil {
return nil, err
}

return res, nil
}

func init() {
//This is done only to find available versions at startup
_, _ = load(WorkloadPath)
}
}

Check failure on line 80 in cilium/oam/register.go

View workflow job for this annotation

GitHub Actions / Check & Review code

File is not `gofmt`-ed with `-s` (gofmt)

Check failure on line 80 in cilium/oam/register.go

View workflow job for this annotation

GitHub Actions / Check & Review code

File is not `gofmt`-ed with `-s` (gofmt)
Loading

0 comments on commit 08dab0c

Please sign in to comment.