Documentation ¶
Index ¶
Examples ¶
- Instance (PrintVersionsTabular)
- Instance.DisplayOutput (Custom)
- Instance.DisplayOutput (Json)
- Instance.DisplayOutput (NoOutput)
- Instance.DisplayOutput (Normal)
- Instance.DisplayOutput (OnlyShowRemoved)
- Instance.DisplayOutput (Wide)
- Instance.DisplayOutput (Yaml)
- Instance.DisplayOutput (ZeroLength)
- Instance.PrintVersionList (Badformat)
- Instance.PrintVersionList (Json)
- Instance.PrintVersionList (Normal)
- Instance.PrintVersionList (Wide)
- Instance.PrintVersionList (Yaml)
Constants ¶
This section is empty.
Variables ¶
var PossibleColumnNames = []string{
"NAME",
"FILEPATH",
"NAMESPACE",
"KIND",
"VERSION",
"REPLACEMENT",
"DEPRECATED",
"DEPRECATED IN",
"REMOVED",
"REMOVED IN",
"COMPONENT",
}
PossibleColumnNames is the list of implmented columns
Functions ¶
func IsFileOrStdin ¶
IsFileOrStdin detects if a file exists, or returns true if - is passed
func StringInSlice ¶
StringInSlice returns true if the string is contained in the slice
Types ¶
type Instance ¶
type Instance struct { Outputs []*Output `json:"items,omitempty" yaml:"items,omitempty"` IgnoreDeprecations bool `json:"-" yaml:"-"` IgnoreRemovals bool `json:"-" yaml:"-"` OnlyShowRemoved bool `json:"-" yaml:"-"` OutputFormat string `json:"-" yaml:"-"` TargetVersions map[string]string `json:"target-versions,omitempty" yaml:"target-versions,omitempty"` DeprecatedVersions []Version `json:"-" yaml:"-"` CustomColumns []string `json:"-" yaml:"-"` Components []string `json:"-" yaml:"-"` }
Instance is an instance of the API. This holds configuration for a "run" of Pluto
Example (PrintVersionsTabular) ¶
instance := Instance{ DeprecatedVersions: []Version{ testVersionDeployment, {Kind: "testkind", Name: "testname", DeprecatedIn: "", RemovedIn: "", Component: "custom"}, }, } _ = instance.printVersionsTabular()
Output: KIND-------- NAME---------------- DEPRECATED IN-- REMOVED IN-- REPLACEMENT-- COMPONENT-- Deployment-- extensions/v1beta1-- v1.9.0--------- v1.16.0----- apps/v1------ k8s-------- testkind---- testname------------ n/a------------ n/a--------- n/a---------- custom-----
func (*Instance) DisplayOutput ¶
DisplayOutput prints the output based on desired variables
Example (Custom) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{ testOutput1, testOutput2, }, OutputFormat: "custom", Components: []string{"foo"}, CustomColumns: []string{"NAMESPACE", "NAME", "DEPRECATED IN", "DEPRECATED", "REPLACEMENT", "VERSION", "KIND", "COMPONENT", "FILEPATH"}, } _ = instance.DisplayOutput()
Output: NAME----------- NAMESPACE-------- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- COMPONENT-- FILEPATH------ some name one-- pluto-namespace-- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- foo-------- path-to-file-- some name two-- <UNKNOWN>-------- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- foo-------- <UNKNOWN>-----
Example (Json) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{ testOutput1, testOutput2, }, OutputFormat: "json", Components: []string{"foo"}, } _ = instance.DisplayOutput()
Output: {"items":[{"name":"some name one","filePath":"path-to-file","namespace":"pluto-namespace","api":{"version":"extensions/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1","component":"foo"},"deprecated":true,"removed":true},{"name":"some name two","api":{"version":"extensions/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1","component":"foo"},"deprecated":true,"removed":true}],"target-versions":{"foo":"v1.16.0"}}
Example (NoOutput) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{ testOutputNoOutput, }, OutputFormat: "normal", Components: []string{"foo"}, } _ = instance.DisplayOutput()
Output: No output to display
Example (Normal) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{ testOutput1, testOutput2, testOutputDeprecatedNotRemoved, }, OutputFormat: "normal", Components: []string{"foo"}, } _ = instance.DisplayOutput()
Output: NAME-------------------- KIND-------- VERSION------------- REPLACEMENT-- REMOVED-- DEPRECATED-- some name one----------- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- some name two----------- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- deprecated not removed-- Deployment-- apps/v1------------- none--------- false---- true--------
Example (OnlyShowRemoved) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, OnlyShowRemoved: true, Outputs: []*Output{ testOutput1, testOutput2, testOutputDeprecatedNotRemoved, }, OutputFormat: "normal", Components: []string{"foo"}, } _ = instance.DisplayOutput()
Output: NAME----------- KIND-------- VERSION------------- REPLACEMENT-- REMOVED-- DEPRECATED-- some name one-- Deployment-- extensions/v1beta1-- apps/v1------ true----- true-------- some name two-- Deployment-- extensions/v1beta1-- apps/v1------ true----- true--------
Example (Wide) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{ testOutput1, testOutput2, }, OutputFormat: "wide", Components: []string{"foo"}, } _ = instance.DisplayOutput()
Output: NAME----------- NAMESPACE-------- KIND-------- VERSION------------- REPLACEMENT-- DEPRECATED-- DEPRECATED IN-- REMOVED-- REMOVED IN-- some name one-- pluto-namespace-- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0----- some name two-- <UNKNOWN>-------- Deployment-- extensions/v1beta1-- apps/v1------ true-------- v1.9.0--------- true----- v1.16.0-----
Example (Yaml) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{ testOutput1, testOutput2, }, Components: []string{"foo"}, OutputFormat: "yaml", } _ = instance.DisplayOutput()
Output: items: - name: some name one filePath: path-to-file namespace: pluto-namespace api: version: extensions/v1beta1 kind: Deployment deprecated-in: v1.9.0 removed-in: v1.16.0 replacement-api: apps/v1 component: foo deprecated: true removed: true - name: some name two api: version: extensions/v1beta1 kind: Deployment deprecated-in: v1.9.0 removed-in: v1.16.0 replacement-api: apps/v1 component: foo deprecated: true removed: true target-versions: foo: v1.16.0
Example (ZeroLength) ¶
instance := &Instance{ TargetVersions: map[string]string{ "foo": "v1.16.0", }, Outputs: []*Output{}, OutputFormat: "normal", } _ = instance.DisplayOutput()
Output: There were no resources found with known deprecated apiVersions.
func (*Instance) FilterOutput ¶
func (instance *Instance) FilterOutput()
func (*Instance) GetReturnCode ¶
GetReturnCode checks for deprecated versions and returns a code. takes a boolean to ignore any errors. exit 2 - version deprecated exit 3 - version removed
func (*Instance) IsVersioned ¶
IsVersioned returns a version if the file data sent can be unmarshaled into a stub and matches a known version in the VersionList
func (*Instance) PrintVersionList ¶
PrintVersionList prints out the list of versions in a specific format
Example (Badformat) ¶
instance := Instance{ DeprecatedVersions: []Version{testVersionDeployment}, } _ = instance.PrintVersionList("foo")
Output: The output format must one of (normal|json|yaml)
Example (Json) ¶
instance := Instance{ DeprecatedVersions: []Version{testVersionDeployment}, } _ = instance.PrintVersionList("json")
Output: {"deprecated-versions":[{"version":"extensions/v1beta1","kind":"Deployment","deprecated-in":"v1.9.0","removed-in":"v1.16.0","replacement-api":"apps/v1","component":"k8s"}]}
Example (Normal) ¶
instance := Instance{ DeprecatedVersions: []Version{testVersionDeployment}, } _ = instance.PrintVersionList("normal")
Output: KIND-------- NAME---------------- DEPRECATED IN-- REMOVED IN-- REPLACEMENT-- COMPONENT-- Deployment-- extensions/v1beta1-- v1.9.0--------- v1.16.0----- apps/v1------ k8s--------
Example (Wide) ¶
instance := Instance{ DeprecatedVersions: []Version{testVersionDeployment}, } _ = instance.PrintVersionList("wide")
Output: KIND-------- NAME---------------- DEPRECATED IN-- REMOVED IN-- REPLACEMENT-- COMPONENT-- Deployment-- extensions/v1beta1-- v1.9.0--------- v1.16.0----- apps/v1------ k8s--------
Example (Yaml) ¶
instance := Instance{ DeprecatedVersions: []Version{testVersionDeployment}, } _ = instance.PrintVersionList("yaml")
Output: deprecated-versions: - version: extensions/v1beta1 kind: Deployment deprecated-in: v1.9.0 removed-in: v1.16.0 replacement-api: apps/v1 component: k8s
type Output ¶
type Output struct { // Name is the name of the object in question. // This might be an object name, or a release Name string `json:"name,omitempty" yaml:"name,omitempty"` // FilePath is the full path of the file if the output came from a file FilePath string `json:"filePath,omitempty" yaml:"filePath,omitempty"` // Namespace is the namespace that the object is in // The output may resolve this to UNKNOWN if there is no way of determining it Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` // APIVersion is the version object corresponding to this output APIVersion *Version `json:"api,omitempty" yaml:"api,omitempty"` // Deprecated is a boolean indicating whether or not the version is deprecated Deprecated bool `json:"deprecated" yaml:"deprecated"` // Removed is a boolean indicating whether or not the version has been removed Removed bool `json:"removed" yaml:"removed"` // CustomColumns is a list of column headers to be displayed when -ocustom CustomColumns []string `json:"-" yaml:"-"` }
Output is a thing that has an apiVersion in it
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"` // Component is the component associated with this version Component string `json:"component" yaml:"component"` }
Version is an apiVersion and a flag for deprecation
func CombineAdditionalVersions ¶
CombineAdditionalVersions adds additional versions into the defaults. If the additional versions contain any that already exist in the defaults, return an error
func GetDefaultVersionList ¶
GetDefaultVersionList gets the default versions from the versions.yaml file
type VersionFile ¶
type VersionFile struct { DeprecatedVersions []Version `json:"deprecated-versions" yaml:"deprecated-versions"` TargetVersions map[string]string `json:"target-versions,omitempty" yaml:"target-versions,omitempty"` }
VersionFile is a file with a list of deprecated versions