Skip to content
This repository has been archived by the owner on Oct 9, 2023. It is now read-only.

Add UpdateProject functionality to Flyte control plane #114

Merged
merged 41 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
8f8f7e6
introduce pr to update project repo
kosigz Aug 13, 2020
0a3c9ef
wip
kosigz Aug 13, 2020
49d2159
wip
kosigz Aug 13, 2020
b82d9a4
wip + merge
kosigz Aug 13, 2020
6d72fc8
wip + compiles woot woot
kosigz Aug 13, 2020
206b18a
don't return types where unused; db write
kosigz Aug 14, 2020
7ebe9d6
check for writeTx error
kosigz Aug 14, 2020
6e1c679
interface
kosigz Aug 17, 2020
b992261
use get
kosigz Aug 17, 2020
a68c819
add first integration test
kosigz Aug 17, 2020
e3c1c72
cmts
kosigz Aug 17, 2020
c3667ad
fix
kosigz Aug 17, 2020
1c612b2
new integration test
kosigz Aug 17, 2020
bae3c4e
ci
kosigz Aug 17, 2020
85451db
apologies for all the commits; running CI off GitHub
kosigz Aug 17, 2020
5f34f8e
nit
kosigz Aug 17, 2020
34738e6
api update
kosigz Aug 17, 2020
7a8bf70
update mock interface
kosigz Aug 17, 2020
2953c95
wip
kosigz Aug 17, 2020
7fd36bd
mock update
kosigz Aug 17, 2020
1c56881
lol
kosigz Aug 17, 2020
20abeb6
bump back some dependencies
kosigz Aug 18, 2020
a319885
dep
kosigz Aug 18, 2020
a281fb6
unit test and migration
kosigz Aug 18, 2020
11daaaf
rebase
kosigz Aug 18, 2020
430a88f
protobuf
kosigz Aug 18, 2020
c2f6bc2
should be last dep change
kosigz Aug 18, 2020
301c7c3
revert go.mode and make compile
kosigz Aug 18, 2020
33e77d3
mock out more things, fix white space
kosigz Aug 18, 2020
a12d9fb
wip
kosigz Aug 18, 2020
5d7775a
wip
kosigz Aug 18, 2020
b8f87ab
gofmt
kosigz Aug 18, 2020
d466c6e
project
kosigz Aug 18, 2020
56a5355
Update pkg/repositories/gormimpl/project_repo.go
kosigz-lyft Aug 18, 2020
bc41a8f
Update pkg/repositories/gormimpl/project_repo.go
kosigz-lyft Aug 18, 2020
01fb1f7
cmnts
kosigz Aug 18, 2020
b2925ef
Merge branch 'update_project_repo' of github.com:lyft/flyteadmin into…
kosigz Aug 18, 2020
b1d7d96
truncate tables before tests
kosigz Aug 18, 2020
dd7e10d
update integration test
kosigz Aug 19, 2020
37b3805
integration test
kosigz Aug 19, 2020
2fcc285
:=
kosigz Aug 19, 2020
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
30 changes: 30 additions & 0 deletions pkg/repositories/gormimpl/project_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,33 @@ func NewProjectRepo(db *gorm.DB, errorTransformer errors.ErrorTransformer,
metrics: metrics,
}
}

func (r *ProjectRepo) UpdateProject(ctx context.Context, updatedProject models.Project) (models.Project, error) {
var project models.Project

timer := r.metrics.GetDuration.Start()
kosigz-lyft marked this conversation as resolved.
Show resolved Hide resolved
tx := r.db.Where(&models.Project{
Identifier: updatedProject.Identifier,
}).First(&project)
timer.Stop()

// Error handling and checking for the result of the database query.
if tx.Error != nil {
return models.Project{}, r.errorTransformer.ToFlyteAdminError(tx.Error)
}

if tx.RecordNotFound() {
return models.Project{}, flyteAdminErrors.NewFlyteAdminErrorf(codes.NotFound, "project [%s] not found", updatedProject.Identifier)
}

// TODO: update the project with the fields and persist to the DB.
if updatedProject.Description != "" {
project.Description = updatedProject.Description;
}

if len(updatedProject.Labels) > 0 {
project.Labels = updatedProject.Labels;
kosigz-lyft marked this conversation as resolved.
Show resolved Hide resolved
}

return models.Project{}, nil
}
2 changes: 2 additions & 0 deletions pkg/repositories/interfaces/project_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ type ProjectRepoInterface interface {
Get(ctx context.Context, projectID string) (models.Project, error)
// Lists unique projects registered as namespaces
ListAll(ctx context.Context, sortParameter common.SortParameter) ([]models.Project, error)
// Updates the properties of the given project.
UpdateProject(ctx context.Context, updatedProject models.Project) (models.Project, error)
}
1 change: 1 addition & 0 deletions pkg/repositories/models/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ type Project struct {
Identifier string `gorm:"primary_key"`
Name string // Human-readable name, not a unique identifier.
Description string `gorm:"type:varchar(300)"`
Labels []byte
}