Skip to content

Commit

Permalink
Merge pull request #1461 from memphisdev/bugfix-RND-255-when-file-nam…
Browse files Browse the repository at this point in the history
…e-is-different-from-function-name-an-informative-reason-is-missing

bugfix-RND-255-when-file-name-is-different-from-function-name-an-informative-reason-is-missing
  • Loading branch information
shohamroditimemphis committed Nov 30, 2023
2 parents 1871906 + 0051689 commit 2c00df8
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 79 deletions.
57 changes: 27 additions & 30 deletions models/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,33 @@ type Function struct {
}

type FunctionResult struct {
ID int `json:"id"`
FunctionName string `json:"function_name"`
Description string `json:"description"`
Tags []string `json:"tags"`
Runtime string `json:"runtime"`
Dependencies string `json:"dependencies"`
Inputs []map[string]string `json:"inputs"`
Memory int `json:"memory"`
Storage int `json:"storage"`
Handler string `json:"handler"`
TenantName string `json:"tenant_name"`
Scm string `json:"scm"`
Owner string `json:"owner"`
Repo string `json:"repo"`
Branch string `json:"branch"`
UpdatedAt time.Time `json:"installed_updated_at"`
Version int `json:"installed_version"`
InProgress bool `json:"installed_in_progress"`
ComputeEngine string `json:"compute_engine"`
Installed bool `json:"installed"`
IsValid bool `json:"is_valid"`
InvalidReason string `json:"invalid_reason"`
UpdatesAvailable bool `json:"updates_available"`
ByMemphis bool `json:"by_memphis"`
Language string `json:"language"`
Link *string `json:"link,omitempty"`
LastCommit *time.Time `json:"last_commit,omitempty"`
ClonedUpdatesAvailable bool `json:"cloned_updates_available"`
ClonedUpdatesIsValid bool `json:"cloned_updates_is_valid"`
ClonedUpdatesInvalidReason string `json:"cloned_updates_invalid_reason"`
ID int `json:"id"`
FunctionName string `json:"function_name"`
Description string `json:"description"`
Tags []string `json:"tags"`
Runtime string `json:"runtime"`
Dependencies string `json:"dependencies"`
Inputs []map[string]string `json:"inputs"`
Memory int `json:"memory"`
Storage int `json:"storage"`
Handler string `json:"handler"`
TenantName string `json:"tenant_name"`
Scm string `json:"scm"`
Owner string `json:"owner"`
Repo string `json:"repo"`
Branch string `json:"branch"`
UpdatedAt time.Time `json:"installed_updated_at"`
Version int `json:"installed_version"`
InProgress bool `json:"installed_in_progress"`
ComputeEngine string `json:"compute_engine"`
Installed bool `json:"installed"`
IsValid bool `json:"is_valid"`
InvalidReason string `json:"invalid_reason"`
UpdatesAvailable bool `json:"updates_available"`
ByMemphis bool `json:"by_memphis"`
Language string `json:"language"`
Link *string `json:"link,omitempty"`
LastCommit *time.Time `json:"last_commit,omitempty"`
}
type FunctionsRes struct {
InstalledFunctions []FunctionResult `json:"installed_functions"`
Expand Down
92 changes: 43 additions & 49 deletions server/memphis_handlers_functions_cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,27 @@ func (fh FunctionsHandler) GetFunctions(tenantName string) (models.FunctionsRes,
for _, function := range functions["other"] {
if function.Owner == memphisDevFunctionsOwnerName && function.Repo == memphisDevFunctionsRepoName {
otherFunctionResult := models.FunctionResult{
FunctionName: function.FunctionName,
Description: function.Description,
Tags: function.Tags,
Runtime: function.Runtime,
Dependencies: function.Dependencies,
Inputs: function.Inputs,
Memory: function.Memory,
Storage: function.Storage,
Handler: function.Handler,
Scm: "github",
Repo: function.Repo,
Branch: function.Branch,
Owner: function.Owner,
Language: function.Language,
Version: -1,
IsValid: function.IsValid,
InvalidReason: function.InvalidReason,
InProgress: false,
UpdatesAvailable: false,
ByMemphis: function.ByMemphis,
TenantName: function.TenantName,
ClonedUpdatesAvailable: function.ClonedUpdatesAvailable,
ClonedUpdatesIsValid: function.ClonedUpdatesIsValid,
ClonedUpdatesInvalidReason: function.ClonedUpdatesInvalidReason,
FunctionName: function.FunctionName,
Description: function.Description,
Tags: function.Tags,
Runtime: function.Runtime,
Dependencies: function.Dependencies,
Inputs: function.Inputs,
Memory: function.Memory,
Storage: function.Storage,
Handler: function.Handler,
Scm: "github",
Repo: function.Repo,
Branch: function.Branch,
Owner: function.Owner,
Language: function.Language,
Version: -1,
IsValid: function.IsValid,
InvalidReason: function.InvalidReason,
InProgress: false,
UpdatesAvailable: false,
ByMemphis: function.ByMemphis,
TenantName: function.TenantName,
}
OtherFunctions = append(OtherFunctions, otherFunctionResult)
lastModified = function.LastCommit
Expand Down Expand Up @@ -261,31 +258,28 @@ func GetFunctionsDetails(functionsDetails map[string][]functionDetails) (map[str
}

functionDetails := models.FunctionResult{
FunctionName: functionName,
Description: description,
Tags: tagsStrings,
Runtime: runtime,
Dependencies: dependencies,
Inputs: inputs,
Memory: memory,
Storage: storage,
Handler: handler,
Scm: "github",
Repo: repo,
Branch: branch,
Owner: owner,
LastCommit: lastCommit,
Link: link,
Language: language,
InProgress: false,
UpdatesAvailable: false,
ByMemphis: byMemphis,
TenantName: tenantName,
IsValid: isValid,
InvalidReason: invalidReason,
ClonedUpdatesAvailable: false,
ClonedUpdatesIsValid: isValid,
ClonedUpdatesInvalidReason: invalidReason,
FunctionName: functionName,
Description: description,
Tags: tagsStrings,
Runtime: runtime,
Dependencies: dependencies,
Inputs: inputs,
Memory: memory,
Storage: storage,
Handler: handler,
Scm: "github",
Repo: repo,
Branch: branch,
Owner: owner,
LastCommit: lastCommit,
Link: link,
Language: language,
InProgress: false,
UpdatesAvailable: false,
ByMemphis: byMemphis,
TenantName: tenantName,
IsValid: isValid,
InvalidReason: invalidReason,
}

functions[key] = append(functions[key], functionDetails)
Expand Down

0 comments on commit 2c00df8

Please sign in to comment.