api

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 17, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var VersionList = []Version{

	{"apps/v1", "Deployment", ""},
	{"extensions/v1beta1", "Deployment", "v1.16.0"},
	{"apps/v1beta2", "Deployment", "v1.16.0"},
	{"apps/v1beta1", "Deployment", "v1.16.0"},

	{"apps/v1beta1", "StatefulSet", "v1.16.0"},
	{"apps/v1beta2", "StatefulSet", "v1.16.0"},

	{"networking.k8s.io/v1", "NetworkPolicy", ""},
	{"extensions/v1beta1", "NetworkPolicy", "v1.16.0"},

	{"apps/v1beta2", "DaemonSet", "v1.16.0"},
	{"extensions/v1beta1", "DaemonSet", "v1.16.0"},

	{"policy/v1beta1", "PodSecurityPolicy", ""},
	{"extensions/v1beta1", "PodSecurityPolicy", "v1.16.0"},

	{"extensions/v1beta1", "ReplicaSet", "v1.16.0"},
	{"apps/v1beta1", "ReplicaSet", "v1.16.0"},
	{"apps/v1beta2", "ReplicaSet", "v1.16.0"},
}

VersionList is a set of apiVersions and if they are deprecated or not. TODO: Find a better way to generate this. Currently using the list for 1.16 from here: https://kubernetes.io/blog/2019/07/18/api-deprecations-in-1-16/

Functions

func DisplayOutput

func DisplayOutput(outputs []*Output, outputFormat string, showNonDeprecated bool, targetVersion string) error

DisplayOutput prints the output based on desired variables

Example
_ = DisplayOutput([]*Output{testOutput1, testOutput2}, "tabular", false, targetVersion116)
Output:

KIND-------- VERSION------------- DEPRECATED-- DEPRECATED IN-- RESOURCE NAME--
Deployment-- extensions/v1beta1-- true-------- v1.16.0-------- some name two--
Example (BadFormat)
_ = DisplayOutput([]*Output{testOutput1}, "foo", true, targetVersion116)
Output:

output format should be one of (json,yaml,tabular)
Example (Json)
_ = DisplayOutput([]*Output{testOutput1}, "json", true, targetVersion116)
Output:

[{"file":"some name one","api":{"version":"apps/v1","kind":"Deployment"}}]
Example (NoOutput)
_ = DisplayOutput([]*Output{testOutput1}, "tabular", false, targetVersion116)
Output:

APIVersions were found, but none were deprecated. Try --show-all.
Example (ShowNonDeprecated)
_ = DisplayOutput([]*Output{testOutput1}, "tabular", true, targetVersion116)
Output:

KIND-------- VERSION-- DEPRECATED-- DEPRECATED IN-- RESOURCE NAME--
Deployment-- apps/v1-- false------- n/a------------ some name one--
Example (Yaml)
_ = DisplayOutput([]*Output{testOutput1}, "yaml", true, targetVersion116)
Output:

- file: some name one
  api:
    version: apps/v1
    kind: Deployment
Example (ZeroLength)
_ = DisplayOutput([]*Output{}, "tabular", false, targetVersion116)
Output:

There were no apiVersions found that match our records.

func GetReturnCode added in v1.0.0

func GetReturnCode(outputs []*Output, ignoreErrors bool, targetVersion string) int

GetReturnCode checks for deprecated versions and returns a code. takes a boolean to ignore any errors.

Types

type Output

type Output struct {
	Name       string   `json:"file,omitempty" yaml:"file,omitempty"`
	APIVersion *Version `json:"api,omitempty" yaml:"api,omitempty"`
}

Output is a thing that has an apiVersion in it

func IsVersioned

func IsVersioned(data []byte) ([]*Output, error)

IsVersioned returns a version if the file data sent can be unmarshaled into a stub and matches a known version in the VersionList

type Stub

type Stub struct {
	Kind       string   `json:"kind" yaml:"kind"`
	APIVersion string   `json:"apiVersion" yaml:"apiVersion"`
	Metadata   StubMeta `json:"metadata" yaml:"metadata"`
}

Stub is a stub of a Kubernetes manifest that has just the name and apiVersion

type StubMeta

type StubMeta struct {
	Name string `json:"name" yaml:"name"`
}

StubMeta will catch kube resource metadata

type Version

type Version struct {
	// Name is the name of the api version
	Name string `json:"version,omitempty" yaml:"version,omitempty"`
	// Kind is the kind of object associated with this version
	Kind string `json:"kind,omitempty" yaml:"kind,omitempty"`
	// DeprecatedIn is a string that indicates what version the api is deprecated in
	// an empty string indicates that the version is not deprecated
	DeprecatedIn string `json:"deprecated-in,omitempty" yaml:"deprecated-in,omitempty"`
}

Version is an apiVersion and a flag for deprecation

func (*Version) IsDeprecatedIn added in v1.1.0

func (v *Version) IsDeprecatedIn(targetVersion string) bool

IsDeprecatedIn returns true if the version is deprecated in the targetVersion Will return false if the targetVersion passed is not a valid semver string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL