whereabouts/vendor/github.com/containernetworking/cni/pkg/version/version.go
dependabot[bot] 1a37f45fc2
Bump the other-go-modules group with 8 updates
Bumps the other-go-modules group with 8 updates:

| Package | From | To |
| --- | --- | --- |
| [github.com/containernetworking/cni](https://github.com/containernetworking/cni) | `1.2.3` | `1.3.0` |
| [github.com/containernetworking/plugins](https://github.com/containernetworking/plugins) | `1.6.1` | `1.6.2` |
| [github.com/k8snetworkplumbingwg/network-attachment-definition-client](https://github.com/k8snetworkplumbingwg/network-attachment-definition-client) | `1.7.0` | `1.7.6` |
| [github.com/onsi/gomega](https://github.com/onsi/gomega) | `1.36.2` | `1.37.0` |
| [gomodules.xyz/jsonpatch/v2](https://github.com/gomodules/jsonpatch) | `2.4.0` | `2.5.0` |
| [github.com/go-co-op/gocron/v2](https://github.com/go-co-op/gocron) | `2.12.4` | `2.16.1` |
| [github.com/fsnotify/fsnotify](https://github.com/fsnotify/fsnotify) | `1.8.0` | `1.9.0` |
| [golang.org/x/time](https://github.com/golang/time) | `0.8.0` | `0.11.0` |


Updates `github.com/containernetworking/cni` from 1.2.3 to 1.3.0
- [Release notes](https://github.com/containernetworking/cni/releases)
- [Commits](https://github.com/containernetworking/cni/compare/v1.2.3...v1.3.0)

Updates `github.com/containernetworking/plugins` from 1.6.1 to 1.6.2
- [Release notes](https://github.com/containernetworking/plugins/releases)
- [Commits](https://github.com/containernetworking/plugins/compare/v1.6.1...v1.6.2)

Updates `github.com/k8snetworkplumbingwg/network-attachment-definition-client` from 1.7.0 to 1.7.6
- [Release notes](https://github.com/k8snetworkplumbingwg/network-attachment-definition-client/releases)
- [Commits](https://github.com/k8snetworkplumbingwg/network-attachment-definition-client/compare/v1.7.0...v1.7.6)

Updates `github.com/onsi/gomega` from 1.36.2 to 1.37.0
- [Release notes](https://github.com/onsi/gomega/releases)
- [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md)
- [Commits](https://github.com/onsi/gomega/compare/v1.36.2...v1.37.0)

Updates `gomodules.xyz/jsonpatch/v2` from 2.4.0 to 2.5.0
- [Release notes](https://github.com/gomodules/jsonpatch/releases)
- [Changelog](https://github.com/gomodules/jsonpatch/blob/release-2.0/CHANGELOG.md)
- [Commits](https://github.com/gomodules/jsonpatch/compare/v2.4.0...v2.5.0)

Updates `github.com/go-co-op/gocron/v2` from 2.12.4 to 2.16.1
- [Release notes](https://github.com/go-co-op/gocron/releases)
- [Commits](https://github.com/go-co-op/gocron/compare/v2.12.4...v2.16.1)

Updates `github.com/fsnotify/fsnotify` from 1.8.0 to 1.9.0
- [Release notes](https://github.com/fsnotify/fsnotify/releases)
- [Changelog](https://github.com/fsnotify/fsnotify/blob/main/CHANGELOG.md)
- [Commits](https://github.com/fsnotify/fsnotify/compare/v1.8.0...v1.9.0)

Updates `golang.org/x/time` from 0.8.0 to 0.11.0
- [Commits](https://github.com/golang/time/compare/v0.8.0...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/containernetworking/cni
  dependency-version: 1.3.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: other-go-modules
- dependency-name: github.com/containernetworking/plugins
  dependency-version: 1.6.2
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: other-go-modules
- dependency-name: github.com/k8snetworkplumbingwg/network-attachment-definition-client
  dependency-version: 1.7.6
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: other-go-modules
- dependency-name: github.com/onsi/gomega
  dependency-version: 1.37.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: other-go-modules
- dependency-name: gomodules.xyz/jsonpatch/v2
  dependency-version: 2.5.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: other-go-modules
- dependency-name: github.com/go-co-op/gocron/v2
  dependency-version: 2.16.1
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: other-go-modules
- dependency-name: github.com/fsnotify/fsnotify
  dependency-version: 1.9.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: other-go-modules
- dependency-name: golang.org/x/time
  dependency-version: 0.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: other-go-modules
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-04-25 03:45:28 +00:00

91 lines
2.8 KiB
Go

// Copyright 2016 CNI 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 version
import (
"encoding/json"
"fmt"
"github.com/containernetworking/cni/pkg/types"
"github.com/containernetworking/cni/pkg/types/create"
)
// Current reports the version of the CNI spec implemented by this library
func Current() string {
return "1.1.0"
}
// Legacy PluginInfo describes a plugin that is backwards compatible with the
// CNI spec version 0.1.0. In particular, a runtime compiled against the 0.1.0
// library ought to work correctly with a plugin that reports support for
// Legacy versions.
//
// Any future CNI spec versions which meet this definition should be added to
// this list.
var (
Legacy = PluginSupports("0.1.0", "0.2.0")
All = PluginSupports("0.1.0", "0.2.0", "0.3.0", "0.3.1", "0.4.0", "1.0.0", "1.1.0")
)
// VersionsFrom returns a list of versions starting from min, inclusive
func VersionsStartingFrom(min string) PluginInfo {
out := []string{}
// cheat, just assume ordered
ok := false
for _, v := range All.SupportedVersions() {
if !ok && v == min {
ok = true
}
if ok {
out = append(out, v)
}
}
return PluginSupports(out...)
}
// Finds a Result object matching the requested version (if any) and asks
// that object to parse the plugin result, returning an error if parsing failed.
func NewResult(version string, resultBytes []byte) (types.Result, error) {
return create.Create(version, resultBytes)
}
// ParsePrevResult parses a prevResult in a NetConf structure and sets
// the NetConf's PrevResult member to the parsed Result object.
func ParsePrevResult(conf *types.PluginConf) error {
if conf.RawPrevResult == nil {
return nil
}
// Prior to 1.0.0, Result types may not marshal a CNIVersion. Since the
// result version must match the config version, if the Result's version
// is empty, inject the config version.
if ver, ok := conf.RawPrevResult["CNIVersion"]; !ok || ver == "" {
conf.RawPrevResult["CNIVersion"] = conf.CNIVersion
}
resultBytes, err := json.Marshal(conf.RawPrevResult)
if err != nil {
return fmt.Errorf("could not serialize prevResult: %w", err)
}
conf.RawPrevResult = nil
conf.PrevResult, err = create.Create(conf.CNIVersion, resultBytes)
if err != nil {
return fmt.Errorf("could not parse prevResult: %w", err)
}
return nil
}