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

Added validation check to impose limits on stored, free-form strings #180

Merged
merged 13 commits into from
Aug 18, 2021
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ require (
github.com/pquerna/cachecontrol v0.0.0-20201205024021-ac21108117ac // indirect
github.com/prometheus/client_golang v1.9.0
github.com/prometheus/common v0.19.0 // indirect
github.com/qor/qor v0.0.0-20200729071734-d587cffbbb93 // indirect
github.com/qor/validations v0.0.0-20171228122639-f364bca61b46
github.com/sendgrid/rest v2.6.4+incompatible // indirect
github.com/sendgrid/sendgrid-go v3.10.0+incompatible
github.com/sirupsen/logrus v1.8.1 // indirect
Expand Down
16 changes: 15 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.0.0/go.mod h1:5f+cELGATgill5Pu3/vK3E
github.com/aws/aws-xray-sdk-go v0.9.4/go.mod h1:XtMKdBQfpVut+tJEwI7+dJFRxxRdxHDyVNp2tHXRq04=
github.com/aws/smithy-go v1.0.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
yindia marked this conversation as resolved.
Show resolved Hide resolved
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benlaurie/objecthash v0.0.0-20180202135721-d1e3d6079fc1 h1:VRtJdDi2lqc3MFwmouppm2jlm6icF+7H3WYKpLENMTo=
Expand Down Expand Up @@ -198,6 +199,7 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764=
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down Expand Up @@ -746,6 +748,7 @@ github.com/gopherjs/gopherjs v0.0.0-20181004151105-1babbf986f6f/go.mod h1:wJfORR
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
github.com/gorilla/handlers v1.4.2/go.mod h1:Qkdc/uu4tH4g6mTK6auzZ766c4CA0Ng8+o/OAirnOIQ=
github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4=
github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q=
Expand All @@ -762,6 +765,7 @@ github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gosimple/slug v1.9.0/go.mod h1:AMZ+sOVe65uByN3kgEyf9WEBKBCSS+dJjMX9x4vDJbg=
github.com/gotestyourself/gotestyourself v1.3.0/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY=
github.com/graymeta/stow v0.2.7 h1:b31cB1Ylw/388sYSZxnmpjT2QxC21AaQ8fRnUtE13b4=
Expand Down Expand Up @@ -857,14 +861,16 @@ github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dv
github.com/jcmturner/gofork v1.0.0/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jinzhu/gorm v1.9.2/go.mod h1:Vla75njaFJ8clLU1W44h34PjIkijhjHIYnZxMqCdxqo=
github.com/jinzhu/gorm v1.9.15/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/gorm v1.9.16 h1:+IyIjPEABKRpsu/F8OvDPy9fyQlgsg2luMV2ZIH5i5o=
github.com/jinzhu/gorm v1.9.16/go.mod h1:G3LB3wezTOWM2ITLzPxEXgSkOXAntiLHS7UdBefADcs=
github.com/jinzhu/inflection v0.0.0-20180308033659-04140366298a/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v0.0.0-20181116074157-8ec929ed50c3/go.mod h1:oHTiXerJ20+SfYcrdlBO7rzZRJWGwSTQ0iUY2jI6Gfc=
github.com/jinzhu/now v1.0.1 h1:HjfetcXq097iXP0uoPCdnM4Efp5/9MsM0/M+XOTeR3M=
github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jinzhu/now v1.1.1 h1:g39TucaRWyV3dwDO++eEc6qf8TVIQ/Da48WmqjZ3i7E=
github.com/jinzhu/now v1.1.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.3.0/go.mod h1:9QtRXoHjLGCJ5IBSaohpXITPlowMeeYCZ7fLUTSywik=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
Expand Down Expand Up @@ -945,6 +951,7 @@ github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.3.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM=
Expand Down Expand Up @@ -1014,6 +1021,7 @@ github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182aff
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/microcosm-cc/bluemonday v1.0.2/go.mod h1:iVP4YcDBq+n/5fb23BhYFvIMq/leAFZyRl6bYmGDlGc=
github.com/microcosm-cc/bluemonday v1.0.3/go.mod h1:8iwZnFn2CDDNZ0r6UXhF4xawGvzaqzCRa1n3/lO3W2w=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand Down Expand Up @@ -1203,6 +1211,12 @@ github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4O
github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4=
github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA=
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/qor/qor v0.0.0-20200729071734-d587cffbbb93 h1:kxseRCbX7NxSvKYSO1rXQCALzl3YLZvooxhhQdA23fU=
yindia marked this conversation as resolved.
Show resolved Hide resolved
github.com/qor/qor v0.0.0-20200729071734-d587cffbbb93/go.mod h1:i3WqgQWpyNJRB9D3ewgthf5/8fR/ALcvPGUqu5vHZA8=
github.com/qor/roles v0.0.0-20171127035124-d6375609fe3e/go.mod h1:++RicL9Ia/BrQHppwAsMc5CA7mAjnBLNniB46MzUteA=
github.com/qor/validations v0.0.0-20171228122639-f364bca61b46 h1:dRlsVUhwD1pwrasuVbNooGQITYjKzmXK5eYoEEvBGQI=
github.com/qor/validations v0.0.0-20171228122639-f364bca61b46/go.mod h1:UJsA0AuvrKNaWtrb1UzKai10mN3ZBbQkPjUHpxwahTc=
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be/go.mod h1:MIDFMn7db1kT65GmV94GzpX9Qdi7N/pQlwb+AN8wh+Q=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/rcrowley/go-metrics v0.0.0-20190826022208-cac0b30c2563/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/remyoudompheng/bigfft v0.0.0-20190728182440-6a916e37a237/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
Expand Down
2 changes: 2 additions & 0 deletions pkg/repositories/config/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres" // Required to import database driver.
"github.com/qor/validations"
)

const Postgres = "postgres"
Expand Down Expand Up @@ -77,5 +78,6 @@ func OpenDbConnection(config DbConnectionConfigProvider) *gorm.DB {
panic(err)
}
db.LogMode(config.IsDebug())
validations.RegisterCallbacks(db)
return db
}
22 changes: 11 additions & 11 deletions pkg/repositories/models/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ import (

// Execution primary key
type ExecutionKey struct {
Project string `gorm:"primary_key;column:execution_project"`
Domain string `gorm:"primary_key;column:execution_domain"`
Name string `gorm:"primary_key;column:execution_name"`
Project string `gorm:"primary_key;column:execution_project" valid:"length(0|255)"`
Domain string `gorm:"primary_key;column:execution_domain" valid:"length(0|255)"`
Name string `gorm:"primary_key;column:execution_name" valid:"length(0|255)"`
}

// Database model to encapsulate a (workflow) execution.
type Execution struct {
BaseModel
ExecutionKey
LaunchPlanID uint `gorm:"index"`
WorkflowID uint `gorm:"index"`
TaskID uint `gorm:"index"`
Phase string
LaunchPlanID uint `gorm:"index"`
WorkflowID uint `gorm:"index"`
TaskID uint `gorm:"index"`
Phase string `valid:"length(0|255)"`
Closure []byte
Spec []byte `gorm:"not null"`
StartedAt *time.Time
Expand All @@ -37,7 +37,7 @@ type Execution struct {
ExecutionEvents []ExecutionEvent
// In the case of an aborted execution this string may be non-empty.
// It should be ignored for any other value of phase other than aborted.
AbortCause string
AbortCause string `valid:"length(0|255)"`
// Corresponds to the execution mode used to trigger this execution
Mode int32
// The "parent" execution (if there is one) that is related to this execution.
Expand All @@ -47,16 +47,16 @@ type Execution struct {
// The parent node execution if this was launched by a node
ParentNodeExecutionID uint
// Cluster where execution was triggered
Cluster string
Cluster string `valid:"length(0|255)"`
// Offloaded location of inputs LiteralMap. These are the inputs evaluated and contain applied defaults.
InputsURI storage.DataReference
// User specified inputs. This map might be incomplete and not include defaults applied
UserInputsURI storage.DataReference
// Execution Error Kind. nullable
ErrorKind *string `gorm:"index"`
// Execution Error Code nullable
ErrorCode *string
ErrorCode *string `valid:"length(0|255)"`
// The user responsible for launching this execution.
// This is also stored in the spec but promoted as a column for filtering.
User string `gorm:"index"`
User string `gorm:"index" valid:"length(0|255)"`
}
2 changes: 1 addition & 1 deletion pkg/repositories/models/execution_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
type ExecutionEvent struct {
BaseModel
ExecutionKey
RequestID string
RequestID string `valid:"length(0|255)"`
OccurredAt time.Time
Phase string `gorm:"primary_key"`
}
8 changes: 4 additions & 4 deletions pkg/repositories/models/launch_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package models

// Launch plan primary key
type LaunchPlanKey struct {
Project string `gorm:"primary_key;index:lp_project_domain_name_idx,lp_project_domain_idx"`
Domain string `gorm:"primary_key;index:lp_project_domain_name_idx,lp_project_domain_idx"`
Name string `gorm:"primary_key;index:lp_project_domain_name_idx"`
Version string `gorm:"primary_key"`
Project string `gorm:"primary_key;index:lp_project_domain_name_idx,lp_project_domain_idx" valid:"length(0|255)"`
Domain string `gorm:"primary_key;index:lp_project_domain_name_idx,lp_project_domain_idx" valid:"length(0|255)"`
Name string `gorm:"primary_key;index:lp_project_domain_name_idx" valid:"length(0|255)"`
Version string `gorm:"primary_key" valid:"length(0|255)"`
}

type LaunchPlanScheduleType string
Expand Down
14 changes: 7 additions & 7 deletions pkg/repositories/models/named_entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

// NamedEntityMetadata primary key
type NamedEntityMetadataKey struct {
ResourceType core.ResourceType `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx"`
Project string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx"`
Domain string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx"`
Name string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx"`
ResourceType core.ResourceType `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
Project string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
Domain string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
Name string `gorm:"primary_key;index:named_entity_metadata_type_project_domain_name_idx" valid:"length(0|255)"`
}

// Fields to be composed into any named entity
Expand All @@ -30,9 +30,9 @@ type NamedEntityMetadata struct {
// fields here should match the ones in NamedEntityMetadataKey.
type NamedEntityKey struct {
ResourceType core.ResourceType
Project string
Domain string
Name string
Project string `valid:"length(0|255)"`
Domain string `valid:"length(0|255)"`
Name string `valid:"length(0|255)"`
}

// Composes an identifier (NamedEntity) and its associated metadata fields
Expand Down
2 changes: 1 addition & 1 deletion pkg/repositories/models/node_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

type NodeExecutionKey struct {
ExecutionKey
NodeID string `gorm:"primary_key;index"`
NodeID string `gorm:"primary_key;index" valid:"length(0|255)"`
}

// By convention, gorm foreign key references are of the form {ModelName}ID
Expand Down
2 changes: 1 addition & 1 deletion pkg/repositories/models/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package models
type Project struct {
BaseModel
Identifier string `gorm:"primary_key"`
Name string // Human-readable name, not a unique identifier.
Name string `valid:"length(0|255)"` // Human-readable name, not a unique identifier.
Description string `gorm:"type:varchar(300)"`
Labels []byte
// GORM doesn't save the zero value for ints, so we use a pointer for the State field
Expand Down
10 changes: 5 additions & 5 deletions pkg/repositories/models/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ type Resource struct {
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time `sql:"index"`
Project string `gorm:"unique_index:resource_idx"`
Domain string `gorm:"unique_index:resource_idx"`
Workflow string `gorm:"unique_index:resource_idx"`
LaunchPlan string `gorm:"unique_index:resource_idx"`
ResourceType string `gorm:"unique_index:resource_idx"`
Project string `gorm:"unique_index:resource_idx" valid:"length(0|255)"`
Domain string `gorm:"unique_index:resource_idx" valid:"length(0|255)"`
Workflow string `gorm:"unique_index:resource_idx" valid:"length(0|255)"`
LaunchPlan string `gorm:"unique_index:resource_idx" valid:"length(0|255)"`
ResourceType string `gorm:"unique_index:resource_idx" valid:"length(0|255)"`
Priority ResourcePriority
// Serialized flyteidl.admin.MatchingAttributes.
Attributes []byte
Expand Down
10 changes: 5 additions & 5 deletions pkg/repositories/models/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ package models

// Task primary key
type TaskKey struct {
Project string `gorm:"primary_key;index:task_project_domain_name_idx,task_project_domain_idx"`
Domain string `gorm:"primary_key;index:task_project_domain_name_idx,task_project_domain_idx"`
Name string `gorm:"primary_key;index:task_project_domain_name_idx"`
Version string `gorm:"primary_key"`
Project string `gorm:"primary_key;index:task_project_domain_name_idx,task_project_domain_idx" valid:"length(0|255)"`
Domain string `gorm:"primary_key;index:task_project_domain_name_idx,task_project_domain_idx" valid:"length(0|255)"`
Name string `gorm:"primary_key;index:task_project_domain_name_idx" valid:"length(0|255)"`
Version string `gorm:"primary_key" valid:"length(0|255)"`
}

// Database model to encapsulate a task.
Expand All @@ -19,5 +19,5 @@ type Task struct {
// Hash of the compiled task closure
Digest []byte
// Task type (also stored in the closure put promoted as a column for filtering).
Type string
Type string `valid:"length(0|255)"`
}
4 changes: 2 additions & 2 deletions pkg/repositories/models/task_execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ type TaskExecutionKey struct {
type TaskExecution struct {
BaseModel
TaskExecutionKey
Phase string
Phase string `valid:"length(0|255)"`
PhaseVersion uint32
InputURI string
InputURI string `valid:"length(0|255)"`
Closure []byte
StartedAt *time.Time
// Corresponds to the CreatedAt field in the TaskExecution closure
Expand Down
8 changes: 4 additions & 4 deletions pkg/repositories/models/workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package models

// Workflow primary key
type WorkflowKey struct {
Project string `gorm:"primary_key;index:workflow_project_domain_name_idx,workflow_project_domain_idx"`
Domain string `gorm:"primary_key;index:workflow_project_domain_name_idx,workflow_project_domain_idx"`
Name string `gorm:"primary_key;index:workflow_project_domain_name_idx"`
Project string `gorm:"primary_key;index:workflow_project_domain_name_idx,workflow_project_domain_idx" valid:"length(0|255)"`
Domain string `gorm:"primary_key;index:workflow_project_domain_name_idx,workflow_project_domain_idx" valid:"length(0|255)"`
Name string `gorm:"primary_key;index:workflow_project_domain_name_idx" valid:"length(0|255)"`
Version string `gorm:"primary_key"`
}

Expand All @@ -13,7 +13,7 @@ type Workflow struct {
BaseModel
WorkflowKey
TypedInterface []byte
RemoteClosureIdentifier string `gorm:"not null"`
RemoteClosureIdentifier string `gorm:"not null" valid:"length(0|255)"`
LaunchPlans []LaunchPlan
Executions []Execution
// Hash of the compiled workflow closure
Expand Down
9 changes: 9 additions & 0 deletions tests/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package tests
import (
"context"
"testing"
"fmt"

"github.com/golang/protobuf/proto"

Expand Down Expand Up @@ -42,13 +43,15 @@ func TestUpdateProjectDomainAttributes(t *testing.T) {
}

_, err := client.UpdateProjectDomainAttributes(ctx, &req)
fmt.Println(err)
assert.Nil(t, err)

response, err := client.GetProjectDomainAttributes(ctx, &admin.ProjectDomainAttributesGetRequest{
Project: "admintests",
Domain: "development",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
fmt.Println(err)
assert.Nil(t, err)
assert.True(t, proto.Equal(&admin.ProjectDomainAttributesGetResponse{
Attributes: &admin.ProjectDomainAttributes{
Expand All @@ -64,6 +67,7 @@ func TestUpdateProjectDomainAttributes(t *testing.T) {
Workflow: "workflow",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
fmt.Println(err)
assert.Nil(t, err)
// Testing that if overrides are not set at workflow level, the one from Project-Domain is returned
assert.True(t, proto.Equal(&admin.WorkflowAttributesGetResponse{
Expand All @@ -80,13 +84,15 @@ func TestUpdateProjectDomainAttributes(t *testing.T) {
Domain: "development",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
fmt.Println(err)
assert.Nil(t, err)

response, err = client.GetProjectDomainAttributes(ctx, &admin.ProjectDomainAttributesGetRequest{
Project: "admintests",
Domain: "development",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
fmt.Println(err)
assert.Nil(t, response)
assert.EqualError(t, err, "rpc error: code = NotFound desc = Resource [{Project:admintests Domain:development Workflow: LaunchPlan: ResourceType:TASK_RESOURCE}] not found")
}
Expand All @@ -110,6 +116,7 @@ func TestUpdateWorkflowAttributes(t *testing.T) {
}

_, err := client.UpdateWorkflowAttributes(ctx, &req)
fmt.Println(err)
assert.Nil(t, err)

response, err := client.GetWorkflowAttributes(ctx, &admin.WorkflowAttributesGetRequest{
Expand All @@ -118,6 +125,7 @@ func TestUpdateWorkflowAttributes(t *testing.T) {
Workflow: "workflow",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
fmt.Println(err)
assert.Nil(t, err)
assert.True(t, proto.Equal(&admin.WorkflowAttributesGetResponse{
Attributes: &admin.WorkflowAttributes{
Expand All @@ -134,6 +142,7 @@ func TestUpdateWorkflowAttributes(t *testing.T) {
Workflow: "workflow",
ResourceType: admin.MatchableResource_TASK_RESOURCE,
})
fmt.Println(err)
assert.Nil(t, err)

_, err = client.GetWorkflowAttributes(ctx, &admin.WorkflowAttributesGetRequest{
Expand Down