-
Notifications
You must be signed in to change notification settings - Fork 932
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
Add CurrentDropletGUID attribute to application resource [main] #3354
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -27,6 +27,8 @@ type Application struct { | |||||
State constant.ApplicationState | ||||||
// Credentials are used by Cloud Native Buildpacks lifecycle to pull buildpacks | ||||||
Credentials map[string]interface{} | ||||||
// CurrentDropletGUID is the unique identifier of the droplet currently attached to the application. | ||||||
CurrentDropletGUID string | ||||||
} | ||||||
|
||||||
// ApplicationNameOnly represents only the name field of a Cloud Controller V3 Application | ||||||
|
@@ -42,10 +44,18 @@ func (a Application) MarshalJSON() ([]byte, error) { | |||||
Metadata: a.Metadata, | ||||||
} | ||||||
|
||||||
relationShips := Relationships{} | ||||||
|
||||||
if a.SpaceGUID != "" { | ||||||
ccApp.Relationships = Relationships{ | ||||||
constant.RelationshipTypeSpace: Relationship{GUID: a.SpaceGUID}, | ||||||
} | ||||||
relationShips[constant.RelationshipTypeSpace] = Relationship{GUID: a.SpaceGUID} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
if a.CurrentDropletGUID != "" { | ||||||
relationShips[constant.RelationshipTypeCurrentDroplet] = Relationship{GUID: a.CurrentDropletGUID} | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
if len(relationShips) > 0 { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this if statement here? if we could I would prefer to have it removed and always set relationships in the struct |
||||||
ccApp.Relationships = relationShips | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
} | ||||||
|
||||||
if a.LifecycleType == constant.AppLifecycleTypeDocker { | ||||||
|
@@ -81,6 +91,9 @@ func (a *Application) UnmarshalJSON(data []byte) error { | |||||
a.LifecycleType = lifecycle.Type | ||||||
a.Name = ccApp.Name | ||||||
a.SpaceGUID = ccApp.Relationships[constant.RelationshipTypeSpace].GUID | ||||||
if _, ok := ccApp.Relationships[constant.RelationshipTypeCurrentDroplet]; ok { | ||||||
a.CurrentDropletGUID = ccApp.Relationships[constant.RelationshipTypeCurrentDroplet].GUID | ||||||
} | ||||||
a.State = ccApp.State | ||||||
a.Metadata = ccApp.Metadata | ||||||
|
||||||
|
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.