-
Notifications
You must be signed in to change notification settings - Fork 558
feat: Multi charts #1013
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
feat: Multi charts #1013
Conversation
api/deployment/DeploymentRouter.go
Outdated
| @@ -0,0 +1,22 @@ | |||
| package deployment | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file name should be DeploymentConfigRouter
| @@ -0,0 +1,122 @@ | |||
| package deployment | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file name should be DeploymentConfigRestHandler
pkg/pipeline/ChartService.go
Outdated
| DeploymentTemplateValidate(templatejson interface{}, chartRefId int) (bool, error) | ||
| JsonSchemaExtractFromFile(chartRefId int) (map[string]interface{}, error) | ||
| GetSchemaAndReadmeForTemplateByChartRefId(chartRefId int) (schema []byte, readme []byte, err error) | ||
| ExtractChartIfMissing(ChartData []byte, RefChartDir string, Location string) (string, string, string, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name of arguments cant start with capital letter do it for all the functions added whereever applicable
pkg/pipeline/ChartService.go
Outdated
|
|
||
| dir := impl.chartTemplateService.GetDir() | ||
|
|
||
| RandomChartWorkingDir := filepath.Join(RefChartDir, Location) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not start with capital letter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and it may not be random
| return | ||
| } | ||
|
|
||
| exists, err := handler.chartRefRepository.DataExists(chartName, chartVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check this before extracting or atleast before copying otherwise this ll create issue, even though it is rejecting the upload it has already copied file in final destination
api/router/router.go
Outdated
| r.pProfRouter.initPProfRouter(pProfListenerRouter) | ||
|
|
||
| // deployment router starts | ||
| deploymentSubRouter := r.Router.PathPrefix("/orchestrator/deployment").Subrouter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is deployment/template
specs/deployments.yaml
Outdated
| description: form-data as request body | ||
| required: true | ||
| content: | ||
| application/json: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
content is not application/json
util/helper.go
Outdated
| } | ||
|
|
||
| func CheckForMissingFiles(ChartLocation string) error { | ||
| listofFiles := [7]string{"app-values.yaml", "Chart.yaml", "env-values.yaml", "pipeline-values.yaml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we had to check for both .yaml file as well as .yml file i dont see that here
| "time" | ||
| ) | ||
|
|
||
| type DeploymentRestHandler interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change interface and impl object from Deployment to DeploymentConfig, so that one does not gets it confused with deployment operation
| } | ||
|
|
||
| if err != nil { | ||
| common.WriteJsonResp(w, err, nil, http.StatusBadRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add log here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging was already done in the function for each and every error so to avoid duplicate logging I ignored logging here
| err = handler.chartRefRepository.Save(chartRefs) | ||
| if err != nil { | ||
| handler.Logger.Errorw("error in saving ConfigMap, CallbackConfigMap", "err", err) | ||
| common.WriteJsonResp(w, err, "Chart couldn't be saved", http.StatusBadRequest) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be InternalServerError(500), right?
|
|
||
| import "github.com/gorilla/mux" | ||
|
|
||
| type DeploymentRouter interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update interface and impl in this file to DeploymentConfig as well
api/router/router.go
Outdated
| r.pProfRouter.initPProfRouter(pProfListenerRouter) | ||
|
|
||
| // deployment router starts | ||
| deploymentSubRouter := r.Router.PathPrefix("/orchestrator/deployment/template").Subrouter() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please update this to deploymentConfig as well
| GetDefault() (*ChartRef, error) | ||
| FindById(id int) (*ChartRef, error) | ||
| GetAll() ([]*ChartRef, error) | ||
| DataExists(name string, version string) (bool, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we change this method name to CheckIfDataExists or something like this for clearer understanding?
pkg/pipeline/ChartService.go
Outdated
| ExtractChartIfMissing(chartData []byte, refChartDir string, location string) (*ChartDataInfo, error) | ||
| CheckChartExists(chartRefId int) error | ||
| GetChartLocation(chartDir string, fileName string) string | ||
| ValidateFileUploaded(fileName string) error |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we uploading any files in response?
pkg/pipeline/ChartService.go
Outdated
| return chartLocation | ||
| } | ||
|
|
||
| func (impl *ChartServiceImpl) ValidateFileUploaded(fileName string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for validating the received file in payload from user.. can we change the uploaded file part to avoid confusion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right it can be ValidateUploadedFile
pkg/pipeline/ChartService.go
Outdated
| CheckChartExists(chartRefId int) error | ||
| GetChartLocation(chartDir string, fileName string) string | ||
| ValidateFileUploaded(fileName string) error | ||
| ReadChartYamlForLocation(chartDir string, fileName string) (string, string, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can update the names of the output data variables here instead of only showing the type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the name of the function also, focus not on how but what. It is more like GetChartNameAndVersionForLocation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
most of the functions are following the above format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main action is fetching chart metadat and not reading file, if tomorrow we start reading it from some other file its name should not change
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is pending
pkg/pipeline/PropertiesConfig.go
Outdated
| var chartService ChartService | ||
| err := chartService.CheckChartExists(environmentProperties.ChartRefId) | ||
| if err != nil { | ||
| impl.logger.Errorw("error in getting missing chart for chartRefId", "err", err, "chartRefId") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please pass value for key chartRefId
util/helper.go
Outdated
| } | ||
| } | ||
| if len(missingFiles) != 0 { | ||
| return errors.New("Missing files " + strings.Join(missingFiles, ",") + " files") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing file name should be chart.yml or chart.yaml and not chart
util/helper.go
Outdated
| ".image_descriptor_template.json": true, | ||
| "chart": true, | ||
| } | ||
| missingFilesMap[".image_descriptor_template.json"] = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is redundant
Description
Added API for uploading templates directly
Fixes #1325
Allowing user to upload custom deployment templates
Type of change
How Has This Been Tested?
Changes are tested
Yes, checked uploading new charts, checked whether it rejects existing charts(name, version), checked by uploading file with missing files
Checklist: