Skip to content
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 DeepCopy for AppSpec #165

Merged
merged 1 commit into from
May 14, 2018
Merged

Add DeepCopy for AppSpec #165

merged 1 commit into from
May 14, 2018

Conversation

disrani-px
Copy link
Contributor

The kubernetes APIs are no longer in 1.10 which causes issues
in projects that vendor torpedo. The recommended way is to generate
deepcopy functions, but AppSpec is simple enough.

out := new(AppSpec)
out.Key = in.Key
out.Enabled = in.Enabled
out.SpecList = make([]interface{}, len(in.SpecList))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either don't initialize the slice with the length, or don't use append

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this will result in a speclist slice of double the size of in.speclist.

The kubernetes APIs are no longer in 1.10 which causes issues
in projects that vendor torpedo. The recommended way is to generate
deepcopy functions, but AppSpec is simple enough.
out.Enabled = in.Enabled
out.SpecList = make([]interface{}, 0)
for _, spec := range in.SpecList {
out.SpecList = append(out.SpecList, spec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure how this will work when spec is a pointer
as we discussed, in future when we run tests in parallel, and modify the specs, it could be a problem

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, will need to be changed when we start running tests in parallel.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay; let's put a TODO here and/or create an issue to track it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created Issue #166

@disrani-px disrani-px merged commit 0cfc63f into master May 14, 2018
@harsh-px harsh-px deleted the deepcopy branch June 29, 2018 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants