-
Notifications
You must be signed in to change notification settings - Fork 42
Remove the ToOCI functions from the specs-go package #208
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
Copyright © 2021 The CDI Authors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cdi | ||
|
||
import ( | ||
spec "github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
|
||
// toOCI returns the opencontainers runtime Spec Hook for this Hook. | ||
func (h *Hook) toOCI() spec.Hook { | ||
return spec.Hook{ | ||
Path: h.Path, | ||
Args: h.Args, | ||
Env: h.Env, | ||
Timeout: h.Timeout, | ||
} | ||
} | ||
|
||
// toOCI returns the opencontainers runtime Spec Mount for this Mount. | ||
func (m *Mount) toOCI() spec.Mount { | ||
return spec.Mount{ | ||
Source: m.HostPath, | ||
Destination: m.ContainerPath, | ||
Options: m.Options, | ||
Type: m.Type, | ||
} | ||
} | ||
|
||
// toOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode. | ||
func (d *DeviceNode) toOCI() spec.LinuxDevice { | ||
return spec.LinuxDevice{ | ||
Path: d.Path, | ||
Type: d.Type, | ||
Major: d.Major, | ||
Minor: d.Minor, | ||
FileMode: d.FileMode, | ||
UID: d.UID, | ||
GID: d.GID, | ||
} | ||
} | ||
|
||
// toOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config. | ||
func (i *IntelRdt) toOCI() *spec.LinuxIntelRdt { | ||
return &spec.LinuxIntelRdt{ | ||
ClosID: i.ClosID, | ||
L3CacheSchema: i.L3CacheSchema, | ||
MemBwSchema: i.MemBwSchema, | ||
EnableCMT: i.EnableCMT, | ||
EnableMBM: i.EnableMBM, | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
module tags.cncf.io/container-device-interface/specs-go | ||
|
||
go 1.19 | ||
|
||
require github.com/opencontainers/runtime-spec v1.1.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +0,0 @@ | ||
github.com/opencontainers/runtime-spec v1.1.0 h1:HHUyrt9mwHUjtasSbXSMvs4cyFxh+Bll4AjJ9odEGpg= | ||
github.com/opencontainers/runtime-spec v1.1.0/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,56 @@ | ||
/* | ||
Copyright © 2021 The CDI Authors | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package specs | ||
|
||
import ( | ||
spec "github.com/opencontainers/runtime-spec/specs-go" | ||
) | ||
import "errors" | ||
|
||
// errDeprecated is returned for the ToOCI functions below. | ||
// This should provide better guidance for user when migrating from the API | ||
// below to the APIs provided in the cdi package. | ||
var errDeprecated = errors.New("deprecated; Use cdi package functions instead") | ||
|
||
// ToOCI returns the opencontainers runtime Spec Hook for this Hook. | ||
func (h *Hook) ToOCI() spec.Hook { | ||
return spec.Hook{ | ||
Path: h.Path, | ||
Args: h.Args, | ||
Env: h.Env, | ||
Timeout: h.Timeout, | ||
} | ||
// | ||
// Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.Hook.toOCI | ||
// and made private. | ||
func (h *Hook) ToOCI() error { | ||
return errDeprecated | ||
} | ||
|
||
// ToOCI returns the opencontainers runtime Spec Mount for this Mount. | ||
func (m *Mount) ToOCI() spec.Mount { | ||
return spec.Mount{ | ||
Source: m.HostPath, | ||
Destination: m.ContainerPath, | ||
Options: m.Options, | ||
Type: m.Type, | ||
} | ||
// | ||
// Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.Mount.toOCI | ||
// and made private. | ||
func (m *Mount) ToOCI() error { | ||
return errDeprecated | ||
} | ||
|
||
// ToOCI returns the opencontainers runtime Spec LinuxDevice for this DeviceNode. | ||
func (d *DeviceNode) ToOCI() spec.LinuxDevice { | ||
return spec.LinuxDevice{ | ||
Path: d.Path, | ||
Type: d.Type, | ||
Major: d.Major, | ||
Minor: d.Minor, | ||
FileMode: d.FileMode, | ||
UID: d.UID, | ||
GID: d.GID, | ||
} | ||
// | ||
// Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.DeviceNode.toOCI | ||
// and made private. | ||
func (d *DeviceNode) ToOCI() error { | ||
return errDeprecated | ||
} | ||
|
||
// ToOCI returns the opencontainers runtime Spec LinuxIntelRdt for this IntelRdt config. | ||
func (i *IntelRdt) ToOCI() *spec.LinuxIntelRdt { | ||
return &spec.LinuxIntelRdt{ | ||
ClosID: i.ClosID, | ||
L3CacheSchema: i.L3CacheSchema, | ||
MemBwSchema: i.MemBwSchema, | ||
EnableCMT: i.EnableCMT, | ||
EnableMBM: i.EnableMBM, | ||
} | ||
// | ||
// Deprecated: This function has been moved to tags.cncf.io/container-device-interface/pkg/cdi.IntelRdt.toOCI | ||
// and made private. | ||
func (i *IntelRdt) ToOCI() error { | ||
return errDeprecated | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@klihub @marquiz since moving these functions here is a breaking change, do we want to add "empty" implementations to
specs-go
so that we can mark these as deprecated. Something like: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.
Would it make sense to keep these APIs in the specs-go and add deprecation warnings to them, so both old and new APIs would co-exist for a deprecation period?
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.
The issue with that is that it would not remove the dependency, but yes, we could do that. Would you have a recommendation as to what the deprecation period should be?
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.
I guess if we really deprecate this the right way, we don't get rid of the dependency yet (so we don't return an interface either as suggested). The other alternative would be to do it the 'incorrectly/agressively', and because of the suggested empty interface-return signature change I am not sure if that is what @bart0sh was after, to keep a dummy implementation that is marked as deprecated, and maybe even panic from it.
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.
+1 for doing it aggressively. It makes sense after the above explanation, thanks @klihub