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

Remove OAM related code #141

Merged
merged 1 commit into from
Oct 30, 2023
Merged
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
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.PHONY: lint tidy verify
.PHONY: check
check: lint
check: tidy
check: verify


lint:
Expand Down
7 changes: 2 additions & 5 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,8 @@ type Handler interface {
// CreateInstance(*chan interface{}) error // Instantiates clients used in deploying and managing mesh instances, e.g. Kubernetes clients.
ApplyOperation(context.Context, OperationRequest) error // Applies an adapter operation. This is adapter specific and needs to be implemented by each adapter.
ListOperations() (Operations, error) // List all operations an adapter supports.
ProcessOAM(ctx context.Context, srv OAMRequest) (string, error)

// Need not implement this method and can be reused
StreamErr(*meshes.EventsResponse, error) // Streams an error event, e.g. to a channel
StreamInfo(*meshes.EventsResponse) // Streams an informational event, e.g. to a channel
StreamErr(*meshes.EventsResponse, error) // Streams an error event, e.g. to a channel
StreamInfo(*meshes.EventsResponse) // Streams an informational event, e.g. to a channel
}

// Adapter contains all handlers, channels, clients, and other parameters for an adapter.
Expand Down
64 changes: 21 additions & 43 deletions adapter/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,27 @@ import (
)

const (
ErrGetNameCode = "1000"
ErrCreateInstanceCode = "1001"
ErrMeshConfigCode = "1002"
ErrValidateKubeconfigCode = "1003"
ErrClientConfigCode = "1004"
ErrClientSetCode = "1005"
ErrStreamEventCode = "1006"
ErrOpInvalidCode = "1007"
ErrApplyOperationCode = "1008"
ErrListOperationsCode = "1009"
ErrNewSmiCode = "1010"
ErrRunSmiCode = "1011"
ErrNoResponseCode = "1011"
ErrOpenOAMDefintionFileCode = "1013"
ErrOpenOAMRefFileCode = "1014"
ErrJSONMarshalCode = "1015"
ErrOAMRetryCode = "1016"
ErrSmiInitCode = "1007"
ErrInstallSmiCode = "1008"
ErrConnectSmiCode = "1009"
ErrDeleteSmiCode = "1010"
ErrGenerateComponentsCode = "1011"
ErrAuthInfosInvalidMsgCode = "1012"
ErrCreatingComponentsCode = "1013"
ErrGetNameCode = "1000"
ErrCreateInstanceCode = "1001"
ErrMeshConfigCode = "1002"
ErrValidateKubeconfigCode = "1003"
ErrClientConfigCode = "1004"
ErrClientSetCode = "1005"
ErrStreamEventCode = "1006"
ErrOpInvalidCode = "1007"
ErrApplyOperationCode = "1008"
ErrListOperationsCode = "1009"
ErrNewSmiCode = "1010"
ErrRunSmiCode = "1011"
ErrNoResponseCode = "1011"
ErrJSONMarshalCode = "1015"
ErrSmiInitCode = "1007"
ErrInstallSmiCode = "1008"
ErrConnectSmiCode = "1009"
ErrDeleteSmiCode = "1010"
ErrGenerateComponentsCode = "1011"
ErrAuthInfosInvalidMsgCode = "1012"
ErrCreatingComponentsCode = "1013"
)

var (
Expand Down Expand Up @@ -116,25 +113,6 @@ func ErrDeleteSmi(err error) error {
return errors.New(ErrDeleteSmiCode, errors.Alert, []string{"Error deleting smi tool: %s"}, []string{err.Error()}, []string{}, []string{})
}

// ErrOpenOAMDefintionFile is the error for opening OAM Definition file
func ErrOpenOAMDefintionFile(err error) error {
return errors.New(ErrOpenOAMDefintionFileCode, errors.Alert, []string{"error opening OAM Definition File: %s"}, []string{err.Error()}, []string{}, []string{})
}

// ErrOpenOAMRefFile is the error for opening OAM Schema Ref file
func ErrOpenOAMRefFile(err error) error {
return errors.New(ErrOpenOAMRefFileCode, errors.Alert, []string{"error opening OAM Schema Ref File: %s"}, []string{err.Error()}, []string{}, []string{})
}

// ErrJSONMarshal is the error for json marhal failure
func ErrJSONMarshal(err error) error {
return errors.New(ErrOAMRetryCode, errors.Alert, []string{"error marshal JSON: %s"}, []string{err.Error()}, []string{}, []string{})
}

func ErrOAMRetry(err error) error {
return errors.New(ErrOAMRetryCode, errors.Alert, []string{"error marshal JSON: %s"}, []string{err.Error()}, []string{}, []string{})
}

// will be depracated
func ErrGenerateComponents(err error) error {
return errors.New(ErrGenerateComponentsCode, errors.Alert, []string{"error generating components"}, []string{err.Error()}, []string{"Invalid component generation method passed, Some invalid field passed in DynamicComponentsConfig"}, []string{"Pass the correct GenerationMethod in DynamicComponentsConfig", "Pass the correct fields in DynamicComponentsConfig"})
Expand Down
20 changes: 0 additions & 20 deletions adapter/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,6 @@ func (s *adapterLogger) GetComponentInfo(svc interface{}) error {
return s.next.GetComponentInfo(svc)
}

// func (s *adapterLogger) CreateInstance(c *chan interface{}) error {
// s.log.Info("Creating instance")
// err := s.next.CreateInstance(c)
// if err != nil {
// s.log.Error(err)
// }
// return err
// }

func (s *adapterLogger) ApplyOperation(ctx context.Context, op OperationRequest) error {
s.log.Info("Applying operation ", op.OperationName)
err := s.next.ApplyOperation(ctx, op)
Expand All @@ -66,17 +57,6 @@ func (s *adapterLogger) ApplyOperation(ctx context.Context, op OperationRequest)
return err
}

// ProcessOAM wraps the Handler's ProcessOAM method along with relevant logging
func (s *adapterLogger) ProcessOAM(ctx context.Context, oamRequest OAMRequest) (string, error) {
s.log.Info("Process OAM components")
msg, err := s.next.ProcessOAM(ctx, oamRequest)
if err != nil {
s.log.Error(err)
}

return msg, err
}

func (s *adapterLogger) ListOperations() (Operations, error) {
s.log.Info("Listing Operations")
ops, err := s.next.ListOperations()
Expand Down
107 changes: 0 additions & 107 deletions adapter/meshmodel.go

This file was deleted.

Loading