Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
834db16c
Unverified
Commit
834db16c
authored
May 31, 2019
by
Kubernetes Prow Robot
Committed by
GitHub
May 31, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #75202 from obitech/fix_linting_kubectl_apply
Fix linting kubectl apply
parents
b7fa33ec
ae41c020
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
0 deletions
+21
-0
apply.go
pkg/kubectl/cmd/apply/apply.go
+7
-0
apply_edit_last_applied.go
pkg/kubectl/cmd/apply/apply_edit_last_applied.go
+1
-0
apply_set_last_applied.go
pkg/kubectl/cmd/apply/apply_set_last_applied.go
+7
-0
apply_view_last_applied.go
pkg/kubectl/cmd/apply/apply_view_last_applied.go
+6
-0
No files found.
pkg/kubectl/cmd/apply/apply.go
View file @
834db16c
...
...
@@ -56,6 +56,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/validation"
)
// ApplyOptions defines flags and other configuration parameters for the `apply` command
type
ApplyOptions
struct
{
RecordFlags
*
genericclioptions
.
RecordFlags
Recorder
genericclioptions
.
Recorder
...
...
@@ -132,6 +133,7 @@ var (
warningNoLastAppliedConfigAnnotation
=
"Warning: %[1]s apply should be used on resource created by either %[1]s create --save-config or %[1]s apply
\n
"
)
// NewApplyOptions creates new ApplyOptions for the `apply` command
func
NewApplyOptions
(
ioStreams
genericclioptions
.
IOStreams
)
*
ApplyOptions
{
return
&
ApplyOptions
{
RecordFlags
:
genericclioptions
.
NewRecordFlags
(),
...
...
@@ -194,6 +196,7 @@ func NewCmdApply(baseName string, f cmdutil.Factory, ioStreams genericclioptions
return
cmd
}
// Complete verifies if ApplyOptions are valid and without conflicts.
func
(
o
*
ApplyOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
o
.
ServerSideApply
=
cmdutil
.
GetServerSideApplyFlag
(
cmd
)
o
.
ForceConflicts
=
cmdutil
.
GetForceConflictsFlag
(
cmd
)
...
...
@@ -325,6 +328,7 @@ func isIncompatibleServerError(err error) bool {
return
err
.
(
*
errors
.
StatusError
)
.
Status
()
.
Code
==
http
.
StatusUnsupportedMediaType
}
// Run executes the `apply` command.
func
(
o
*
ApplyOptions
)
Run
()
error
{
var
openapiSchema
openapi
.
Resources
if
o
.
OpenAPIPatch
{
...
...
@@ -761,6 +765,7 @@ func (p *Patcher) delete(namespace, name string) error {
return
runDelete
(
namespace
,
name
,
p
.
Mapping
,
p
.
DynamicClient
,
p
.
Cascade
,
p
.
GracePeriod
,
p
.
ServerDryRun
)
}
// Patcher defines options to patch OpenAPI objects.
type
Patcher
struct
{
Mapping
*
meta
.
RESTMapping
Helper
*
resource
.
Helper
...
...
@@ -926,6 +931,8 @@ func (p *Patcher) patchSimple(obj runtime.Object, modified []byte, source, names
return
patch
,
patchedObj
,
err
}
// Patch tries to patch an OpenAPI resource. On success, returns the merge patch as well
// the final patched object. On failure, returns an error.
func
(
p
*
Patcher
)
Patch
(
current
runtime
.
Object
,
modified
[]
byte
,
source
,
namespace
,
name
string
,
errOut
io
.
Writer
)
([]
byte
,
runtime
.
Object
,
error
)
{
var
getErr
error
patchBytes
,
patchObject
,
err
:=
p
.
patchSimple
(
current
,
modified
,
source
,
namespace
,
name
,
errOut
)
...
...
pkg/kubectl/cmd/apply/apply_edit_last_applied.go
View file @
834db16c
...
...
@@ -55,6 +55,7 @@ var (
kubectl apply edit-last-applied -f deploy.yaml -o json`
)
)
// NewCmdApplyEditLastApplied created the cobra CLI command for the `apply edit-last-applied` command.
func
NewCmdApplyEditLastApplied
(
f
cmdutil
.
Factory
,
ioStreams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
o
:=
editor
.
NewEditOptions
(
editor
.
ApplyEditMode
,
ioStreams
)
...
...
pkg/kubectl/cmd/apply/apply_set_last_applied.go
View file @
834db16c
...
...
@@ -37,6 +37,7 @@ import (
"k8s.io/kubernetes/pkg/kubectl/util/templates"
)
// SetLastAppliedOptions defines options for the `apply set-last-applied` command.`
type
SetLastAppliedOptions
struct
{
CreateAnnotation
bool
...
...
@@ -58,6 +59,7 @@ type SetLastAppliedOptions struct {
genericclioptions
.
IOStreams
}
// PatchBuffer caches changes that are to be applied.
type
PatchBuffer
struct
{
Patch
[]
byte
PatchType
types
.
PatchType
...
...
@@ -81,6 +83,7 @@ var (
`
))
)
// NewSetLastAppliedOptions takes option arguments from a CLI stream and returns it at SetLastAppliedOptions type.
func
NewSetLastAppliedOptions
(
ioStreams
genericclioptions
.
IOStreams
)
*
SetLastAppliedOptions
{
return
&
SetLastAppliedOptions
{
PrintFlags
:
genericclioptions
.
NewPrintFlags
(
"configured"
)
.
WithTypeSetter
(
scheme
.
Scheme
),
...
...
@@ -88,6 +91,7 @@ func NewSetLastAppliedOptions(ioStreams genericclioptions.IOStreams) *SetLastApp
}
}
// NewCmdApplySetLastApplied creates the cobra CLI `apply` subcommand `set-last-applied`.`
func
NewCmdApplySetLastApplied
(
f
cmdutil
.
Factory
,
ioStreams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
o
:=
NewSetLastAppliedOptions
(
ioStreams
)
cmd
:=
&
cobra
.
Command
{
...
...
@@ -112,6 +116,7 @@ func NewCmdApplySetLastApplied(f cmdutil.Factory, ioStreams genericclioptions.IO
return
cmd
}
// Complete populates dry-run and output flag options.
func
(
o
*
SetLastAppliedOptions
)
Complete
(
f
cmdutil
.
Factory
,
cmd
*
cobra
.
Command
)
error
{
o
.
dryRun
=
cmdutil
.
GetDryRunFlag
(
cmd
)
o
.
output
=
cmdutil
.
GetFlagString
(
cmd
,
"output"
)
...
...
@@ -141,6 +146,7 @@ func (o *SetLastAppliedOptions) Complete(f cmdutil.Factory, cmd *cobra.Command)
return
nil
}
// Validate checks SetLastAppliedOptions for validity.
func
(
o
*
SetLastAppliedOptions
)
Validate
()
error
{
r
:=
o
.
builder
.
Unstructured
()
.
...
...
@@ -187,6 +193,7 @@ func (o *SetLastAppliedOptions) Validate() error {
return
err
}
// RunSetLastApplied executes the `set-last-applied` command according to SetLastAppliedOptions.
func
(
o
*
SetLastAppliedOptions
)
RunSetLastApplied
()
error
{
for
i
,
patch
:=
range
o
.
patchBufferList
{
info
:=
o
.
infoList
[
i
]
...
...
pkg/kubectl/cmd/apply/apply_view_last_applied.go
View file @
834db16c
...
...
@@ -31,6 +31,7 @@ import (
"sigs.k8s.io/yaml"
)
// ViewLastAppliedOptions defines options for the `apply view-last-applied` command.`
type
ViewLastAppliedOptions
struct
{
FilenameOptions
resource
.
FilenameOptions
Selector
string
...
...
@@ -57,6 +58,7 @@ var (
kubectl apply view-last-applied -f deploy.yaml -o json`
))
)
// NewViewLastAppliedOptions takes option arguments from a CLI stream and returns it at ViewLastAppliedOptions type.
func
NewViewLastAppliedOptions
(
ioStreams
genericclioptions
.
IOStreams
)
*
ViewLastAppliedOptions
{
return
&
ViewLastAppliedOptions
{
OutputFormat
:
"yaml"
,
...
...
@@ -65,6 +67,7 @@ func NewViewLastAppliedOptions(ioStreams genericclioptions.IOStreams) *ViewLastA
}
}
// NewCmdApplyViewLastApplied creates the cobra CLI `apply` subcommand `view-last-applied`.`
func
NewCmdApplyViewLastApplied
(
f
cmdutil
.
Factory
,
ioStreams
genericclioptions
.
IOStreams
)
*
cobra
.
Command
{
options
:=
NewViewLastAppliedOptions
(
ioStreams
)
...
...
@@ -90,6 +93,7 @@ func NewCmdApplyViewLastApplied(f cmdutil.Factory, ioStreams genericclioptions.I
return
cmd
}
// Complete checks an object for last-applied-configuration annotations.
func
(
o
*
ViewLastAppliedOptions
)
Complete
(
cmd
*
cobra
.
Command
,
f
cmdutil
.
Factory
,
args
[]
string
)
error
{
cmdNamespace
,
enforceNamespace
,
err
:=
f
.
ToRawKubeConfigLoader
()
.
Namespace
()
if
err
!=
nil
{
...
...
@@ -134,10 +138,12 @@ func (o *ViewLastAppliedOptions) Complete(cmd *cobra.Command, f cmdutil.Factory,
return
nil
}
// Validate checks ViewLastAppliedOptions for validity.
func
(
o
*
ViewLastAppliedOptions
)
Validate
(
cmd
*
cobra
.
Command
)
error
{
return
nil
}
// RunApplyViewLastApplied executes the `view-last-applied` command according to ViewLastAppliedOptions.
func
(
o
*
ViewLastAppliedOptions
)
RunApplyViewLastApplied
(
cmd
*
cobra
.
Command
)
error
{
for
_
,
str
:=
range
o
.
LastAppliedConfigurationList
{
switch
o
.
OutputFormat
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment