Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
a99e7c87
Commit
a99e7c87
authored
Jan 02, 2020
by
Matt Kasa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Kubernetes TlsSecret
Relates to
https://gitlab.com/gitlab-org/gitlab/issues/33559
parent
b84eb951
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
+76
-0
lib/gitlab/kubernetes/tls_secret.rb
lib/gitlab/kubernetes/tls_secret.rb
+44
-0
spec/lib/gitlab/kubernetes/tls_secret_spec.rb
spec/lib/gitlab/kubernetes/tls_secret_spec.rb
+32
-0
No files found.
lib/gitlab/kubernetes/tls_secret.rb
0 → 100644
View file @
a99e7c87
# frozen_string_literal: true
module
Gitlab
module
Kubernetes
class
TlsSecret
attr_reader
:name
,
:cert
,
:key
,
:namespace_name
def
initialize
(
name
,
cert
,
key
,
namespace_name
)
@name
=
name
@cert
=
cert
@key
=
key
@namespace_name
=
namespace_name
end
def
generate
::
Kubeclient
::
Resource
.
new
(
type:
tls_secret_type
,
metadata:
metadata
,
data:
data
)
end
private
def
tls_secret_type
'kubernetes.io/tls'
end
def
metadata
{
name:
name
,
namespace:
namespace_name
}
end
def
data
{
'tls.crt'
:
Base64
.
strict_encode64
(
cert
),
'tls.key'
:
Base64
.
strict_encode64
(
key
)
}
end
end
end
end
spec/lib/gitlab/kubernetes/tls_secret_spec.rb
0 → 100644
View file @
a99e7c87
# frozen_string_literal: true
require
'spec_helper'
describe
Gitlab
::
Kubernetes
::
TlsSecret
do
let
(
:secret
)
{
described_class
.
new
(
name
,
cert
,
key
,
namespace
)
}
let
(
:name
)
{
'example-name'
}
let
(
:cert
)
{
'example-cert'
}
let
(
:key
)
{
'example-key'
}
let
(
:namespace
)
{
'example-namespace'
}
let
(
:data
)
do
{
'tls.crt'
:
Base64
.
strict_encode64
(
cert
),
'tls.key'
:
Base64
.
strict_encode64
(
key
)
}
end
describe
'#generate'
do
subject
{
secret
.
generate
}
let
(
:resource
)
do
::
Kubeclient
::
Resource
.
new
(
type:
'kubernetes.io/tls'
,
metadata:
{
name:
name
,
namespace:
namespace
},
data:
data
)
end
it
{
is_expected
.
to
eq
(
resource
)
}
end
end
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