Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
flux2
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
fluxcd
flux2
Commits
6c9c9c75
Unverified
Commit
6c9c9c75
authored
4 years ago
by
Michael Bridgen
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #790 from fluxcd/certs-for-imagerepo
Give image repository a cert-secret-ref flag
parents
b3b224b0
cc7b7b06
Branches
Branches containing commit
Tags
v0.37.0
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/flux/create_image_repository.go
+35
-3
35 additions, 3 deletions
cmd/flux/create_image_repository.go
docs/cmd/flux_create_image_repository.md
+31
-0
31 additions, 0 deletions
docs/cmd/flux_create_image_repository.md
with
66 additions
and
3 deletions
cmd/flux/create_image_repository.go
+
35
−
3
View file @
6c9c9c75
...
@@ -34,13 +34,39 @@ var createImageRepositoryCmd = &cobra.Command{
...
@@ -34,13 +34,39 @@ var createImageRepositoryCmd = &cobra.Command{
Short
:
"Create or update an ImageRepository object"
,
Short
:
"Create or update an ImageRepository object"
,
Long
:
`The create image repository command generates an ImageRepository resource.
Long
:
`The create image repository command generates an ImageRepository resource.
An ImageRepository object specifies an image repository to scan.`
,
An ImageRepository object specifies an image repository to scan.`
,
Example
:
` # Create an ImageRepository object to scan the alpine image repository:
flux create image repository alpine-repo --image alpine --interval 20m
# Create an image repository that uses an image pull secret (assumed to
# have been created already):
flux create image repository myapp-repo \
--secret-ref image-pull \
--image ghcr.io/example.com/myapp --interval 5m
# Create a TLS secret for a local image registry using a self-signed
# host certificate, and use it to scan an image. ca.pem is a file
# containing the CA certificate used to sign the host certificate.
flux create secret tls local-registry-cert --ca-file ./ca.pem
flux create image repository app-repo \
--cert-secret-ref local-registry-cert \
--image local-registry:5000/app --interval 5m
# Create a TLS secret with a client certificate and key, and use it
# to scan a private image registry.
flux create secret tls client-cert \
--cert-file client.crt --key-file client.key
flux create image repository app-repo \
--cert-secret-ref client-cert \
--image registry.example.com/private/app --interval 5m
`
,
RunE
:
createImageRepositoryRun
,
RunE
:
createImageRepositoryRun
,
}
}
type
imageRepoFlags
struct
{
type
imageRepoFlags
struct
{
image
string
image
string
secretRef
string
secretRef
string
timeout
time
.
Duration
certSecretRef
string
timeout
time
.
Duration
}
}
var
imageRepoArgs
=
imageRepoFlags
{}
var
imageRepoArgs
=
imageRepoFlags
{}
...
@@ -49,6 +75,7 @@ func init() {
...
@@ -49,6 +75,7 @@ func init() {
flags
:=
createImageRepositoryCmd
.
Flags
()
flags
:=
createImageRepositoryCmd
.
Flags
()
flags
.
StringVar
(
&
imageRepoArgs
.
image
,
"image"
,
""
,
"the image repository to scan; e.g., library/alpine"
)
flags
.
StringVar
(
&
imageRepoArgs
.
image
,
"image"
,
""
,
"the image repository to scan; e.g., library/alpine"
)
flags
.
StringVar
(
&
imageRepoArgs
.
secretRef
,
"secret-ref"
,
""
,
"the name of a docker-registry secret to use for credentials"
)
flags
.
StringVar
(
&
imageRepoArgs
.
secretRef
,
"secret-ref"
,
""
,
"the name of a docker-registry secret to use for credentials"
)
flags
.
StringVar
(
&
imageRepoArgs
.
certSecretRef
,
"cert-ref"
,
""
,
"the name of a secret to use for TLS certificates"
)
// NB there is already a --timeout in the global flags, for
// NB there is already a --timeout in the global flags, for
// controlling timeout on operations while e.g., creating objects.
// controlling timeout on operations while e.g., creating objects.
flags
.
DurationVar
(
&
imageRepoArgs
.
timeout
,
"scan-timeout"
,
0
,
"a timeout for scanning; this defaults to the interval if not set"
)
flags
.
DurationVar
(
&
imageRepoArgs
.
timeout
,
"scan-timeout"
,
0
,
"a timeout for scanning; this defaults to the interval if not set"
)
...
@@ -94,6 +121,11 @@ func createImageRepositoryRun(cmd *cobra.Command, args []string) error {
...
@@ -94,6 +121,11 @@ func createImageRepositoryRun(cmd *cobra.Command, args []string) error {
Name
:
imageRepoArgs
.
secretRef
,
Name
:
imageRepoArgs
.
secretRef
,
}
}
}
}
if
imageRepoArgs
.
certSecretRef
!=
""
{
repo
.
Spec
.
CertSecretRef
=
&
meta
.
LocalObjectReference
{
Name
:
imageRepoArgs
.
certSecretRef
,
}
}
if
createArgs
.
export
{
if
createArgs
.
export
{
return
printExport
(
exportImageRepository
(
&
repo
))
return
printExport
(
exportImageRepository
(
&
repo
))
...
...
This diff is collapsed.
Click to expand it.
docs/cmd/flux_create_image_repository.md
+
31
−
0
View file @
6c9c9c75
...
@@ -11,9 +11,40 @@ An ImageRepository object specifies an image repository to scan.
...
@@ -11,9 +11,40 @@ An ImageRepository object specifies an image repository to scan.
flux create image repository <name> [flags]
flux create image repository <name> [flags]
```
```
### Examples
```
# Create an ImageRepository object to scan the alpine image repository:
flux create image repository alpine-repo --image alpine --interval 20m
# Create an image repository that uses an image pull secret (assumed to
# have been created already):
flux create image repository myapp-repo \
--secret-ref image-pull \
--image ghcr.io/example.com/myapp --interval 5m
# Create a TLS secret for a local image registry using a self-signed
# host certificate, and use it to scan an image. ca.pem is a file
# containing the CA certificate used to sign the host certificate.
flux create secret tls local-registry-cert --ca-file ./ca.pem
flux create image repository app-repo \
--cert-secret-ref local-registry-cert \
--image local-registry:5000/app --interval 5m
# Create a TLS secret with a client certificate and key, and use it
# to scan a private image registry.
flux create secret tls client-cert \
--cert-file client.crt --key-file client.key
flux create image repository app-repo \
--cert-secret-ref client-cert \
--image registry.example.com/private/app --interval 5m
```
### Options
### Options
```
```
--cert-ref string the name of a secret to use for TLS certificates
-h, --help help for repository
-h, --help help for repository
--image string the image repository to scan; e.g., library/alpine
--image string the image repository to scan; e.g., library/alpine
--scan-timeout duration a timeout for scanning; this defaults to the interval if not set
--scan-timeout duration a timeout for scanning; this defaults to the interval if not set
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment