Skip to content

Commit

Permalink
Merge pull request #264 from utkarsh-pro/utkarsh-pro/fix/istio-instal…
Browse files Browse the repository at this point in the history
…lation
  • Loading branch information
leecalcote authored Aug 18, 2021
2 parents 001951a + 11181c1 commit 7d73a27
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 17 deletions.
1 change: 0 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,6 @@ github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3
github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34/go.mod h1:BQPLwdJt7v7y0fXIejI4whR9zMyX07Wjt5xrbgEmHLw=
github.com/layer5io/meshery-adapter-library v0.1.22 h1:eryv812OTx1uacU2tA5q9oBNm1uJswmSWv6kKHaOK1g=
github.com/layer5io/meshery-adapter-library v0.1.22/go.mod h1:m8MtMkpF6pRxreZBxz+PqKiHP2msK6o+VIPTfmnlF1I=
github.com/layer5io/meshkit v0.2.20 h1:a4KIejSCK2YiDeHUgWG0y8lQhIzKKi4vjIi27kScZ5Y=
github.com/layer5io/meshkit v0.2.20/go.mod h1:nkTKAEL9jZ74az1LEd157tSe3o382DxPOCgxqI7gCjk=
github.com/layer5io/meshkit v0.2.21 h1:hUJ/DqXfG7OiZFUfoIzaBi0zmIWyrzAjgZj8z7jyJpY=
github.com/layer5io/meshkit v0.2.21/go.mod h1:blHAWgbcsNJ3rjKr8YvYke8jQILV75vRaARXYwSh0YA=
Expand Down
48 changes: 37 additions & 11 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"path"
"strings"

"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshery-adapter-library/common"
"github.com/layer5io/meshery-adapter-library/config"
configprovider "github.com/layer5io/meshery-adapter-library/config/provider"
"github.com/layer5io/meshery-adapter-library/status"
configprovider "github.com/layer5io/meshkit/config/provider"
"github.com/layer5io/meshkit/utils"
smp "github.com/layer5io/service-mesh-performance/spec"
)
Expand Down Expand Up @@ -55,10 +56,9 @@ var (
configRootPath = path.Join(utils.GetHome(), ".meshery")

Config = configprovider.Options{
ServerConfig: ServerConfig,
MeshSpec: MeshSpec,
ProviderConfig: ProviderConfig,
Operations: Operations,
FilePath: configRootPath,
FileName: "istio",
FileType: "yaml",
}

ServerConfig = map[string]string{
Expand Down Expand Up @@ -91,21 +91,47 @@ var (
)

// New creates a new config instance
func New(provider string) (config.Handler, error) {
func New(provider string) (h config.Handler, err error) {
// Config provider
switch provider {
case configprovider.ViperKey:
return configprovider.NewViper(Config)
h, err = configprovider.NewViper(Config)
if err != nil {
return nil, err
}
case configprovider.InMemKey:
return configprovider.NewInMem(Config)
h, err = configprovider.NewInMem(Config)
if err != nil {
return nil, err
}
default:
return nil, ErrEmptyConfig
}

return nil, ErrEmptyConfig
// Setup server config
if err := h.SetObject(adapter.ServerKey, ServerConfig); err != nil {
return nil, err
}

// Setup mesh config
if err := h.SetObject(adapter.MeshSpecKey, MeshSpec); err != nil {
return nil, err
}

// Setup Operations Config
if err := h.SetObject(adapter.OperationsKey, Operations); err != nil {
return nil, err
}

return h, nil
}

func NewKubeconfigBuilder(provider string) (config.Handler, error) {
opts := configprovider.Options{}
opts.ProviderConfig = KubeConfig
opts := configprovider.Options{
FilePath: configRootPath,
FileType: "yaml",
FileName: "kubeconfig",
}

// Config provider
switch provider {
Expand Down
4 changes: 2 additions & 2 deletions istio/istio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (

"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshery-adapter-library/common"
adapterconfig "github.com/layer5io/meshery-adapter-library/config"
"github.com/layer5io/meshery-adapter-library/meshes"
"github.com/layer5io/meshery-adapter-library/status"
internalconfig "github.com/layer5io/meshery-istio/internal/config"
"github.com/layer5io/meshery-istio/istio/oam"
meshkitCfg "github.com/layer5io/meshkit/config"
"github.com/layer5io/meshkit/logger"
"github.com/layer5io/meshkit/models/oam/core/v1alpha1"
)
Expand All @@ -21,7 +21,7 @@ type Istio struct {
}

// New initializes istio handler.
func New(c adapterconfig.Handler, l logger.Handler, kc adapterconfig.Handler) adapter.Handler {
func New(c meshkitCfg.Handler, l logger.Handler, kc meshkitCfg.Handler) adapter.Handler {
return &Istio{
Adapter: adapter.Adapter{
Config: c,
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ import (
// "github.com/layer5io/meshkit/tracing"
"github.com/layer5io/meshery-adapter-library/adapter"
"github.com/layer5io/meshery-adapter-library/api/grpc"
configprovider "github.com/layer5io/meshery-adapter-library/config/provider"
"github.com/layer5io/meshery-istio/internal/config"
"github.com/layer5io/meshery-istio/istio/oam"
configprovider "github.com/layer5io/meshkit/config/provider"
)

var (
Expand Down Expand Up @@ -70,7 +70,7 @@ func main() {

// Initialize application specific configs and dependencies
// App and request config
cfg, err := config.New(configprovider.InMemKey)
cfg, err := config.New(configprovider.ViperKey)
if err != nil {
log.Error(err)
os.Exit(1)
Expand All @@ -83,7 +83,7 @@ func main() {
os.Exit(1)
}

kubeconfigHandler, err := config.NewKubeconfigBuilder(configprovider.InMemKey)
kubeconfigHandler, err := config.NewKubeconfigBuilder(configprovider.ViperKey)
if err != nil {
log.Error(err)
os.Exit(1)
Expand Down

0 comments on commit 7d73a27

Please sign in to comment.