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
1d6b83d8
Commit
1d6b83d8
authored
Apr 23, 2020
by
galal-hussein
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go generate
parent
30b1fb0e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
32 deletions
+48
-32
factory.go
pkg/generated/controllers/k3s.cattle.io/factory.go
+25
-10
addon.go
pkg/generated/controllers/k3s.cattle.io/v1/addon.go
+23
-22
No files found.
pkg/generated/controllers/k3s.cattle.io/factory.go
View file @
1d6b83d8
...
...
@@ -52,18 +52,23 @@ func NewFactoryFromConfigOrDie(config *rest.Config) *Factory {
}
func
NewFactoryFromConfig
(
config
*
rest
.
Config
)
(
*
Factory
,
error
)
{
cs
,
err
:=
clientset
.
NewForConfig
(
config
)
if
err
!=
nil
{
return
nil
,
err
}
informerFactory
:=
informers
.
NewSharedInformerFactory
(
cs
,
2
*
time
.
Hour
)
return
NewFactory
(
cs
,
informerFactory
),
nil
return
NewFactoryFromConfigWithOptions
(
config
,
nil
)
}
func
NewFactoryFromConfigWithNamespace
(
config
*
rest
.
Config
,
namespace
string
)
(
*
Factory
,
error
)
{
if
namespace
==
""
{
return
NewFactoryFromConfig
(
config
)
return
NewFactoryFromConfigWithOptions
(
config
,
&
FactoryOptions
{
Namespace
:
namespace
,
})
}
type
FactoryOptions
struct
{
Namespace
string
Resync
time
.
Duration
}
func
NewFactoryFromConfigWithOptions
(
config
*
rest
.
Config
,
opts
*
FactoryOptions
)
(
*
Factory
,
error
)
{
if
opts
==
nil
{
opts
=
&
FactoryOptions
{}
}
cs
,
err
:=
clientset
.
NewForConfig
(
config
)
...
...
@@ -71,7 +76,17 @@ func NewFactoryFromConfigWithNamespace(config *rest.Config, namespace string) (*
return
nil
,
err
}
informerFactory
:=
informers
.
NewSharedInformerFactoryWithOptions
(
cs
,
2
*
time
.
Hour
,
informers
.
WithNamespace
(
namespace
))
resync
:=
opts
.
Resync
if
resync
==
0
{
resync
=
2
*
time
.
Hour
}
if
opts
.
Namespace
==
""
{
informerFactory
:=
informers
.
NewSharedInformerFactory
(
cs
,
resync
)
return
NewFactory
(
cs
,
informerFactory
),
nil
}
informerFactory
:=
informers
.
NewSharedInformerFactoryWithOptions
(
cs
,
resync
,
informers
.
WithNamespace
(
opts
.
Namespace
))
return
NewFactory
(
cs
,
informerFactory
),
nil
}
...
...
pkg/generated/controllers/k3s.cattle.io/v1/addon.go
View file @
1d6b83d8
...
...
@@ -29,6 +29,7 @@ import (
"github.com/rancher/wrangler/pkg/apply"
"github.com/rancher/wrangler/pkg/condition"
"github.com/rancher/wrangler/pkg/generic"
"github.com/rancher/wrangler/pkg/kv"
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/api/errors"
metav1
"k8s.io/apimachinery/pkg/apis/meta/v1"
...
...
@@ -267,6 +268,7 @@ func RegisterAddonGeneratingHandler(ctx context.Context, controller AddonControl
if
opts
!=
nil
{
statusHandler
.
opts
=
*
opts
}
controller
.
OnChange
(
ctx
,
name
,
statusHandler
.
Remove
)
RegisterAddonStatusHandler
(
ctx
,
controller
,
condition
,
name
,
statusHandler
.
Handle
)
}
...
...
@@ -281,7 +283,7 @@ func (a *addonStatusHandler) sync(key string, obj *v1.Addon) (*v1.Addon, error)
return
obj
,
nil
}
origStatus
:=
obj
.
Status
origStatus
:=
obj
.
Status
.
DeepCopy
()
obj
=
obj
.
DeepCopy
()
newStatus
,
err
:=
a
.
handler
(
obj
,
obj
.
Status
)
if
err
!=
nil
{
...
...
@@ -289,16 +291,16 @@ func (a *addonStatusHandler) sync(key string, obj *v1.Addon) (*v1.Addon, error)
newStatus
=
*
origStatus
.
DeepCopy
()
}
obj
.
Status
=
newStatus
if
a
.
condition
!=
""
{
if
errors
.
IsConflict
(
err
)
{
a
.
condition
.
SetError
(
obj
,
""
,
nil
)
a
.
condition
.
SetError
(
&
newStatus
,
""
,
nil
)
}
else
{
a
.
condition
.
SetError
(
obj
,
""
,
err
)
a
.
condition
.
SetError
(
&
newStatus
,
""
,
err
)
}
}
if
!
equality
.
Semantic
.
DeepEqual
(
origStatus
,
obj
.
Status
)
{
if
!
equality
.
Semantic
.
DeepEqual
(
origStatus
,
&
new
Status
)
{
var
newErr
error
obj
.
Status
=
newStatus
obj
,
newErr
=
a
.
client
.
UpdateStatus
(
obj
)
if
err
==
nil
{
err
=
newErr
...
...
@@ -315,29 +317,28 @@ type addonGeneratingHandler struct {
name
string
}
func
(
a
*
addonGeneratingHandler
)
Handle
(
obj
*
v1
.
Addon
,
status
v1
.
AddonStatus
)
(
v1
.
AddonStatus
,
error
)
{
objs
,
newStatus
,
err
:=
a
.
AddonGeneratingHandler
(
obj
,
status
)
if
err
!=
nil
{
return
newStatus
,
err
func
(
a
*
addonGeneratingHandler
)
Remove
(
key
string
,
obj
*
v1
.
Addon
)
(
*
v1
.
Addon
,
error
)
{
if
obj
!=
nil
{
return
obj
,
nil
}
apply
:=
a
.
apply
if
!
a
.
opts
.
DynamicLookup
{
apply
=
apply
.
WithStrictCaching
()
}
obj
=
&
v1
.
Addon
{}
obj
.
Namespace
,
obj
.
Name
=
kv
.
RSplit
(
key
,
"/"
)
obj
.
SetGroupVersionKind
(
a
.
gvk
)
if
!
a
.
opts
.
AllowCrossNamespace
&&
!
a
.
opts
.
AllowClusterScoped
{
apply
=
apply
.
WithSetOwnerReference
(
true
,
false
)
.
WithDefaultNamespace
(
obj
.
GetNamespace
()
)
.
WithListerNamespace
(
obj
.
GetNamespace
()
)
}
return
nil
,
generic
.
ConfigureApplyForObject
(
a
.
apply
,
obj
,
&
a
.
opts
)
.
WithOwner
(
obj
)
.
WithSetID
(
a
.
name
)
.
ApplyObjects
(
)
}
if
!
a
.
opts
.
AllowClusterScoped
{
apply
=
apply
.
WithRestrictClusterScoped
()
func
(
a
*
addonGeneratingHandler
)
Handle
(
obj
*
v1
.
Addon
,
status
v1
.
AddonStatus
)
(
v1
.
AddonStatus
,
error
)
{
objs
,
newStatus
,
err
:=
a
.
AddonGeneratingHandler
(
obj
,
status
)
if
err
!=
nil
{
return
newStatus
,
err
}
return
newStatus
,
apply
.
return
newStatus
,
generic
.
ConfigureApplyForObject
(
a
.
apply
,
obj
,
&
a
.
opts
)
.
WithOwner
(
obj
)
.
WithSetID
(
a
.
name
)
.
ApplyObjects
(
objs
...
)
...
...
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