diff --git a/cmd/flux/create_image_repository.go b/cmd/flux/create_image_repository.go index 36357871..a853610d 100644 --- a/cmd/flux/create_image_repository.go +++ b/cmd/flux/create_image_repository.go @@ -34,6 +34,31 @@ var createImageRepositoryCmd = &cobra.Command{ Short: "Create or update an ImageRepository object", Long: `The create image repository command generates an ImageRepository resource. 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, } diff --git a/docs/cmd/flux_create_image_repository.md b/docs/cmd/flux_create_image_repository.md index d3ea7604..11dfc13f 100644 --- a/docs/cmd/flux_create_image_repository.md +++ b/docs/cmd/flux_create_image_repository.md @@ -11,9 +11,40 @@ An ImageRepository object specifies an image repository to scan. flux create image repository [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 ``` + --cert-ref string the name of a secret to use for TLS certificates -h, --help help for repository --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