api

package
v2.2.101 Latest Latest
Warning

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

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

Documentation

Overview

Example (PrintVersionsTabular)
padChar = '-'
_ = printVersionsTabular()
Output:

KIND-------------------------- NAME---------------------------------- DEPRECATED IN-- REMOVED IN-- REPLACEMENT----------------------
Deployment-------------------- apps/v1------------------------------- n/a------------ n/a--------- n/a------------------------------
NetworkPolicy----------------- networking.k8s.io/v1------------------ n/a------------ n/a--------- n/a------------------------------
PodSecurityPolicy------------- policy/v1beta1------------------------ n/a------------ n/a--------- n/a------------------------------
Deployment-------------------- extensions/v1beta1-------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
Deployment-------------------- apps/v1beta2-------------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
Deployment-------------------- apps/v1beta1-------------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
StatefulSet------------------- apps/v1beta1-------------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
StatefulSet------------------- apps/v1beta2-------------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
NetworkPolicy----------------- extensions/v1beta1-------------------- v1.9.0--------- v1.16.0----- networking.k8s.io/v1-------------
Ingress----------------------- extensions/v1beta1-------------------- v1.14.0-------- v1.22.0----- networking.k8s.io/v1beta1--------
DaemonSet--------------------- apps/v1beta2-------------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
DaemonSet--------------------- extensions/v1beta1-------------------- v1.9.0--------- v1.16.0----- apps/v1--------------------------
PodSecurityPolicy------------- extensions/v1beta1-------------------- v1.10.0-------- v1.16.0----- policy/v1beta1-------------------
ReplicaSet-------------------- extensions/v1beta1-------------------- n/a------------ v1.16.0----- apps/v1--------------------------
ReplicaSet-------------------- apps/v1beta1-------------------------- n/a------------ v1.16.0----- apps/v1--------------------------
ReplicaSet-------------------- apps/v1beta2-------------------------- n/a------------ v1.16.0----- apps/v1--------------------------
PriorityClass----------------- scheduling.k8s.io/v1beta1------------- v1.14.0-------- v1.17.0----- scheduling.k8s.io/v1-------------
PriorityClass----------------- scheduling.k8s.io/v1alpha1------------ v1.14.0-------- v1.17.0----- scheduling.k8s.io/v1-------------
CustomResourceDefinition------ apiextensions.k8s.io/v1beta1---------- v1.16.0-------- v1.19.0----- apiextensions.k8s.io/v1----------
MutatingWebhookConfiguration-- admissionregistration.k8s.io/v1beta1-- v1.16.0-------- v1.19.0----- admissionregistration.k8s.io/v1--
ClusterRoleBinding------------ rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
ClusterRole------------------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
ClusterRoleBindingList-------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
ClusterRoleList--------------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
Role-------------------------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
RoleBinding------------------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
RoleList---------------------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
RoleBindingList--------------- rbac.authorization.k8s.io/v1alpha1---- v1.17.0-------- v1.20.0----- rbac.authorization.k8s.io/v1-----
CSINode----------------------- storage.k8s.io/v1beta1---------------- v1.17.0-------- n/a--------- n/a------------------------------

Index

Examples

Constants

This section is empty.

Variables

View Source
var VersionList = []Version{

	{"apps/v1", "Deployment", "", "", ""},
	{"networking.k8s.io/v1", "NetworkPolicy", "", "", ""},
	{"policy/v1beta1", "PodSecurityPolicy", "", "", ""},

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

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

	{"extensions/v1beta1", "NetworkPolicy", "v1.9.0", "v1.16.0", "networking.k8s.io/v1"},
	{"extensions/v1beta1", "Ingress", "v1.14.0", "v1.22.0", "networking.k8s.io/v1beta1"},

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

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

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

	{"scheduling.k8s.io/v1beta1", "PriorityClass", "v1.14.0", "v1.17.0", "scheduling.k8s.io/v1"},
	{"scheduling.k8s.io/v1alpha1", "PriorityClass", "v1.14.0", "v1.17.0", "scheduling.k8s.io/v1"},
	{"apiextensions.k8s.io/v1beta1", "CustomResourceDefinition", "v1.16.0", "v1.19.0", "apiextensions.k8s.io/v1"},

	{"admissionregistration.k8s.io/v1beta1", "MutatingWebhookConfiguration", "v1.16.0", "v1.19.0", "admissionregistration.k8s.io/v1"},

	{"rbac.authorization.k8s.io/v1alpha1", "ClusterRoleBinding", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "ClusterRole", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "ClusterRoleBindingList", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "ClusterRoleList", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "Role", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "RoleBinding", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "RoleList", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},
	{"rbac.authorization.k8s.io/v1alpha1", "RoleBindingList", "v1.17.0", "v1.20.0", "rbac.authorization.k8s.io/v1"},

	{"storage.k8s.io/v1beta1", "CSINode", "v1.17.0", "", ""},
}

VersionList is a set of apiVersions and if they are deprecated or not.

Functions

func PrintVersionList

func PrintVersionList(outputFormat string) error

PrintVersionList prints out the list of versions in a specific format

Example (Badformat)
VersionList = TestVersionList
_ = PrintVersionList("foo")
Output:

The output format must one of (normal|json|yaml)
Example (Json)
VersionList = TestVersionList
_ = PrintVersionList("json")
Output:

[{"version":"apps/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1"}]
Example (Normal)
VersionList = TestVersionList
_ = PrintVersionList("normal")
Output:

KIND-------- NAME---------- DEPRECATED IN-- REMOVED IN-- REPLACEMENT--
Deployment-- apps/v1beta1-- v1.9.0--------- v1.16.0----- apps/v1------
Example (Wide)
VersionList = TestVersionList
_ = PrintVersionList("wide")
Output:

KIND-------- NAME---------- DEPRECATED IN-- REMOVED IN-- REPLACEMENT--
Deployment-- apps/v1beta1-- v1.9.0--------- v1.16.0----- apps/v1------
Example (Yaml)
VersionList = TestVersionList
_ = PrintVersionList("yaml")
Output:

- version: apps/v1beta1
  kind: Deployment
  deprecated-in: v1.9.0
  removed-in: v1.16.0
  replacement-api: apps/v1

Types

type Instance

type Instance struct {
	Outputs            []*Output `json:"items,omitempty" yaml:"items,omitempty"`
	IgnoreDeprecations bool      `json:"-" yaml:"-"`
	IgnoreRemovals     bool      `json:"-" yaml:"-"`
	OutputFormat       string    `json:"-" yaml:"-"`
	ShowAll            bool      `json:"show-all,omitempty" yaml:"show-all,omitempty"`
	TargetVersion      string    `json:"target-version,omitempty" yaml:"target-version,omitempty"`
}

Instance is an instance of the API. This holds configuration for a "run" of Pluto

func (*Instance) DisplayOutput

func (instance *Instance) DisplayOutput() error

DisplayOutput prints the output based on desired variables

Example (BadFormat)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "foo",
	ShowAll:      false,
}
_ = instance.DisplayOutput()
Output:

output format should be one of (json,yaml,normal,wide)
Example (NoOutput)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
	},
	OutputFormat: "normal",
	ShowAll:      false,
}
_ = instance.DisplayOutput()
Output:

APIVersions were found, but none were deprecated. Try --show-all.
Example (Normal)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "normal",
	ShowAll:      false,
}
_ = instance.DisplayOutput()
Output:

NAME----------- KIND-------- VERSION------------- REPLACEMENT-- REMOVED-- DEPRECATED--
some name two-- Deployment-- extensions/v1beta1-- apps/v1------ true----- true--------
Example (ShowAll_json)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "json",
	ShowAll:      true,
}
_ = instance.DisplayOutput()
Output:

{"items":[{"name":"some name one","namespace":"pluto-namespace","api":{"version":"apps/v1","kind":"Deployment","deprecated-in":"","removed-in":"","replacement-api":""},"deprecated":false,"removed":false},{"name":"some name two","api":{"version":"extensions/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1"},"deprecated":true,"removed":true}],"show-all":true,"target-version":"v1.16.0"}
Example (ShowAll_normal)
instance := &Instance{
	TargetVersion: "v1.15.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "normal",
	ShowAll:      true,
}
_ = instance.DisplayOutput()
Output:

NAME----------- KIND-------- VERSION------------- REPLACEMENT-- REMOVED-- DEPRECATED--
some name one-- Deployment-- apps/v1------------- ------------- false---- false-------
some name two-- Deployment-- extensions/v1beta1-- apps/v1------ false---- true--------
Example (ShowAll_wide)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "wide",
	ShowAll:      true,
}
_ = instance.DisplayOutput()
Output:

NAME----------- NAMESPACE-------- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN--
some name one-- pluto-namespace-- Deployment-- apps/v1------------- ------------- false------- --------------- false---- ------------
some name two-- <UNKNOWN>-------- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0-----
Example (ShowAll_yaml)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "yaml",
	ShowAll:      true,
}
_ = instance.DisplayOutput()
Output:

items:
- name: some name one
  namespace: pluto-namespace
  api:
    version: apps/v1
    kind: Deployment
    deprecated-in: ""
    removed-in: ""
    replacement-api: ""
  deprecated: false
  removed: false
- name: some name two
  api:
    version: extensions/v1beta1
    kind: Deployment
    deprecated-in: v1.9.0
    removed-in: v1.16.0
    replacement-api: apps/v1
  deprecated: true
  removed: true
show-all: true
target-version: v1.16.0
Example (Wide)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs: []*Output{
		testOutput1,
		testOutput2,
	},
	OutputFormat: "wide",
	ShowAll:      false,
}
_ = instance.DisplayOutput()
Output:

NAME----------- NAMESPACE-- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN--
some name two-- <UNKNOWN>-- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0-----
Example (ZeroLength)
instance := &Instance{
	TargetVersion: "v1.16.0",
	Outputs:       []*Output{},
	OutputFormat:  "normal",
	ShowAll:       false,
}
_ = instance.DisplayOutput()
Output:

There were no apiVersions found that match our records.

func (*Instance) GetReturnCode

func (instance *Instance) GetReturnCode() int

GetReturnCode checks for deprecated versions and returns a code. takes a boolean to ignore any errors. exit 2 - version deprecated exit 3 - version removed

type Output

type Output struct {
	Name       string   `json:"name,omitempty" yaml:"name,omitempty"`
	Namespace  string   `json:"namespace,omitempty" yaml:"namespace,omitempty"`
	APIVersion *Version `json:"api,omitempty" yaml:"api,omitempty"`
	Deprecated bool     `json:"deprecated" yaml:"deprecated"`
	Removed    bool     `json:"removed" yaml:"removed"`
}

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"`
	Namespace string `json:"namespace" yaml:"namespace"`
}

StubMeta will catch kube resource metadata

type Version

type Version struct {
	// Name is the name of the api version
	Name string `json:"version" yaml:"version"`
	// Kind is the kind of object associated with this version
	Kind string `json:"kind" yaml:"kind"`
	// 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" yaml:"deprecated-in"`
	// RemovedIn denotes the version that the api was actually removed in
	// An empty string indicates that the version has not been removed yet
	RemovedIn string `json:"removed-in" yaml:"removed-in"`
	// ReplacementAPI is the apiVersion that replaces the deprecated one
	ReplacementAPI string `json:"replacement-api" yaml:"replacement-api"`
}

Version is an apiVersion and a flag for deprecation

Jump to

Keyboard shortcuts

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