Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
9b5bec1d
Commit
9b5bec1d
authored
Nov 04, 2018
by
Song.Jin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
check if crd exist before try creating them
parent
d2daa4e2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
storage.go
storage/kubernetes/storage.go
+7
-3
No files found.
storage/kubernetes/storage.go
View file @
9b5bec1d
...
@@ -40,7 +40,6 @@ type Config struct {
...
@@ -40,7 +40,6 @@ type Config struct {
InCluster
bool
`json:"inCluster"`
InCluster
bool
`json:"inCluster"`
KubeConfigFile
string
`json:"kubeConfigFile"`
KubeConfigFile
string
`json:"kubeConfigFile"`
UseTPR
bool
`json:"useTPR"`
// Flag option to use TPRs instead of CRDs
UseTPR
bool
`json:"useTPR"`
// Flag option to use TPRs instead of CRDs
NoCrdCreation
bool
`json:"noCrdCreation"`
// Flag to disable creation of CRDs at cluster level
}
}
// Open returns a storage using Kubernetes third party resource.
// Open returns a storage using Kubernetes third party resource.
...
@@ -86,7 +85,7 @@ func (c *Config) open(logger logrus.FieldLogger, waitForResources bool) (*client
...
@@ -86,7 +85,7 @@ func (c *Config) open(logger logrus.FieldLogger, waitForResources bool) (*client
}
}
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
if
!
c
.
NoCrdCreation
{
logger
.
Info
(
"creating custom Kubernetes resources"
)
logger
.
Info
(
"creating custom Kubernetes resources"
)
if
!
cli
.
registerCustomResources
(
c
.
UseTPR
)
{
if
!
cli
.
registerCustomResources
(
c
.
UseTPR
)
{
if
waitForResources
{
if
waitForResources
{
...
@@ -119,7 +118,6 @@ func (c *Config) open(logger logrus.FieldLogger, waitForResources bool) (*client
...
@@ -119,7 +118,6 @@ func (c *Config) open(logger logrus.FieldLogger, waitForResources bool) (*client
return
nil
,
err
return
nil
,
err
}
}
}
}
}
// If the client is closed, stop trying to create resources.
// If the client is closed, stop trying to create resources.
cli
.
cancel
=
cancel
cli
.
cancel
=
cancel
...
@@ -150,6 +148,12 @@ func (cli *client) registerCustomResources(useTPR bool) (ok bool) {
...
@@ -150,6 +148,12 @@ func (cli *client) registerCustomResources(useTPR bool) (ok bool) {
resourceName
=
r
.
ObjectMeta
.
Name
resourceName
=
r
.
ObjectMeta
.
Name
}
else
{
}
else
{
r
:=
customResourceDefinitions
[
i
]
r
:=
customResourceDefinitions
[
i
]
var
i
interface
{}
cli
.
logger
.
Infof
(
"checking if resource %s has been created already..."
,
r
.
ObjectMeta
.
Name
)
if
err
:=
cli
.
list
(
r
.
Spec
.
Names
.
Plural
,
&
i
);
err
==
nil
{
cli
.
logger
.
Infof
(
"The custom resource already created %s, hence continue"
,
r
.
ObjectMeta
.
Name
)
continue
}
err
=
cli
.
postResource
(
"apiextensions.k8s.io/v1beta1"
,
""
,
"customresourcedefinitions"
,
r
)
err
=
cli
.
postResource
(
"apiextensions.k8s.io/v1beta1"
,
""
,
"customresourcedefinitions"
,
r
)
resourceName
=
r
.
ObjectMeta
.
Name
resourceName
=
r
.
ObjectMeta
.
Name
}
}
...
...
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