├── .github ├── dependabot.yaml └── workflows │ ├── govulncheck.yaml │ ├── make-self-upgrade.yaml │ └── release.yaml ├── .gitignore ├── .golangci.yaml ├── .goreleaser.yml ├── LICENSE ├── Makefile ├── OWNERS ├── OWNERS_ALIASES ├── README.md ├── RELEASE.md ├── cmd └── cmd.go ├── go.mod ├── go.sum ├── internal ├── util │ ├── exit.go │ ├── exit_test.go │ ├── signal.go │ ├── signal_posix.go │ ├── signal_test.go │ └── signal_windows.go └── versionchecker │ ├── fromcrd.go │ ├── fromlabels.go │ ├── fromservice.go │ ├── test │ ├── getpodfromtemplate_test.go │ ├── testdata │ │ ├── fetch.go │ │ ├── go.mod │ │ ├── go.sum │ │ └── test_manifests.yaml │ └── versionchecker_test.go │ └── versionchecker.go ├── klone.yaml ├── main.go ├── make ├── 00_mod.mk ├── 02_mod.mk ├── _shared │ ├── boilerplate │ │ ├── 00_mod.mk │ │ ├── 01_mod.mk │ │ └── template │ │ │ └── boilerplate.go.txt │ ├── cert-manager │ │ ├── 00_mod.mk │ │ └── 01_mod.mk │ ├── executable │ │ ├── 00_mod.mk │ │ └── 01_mod.mk │ ├── generate-verify │ │ ├── 00_mod.mk │ │ ├── 02_mod.mk │ │ └── util │ │ │ └── verify.sh │ ├── go │ │ ├── .golangci.override.yaml │ │ ├── 01_mod.mk │ │ ├── README.md │ │ └── base │ │ │ └── .github │ │ │ └── workflows │ │ │ └── govulncheck.yaml │ ├── help │ │ ├── 01_mod.mk │ │ └── help.sh │ ├── klone │ │ └── 01_mod.mk │ ├── repository-base │ │ ├── 01_mod.mk │ │ ├── base-dependabot │ │ │ └── .github │ │ │ │ └── dependabot.yaml │ │ └── base │ │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── make-self-upgrade.yaml │ │ │ ├── LICENSE │ │ │ ├── Makefile │ │ │ └── OWNERS_ALIASES │ └── tools │ │ ├── 00_mod.mk │ │ └── util │ │ ├── checkhash.sh │ │ ├── hash.sh │ │ └── lock.sh ├── test-integration.mk └── test-unit.mk ├── pkg ├── approve │ ├── approve.go │ └── approve_test.go ├── build │ ├── build.go │ └── commands │ │ └── commands.go ├── check │ ├── api │ │ └── api.go │ └── check.go ├── completion │ ├── bash.go │ ├── completion.go │ ├── fish.go │ ├── kubectl.go │ ├── powershell.go │ └── zsh.go ├── convert │ ├── convert.go │ ├── internal │ │ └── apis │ │ │ ├── acme │ │ │ ├── doc.go │ │ │ ├── fuzzer │ │ │ │ └── fuzzer.go │ │ │ ├── install │ │ │ │ ├── install.go │ │ │ │ └── roundtrip_test.go │ │ │ ├── register.go │ │ │ ├── types_challenge.go │ │ │ ├── types_issuer.go │ │ │ ├── types_order.go │ │ │ ├── v1 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ └── zz_generated.defaults.go │ │ │ ├── v1alpha2 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── types.go │ │ │ │ ├── types_challenge.go │ │ │ │ ├── types_issuer.go │ │ │ │ ├── types_order.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ ├── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.defaults.go │ │ │ ├── v1alpha3 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── types.go │ │ │ │ ├── types_challenge.go │ │ │ │ ├── types_issuer.go │ │ │ │ ├── types_order.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ ├── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.defaults.go │ │ │ ├── v1beta1 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── types.go │ │ │ │ ├── types_challenge.go │ │ │ │ ├── types_issuer.go │ │ │ │ ├── types_order.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ ├── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.defaults.go │ │ │ └── zz_generated.deepcopy.go │ │ │ ├── certmanager │ │ │ ├── doc.go │ │ │ ├── fuzzer │ │ │ │ └── fuzzer.go │ │ │ ├── install │ │ │ │ ├── install.go │ │ │ │ └── roundtrip_test.go │ │ │ ├── register.go │ │ │ ├── types.go │ │ │ ├── types_certificate.go │ │ │ ├── types_certificaterequest.go │ │ │ ├── types_issuer.go │ │ │ ├── v1 │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ └── zz_generated.defaults.go │ │ │ ├── v1alpha2 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── types.go │ │ │ │ ├── types_certificate.go │ │ │ │ ├── types_certificaterequest.go │ │ │ │ ├── types_issuer.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ ├── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.defaults.go │ │ │ ├── v1alpha3 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── types.go │ │ │ │ ├── types_certificate.go │ │ │ │ ├── types_certificaterequest.go │ │ │ │ ├── types_issuer.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ ├── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.defaults.go │ │ │ ├── v1beta1 │ │ │ │ ├── conversion.go │ │ │ │ ├── defaults.go │ │ │ │ ├── doc.go │ │ │ │ ├── register.go │ │ │ │ ├── types.go │ │ │ │ ├── types_certificate.go │ │ │ │ ├── types_certificaterequest.go │ │ │ │ ├── types_issuer.go │ │ │ │ ├── zz_generated.conversion.go │ │ │ │ ├── zz_generated.deepcopy.go │ │ │ │ └── zz_generated.defaults.go │ │ │ └── zz_generated.deepcopy.go │ │ │ └── meta │ │ │ ├── doc.go │ │ │ ├── fuzzer │ │ │ └── fuzzer.go │ │ │ ├── install │ │ │ ├── install.go │ │ │ └── roundtrip_test.go │ │ │ ├── register.go │ │ │ ├── types.go │ │ │ ├── v1 │ │ │ ├── conversion.go │ │ │ ├── defaults.go │ │ │ ├── doc.go │ │ │ ├── register.go │ │ │ ├── zz_generated.conversion.go │ │ │ └── zz_generated.defaults.go │ │ │ └── zz_generated.deepcopy.go │ └── scheme.go ├── create │ ├── certificaterequest │ │ ├── certificaterequest.go │ │ └── certificaterequest_test.go │ ├── certificatesigningrequest │ │ ├── certificatesigningrequest.go │ │ └── certificatesigningrequest_test.go │ └── create.go ├── deny │ ├── deny.go │ └── deny_test.go ├── experimental │ └── experimental.go ├── factory │ ├── factory.go │ └── validargs.go ├── inspect │ ├── inspect.go │ └── secret │ │ ├── secret.go │ │ ├── secret_test.go │ │ ├── util.go │ │ └── util_test.go ├── install │ ├── helm │ │ ├── applycrd.go │ │ ├── flags.go │ │ ├── resource.go │ │ └── settings.go │ ├── install.go │ └── util.go ├── renew │ ├── renew.go │ └── renew_test.go ├── status │ ├── certificate │ │ ├── certificate.go │ │ ├── certificate_test.go │ │ └── types.go │ ├── status.go │ └── util │ │ └── util.go ├── uninstall │ └── uninstall.go ├── upgrade │ ├── migrateapiversion │ │ ├── command.go │ │ └── migrator.go │ └── upgrade.go └── version │ └── version.go └── test └── integration ├── ctl_convert_test.go ├── ctl_create_cr_test.go ├── ctl_install_test.go ├── ctl_renew_test.go ├── ctl_status_certificate_test.go ├── ctl_uninstall_test.go ├── framework ├── apiserver.go └── helpers.go ├── install_framework └── framework.go ├── migrate └── ctl_upgrade_migrate_test.go └── testdata ├── apis └── testgroup │ ├── crds │ ├── README.md │ └── testgroup.testing.cert-manager.io_testtypes.yaml │ ├── doc.go │ ├── fuzzer │ └── fuzzer.go │ ├── install │ ├── install.go │ └── roundtrip_test.go │ ├── register.go │ ├── types.go │ ├── v1 │ ├── defaults.go │ ├── doc.go │ ├── register.go │ ├── types.go │ ├── zz_generated.conversion.go │ ├── zz_generated.deepcopy.go │ └── zz_generated.defaults.go │ ├── v2 │ ├── convert.go │ ├── defaults.go │ ├── doc.go │ ├── register.go │ ├── types.go │ ├── validation.go │ ├── zz_generated.conversion.go │ ├── zz_generated.deepcopy.go │ └── zz_generated.defaults.go │ ├── validation │ ├── validation.go │ └── validation_test.go │ └── zz_generated.deepcopy.go ├── convert ├── input │ ├── resource1.yaml │ ├── resource2.yaml │ ├── resource3.yaml │ ├── resource_with_organization_v1alpha2.yaml │ └── resources_as_list_v1alpha2.yaml └── output │ ├── no_output_error.yaml │ ├── resource1_v1.yaml │ ├── resource1_v1alpha2.yaml │ ├── resource1_v1alpha3.yaml │ ├── resource2_v1.yaml │ ├── resource2_v1alpha2.yaml │ ├── resource2_v1alpha3.yaml │ ├── resource_with_organization_v1.yaml │ ├── resource_with_organization_v1alpha3.yaml │ ├── resource_with_organization_v1beta1.yaml │ ├── resources_as_list_v1.yaml │ ├── resources_as_list_v1alpha2.yaml │ ├── resources_as_list_v1alpha3.yaml │ └── resources_as_list_v1beta1.yaml ├── create_cr_cert_with_ns1.yaml ├── create_cr_issuer.yaml └── create_cr_v1alpha3_cert_with_ns1.yaml /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. 2 | # Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base-dependabot/.github/dependabot.yaml instead. 3 | 4 | # Update Go dependencies and GitHub Actions dependencies daily. 5 | version: 2 6 | updates: 7 | - package-ecosystem: gomod 8 | directory: / 9 | schedule: 10 | interval: daily 11 | groups: 12 | all: 13 | patterns: ["*"] 14 | - package-ecosystem: github-actions 15 | directory: / 16 | schedule: 17 | interval: daily 18 | groups: 19 | all: 20 | patterns: ["*"] 21 | -------------------------------------------------------------------------------- /.github/workflows/govulncheck.yaml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. 2 | # Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/go/base/.github/workflows/govulncheck.yaml instead. 3 | 4 | # Run govulncheck at midnight every night on the main branch, 5 | # to alert us to recent vulnerabilities which affect the Go code in this 6 | # project. 7 | name: govulncheck 8 | on: 9 | workflow_dispatch: {} 10 | schedule: 11 | - cron: '0 0 * * *' 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | govulncheck: 18 | runs-on: ubuntu-latest 19 | 20 | if: github.repository_owner == 'cert-manager' 21 | 22 | steps: 23 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 24 | # Adding `fetch-depth: 0` makes sure tags are also fetched. We need 25 | # the tags so `git describe` returns a valid version. 26 | # see https://github.com/actions/checkout/issues/701 for extra info about this option 27 | with: { fetch-depth: 0 } 28 | 29 | - id: go-version 30 | run: | 31 | make print-go-version >> "$GITHUB_OUTPUT" 32 | 33 | - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 34 | with: 35 | go-version: ${{ steps.go-version.outputs.result }} 36 | 37 | - run: make verify-govulncheck 38 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: release 2 | on: 3 | push: 4 | tags: 5 | - "v*" 6 | 7 | env: 8 | VERSION: ${{ github.ref_name }} 9 | 10 | jobs: 11 | build_images: 12 | runs-on: ubuntu-latest 13 | 14 | permissions: 15 | contents: write # needed to write releases 16 | packages: write # needed for push images 17 | id-token: write # needed for keyless signing 18 | 19 | steps: 20 | - uses: actions/checkout@v4 21 | 22 | - id: go-version 23 | run: | 24 | make print-go-version >> "$GITHUB_OUTPUT" 25 | 26 | - uses: docker/login-action@v3 27 | with: 28 | registry: ghcr.io 29 | username: ${{ github.actor }} 30 | password: ${{ secrets.GITHUB_TOKEN }} 31 | 32 | - uses: actions/setup-go@v5 33 | with: 34 | go-version: ${{ steps.go-version.outputs.result }} 35 | 36 | - env: 37 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 38 | run: make release 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /_bin 2 | *.iml 3 | .idea/ 4 | -------------------------------------------------------------------------------- /.golangci.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | linters: 3 | default: none 4 | exclusions: 5 | generated: lax 6 | presets: [comments, common-false-positives, legacy, std-error-handling] 7 | rules: 8 | - linters: 9 | - nilnil 10 | text: .* 11 | paths: [third_party$, builtin$, examples$] 12 | warn-unused: true 13 | settings: 14 | staticcheck: 15 | checks: ["all", "-ST1000", "-ST1001", "-ST1003", "-ST1005", "-ST1012", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1001", "-QF1003", "-QF1008"] 16 | enable: 17 | - asasalint 18 | - asciicheck 19 | - bidichk 20 | - bodyclose 21 | - canonicalheader 22 | - contextcheck 23 | - copyloopvar 24 | - decorder 25 | - dogsled 26 | - dupword 27 | - durationcheck 28 | - errcheck 29 | - errchkjson 30 | - errname 31 | - exhaustive 32 | - exptostd 33 | - forbidigo 34 | - ginkgolinter 35 | - gocheckcompilerdirectives 36 | - gochecksumtype 37 | - gocritic 38 | - goheader 39 | - goprintffuncname 40 | - gosec 41 | - gosmopolitan 42 | - govet 43 | - grouper 44 | - importas 45 | - ineffassign 46 | - interfacebloat 47 | - intrange 48 | - loggercheck 49 | - makezero 50 | - mirror 51 | - misspell 52 | - musttag 53 | - nakedret 54 | - nilerr 55 | - nilnil 56 | - noctx 57 | - nosprintfhostport 58 | - predeclared 59 | - promlinter 60 | - protogetter 61 | - reassign 62 | - sloglint 63 | - staticcheck 64 | - tagalign 65 | - testableexamples 66 | - unconvert 67 | - unparam 68 | - unused 69 | - usestdlibvars 70 | - usetesting 71 | - wastedassign 72 | formatters: 73 | enable: [gci, gofmt] 74 | settings: 75 | gci: 76 | sections: 77 | - standard # Standard section: captures all standard packages. 78 | - default # Default section: contains all imports that could not be matched to another section type. 79 | - prefix(github.com/cert-manager/cmctl/v2) # Custom section: groups all imports with the specified Prefix. 80 | - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. 81 | - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. 82 | exclusions: 83 | generated: lax 84 | paths: [third_party$, builtin$, examples$] 85 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | # Our Makefile will automatically add additional settings 2 | # to this builds array (environment variables, flags, ...) 3 | builds: 4 | - id: cmctl 5 | 6 | # config the checksum filename 7 | # https://goreleaser.com/customization/checksum 8 | checksum: 9 | name_template: 'checksums.txt' 10 | 11 | # creates SBOMs of all archives and the source tarball using syft 12 | # https://goreleaser.com/customization/sbom 13 | sboms: 14 | - artifacts: binary 15 | documents: 16 | - "{{ .ArtifactName }}{{ .ArtifactExt }}.spdx.sbom" 17 | 18 | # signs the checksum file 19 | # all files (including the sboms) are included in the checksum, so we don't need to sign each one if we don't want to 20 | # https://goreleaser.com/customization/sign 21 | signs: 22 | - cmd: cosign 23 | signature: "${artifact}.cosign.bundle" 24 | env: 25 | - COSIGN_EXPERIMENTAL=1 26 | args: 27 | - sign-blob 28 | - '--bundle=${signature}' 29 | - '${artifact}' 30 | - "--yes" # needed on cosign 2.0.0+ 31 | artifacts: checksum 32 | output: true 33 | 34 | archives: 35 | - name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}" 36 | format: binary 37 | 38 | - id: tar-gz-archives 39 | name_template: "{{ .Binary }}_{{ .Os }}_{{ .Arch }}" 40 | format: tar.gz 41 | 42 | release: 43 | draft: true 44 | make_latest: false 45 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | approvers: 2 | - cm-maintainers 3 | reviewers: 4 | - cm-maintainers 5 | - thatsmrtalbot 6 | -------------------------------------------------------------------------------- /OWNERS_ALIASES: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. 2 | # Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/OWNERS_ALIASES instead. 3 | 4 | aliases: 5 | cm-maintainers: 6 | - munnerz 7 | - joshvanl 8 | - wallrj 9 | - jakexks 10 | - maelvls 11 | - sgtcodfish 12 | - inteon 13 | - thatsmrtalbot 14 | - erikgb 15 | -------------------------------------------------------------------------------- /RELEASE.md: -------------------------------------------------------------------------------- 1 | # Releases 2 | 3 | ## Schedule 4 | 5 | The release schedule for this project is ad-hoc. Given the pre-1.0 status of the project we do not have a fixed release cadence. However if a vulnerability is discovered we will respond in accordance with our [security policy](https://github.com/cert-manager/community/blob/main/SECURITY.md) and this response may include a release. 6 | 7 | ## Process 8 | 9 | There is a semi-automated release process for this project. When you create a Git tag with a tagname that has a `v` prefix and push it to GitHub it will trigger the [release workflow]. 10 | 11 | The release process for this repo is documented below: 12 | 13 | 1. Create a tag for the new release: 14 | ```sh 15 | export VERSION=v0.5.0-alpha.0 16 | git tag --annotate --message="Release ${VERSION}" "${VERSION}" 17 | git push origin "${VERSION}" 18 | ``` 19 | 2. A GitHub action will see the new tag and do the following: 20 | - Build the binaries 21 | - Create checksums for the binaries 22 | - Sign the checksums 23 | - Create a draft GitHub release 24 | - Upload binaries, checksums and signature to the GitHub release 25 | 3. Visit the [releases page], edit the draft release, click "Generate release notes", then edit the notes to add the following to the top 26 | ``` 27 | cmctl is the command line tool for interacting with cert-manager. 28 | ``` 29 | 4. Publish the release. 30 | 31 | ## Artifacts 32 | 33 | This repo will produce the following artifacts each release. For documentation on how those artifacts are produced see the "Process" section. 34 | 35 | - *Binaries* - The `cmctl` binary is created and attached to the GitHub release, along with its shasum 36 | 37 | [release workflow]: https://github.com/cert-manager/cmctl/actions/workflows/release.yaml 38 | [releases page]: https://github.com/cert-manager/cmctl/releases -------------------------------------------------------------------------------- /cmd/cmd.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package cmd 18 | 19 | import ( 20 | "context" 21 | "io" 22 | 23 | logf "github.com/cert-manager/cert-manager/pkg/logs" 24 | "github.com/spf13/cobra" 25 | "k8s.io/cli-runtime/pkg/genericclioptions" 26 | "k8s.io/component-base/logs" 27 | 28 | "github.com/cert-manager/cmctl/v2/pkg/build" 29 | "github.com/cert-manager/cmctl/v2/pkg/build/commands" 30 | ) 31 | 32 | func NewCertManagerCtlCommand(ctx context.Context, in io.Reader, out, err io.Writer) *cobra.Command { 33 | logOptions := logs.NewOptions() 34 | 35 | cmds := &cobra.Command{ 36 | Use: build.Name(ctx), 37 | Annotations: map[string]string{ 38 | // For commands that have a space (eg. kubectl cert-manager), the name 39 | // is not correctly determined based on just the Use field. 40 | cobra.CommandDisplayNameAnnotation: build.Name(ctx), 41 | }, 42 | 43 | Short: "cert-manager CLI tool to manage and configure cert-manager resources", 44 | Long: build.WithTemplate(ctx, ` 45 | {{.BuildName}} is a CLI tool manage and configure cert-manager resources for Kubernetes`), 46 | CompletionOptions: cobra.CompletionOptions{ 47 | DisableDefaultCmd: true, 48 | }, 49 | PersistentPreRunE: func(cmd *cobra.Command, args []string) error { 50 | return logf.ValidateAndApply(logOptions) 51 | }, 52 | SilenceErrors: true, // Errors are already logged when calling cmd.Execute() 53 | SilenceUsage: true, // Don't print usage when an error occurs 54 | } 55 | 56 | logf.AddFlagsNonDeprecated(logOptions, cmds.PersistentFlags()) 57 | 58 | ioStreams := genericclioptions.IOStreams{In: in, Out: out, ErrOut: err} 59 | for _, registerCmd := range commands.Commands() { 60 | cmds.AddCommand(registerCmd(ctx, ioStreams)) 61 | } 62 | 63 | return cmds 64 | } 65 | -------------------------------------------------------------------------------- /internal/util/exit.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "context" 21 | "errors" 22 | ) 23 | 24 | // SetExitCode sets the exit code to 1 if the error is not a context.Canceled error. 25 | func SetExitCode(err error) { 26 | switch { 27 | case err == nil || errors.Is(err, context.Canceled): 28 | // If the context was canceled, we don't need to set the exit code 29 | case errors.Is(err, context.DeadlineExceeded): 30 | SetExitCodeValue(124) // Indicate that there was a timeout error 31 | default: 32 | SetExitCodeValue(1) // Indicate that there was an error 33 | } 34 | } 35 | 36 | // SetExitCode sets the exit code to 1 if the error is not a context.Canceled error. 37 | func SetExitCodeValue(code int) { 38 | if code != 0 { 39 | select { 40 | case errorExitCodeChannel <- code: 41 | default: 42 | // The exit code has already been set to a non-zero value. 43 | } 44 | } 45 | // If the exit code is 0, we don't need to set the exit code 46 | } 47 | -------------------------------------------------------------------------------- /internal/util/exit_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "context" 21 | "errors" 22 | "fmt" 23 | "testing" 24 | ) 25 | 26 | func TestSetExitCode(t *testing.T) { 27 | tests := []struct { 28 | name string 29 | err error 30 | expCode int 31 | }{ 32 | {"Test context.Canceled", context.Canceled, 0}, 33 | {"Test wrapped context.Canceled", fmt.Errorf("wrapped: %w", context.Canceled), 0}, 34 | {"Test context.DeadlineExceeded", context.DeadlineExceeded, 124}, 35 | {"Test wrapped context.DeadlineExceeded", fmt.Errorf("wrapped: %w", context.DeadlineExceeded), 124}, 36 | {"Test error", errors.New("error"), 1}, 37 | {"Test nil", nil, 0}, 38 | } 39 | for _, tt := range tests { 40 | t.Run(tt.name, func(t *testing.T) { 41 | // Every testExitCode call has to be run in its own test, because 42 | // it calls the test again filtered by the name of the subtest with 43 | // the variable BE_CRASHER=1. 44 | exitCode := testExitCode(t, func(t *testing.T) { 45 | SetExitCode(tt.err) 46 | 47 | _, complete := SetupExitHandler(t.Context(), AlwaysErrCode) 48 | complete() 49 | }) 50 | 51 | if exitCode != tt.expCode { 52 | t.Errorf("Test %s: expected exit code %d, got %d", tt.name, tt.expCode, exitCode) 53 | } 54 | }) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /internal/util/signal_posix.go: -------------------------------------------------------------------------------- 1 | //go:build !windows 2 | 3 | /* 4 | Copyright 2020 The cert-manager Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | package util 20 | 21 | import ( 22 | "os" 23 | "syscall" 24 | ) 25 | 26 | var shutdownSignals = []os.Signal{os.Interrupt, syscall.SIGTERM} 27 | -------------------------------------------------------------------------------- /internal/util/signal_windows.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package util 18 | 19 | import ( 20 | "os" 21 | ) 22 | 23 | var shutdownSignals = []os.Signal{os.Interrupt} 24 | -------------------------------------------------------------------------------- /internal/versionchecker/fromlabels.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package versionchecker 18 | 19 | import ( 20 | "regexp" 21 | ) 22 | 23 | var helmChartVersion = regexp.MustCompile(`-(v(?:\d+)\.(?:\d+)\.(?:\d+)(?:.*))$`) 24 | 25 | func extractVersionFromLabels(crdLabels map[string]string) string { 26 | if version, ok := crdLabels["app.kubernetes.io/version"]; ok { 27 | return version 28 | } 29 | 30 | if chartName, ok := crdLabels["helm.sh/chart"]; ok { 31 | version := helmChartVersion.FindStringSubmatch(chartName) 32 | if len(version) == 2 { 33 | return version[1] 34 | } 35 | } 36 | 37 | if chartName, ok := crdLabels["chart"]; ok { 38 | version := helmChartVersion.FindStringSubmatch(chartName) 39 | if len(version) == 2 { 40 | return version[1] 41 | } 42 | } 43 | 44 | return "" 45 | } 46 | -------------------------------------------------------------------------------- /internal/versionchecker/fromservice.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package versionchecker 18 | 19 | import ( 20 | "context" 21 | "regexp" 22 | 23 | corev1 "k8s.io/api/core/v1" 24 | "k8s.io/apimachinery/pkg/labels" 25 | "sigs.k8s.io/controller-runtime/pkg/client" 26 | ) 27 | 28 | var imageVersion = regexp.MustCompile(`^quay\.io/jetstack/cert-manager-webhook:(v(?:\d+)\.(?:\d+)\.(?:\d+)(?:.*))$`) 29 | 30 | func (o *VersionChecker) extractVersionFromService( 31 | ctx context.Context, 32 | namespace string, 33 | serviceName string, 34 | ) error { 35 | service := &corev1.Service{} 36 | serviceKey := client.ObjectKey{Namespace: namespace, Name: serviceName} 37 | err := o.client.Get(ctx, serviceKey, service) 38 | if err != nil { 39 | return err 40 | } 41 | 42 | if label := extractVersionFromLabels(service.Labels); label != "" { 43 | o.versionSources["webhookServiceLabelVersion"] = label 44 | } 45 | 46 | listOptions := client.MatchingLabelsSelector{ 47 | Selector: labels.Set(service.Spec.Selector).AsSelector(), 48 | } 49 | pods := &corev1.PodList{} 50 | err = o.client.List(ctx, pods, listOptions) 51 | if err != nil { 52 | return err 53 | } 54 | 55 | for _, pod := range pods.Items { 56 | if pod.Status.Phase != corev1.PodRunning { 57 | continue 58 | } 59 | 60 | if label := extractVersionFromLabels(pod.Labels); label != "" { 61 | o.versionSources["webhookPodLabelVersion"] = label 62 | } 63 | 64 | for _, container := range pod.Spec.Containers { 65 | version := imageVersion.FindStringSubmatch(container.Image) 66 | if len(version) == 2 { 67 | o.versionSources["webhookPodImageVersion"] = version[1] 68 | return nil 69 | } 70 | } 71 | } 72 | 73 | return nil 74 | } 75 | -------------------------------------------------------------------------------- /internal/versionchecker/test/testdata/go.mod: -------------------------------------------------------------------------------- 1 | module fetch 2 | 3 | go 1.22.0 4 | 5 | require ( 6 | golang.org/x/mod v0.16.0 7 | golang.org/x/sync v0.6.0 8 | gopkg.in/yaml.v2 v2.4.0 9 | ) 10 | -------------------------------------------------------------------------------- /internal/versionchecker/test/testdata/go.sum: -------------------------------------------------------------------------------- 1 | golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= 2 | golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= 3 | golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= 4 | golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= 5 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 6 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 7 | gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 8 | gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 9 | -------------------------------------------------------------------------------- /klone.yaml: -------------------------------------------------------------------------------- 1 | # This klone.yaml file describes the Makefile modules and versions that are 2 | # cloned into the "make/_shared" folder. These modules are dynamically imported 3 | # by the root Makefile. The "make upgrade-klone" target can be used to pull 4 | # the latest version from the upstream repositories (using the repo_ref value). 5 | # 6 | # More info can be found here: https://github.com/cert-manager/makefile-modules 7 | 8 | targets: 9 | make/_shared: 10 | - folder_name: boilerplate 11 | repo_url: https://github.com/cert-manager/makefile-modules.git 12 | repo_ref: main 13 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 14 | repo_path: modules/boilerplate 15 | - folder_name: cert-manager 16 | repo_url: https://github.com/cert-manager/makefile-modules.git 17 | repo_ref: main 18 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 19 | repo_path: modules/cert-manager 20 | - folder_name: executable 21 | repo_url: https://github.com/cert-manager/makefile-modules.git 22 | repo_ref: main 23 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 24 | repo_path: modules/executable 25 | - folder_name: generate-verify 26 | repo_url: https://github.com/cert-manager/makefile-modules.git 27 | repo_ref: main 28 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 29 | repo_path: modules/generate-verify 30 | - folder_name: go 31 | repo_url: https://github.com/cert-manager/makefile-modules.git 32 | repo_ref: main 33 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 34 | repo_path: modules/go 35 | - folder_name: help 36 | repo_url: https://github.com/cert-manager/makefile-modules.git 37 | repo_ref: main 38 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 39 | repo_path: modules/help 40 | - folder_name: klone 41 | repo_url: https://github.com/cert-manager/makefile-modules.git 42 | repo_ref: main 43 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 44 | repo_path: modules/klone 45 | - folder_name: repository-base 46 | repo_url: https://github.com/cert-manager/makefile-modules.git 47 | repo_ref: main 48 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 49 | repo_path: modules/repository-base 50 | - folder_name: tools 51 | repo_url: https://github.com/cert-manager/makefile-modules.git 52 | repo_ref: main 53 | repo_hash: 5c3266f17637fbd1d4af1191b34674991e2160ab 54 | repo_path: modules/tools 55 | -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package main 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | "os" 23 | "runtime" 24 | "strings" 25 | 26 | logf "github.com/cert-manager/cert-manager/pkg/logs" 27 | cmdutil "k8s.io/kubectl/pkg/cmd/util" 28 | ctrl "sigs.k8s.io/controller-runtime" 29 | 30 | ctlcmd "github.com/cert-manager/cmctl/v2/cmd" 31 | "github.com/cert-manager/cmctl/v2/internal/util" 32 | "github.com/cert-manager/cmctl/v2/pkg/build" 33 | ) 34 | 35 | func main() { 36 | ctx, exit := util.SetupExitHandler(context.Background(), util.AlwaysErrCode) 37 | defer exit() // This function might call os.Exit, so defer last 38 | 39 | ctlName, isKubectlPlugin := build.DetectCtlInfo(os.Args) 40 | 41 | logf.InitLogs() 42 | defer logf.FlushLogs() 43 | ctrl.SetLogger(logf.Log) 44 | ctx = logf.NewContext(ctx, logf.Log, ctlName) 45 | ctx = build.WithCtlInfo(ctx, ctlName, isKubectlPlugin) 46 | 47 | // In cmctl, we are using cmdutil.CheckErr, a kubectl utility function that creates human readable 48 | // error messages from errors. By default, this function will call os.Exit(1) if it receives an error. 49 | // Instead, we want to do a soft exit, and use SetExitCode to set the correct exit code. 50 | // Additionally, we make sure to output the final error message to stdout, as we do not want this 51 | // message to be mixed with other log outputs from the execution of the command. 52 | // To do this, we need to set a custom error handler. 53 | cmdutil.BehaviorOnFatal(func(msg string, code int) { 54 | if len(msg) > 0 { 55 | // add newline if needed 56 | if !strings.HasSuffix(msg, "\n") { 57 | msg += "\n" 58 | } 59 | fmt.Fprint(os.Stdout, msg) 60 | } 61 | 62 | util.SetExitCodeValue(code) 63 | runtime.Goexit() // Do soft exit (handle all defers, that should set correct exit code) 64 | }) 65 | 66 | cmd := ctlcmd.NewCertManagerCtlCommand(ctx, os.Stdin, os.Stdout, os.Stderr) 67 | 68 | if err := cmd.ExecuteContext(ctx); err != nil { 69 | cmdutil.CheckErr(err) 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /make/00_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | repo_name := github.com/cert-manager/cmctl/v2 16 | 17 | exe_build_names := cmctl 18 | gorelease_file := .goreleaser.yml 19 | 20 | go_cmctl_main_dir := . 21 | go_cmctl_mod_dir := . 22 | go_cmctl_ldflags := \ 23 | -X github.com/cert-manager/cert-manager/pkg/util.AppVersion=$(VERSION) \ 24 | -X github.com/cert-manager/cert-manager/pkg/util.AppGitCommit=$(GITCOMMIT) 25 | 26 | golangci_lint_config := .golangci.yaml 27 | -------------------------------------------------------------------------------- /make/02_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | include make/test-unit.mk 16 | include make/test-integration.mk 17 | 18 | .PHONY: dryrun-release 19 | ## Dry-run release process 20 | ## @category [shared] Release 21 | dryrun-release: export RELEASE_DRYRUN := true 22 | dryrun-release: release 23 | 24 | .PHONY: generate-conversion 25 | ## Generate code for converting between versions of the cert-manager API 26 | ## @category Generate/ Verify 27 | generate-conversion: | $(NEEDS_CONTROLLER-GEN) $(NEEDS_DEFAULTER-GEN) $(NEEDS_CONVERSION-GEN) 28 | rm -rf ./pkg/convert/internal/apis/**/zz_generated.* 29 | rm -rf ./pkg/convert/internal/apis/**/**/zz_generated.* 30 | 31 | $(CONTROLLER-GEN) \ 32 | object:headerFile=$(go_header_file) \ 33 | paths=./pkg/convert/internal/apis/... 34 | 35 | $(DEFAULTER-GEN) \ 36 | --go-header-file=$(go_header_file) \ 37 | --output-file=zz_generated.defaults.go \ 38 | ./pkg/convert/internal/apis/{acme,certmanager}/v{1,1alpha2,1alpha3,1beta1}/... \ 39 | ./pkg/convert/internal/apis/meta/v1/... 40 | 41 | 42 | $(CONVERSION-GEN) \ 43 | --go-header-file=$(go_header_file) \ 44 | --output-file=zz_generated.conversion.go \ 45 | ./pkg/convert/internal/apis/{acme,certmanager}/v{1,1alpha2,1alpha3,1beta1}/... \ 46 | ./pkg/convert/internal/apis/meta/v1/... 47 | 48 | shared_generate_targets += generate-conversion 49 | 50 | .PHONY: release 51 | ## Publish all release artifacts (image + helm chart) 52 | ## @category [shared] Release 53 | release: | $(NEEDS_CRANE) $(bin_dir)/scratch 54 | $(MAKE) exe-publish 55 | 56 | @echo "Release complete!" 57 | -------------------------------------------------------------------------------- /make/_shared/boilerplate/00_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | default_go_header_file := $(dir $(lastword $(MAKEFILE_LIST)))/template/boilerplate.go.txt 16 | 17 | go_header_file ?= $(default_go_header_file) 18 | -------------------------------------------------------------------------------- /make/_shared/boilerplate/01_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | .PHONY: verify-boilerplate 16 | ## Verify that all files have the correct boilerplate. 17 | ## @category [shared] Generate/ Verify 18 | verify-boilerplate: | $(NEEDS_BOILERSUITE) 19 | $(BOILERSUITE) . 20 | 21 | shared_verify_targets += verify-boilerplate 22 | -------------------------------------------------------------------------------- /make/_shared/boilerplate/template/boilerplate.go.txt: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ -------------------------------------------------------------------------------- /make/_shared/cert-manager/00_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | images_amd64 ?= 16 | images_arm64 ?= 17 | 18 | cert_manager_version := v1.17.0 19 | 20 | images_amd64 += quay.io/jetstack/cert-manager-controller:$(cert_manager_version)@sha256:7722bca28c95b4c568f3d4cd2debc9286e0c4b092f0426840ed4d8ed314c09db 21 | images_amd64 += quay.io/jetstack/cert-manager-cainjector:$(cert_manager_version)@sha256:d99797c5d6e702416e69defb4c28a978d515a37a8a03b4405c4991b818cc791c 22 | images_amd64 += quay.io/jetstack/cert-manager-webhook:$(cert_manager_version)@sha256:e43e270c7c50a3c1872e115df93458a78c230118cc3d12e9f6c848956e94c151 23 | images_amd64 += quay.io/jetstack/cert-manager-startupapicheck:$(cert_manager_version)@sha256:ce2f25777ad4a159b736e47dbaabfd62bf2c339c6f49fb6a6de79fb6b4a8ebed 24 | 25 | images_arm64 += quay.io/jetstack/cert-manager-controller:$(cert_manager_version)@sha256:d63cd0d15a3ed99736dd5623b798a3dd78fc36495623528d1bf58df37bc4a6cd 26 | images_arm64 += quay.io/jetstack/cert-manager-cainjector:$(cert_manager_version)@sha256:aaae16a38c8f4176b9645ff3069797ca2ec6e3262142794729440b342d759b89 27 | images_arm64 += quay.io/jetstack/cert-manager-webhook:$(cert_manager_version)@sha256:45e8765b48d913ef26188782ec8dbee32f132c142249456a4e06c5c5c41e3927 28 | images_arm64 += quay.io/jetstack/cert-manager-startupapicheck:$(cert_manager_version)@sha256:c29e6270e6fc78181bb3a956c0714df24ea56840b9d3916122a36ee25ec6eac6 29 | -------------------------------------------------------------------------------- /make/_shared/cert-manager/01_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | cert_manager_crds := $(bin_dir)/scratch/cert-manager-$(cert_manager_version).yaml 16 | $(cert_manager_crds): | $(bin_dir)/scratch 17 | curl -sSLo $@ https://github.com/cert-manager/cert-manager/releases/download/$(cert_manager_version)/cert-manager.crds.yaml 18 | -------------------------------------------------------------------------------- /make/_shared/generate-verify/00_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | shared_generate_targets ?= 16 | shared_generate_targets_dirty ?= 17 | shared_verify_targets ?= 18 | shared_verify_targets_dirty ?= 19 | -------------------------------------------------------------------------------- /make/_shared/generate-verify/02_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | .PHONY: generate 16 | ## Generate all generate targets. 17 | ## @category [shared] Generate/ Verify 18 | generate: $$(shared_generate_targets) 19 | @echo "The following targets cannot be run simultaneously with each other or other generate scripts:" 20 | $(foreach TARGET,$(shared_generate_targets_dirty), $(MAKE) $(TARGET)) 21 | 22 | verify_script := $(dir $(lastword $(MAKEFILE_LIST)))/util/verify.sh 23 | 24 | # Run the supplied make target argument in a temporary workspace and diff the results. 25 | verify-%: FORCE 26 | +$(verify_script) $(MAKE) $* 27 | 28 | verify_generated_targets = $(shared_generate_targets:%=verify-%) 29 | verify_generated_targets_dirty = $(shared_generate_targets_dirty:%=verify-%) 30 | 31 | verify_targets = $(sort $(verify_generated_targets) $(shared_verify_targets)) 32 | verify_targets_dirty = $(sort $(verify_generated_targets_dirty) $(shared_verify_targets_dirty)) 33 | 34 | .PHONY: verify 35 | ## Verify code and generate targets. 36 | ## @category [shared] Generate/ Verify 37 | verify: $$(verify_targets) 38 | @echo "The following targets create temporary files in the current directory, that is why they have to be run last:" 39 | $(foreach TARGET,$(verify_targets_dirty), $(MAKE) $(TARGET)) 40 | -------------------------------------------------------------------------------- /make/_shared/go/.golangci.override.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | linters: 3 | default: none 4 | exclusions: 5 | generated: lax 6 | presets: [ comments, common-false-positives, legacy, std-error-handling ] 7 | paths: [ third_party$, builtin$, examples$ ] 8 | warn-unused: true 9 | settings: 10 | staticcheck: 11 | checks: [ "all", "-ST1000", "-ST1001", "-ST1003", "-ST1005", "-ST1012", "-ST1016", "-ST1020", "-ST1021", "-ST1022", "-QF1001", "-QF1003", "-QF1008" ] 12 | enable: 13 | - asasalint 14 | - asciicheck 15 | - bidichk 16 | - bodyclose 17 | - canonicalheader 18 | - contextcheck 19 | - copyloopvar 20 | - decorder 21 | - dogsled 22 | - dupword 23 | - durationcheck 24 | - errcheck 25 | - errchkjson 26 | - errname 27 | - exhaustive 28 | - exptostd 29 | - forbidigo 30 | - ginkgolinter 31 | - gocheckcompilerdirectives 32 | - gochecksumtype 33 | - gocritic 34 | - goheader 35 | - goprintffuncname 36 | - gosec 37 | - gosmopolitan 38 | - govet 39 | - grouper 40 | - importas 41 | - ineffassign 42 | - interfacebloat 43 | - intrange 44 | - loggercheck 45 | - makezero 46 | - mirror 47 | - misspell 48 | - musttag 49 | - nakedret 50 | - nilerr 51 | - nilnil 52 | - noctx 53 | - nosprintfhostport 54 | - predeclared 55 | - promlinter 56 | - protogetter 57 | - reassign 58 | - sloglint 59 | - staticcheck 60 | - tagalign 61 | - testableexamples 62 | - unconvert 63 | - unparam 64 | - unused 65 | - usestdlibvars 66 | - usetesting 67 | - wastedassign 68 | formatters: 69 | enable: [ gci, gofmt ] 70 | settings: 71 | gci: 72 | sections: 73 | - standard # Standard section: captures all standard packages. 74 | - default # Default section: contains all imports that could not be matched to another section type. 75 | - prefix({{REPO-NAME}}) # Custom section: groups all imports with the specified Prefix. 76 | - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. 77 | - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. 78 | exclusions: 79 | generated: lax 80 | paths: [ third_party$, builtin$, examples$ ] 81 | -------------------------------------------------------------------------------- /make/_shared/go/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | A module for various Go static checks. 4 | -------------------------------------------------------------------------------- /make/_shared/go/base/.github/workflows/govulncheck.yaml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. 2 | # Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/go/base/.github/workflows/govulncheck.yaml instead. 3 | 4 | # Run govulncheck at midnight every night on the main branch, 5 | # to alert us to recent vulnerabilities which affect the Go code in this 6 | # project. 7 | name: govulncheck 8 | on: 9 | workflow_dispatch: {} 10 | schedule: 11 | - cron: '0 0 * * *' 12 | 13 | permissions: 14 | contents: read 15 | 16 | jobs: 17 | govulncheck: 18 | runs-on: ubuntu-latest 19 | 20 | if: github.repository_owner == 'cert-manager' 21 | 22 | steps: 23 | - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 24 | # Adding `fetch-depth: 0` makes sure tags are also fetched. We need 25 | # the tags so `git describe` returns a valid version. 26 | # see https://github.com/actions/checkout/issues/701 for extra info about this option 27 | with: { fetch-depth: 0 } 28 | 29 | - id: go-version 30 | run: | 31 | make print-go-version >> "$GITHUB_OUTPUT" 32 | 33 | - uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0 34 | with: 35 | go-version: ${{ steps.go-version.outputs.result }} 36 | 37 | - run: make verify-govulncheck 38 | -------------------------------------------------------------------------------- /make/_shared/help/01_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | 16 | help_sh := $(dir $(lastword $(MAKEFILE_LIST)))/help.sh 17 | 18 | .PHONY: help 19 | help: 20 | @MAKEFILE_LIST="$(MAKEFILE_LIST)" \ 21 | MAKE="$(MAKE)" \ 22 | $(help_sh) 23 | -------------------------------------------------------------------------------- /make/_shared/klone/01_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | .PHONY: generate-klone 16 | ## Generate klone shared Makefiles 17 | ## @category [shared] Generate/ Verify 18 | generate-klone: | $(NEEDS_KLONE) 19 | $(KLONE) sync 20 | 21 | shared_generate_targets += generate-klone 22 | 23 | .PHONY: upgrade-klone 24 | ## Upgrade klone Makefile modules to latest version 25 | ## @category [shared] Self-upgrade 26 | upgrade-klone: | $(NEEDS_KLONE) 27 | $(KLONE) upgrade 28 | -------------------------------------------------------------------------------- /make/_shared/repository-base/01_mod.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | base_dir := $(dir $(lastword $(MAKEFILE_LIST)))/base/ 16 | base_dependabot_dir := $(dir $(lastword $(MAKEFILE_LIST)))/base-dependabot/ 17 | 18 | ifdef repository_base_no_dependabot 19 | .PHONY: generate-base 20 | ## Generate base files in the repository 21 | ## @category [shared] Generate/ Verify 22 | generate-base: 23 | cp -r $(base_dir)/. ./ 24 | else 25 | .PHONY: generate-base 26 | ## Generate base files in the repository 27 | ## @category [shared] Generate/ Verify 28 | generate-base: 29 | cp -r $(base_dir)/. ./ 30 | cp -r $(base_dependabot_dir)/. ./ 31 | endif 32 | 33 | shared_generate_targets += generate-base 34 | -------------------------------------------------------------------------------- /make/_shared/repository-base/base-dependabot/.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. 2 | # Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base-dependabot/.github/dependabot.yaml instead. 3 | 4 | # Update Go dependencies and GitHub Actions dependencies daily. 5 | version: 2 6 | updates: 7 | - package-ecosystem: gomod 8 | directory: / 9 | schedule: 10 | interval: daily 11 | groups: 12 | all: 13 | patterns: ["*"] 14 | - package-ecosystem: github-actions 15 | directory: / 16 | schedule: 17 | interval: daily 18 | groups: 19 | all: 20 | patterns: ["*"] 21 | -------------------------------------------------------------------------------- /make/_shared/repository-base/base/OWNERS_ALIASES: -------------------------------------------------------------------------------- 1 | # THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT. 2 | # Edit https://github.com/cert-manager/makefile-modules/blob/main/modules/repository-base/base/OWNERS_ALIASES instead. 3 | 4 | aliases: 5 | cm-maintainers: 6 | - munnerz 7 | - joshvanl 8 | - wallrj 9 | - jakexks 10 | - maelvls 11 | - sgtcodfish 12 | - inteon 13 | - thatsmrtalbot 14 | - erikgb 15 | -------------------------------------------------------------------------------- /make/_shared/tools/util/checkhash.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2023 The cert-manager Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" 22 | 23 | # This script takes the hash of its first argument and verifies it against the 24 | # hex hash given in its second argument 25 | 26 | function usage_and_exit() { 27 | echo "usage: $0 " 28 | echo "or: LEARN_FILE= $0 " 29 | exit 1 30 | } 31 | 32 | HASH_TARGET=${1:-} 33 | EXPECTED_HASH=${2:-} 34 | 35 | if [[ -z $HASH_TARGET ]]; then 36 | usage_and_exit 37 | fi 38 | 39 | if [[ -z $EXPECTED_HASH ]]; then 40 | usage_and_exit 41 | fi 42 | 43 | SHASUM=$("${SCRIPT_DIR}/hash.sh" "$HASH_TARGET") 44 | 45 | if [[ "$SHASUM" == "$EXPECTED_HASH" ]]; then 46 | exit 0 47 | fi 48 | 49 | # When running 'make learn-sha-tools', we don't want this script to fail. 50 | # Instead we log what sha values are wrong, so the make.mk file can be updated. 51 | 52 | if [ "${LEARN_FILE:-}" != "" ]; then 53 | echo "s/$EXPECTED_HASH/$SHASUM/g" >> "${LEARN_FILE:-}" 54 | exit 0 55 | fi 56 | 57 | echo "invalid checksum for \"$HASH_TARGET\": wanted \"$EXPECTED_HASH\" but got \"$SHASUM\"" 58 | exit 1 59 | -------------------------------------------------------------------------------- /make/_shared/tools/util/hash.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2023 The cert-manager Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | # This script is a wrapper for outputting purely the sha256 hash of the input file, 22 | # ideally in a portable way. 23 | 24 | case "$(uname -s)" in 25 | Darwin*) shasum -a 256 "$1";; 26 | *) sha256sum "$1" 27 | esac | cut -d" " -f1 -------------------------------------------------------------------------------- /make/_shared/tools/util/lock.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright 2023 The cert-manager Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | # This script is used to lock a file while it is being downloaded. It prevents 22 | # multiple processes from downloading the same file at the same time or from reading 23 | # a half-downloaded file. 24 | # We need this solution because we have recursive $(MAKE) calls in our makefile 25 | # which each will try to download a set of tools. To prevent them from all downloading 26 | # the same files, we re-use the same downloads folder for all $(MAKE) invocations and 27 | # use this script to deduplicate the download processes. 28 | 29 | finalfile="$1" 30 | lockfile="$finalfile.lock" 31 | 32 | # On macOS, flock is not installed, we just skip locking in that case, 33 | # this means that running verify in parallel without downloading all 34 | # tools first will not work. 35 | flock_installed=$(command -v flock >/dev/null && echo "yes" || echo "no") 36 | 37 | if [[ "$flock_installed" == "yes" ]]; then 38 | mkdir -p "$(dirname "$lockfile")" 39 | touch "$lockfile" 40 | exec {FD}<>"$lockfile" 41 | 42 | # wait for the file to be unlocked 43 | if ! flock -x $FD; then 44 | echo "Failed to obtain a lock for $lockfile" 45 | exit 1 46 | fi 47 | fi 48 | 49 | # now that we have the lock, check if file is already there 50 | if [[ -e "$finalfile" ]]; then 51 | exit 0 52 | fi 53 | 54 | # use a temporary file to prevent Make from thinking the file is ready 55 | # while in reality is is only a partial download 56 | # shellcheck disable=SC2034 57 | outfile="$finalfile.tmp" 58 | 59 | finish() { 60 | rv=$? 61 | if [[ $rv -eq 0 ]]; then 62 | mv "$outfile" "$finalfile" 63 | echo "[info]: downloaded $finalfile" 64 | else 65 | rm -rf "$outfile" || true 66 | rm -rf "$finalfile" || true 67 | fi 68 | rm -rf "$lockfile" || true 69 | } 70 | trap finish EXIT SIGINT 71 | -------------------------------------------------------------------------------- /make/test-integration.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | .PHONY: generate-testgroup 16 | ## Generate code and crds for testgroup API 17 | ## @category Generate/ Verify 18 | generate-testgroup: | $(NEEDS_CONTROLLER-GEN) $(NEEDS_DEFAULTER-GEN) $(NEEDS_CONVERSION-GEN) 19 | rm -rf ./test/integration/testdata/apis/testgroup/crds/*.yaml 20 | rm -rf ./test/integration/testdata/apis/testgroup/**/zz_generated.* 21 | 22 | $(CONTROLLER-GEN) \ 23 | object:headerFile=$(go_header_file) \ 24 | paths=./test/integration/testdata/apis/testgroup/... 25 | 26 | $(CONTROLLER-GEN) \ 27 | crd \ 28 | paths=./test/integration/testdata/apis/testgroup/v{1,2}/... \ 29 | output:crd:dir=./test/integration/testdata/apis/testgroup/crds 30 | 31 | $(DEFAULTER-GEN) \ 32 | --go-header-file=$(go_header_file) \ 33 | --output-file=zz_generated.defaults.go \ 34 | ./test/integration/testdata/apis/testgroup/v{1,2}/... 35 | 36 | $(CONVERSION-GEN) \ 37 | --go-header-file=$(go_header_file) \ 38 | --output-file=zz_generated.conversion.go \ 39 | ./test/integration/testdata/apis/testgroup/v{1,2}/... 40 | 41 | shared_generate_targets += generate-testgroup 42 | 43 | .PHONY: test-integration 44 | ## Integration tests 45 | ## @category Testing 46 | test-integration: | $(cert_manager_crds) $(NEEDS_GO) $(NEEDS_GOTESTSUM) $(NEEDS_ETCD) $(NEEDS_KUBE-APISERVER) $(NEEDS_KUBECTL) $(NEEDS_HELM) $(ARTIFACTS) 47 | TEST_ASSET_ETCD=$(ETCD) \ 48 | TEST_ASSET_KUBE_APISERVER=$(KUBE-APISERVER) \ 49 | TEST_ASSET_KUBECTL=$(KUBECTL) \ 50 | TEST_CRDS=$(CURDIR)/test/integration/testdata/apis/testgroup \ 51 | CERT_MANAGER_CRDS=$(CURDIR)/$(cert_manager_crds) \ 52 | HELM_BIN=$(HELM) \ 53 | $(GOTESTSUM) \ 54 | --junitfile=$(ARTIFACTS)/junit-go-e2e.xml \ 55 | -- \ 56 | -coverprofile=$(ARTIFACTS)/filtered.cov \ 57 | ./test/integration/... \ 58 | -- \ 59 | -ldflags $(go_cmctl_ldflags) 60 | 61 | $(GO) tool cover -html=$(ARTIFACTS)/filtered.cov -o=$(ARTIFACTS)/filtered.html 62 | -------------------------------------------------------------------------------- /make/test-unit.mk: -------------------------------------------------------------------------------- 1 | # Copyright 2023 The cert-manager Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | .PHONY: generate-versionchecker-testdata 16 | ## Generate versionchecker testdata 17 | ## @category Testing 18 | generate-versionchecker-testdata: | $(NEEDS_GO) 19 | cd ./internal/versionchecker/test/testdata/ && \ 20 | $(GO) run . \ 21 | $(CURDIR)/internal/versionchecker/test/testdata/test_manifests.yaml \ 22 | $(cert_manager_version) 23 | 24 | shared_generate_targets += generate-versionchecker-testdata 25 | 26 | .PHONY: test-unit 27 | ## Unit tests 28 | ## @category Testing 29 | test-unit: | $(NEEDS_GO) $(NEEDS_GOTESTSUM) $(ARTIFACTS) 30 | KUBEBUILDER_ASSETS=$(CURDIR)/$(bin_dir)/tools \ 31 | $(GOTESTSUM) \ 32 | --junitfile=$(ARTIFACTS)/junit-go-e2e.xml \ 33 | -- \ 34 | -coverprofile=$(ARTIFACTS)/filtered.cov \ 35 | ./cmd/... ./internal/... ./pkg/... \ 36 | -- \ 37 | -ldflags $(go_cmctl_ldflags) 38 | 39 | $(GO) tool cover -html=$(ARTIFACTS)/filtered.cov -o=$(ARTIFACTS)/filtered.html 40 | -------------------------------------------------------------------------------- /pkg/approve/approve_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package approve 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestValidate(t *testing.T) { 24 | tests := map[string]struct { 25 | args []string 26 | reason, message string 27 | expErr bool 28 | expErrMsg string 29 | }{ 30 | "CR name not passed as arg throws error": { 31 | args: []string{}, 32 | reason: "", 33 | message: "", 34 | expErr: true, 35 | expErrMsg: "the name of the CertificateRequest to approve has to be provided as an argument", 36 | }, 37 | "multiple CR names passed as arg throws error": { 38 | args: []string{"cr-1", "cr-1"}, 39 | reason: "", 40 | message: "", 41 | expErr: true, 42 | expErrMsg: "only one argument can be passed: the name of the CertificateRequest", 43 | }, 44 | "empty reason given should throw error": { 45 | args: []string{"cr-1"}, 46 | reason: "", 47 | message: "", 48 | expErr: true, 49 | expErrMsg: "a reason must be given as to who approved this CertificateRequest", 50 | }, 51 | "empty message given should throw error": { 52 | args: []string{"cr-1"}, 53 | reason: "foo", 54 | message: "", 55 | expErr: true, 56 | expErrMsg: "a message must be given as to why this CertificateRequest is approved", 57 | }, 58 | "all fields populated should not error": { 59 | args: []string{"cr-1"}, 60 | reason: "foo", 61 | message: "bar", 62 | expErr: false, 63 | }, 64 | } 65 | 66 | for name, test := range tests { 67 | t.Run(name, func(t *testing.T) { 68 | opts := &Options{ 69 | Reason: test.reason, 70 | Message: test.message, 71 | } 72 | 73 | // Validating args and flags 74 | err := opts.Validate(test.args) 75 | if (err != nil) != test.expErr { 76 | t.Errorf("unexpected error, exp=%t got=%v", 77 | test.expErr, err) 78 | } 79 | if err != nil && err.Error() != test.expErrMsg { 80 | t.Errorf("got unexpected error when validating args and flags, expected: %v; actual: %v", test.expErrMsg, err) 81 | } 82 | }) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /pkg/build/build.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package build 18 | 19 | import ( 20 | "bytes" 21 | "context" 22 | "os" 23 | "path/filepath" 24 | "strings" 25 | "text/template" 26 | ) 27 | 28 | var defaultCtlName string = "cmctl" 29 | var defaultIsKubectlPlugin bool = false 30 | 31 | func DetectCtlInfo(args []string) (name string, isKubectlPlugin bool) { 32 | commandName := filepath.Base(os.Args[0]) 33 | if strings.HasPrefix(commandName, "kubectl-") || strings.HasPrefix(commandName, "kubectl_") { 34 | return "kubectl cert-manager", true 35 | } 36 | 37 | return commandName, false 38 | } 39 | 40 | // contextNameKey is how we find the ctl name in a context.Context. 41 | type contextNameKey struct{} 42 | 43 | // contextIsKubectlPluginKey is how we find if the ctl is a Kubectl plugin in a context.Context. 44 | type contextIsKubectlPluginKey struct{} 45 | 46 | func WithCtlInfo(ctx context.Context, name string, isKubectlPlugin bool) context.Context { 47 | ctx = context.WithValue(ctx, contextNameKey{}, name) 48 | ctx = context.WithValue(ctx, contextIsKubectlPluginKey{}, isKubectlPlugin) 49 | return ctx 50 | } 51 | 52 | func Name(ctx context.Context) string { 53 | name, ok := ctx.Value(contextNameKey{}).(string) 54 | if !ok { 55 | return defaultCtlName 56 | } 57 | 58 | return name 59 | } 60 | 61 | func IsKubectlPlugin(ctx context.Context) bool { 62 | isKubectlPlugin, ok := ctx.Value(contextIsKubectlPluginKey{}).(bool) 63 | if !ok { 64 | return defaultIsKubectlPlugin 65 | } 66 | 67 | return isKubectlPlugin 68 | } 69 | 70 | // WithTemplate returns a string that has the build name templated out with the 71 | // configured build name. Build name templates on '{{ .BuildName }}' variable. 72 | func WithTemplate(ctx context.Context, str string) string { 73 | buildName := Name(ctx) 74 | tmpl := template.Must(template.New("build-name").Parse(str)) 75 | var buf bytes.Buffer 76 | if err := tmpl.Execute(&buf, struct{ BuildName string }{buildName}); err != nil { 77 | // We panic here as it should never be possible that this template fails. 78 | panic(err) 79 | } 80 | return buf.String() 81 | } 82 | -------------------------------------------------------------------------------- /pkg/build/commands/commands.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package commands 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/approve" 26 | "github.com/cert-manager/cmctl/v2/pkg/check" 27 | "github.com/cert-manager/cmctl/v2/pkg/completion" 28 | "github.com/cert-manager/cmctl/v2/pkg/convert" 29 | "github.com/cert-manager/cmctl/v2/pkg/create" 30 | "github.com/cert-manager/cmctl/v2/pkg/deny" 31 | "github.com/cert-manager/cmctl/v2/pkg/experimental" 32 | "github.com/cert-manager/cmctl/v2/pkg/inspect" 33 | "github.com/cert-manager/cmctl/v2/pkg/renew" 34 | "github.com/cert-manager/cmctl/v2/pkg/status" 35 | "github.com/cert-manager/cmctl/v2/pkg/upgrade" 36 | "github.com/cert-manager/cmctl/v2/pkg/version" 37 | ) 38 | 39 | type RegisterCommandFunc func(context.Context, genericclioptions.IOStreams) *cobra.Command 40 | 41 | // Commands returns the cobra Commands that should be registered for the CLI 42 | // build. 43 | func Commands() []RegisterCommandFunc { 44 | cmds := []RegisterCommandFunc{ 45 | version.NewCmdVersion, 46 | convert.NewCmdConvert, 47 | create.NewCmdCreate, 48 | renew.NewCmdRenew, 49 | status.NewCmdStatus, 50 | inspect.NewCmdInspect, 51 | approve.NewCmdApprove, 52 | deny.NewCmdDeny, 53 | check.NewCmdCheck, 54 | upgrade.NewCmdUpgrade, 55 | 56 | // Experimental features 57 | experimental.NewCmdExperimental, 58 | 59 | completion.NewCmdCompletion, 60 | } 61 | 62 | return cmds 63 | } 64 | -------------------------------------------------------------------------------- /pkg/check/check.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package check 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/check/api" 26 | ) 27 | 28 | // NewCmdCheck returns a cobra command for checking cert-manager components. 29 | func NewCmdCheck(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 30 | cmds := NewCmdCreateBare() 31 | cmds.AddCommand(api.NewCmdCheckApi(setupCtx, ioStreams)) 32 | 33 | return cmds 34 | } 35 | 36 | // NewCmdCreateBare returns bare cobra command for checking cert-manager components. 37 | func NewCmdCreateBare() *cobra.Command { 38 | return &cobra.Command{ 39 | Use: "check", 40 | Short: "Check cert-manager components", 41 | Long: `Check cert-manager components`, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pkg/completion/bash.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package completion 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/build" 26 | ) 27 | 28 | func newCmdCompletionBash(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | return &cobra.Command{ 30 | Use: "bash", 31 | Short: "Generate cert-manager CLI scripts for a Bash shell", 32 | Long: build.WithTemplate(setupCtx, `To load completions: 33 | Bash: 34 | $ source <({{.BuildName}} completion bash) 35 | # To load completions for each session, execute once: 36 | # Linux: 37 | $ {{.BuildName}} completion bash > /etc/bash_completion.d/{{.BuildName}} 38 | 39 | # macOS: 40 | $ {{.BuildName}} completion bash > /usr/local/etc/bash_completion.d/{{.BuildName}} 41 | `), 42 | DisableFlagsInUseLine: true, 43 | RunE: func(cmd *cobra.Command, args []string) error { 44 | return cmd.Root().GenBashCompletion(ioStreams.Out) 45 | }, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /pkg/completion/completion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package completion 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/build" 26 | ) 27 | 28 | func NewCmdCompletion(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | cmds := &cobra.Command{ 30 | Use: "completion", 31 | Short: "Generate completion scripts for the cert-manager CLI", 32 | Long: "Generate completion for the cert-manager CLI so arguments and flags can be suggested and auto-completed", 33 | } 34 | 35 | if build.IsKubectlPlugin(setupCtx) { 36 | cmds.AddCommand(newCmdCompletionKubectl(setupCtx, ioStreams)) 37 | } else { 38 | cmds.AddCommand(newCmdCompletionBash(setupCtx, ioStreams)) 39 | cmds.AddCommand(newCmdCompletionZSH(setupCtx, ioStreams)) 40 | cmds.AddCommand(newCmdCompletionFish(setupCtx, ioStreams)) 41 | cmds.AddCommand(newCmdCompletionPowerShell(setupCtx, ioStreams)) 42 | } 43 | 44 | return cmds 45 | } 46 | -------------------------------------------------------------------------------- /pkg/completion/fish.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package completion 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/build" 26 | ) 27 | 28 | func newCmdCompletionFish(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | return &cobra.Command{ 30 | Use: "fish", 31 | Short: "Generate cert-manager CLI scripts for a Fish shell", 32 | Long: build.WithTemplate(setupCtx, `To load completions: 33 | $ {{.BuildName}} completion fish | source 34 | 35 | # To load completions for each session, execute once: 36 | $ {{.BuildName}} completion fish > ~/.config/fish/completions/{{.BuildName}}.fish 37 | `), 38 | DisableFlagsInUseLine: true, 39 | RunE: func(cmd *cobra.Command, args []string) error { 40 | return cmd.Root().GenFishCompletion(ioStreams.Out, true) 41 | }, 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /pkg/completion/kubectl.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package completion 18 | 19 | import ( 20 | "context" 21 | "fmt" 22 | 23 | "github.com/spf13/cobra" 24 | "k8s.io/cli-runtime/pkg/genericclioptions" 25 | 26 | "github.com/cert-manager/cmctl/v2/pkg/build" 27 | ) 28 | 29 | func newCmdCompletionKubectl(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 30 | return &cobra.Command{ 31 | Use: "kubectl", 32 | Short: "Generate cert-manager CLI scripts for Kubectl", 33 | Long: build.WithTemplate(setupCtx, `To load completions: 34 | $ {{.BuildName}} completion kubectl > kubectl_complete-cert_manager 35 | $ sudo install kubectl_complete-cert_manager /usr/local/bin 36 | `), 37 | DisableFlagsInUseLine: true, 38 | RunE: func(cmd *cobra.Command, args []string) error { 39 | _, err := fmt.Fprint(ioStreams.Out, `#!/usr/bin/env sh 40 | kubectl cert-manager __complete "$@" 41 | `) 42 | return err 43 | }, 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /pkg/completion/powershell.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package completion 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/build" 26 | ) 27 | 28 | func newCmdCompletionPowerShell(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | return &cobra.Command{ 30 | Use: "powershell", 31 | Short: "Generate cert-manager CLI scripts for a PowerShell shell", 32 | Long: build.WithTemplate(setupCtx, `To load completions: 33 | PS> {{.BuildName}} completion powershell | Out-String | Invoke-Expression 34 | 35 | # To load completions for every new session, run: 36 | PS> {{.BuildName}} completion powershell > {{.BuildName}}.ps1 37 | # and source this file from your PowerShell profile. 38 | `), 39 | DisableFlagsInUseLine: true, 40 | RunE: func(cmd *cobra.Command, args []string) error { 41 | return cmd.Root().GenPowerShellCompletion(ioStreams.Out) 42 | }, 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /pkg/completion/zsh.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package completion 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/build" 26 | ) 27 | 28 | func newCmdCompletionZSH(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | return &cobra.Command{ 30 | Use: "zsh", 31 | Short: "Generation cert-manager CLI scripts for a ZSH shell", 32 | Long: build.WithTemplate(setupCtx, `To load completions: 33 | # If shell completion is not already enabled in your environment, 34 | # you will need to enable it. You can execute the following once: 35 | $ echo "autoload -U compinit; compinit" >> ~/.zshrc 36 | 37 | # To load completions for each session, execute once: 38 | $ {{.BuildName}} completion zsh > "${fpath[1]}/_{{.BuildName}}" 39 | # You will need to start a new shell for this setup to take effect. 40 | `), 41 | DisableFlagsInUseLine: true, 42 | RunE: func(cmd *cobra.Command, args []string) error { 43 | return cmd.Root().GenZshCompletion(ioStreams.Out) 44 | }, 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | 19 | // Package acme is the internal version of the API. 20 | // +groupName=acme.cert-manager.io 21 | package acme 22 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/fuzzer/fuzzer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package fuzzer 18 | 19 | import ( 20 | v1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" 21 | apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" 22 | runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" 23 | "sigs.k8s.io/randfill" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme" 26 | ) 27 | 28 | // Funcs returns the fuzzer functions for the apps api group. 29 | var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { 30 | return []interface{}{ 31 | func(s *acme.Order, c randfill.Continue) { 32 | c.FillNoCustom(s) // fuzz self without calling this function again 33 | 34 | if s.Spec.IssuerRef.Kind == "" { 35 | s.Spec.IssuerRef.Kind = v1.IssuerKind 36 | } 37 | }, 38 | func(s *acme.Challenge, c randfill.Continue) { 39 | c.FillNoCustom(s) // fuzz self without calling this function again 40 | 41 | if s.Spec.IssuerRef.Kind == "" { 42 | s.Spec.IssuerRef.Kind = v1.IssuerKind 43 | } 44 | }, 45 | func(s *apiextensionsv1.JSON, c randfill.Continue) { 46 | // ensure the webhook's config is valid JSON 47 | s.Raw = []byte("{}") 48 | }, 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the API group, making it available as an option to 18 | // all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | 25 | internalacme "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme" 26 | v1 "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1" 27 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1alpha2" 28 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1alpha3" 29 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1beta1" 30 | cmmetav1 "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/meta/v1" 31 | ) 32 | 33 | // Install registers the API group and adds types to a scheme 34 | func Install(scheme *runtime.Scheme) { 35 | utilruntime.Must(internalacme.AddToScheme(scheme)) 36 | // The first version in this list will be the default version used 37 | utilruntime.Must(v1.AddToScheme(scheme)) 38 | utilruntime.Must(v1alpha2.AddToScheme(scheme)) 39 | utilruntime.Must(v1alpha3.AddToScheme(scheme)) 40 | utilruntime.Must(v1beta1.AddToScheme(scheme)) 41 | 42 | utilruntime.Must(cmmetav1.AddToScheme(scheme)) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/install/roundtrip_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package install 18 | 19 | import ( 20 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 23 | 24 | acmefuzzer "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/fuzzer" 25 | ) 26 | 27 | func TestRoundTripTypes(t *testing.T) { 28 | roundtrip.RoundTripTestForAPIGroup(t, Install, acmefuzzer.Funcs) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package acme 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/acme" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | var ( 26 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 27 | AddToScheme = SchemeBuilder.AddToScheme 28 | ) 29 | 30 | // SchemeGroupVersion is group version used to register these objects 31 | var SchemeGroupVersion = schema.GroupVersion{Group: acme.GroupName, Version: runtime.APIVersionInternal} 32 | 33 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 34 | func Resource(resource string) schema.GroupResource { 35 | return SchemeGroupVersion.WithResource(resource).GroupResource() 36 | } 37 | 38 | // Adds the list of known types to api.Scheme. 39 | func addKnownTypes(scheme *runtime.Scheme) error { 40 | scheme.AddKnownTypes(SchemeGroupVersion, 41 | &Order{}, 42 | &OrderList{}, 43 | &Challenge{}, 44 | &ChallengeList{}, 45 | ) 46 | return nil 47 | } 48 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1/conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | v1 "github.com/cert-manager/cert-manager/pkg/apis/acme/v1" 21 | "k8s.io/apimachinery/pkg/conversion" 22 | 23 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme" 24 | ) 25 | 26 | // Convert_acme_ACMEIssuer_To_v1_ACMEIssuer is explicitly defined to avoid issues in conversion-gen 27 | // when referencing types in other API groups. 28 | func Convert_acme_ACMEIssuer_To_v1_ACMEIssuer(in *acme.ACMEIssuer, out *v1.ACMEIssuer, s conversion.Scope) error { 29 | return autoConvert_acme_ACMEIssuer_To_v1_ACMEIssuer(in, out, s) 30 | } 31 | 32 | // Convert_v1_ACMEIssuer_To_acme_ACMEIssuer is explicitly defined to avoid issues in conversion-gen 33 | // when referencing types in other API groups. 34 | func Convert_v1_ACMEIssuer_To_acme_ACMEIssuer(in *v1.ACMEIssuer, out *acme.ACMEIssuer, s conversion.Scope) error { 35 | return autoConvert_v1_ACMEIssuer_To_acme_ACMEIssuer(in, out, s) 36 | } 37 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cert-manager/pkg/apis/acme/v1 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:defaulter-gen-input=github.com/cert-manager/cert-manager/pkg/apis/acme/v1 21 | 22 | // +groupName=acme.cert-manager.io 23 | package v1 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/acme" 21 | cmacme "github.com/cert-manager/cert-manager/pkg/apis/acme/v1" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | // SchemeGroupVersion is group version used to register these objects 26 | var SchemeGroupVersion = schema.GroupVersion{Group: acme.GroupName, Version: "v1"} 27 | 28 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 29 | func Resource(resource string) schema.GroupResource { 30 | return SchemeGroupVersion.WithResource(resource).GroupResource() 31 | } 32 | 33 | var ( 34 | localSchemeBuilder = &cmacme.SchemeBuilder 35 | AddToScheme = localSchemeBuilder.AddToScheme 36 | ) 37 | 38 | func init() { 39 | // We only register manually written functions here. The registration of the 40 | // generated functions takes place in the generated files. The separation 41 | // makes the code compile even when the generated files are missing. 42 | localSchemeBuilder.Register(addDefaultingFuncs) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha2/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha2 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha2/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1alpha2 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:deepcopy-gen=package,register 21 | 22 | // +groupName=acme.cert-manager.io 23 | package v1alpha2 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha2/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha2 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/acme" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: acme.GroupName, Version: "v1alpha2"} 28 | 29 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 30 | func Resource(resource string) schema.GroupResource { 31 | return SchemeGroupVersion.WithResource(resource).GroupResource() 32 | } 33 | 34 | var ( 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | AddToScheme = localSchemeBuilder.AddToScheme 38 | ) 39 | 40 | func init() { 41 | // We only register manually written functions here. The registration of the 42 | // generated functions takes place in the generated files. The separation 43 | // makes the code compile even when the generated files are missing. 44 | localSchemeBuilder.Register(addDefaultingFuncs) 45 | 46 | // We only register manually written functions here. The registration of the 47 | // generated functions takes place in the generated files. The separation 48 | // makes the code compile even when the generated files are missing. 49 | localSchemeBuilder.Register(addKnownTypes) 50 | } 51 | 52 | // Adds the list of known types to api.Scheme. 53 | func addKnownTypes(scheme *runtime.Scheme) error { 54 | scheme.AddKnownTypes(SchemeGroupVersion, 55 | &Order{}, 56 | &OrderList{}, 57 | &Challenge{}, 58 | &ChallengeList{}, 59 | ) 60 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha2/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha2 18 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha2/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1alpha2 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha3/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha3 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha3/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1alpha3 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:deepcopy-gen=package,register 21 | 22 | // +groupName=acme.cert-manager.io 23 | package v1alpha3 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha3/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha3 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/acme" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: acme.GroupName, Version: "v1alpha3"} 28 | 29 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 30 | func Resource(resource string) schema.GroupResource { 31 | return SchemeGroupVersion.WithResource(resource).GroupResource() 32 | } 33 | 34 | var ( 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | AddToScheme = localSchemeBuilder.AddToScheme 38 | ) 39 | 40 | func init() { 41 | // We only register manually written functions here. The registration of the 42 | // generated functions takes place in the generated files. The separation 43 | // makes the code compile even when the generated files are missing. 44 | localSchemeBuilder.Register(addDefaultingFuncs) 45 | 46 | // We only register manually written functions here. The registration of the 47 | // generated functions takes place in the generated files. The separation 48 | // makes the code compile even when the generated files are missing. 49 | localSchemeBuilder.Register(addKnownTypes) 50 | } 51 | 52 | // Adds the list of known types to api.Scheme. 53 | func addKnownTypes(scheme *runtime.Scheme) error { 54 | scheme.AddKnownTypes(SchemeGroupVersion, 55 | &Order{}, 56 | &OrderList{}, 57 | &Challenge{}, 58 | &ChallengeList{}, 59 | ) 60 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha3/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha3 18 | 19 | const ( 20 | OrderKind = "Order" 21 | ChallengeKind = "Challenge" 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1alpha3/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1alpha3 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1beta1/conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/conversion" 21 | 22 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme" 23 | ) 24 | 25 | // Convert_acme_ACMEIssuer_To_v1beta1_ACMEIssuer is explicitly defined to avoid issues in conversion-gen 26 | // when referencing types in other API groups. 27 | func Convert_acme_ACMEIssuer_To_v1beta1_ACMEIssuer(in *acme.ACMEIssuer, out *ACMEIssuer, s conversion.Scope) error { 28 | return autoConvert_acme_ACMEIssuer_To_v1beta1_ACMEIssuer(in, out, s) 29 | } 30 | 31 | // Convert_v1beta1_ACMEIssuer_To_acme_ACMEIssuer is explicitly defined to avoid issues in conversion-gen 32 | // when referencing types in other API groups. 33 | func Convert_v1beta1_ACMEIssuer_To_acme_ACMEIssuer(in *ACMEIssuer, out *acme.ACMEIssuer, s conversion.Scope) error { 34 | return autoConvert_v1beta1_ACMEIssuer_To_acme_ACMEIssuer(in, out, s) 35 | } 36 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1beta1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/v1beta1 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:deepcopy-gen=package,register 21 | 22 | // +groupName=acme.cert-manager.io 23 | package v1beta1 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1beta1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/acme" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: acme.GroupName, Version: "v1beta1"} 28 | 29 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 30 | func Resource(resource string) schema.GroupResource { 31 | return SchemeGroupVersion.WithResource(resource).GroupResource() 32 | } 33 | 34 | var ( 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | AddToScheme = localSchemeBuilder.AddToScheme 38 | ) 39 | 40 | func init() { 41 | // We only register manually written functions here. The registration of the 42 | // generated functions takes place in the generated files. The separation 43 | // makes the code compile even when the generated files are missing. 44 | localSchemeBuilder.Register(addDefaultingFuncs) 45 | 46 | // We only register manually written functions here. The registration of the 47 | // generated functions takes place in the generated files. The separation 48 | // makes the code compile even when the generated files are missing. 49 | localSchemeBuilder.Register(addKnownTypes) 50 | } 51 | 52 | // Adds the list of known types to api.Scheme. 53 | func addKnownTypes(scheme *runtime.Scheme) error { 54 | scheme.AddKnownTypes(SchemeGroupVersion, 55 | &Order{}, 56 | &OrderList{}, 57 | &Challenge{}, 58 | &ChallengeList{}, 59 | ) 60 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 61 | return nil 62 | } 63 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1beta1/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | const ( 20 | OrderKind = "Order" 21 | ChallengeKind = "Challenge" 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/acme/v1beta1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1beta1 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | 19 | // Package certmanager is the internal version of the API. 20 | // +groupName=cert-manager.io 21 | package certmanager 22 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/fuzzer/fuzzer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package fuzzer 18 | 19 | import ( 20 | v1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" 23 | "sigs.k8s.io/randfill" 24 | 25 | acmefuzzer "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/acme/fuzzer" 26 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager" 27 | ) 28 | 29 | // Funcs returns the fuzzer functions for the apps api group. 30 | var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { 31 | return append(acmefuzzer.Funcs(codecs), []interface{}{ 32 | func(s *certmanager.Certificate, c randfill.Continue) { 33 | c.FillNoCustom(s) // fuzz self without calling this function again 34 | 35 | if len(s.Spec.DNSNames) == 0 { 36 | s.Spec.DNSNames = []string{s.Spec.CommonName} 37 | } 38 | if s.Spec.IssuerRef.Kind == "" { 39 | s.Spec.IssuerRef.Kind = v1.IssuerKind 40 | } 41 | if s.Spec.Duration == nil { 42 | s.Spec.Duration = &metav1.Duration{Duration: v1.DefaultCertificateDuration} 43 | } 44 | }, 45 | func(s *certmanager.CertificateRequest, c randfill.Continue) { 46 | c.FillNoCustom(s) // fuzz self without calling this function again 47 | 48 | if s.Spec.IssuerRef.Kind == "" { 49 | s.Spec.IssuerRef.Kind = v1.IssuerKind 50 | } 51 | if s.Spec.Duration == nil { 52 | s.Spec.Duration = &metav1.Duration{Duration: v1.DefaultCertificateDuration} 53 | } 54 | }, 55 | }...) 56 | } 57 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the API group, making it available as an option to 18 | // all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | 25 | internalcertmanager "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager" 26 | v1 "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1" 27 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1alpha2" 28 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1alpha3" 29 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1beta1" 30 | cmmetav1 "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/meta/v1" 31 | ) 32 | 33 | // Install registers the API group and adds types to a scheme 34 | func Install(scheme *runtime.Scheme) { 35 | utilruntime.Must(internalcertmanager.AddToScheme(scheme)) 36 | // The first version in this list will be the default version used 37 | utilruntime.Must(v1.AddToScheme(scheme)) 38 | utilruntime.Must(v1beta1.AddToScheme(scheme)) 39 | utilruntime.Must(v1alpha3.AddToScheme(scheme)) 40 | utilruntime.Must(v1alpha2.AddToScheme(scheme)) 41 | 42 | utilruntime.Must(cmmetav1.AddToScheme(scheme)) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/install/roundtrip_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package install 18 | 19 | import ( 20 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 23 | 24 | cmfuzzer "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/fuzzer" 25 | ) 26 | 27 | func TestRoundTripTypes(t *testing.T) { 28 | roundtrip.RoundTripTestForAPIGroup(t, Install, cmfuzzer.Funcs) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package certmanager 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/certmanager" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | var ( 26 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 27 | AddToScheme = SchemeBuilder.AddToScheme 28 | ) 29 | 30 | // SchemeGroupVersion is group version used to register these objects 31 | var SchemeGroupVersion = schema.GroupVersion{Group: certmanager.GroupName, Version: runtime.APIVersionInternal} 32 | 33 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 34 | func Resource(resource string) schema.GroupResource { 35 | return SchemeGroupVersion.WithResource(resource).GroupResource() 36 | } 37 | 38 | // Adds the list of known types to api.Scheme. 39 | func addKnownTypes(scheme *runtime.Scheme) error { 40 | scheme.AddKnownTypes(SchemeGroupVersion, 41 | &Certificate{}, 42 | &CertificateList{}, 43 | &Issuer{}, 44 | &IssuerList{}, 45 | &ClusterIssuer{}, 46 | &ClusterIssuerList{}, 47 | &CertificateRequest{}, 48 | &CertificateRequestList{}, 49 | ) 50 | return nil 51 | } 52 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:defaulter-gen-input=github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1 21 | 22 | // +groupName=cert-manager.io 23 | package v1 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/certmanager" 21 | cmapi "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | // SchemeGroupVersion is group version used to register these objects 26 | var SchemeGroupVersion = schema.GroupVersion{Group: certmanager.GroupName, Version: "v1"} 27 | 28 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 29 | func Resource(resource string) schema.GroupResource { 30 | return SchemeGroupVersion.WithResource(resource).GroupResource() 31 | } 32 | 33 | var ( 34 | localSchemeBuilder = &cmapi.SchemeBuilder 35 | AddToScheme = localSchemeBuilder.AddToScheme 36 | ) 37 | 38 | func init() { 39 | // We only register manually written functions here. The registration of the 40 | // generated functions takes place in the generated files. The separation 41 | // makes the code compile even when the generated files are missing. 42 | localSchemeBuilder.Register(addDefaultingFuncs) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha2/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha2 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha2/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1alpha2 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:deepcopy-gen=package,register 21 | 22 | // +groupName=cert-manager.io 23 | package v1alpha2 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha2/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha2 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/certmanager" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: certmanager.GroupName, Version: "v1alpha2"} 28 | 29 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 30 | func Resource(resource string) schema.GroupResource { 31 | return SchemeGroupVersion.WithResource(resource).GroupResource() 32 | } 33 | 34 | var ( 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | AddToScheme = localSchemeBuilder.AddToScheme 38 | ) 39 | 40 | func init() { 41 | // We only register manually written functions here. The registration of the 42 | // generated functions takes place in the generated files. The separation 43 | // makes the code compile even when the generated files are missing. 44 | localSchemeBuilder.Register(addDefaultingFuncs) 45 | 46 | // We only register manually written functions here. The registration of the 47 | // generated functions takes place in the generated files. The separation 48 | // makes the code compile even when the generated files are missing. 49 | localSchemeBuilder.Register(addKnownTypes) 50 | } 51 | 52 | // Adds the list of known types to api.Scheme. 53 | func addKnownTypes(scheme *runtime.Scheme) error { 54 | scheme.AddKnownTypes(SchemeGroupVersion, 55 | &Certificate{}, 56 | &CertificateList{}, 57 | &Issuer{}, 58 | &IssuerList{}, 59 | &ClusterIssuer{}, 60 | &ClusterIssuerList{}, 61 | &CertificateRequest{}, 62 | &CertificateRequestList{}, 63 | ) 64 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha2/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1alpha2 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha3/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha3 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha3/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1alpha3 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:deepcopy-gen=package,register 21 | 22 | // +groupName=cert-manager.io 23 | package v1alpha3 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha3/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1alpha3 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/certmanager" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: certmanager.GroupName, Version: "v1alpha3"} 28 | 29 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 30 | func Resource(resource string) schema.GroupResource { 31 | return SchemeGroupVersion.WithResource(resource).GroupResource() 32 | } 33 | 34 | var ( 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | AddToScheme = localSchemeBuilder.AddToScheme 38 | ) 39 | 40 | func init() { 41 | // We only register manually written functions here. The registration of the 42 | // generated functions takes place in the generated files. The separation 43 | // makes the code compile even when the generated files are missing. 44 | localSchemeBuilder.Register(addDefaultingFuncs) 45 | 46 | // We only register manually written functions here. The registration of the 47 | // generated functions takes place in the generated files. The separation 48 | // makes the code compile even when the generated files are missing. 49 | localSchemeBuilder.Register(addKnownTypes) 50 | } 51 | 52 | // Adds the list of known types to api.Scheme. 53 | func addKnownTypes(scheme *runtime.Scheme) error { 54 | scheme.AddKnownTypes(SchemeGroupVersion, 55 | &Certificate{}, 56 | &CertificateList{}, 57 | &Issuer{}, 58 | &IssuerList{}, 59 | &ClusterIssuer{}, 60 | &ClusterIssuerList{}, 61 | &CertificateRequest{}, 62 | &CertificateRequestList{}, 63 | ) 64 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1alpha3/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1alpha3 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1beta1/conversion.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/conversion" 21 | 22 | "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager" 23 | ) 24 | 25 | func Convert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec(in *CertificateSpec, out *certmanager.CertificateSpec, s conversion.Scope) error { 26 | if err := autoConvert_v1beta1_CertificateSpec_To_certmanager_CertificateSpec(in, out, s); err != nil { 27 | return err 28 | } 29 | 30 | out.EmailAddresses = in.EmailSANs 31 | out.URIs = in.URISANs 32 | 33 | return nil 34 | } 35 | 36 | func Convert_certmanager_CertificateSpec_To_v1beta1_CertificateSpec(in *certmanager.CertificateSpec, out *CertificateSpec, s conversion.Scope) error { 37 | if err := autoConvert_certmanager_CertificateSpec_To_v1beta1_CertificateSpec(in, out, s); err != nil { 38 | return err 39 | } 40 | 41 | out.EmailSANs = in.EmailAddresses 42 | out.URISANs = in.URIs 43 | 44 | return nil 45 | } 46 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1beta1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1beta1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/certmanager/v1beta1 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:deepcopy-gen=package,register 21 | 22 | // +groupName=cert-manager.io 23 | package v1beta1 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1beta1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1beta1 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/certmanager" 21 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime" 23 | "k8s.io/apimachinery/pkg/runtime/schema" 24 | ) 25 | 26 | // SchemeGroupVersion is group version used to register these objects 27 | var SchemeGroupVersion = schema.GroupVersion{Group: certmanager.GroupName, Version: "v1beta1"} 28 | 29 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 30 | func Resource(resource string) schema.GroupResource { 31 | return SchemeGroupVersion.WithResource(resource).GroupResource() 32 | } 33 | 34 | var ( 35 | SchemeBuilder runtime.SchemeBuilder 36 | localSchemeBuilder = &SchemeBuilder 37 | AddToScheme = localSchemeBuilder.AddToScheme 38 | ) 39 | 40 | func init() { 41 | // We only register manually written functions here. The registration of the 42 | // generated functions takes place in the generated files. The separation 43 | // makes the code compile even when the generated files are missing. 44 | localSchemeBuilder.Register(addDefaultingFuncs) 45 | 46 | // We only register manually written functions here. The registration of the 47 | // generated functions takes place in the generated files. The separation 48 | // makes the code compile even when the generated files are missing. 49 | localSchemeBuilder.Register(addKnownTypes) 50 | } 51 | 52 | // Adds the list of known types to api.Scheme. 53 | func addKnownTypes(scheme *runtime.Scheme) error { 54 | scheme.AddKnownTypes(SchemeGroupVersion, 55 | &Certificate{}, 56 | &CertificateList{}, 57 | &Issuer{}, 58 | &IssuerList{}, 59 | &ClusterIssuer{}, 60 | &ClusterIssuerList{}, 61 | &CertificateRequest{}, 62 | &CertificateRequestList{}, 63 | ) 64 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 65 | return nil 66 | } 67 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/certmanager/v1beta1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1beta1 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | 19 | // Package meta is the internal version of the API. 20 | // +groupName=meta.cert-manager.io 21 | package meta 22 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/fuzzer/fuzzer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package fuzzer 18 | 19 | import ( 20 | runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" 21 | ) 22 | 23 | // Funcs returns the fuzzer functions for the apps api group. 24 | var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { 25 | return []interface{}{} 26 | } 27 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the API group, making it available as an option to 18 | // all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | 25 | internalmeta "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/meta" 26 | cmmetav1 "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/meta/v1" 27 | ) 28 | 29 | // Install registers the API group and adds types to a scheme 30 | func Install(scheme *runtime.Scheme) { 31 | utilruntime.Must(internalmeta.AddToScheme(scheme)) 32 | utilruntime.Must(cmmetav1.AddToScheme(scheme)) 33 | } 34 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/install/roundtrip_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package install 18 | 19 | import ( 20 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 23 | 24 | metafuzzer "github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/meta/fuzzer" 25 | ) 26 | 27 | func TestRoundTripTypes(t *testing.T) { 28 | roundtrip.RoundTripTestForAPIGroup(t, Install, metafuzzer.Funcs) 29 | } 30 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package meta 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/meta" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | var ( 26 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 27 | AddToScheme = SchemeBuilder.AddToScheme 28 | ) 29 | 30 | // SchemeGroupVersion is group version used to register these objects 31 | var SchemeGroupVersion = schema.GroupVersion{Group: meta.GroupName, Version: runtime.APIVersionInternal} 32 | 33 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 34 | func Resource(resource string) schema.GroupResource { 35 | return SchemeGroupVersion.WithResource(resource).GroupResource() 36 | } 37 | 38 | // Adds the list of known types to api.Scheme. 39 | func addKnownTypes(scheme *runtime.Scheme) error { 40 | // No types to register in the meta group 41 | return nil 42 | } 43 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/v1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | ) 22 | 23 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 24 | return RegisterDefaults(scheme) 25 | } 26 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/pkg/convert/internal/apis/meta 18 | // +k8s:conversion-gen-external-types=github.com/cert-manager/cert-manager/pkg/apis/meta/v1 19 | // +k8s:defaulter-gen=TypeMeta 20 | // +k8s:defaulter-gen-input=github.com/cert-manager/cert-manager/pkg/apis/meta/v1 21 | 22 | // +groupName=meta.cert-manager.io 23 | package v1 24 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/v1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "github.com/cert-manager/cert-manager/pkg/apis/meta" 21 | cmmeta "github.com/cert-manager/cert-manager/pkg/apis/meta/v1" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | ) 24 | 25 | // SchemeGroupVersion is group version used to register these objects 26 | var SchemeGroupVersion = schema.GroupVersion{Group: meta.GroupName, Version: "v1"} 27 | 28 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 29 | func Resource(resource string) schema.GroupResource { 30 | return SchemeGroupVersion.WithResource(resource).GroupResource() 31 | } 32 | 33 | var ( 34 | localSchemeBuilder = &cmmeta.SchemeBuilder 35 | AddToScheme = localSchemeBuilder.AddToScheme 36 | ) 37 | 38 | func init() { 39 | // We only register manually written functions here. The registration of the 40 | // generated functions takes place in the generated files. The separation 41 | // makes the code compile even when the generated files are missing. 42 | localSchemeBuilder.Register(addDefaultingFuncs) 43 | } 44 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | return nil 32 | } 33 | -------------------------------------------------------------------------------- /pkg/convert/internal/apis/meta/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright The cert-manager Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package meta 22 | 23 | import () 24 | 25 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 26 | func (in *LocalObjectReference) DeepCopyInto(out *LocalObjectReference) { 27 | *out = *in 28 | } 29 | 30 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LocalObjectReference. 31 | func (in *LocalObjectReference) DeepCopy() *LocalObjectReference { 32 | if in == nil { 33 | return nil 34 | } 35 | out := new(LocalObjectReference) 36 | in.DeepCopyInto(out) 37 | return out 38 | } 39 | 40 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 41 | func (in *ObjectReference) DeepCopyInto(out *ObjectReference) { 42 | *out = *in 43 | } 44 | 45 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ObjectReference. 46 | func (in *ObjectReference) DeepCopy() *ObjectReference { 47 | if in == nil { 48 | return nil 49 | } 50 | out := new(ObjectReference) 51 | in.DeepCopyInto(out) 52 | return out 53 | } 54 | 55 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 56 | func (in *SecretKeySelector) DeepCopyInto(out *SecretKeySelector) { 57 | *out = *in 58 | out.LocalObjectReference = in.LocalObjectReference 59 | } 60 | 61 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SecretKeySelector. 62 | func (in *SecretKeySelector) DeepCopy() *SecretKeySelector { 63 | if in == nil { 64 | return nil 65 | } 66 | out := new(SecretKeySelector) 67 | in.DeepCopyInto(out) 68 | return out 69 | } 70 | -------------------------------------------------------------------------------- /pkg/create/create.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package create 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/create/certificaterequest" 26 | ) 27 | 28 | func NewCmdCreate(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | cmds := NewCmdCreateBare() 30 | cmds.AddCommand(certificaterequest.NewCmdCreateCR(setupCtx, ioStreams)) 31 | 32 | return cmds 33 | } 34 | 35 | // NewCmdCreateBare creates a bare Create Command, without any subcommands 36 | func NewCmdCreateBare() *cobra.Command { 37 | return &cobra.Command{ 38 | Use: "create", 39 | Short: "Create cert-manager resources", 40 | Long: `Create cert-manager resources e.g. a CertificateRequest`, 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /pkg/deny/deny_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package deny 18 | 19 | import ( 20 | "testing" 21 | ) 22 | 23 | func TestValidate(t *testing.T) { 24 | tests := map[string]struct { 25 | args []string 26 | reason, message string 27 | expErr bool 28 | expErrMsg string 29 | }{ 30 | "CR name not passed as arg throws error": { 31 | args: []string{}, 32 | reason: "", 33 | message: "", 34 | expErr: true, 35 | expErrMsg: "the name of the CertificateRequest to deny has to be provided as an argument", 36 | }, 37 | "multiple CR names passed as arg throws error": { 38 | args: []string{"cr-1", "cr-1"}, 39 | reason: "", 40 | message: "", 41 | expErr: true, 42 | expErrMsg: "only one argument can be passed: the name of the CertificateRequest", 43 | }, 44 | "empty reason given should throw error": { 45 | args: []string{"cr-1"}, 46 | reason: "", 47 | message: "", 48 | expErr: true, 49 | expErrMsg: "a reason must be given as to who denied this CertificateRequest", 50 | }, 51 | "empty message given should throw error": { 52 | args: []string{"cr-1"}, 53 | reason: "foo", 54 | message: "", 55 | expErr: true, 56 | expErrMsg: "a message must be given as to why this CertificateRequest is denied", 57 | }, 58 | "all fields populated should not error": { 59 | args: []string{"cr-1"}, 60 | reason: "foo", 61 | message: "bar", 62 | expErr: false, 63 | }, 64 | } 65 | 66 | for name, test := range tests { 67 | t.Run(name, func(t *testing.T) { 68 | opts := &Options{ 69 | Reason: test.reason, 70 | Message: test.message, 71 | } 72 | 73 | // Validating args and flags 74 | err := opts.Validate(test.args) 75 | if (err != nil) != test.expErr { 76 | t.Errorf("unexpected error, exp=%t got=%v", 77 | test.expErr, err) 78 | } 79 | if err != nil && err.Error() != test.expErrMsg { 80 | t.Errorf("got unexpected error when validating args and flags, expected: %v; actual: %v", test.expErrMsg, err) 81 | } 82 | }) 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /pkg/experimental/experimental.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package experimental 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/create" 26 | "github.com/cert-manager/cmctl/v2/pkg/create/certificatesigningrequest" 27 | "github.com/cert-manager/cmctl/v2/pkg/install" 28 | "github.com/cert-manager/cmctl/v2/pkg/uninstall" 29 | ) 30 | 31 | func NewCmdExperimental(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 32 | cmds := &cobra.Command{ 33 | Use: "experimental", 34 | Aliases: []string{"x"}, 35 | Short: "Interact with experimental features", 36 | Long: "Interact with experimental features", 37 | } 38 | 39 | create := create.NewCmdCreateBare() 40 | create.AddCommand(certificatesigningrequest.NewCmdCreateCSR(setupCtx, ioStreams)) 41 | cmds.AddCommand(create) 42 | cmds.AddCommand(install.NewCmdInstall(setupCtx, ioStreams)) 43 | cmds.AddCommand(uninstall.NewCmd(setupCtx, ioStreams)) 44 | 45 | return cmds 46 | } 47 | -------------------------------------------------------------------------------- /pkg/inspect/inspect.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package inspect 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/inspect/secret" 26 | ) 27 | 28 | func NewCmdInspect(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | cmds := &cobra.Command{ 30 | Use: "inspect", 31 | Short: "Get details on certificate related resources", 32 | Long: `Get details on certificate related resources, e.g. secrets`, 33 | } 34 | 35 | cmds.AddCommand(secret.NewCmdInspectSecret(setupCtx, ioStreams)) 36 | 37 | return cmds 38 | } 39 | -------------------------------------------------------------------------------- /pkg/install/helm/applycrd.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helm 18 | 19 | import ( 20 | "time" 21 | 22 | logf "github.com/cert-manager/cert-manager/pkg/logs" 23 | "helm.sh/helm/v3/pkg/action" 24 | "k8s.io/cli-runtime/pkg/resource" 25 | ) 26 | 27 | // CreateCRDs creates cert manager CRDs. Before calling this function, we 28 | // made sure that the CRDs are not yet installed on the cluster. 29 | func CreateCRDs(allCRDs []*resource.Info, cfg *action.Configuration) error { 30 | logf.Log.Info("Creating the cert-manager CRDs") 31 | 32 | // Create all CRDs 33 | rr, err := cfg.KubeClient.Create(allCRDs) 34 | if err != nil { 35 | return err 36 | } 37 | createdCRDs := rr.Created 38 | 39 | // Invalidate the local cache, since it will not have the new CRDs 40 | // present. 41 | discoveryClient, err := cfg.RESTClientGetter.ToDiscoveryClient() 42 | if err != nil { 43 | return err 44 | } 45 | 46 | logf.Log.Info("Clearing discovery cache") 47 | discoveryClient.Invalidate() 48 | 49 | // Give time for the CRD to be recognized. 50 | if err := cfg.KubeClient.Wait(createdCRDs, 60*time.Second); err != nil { 51 | return err 52 | } 53 | 54 | // Make sure to force a rebuild of the cache. 55 | if _, err := discoveryClient.ServerGroups(); err != nil { 56 | return err 57 | } 58 | 59 | return nil 60 | } 61 | -------------------------------------------------------------------------------- /pkg/install/helm/flags.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2021 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package helm 18 | 19 | import ( 20 | "time" 21 | 22 | "github.com/spf13/pflag" 23 | ) 24 | 25 | // Flags that are shared between the Install and the Uninstall command 26 | func AddInstallUninstallFlags(f *pflag.FlagSet, timeout *time.Duration, wait *bool) { 27 | f.DurationVar(timeout, "timeout", 300*time.Second, "Time to wait for any individual Kubernetes operation (like Jobs for hooks)") 28 | if err := f.MarkHidden("timeout"); err != nil { 29 | panic(err) 30 | } 31 | f.BoolVar(wait, "wait", true, "If set, will wait until all Pods, PVCs, Services, and minimum number of Pods of a Deployment, StatefulSet, or ReplicaSet are in a ready state before marking the release as successful. It will wait for as long as --timeout") 32 | if err := f.MarkHidden("wait"); err != nil { 33 | panic(err) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /pkg/status/status.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package status 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/status/certificate" 26 | ) 27 | 28 | func NewCmdStatus(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | cmds := &cobra.Command{ 30 | Use: "status", 31 | Short: "Get details on current status of cert-manager resources", 32 | Long: `Get details on current status of cert-manager resources, e.g. Certificate`, 33 | } 34 | 35 | cmds.AddCommand(certificate.NewCmdStatusCert(setupCtx, ioStreams)) 36 | 37 | return cmds 38 | } 39 | -------------------------------------------------------------------------------- /pkg/upgrade/upgrade.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2022 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package upgrade 18 | 19 | import ( 20 | "context" 21 | 22 | "github.com/spf13/cobra" 23 | "k8s.io/cli-runtime/pkg/genericclioptions" 24 | 25 | "github.com/cert-manager/cmctl/v2/pkg/upgrade/migrateapiversion" 26 | ) 27 | 28 | func NewCmdUpgrade(setupCtx context.Context, ioStreams genericclioptions.IOStreams) *cobra.Command { 29 | cmds := &cobra.Command{ 30 | Use: "upgrade", 31 | Short: "Tools that assist in upgrading cert-manager", 32 | Long: `Note: this command does NOT actually upgrade cert-manager installations`, 33 | } 34 | 35 | cmds.AddCommand(migrateapiversion.NewCmdMigrate(setupCtx, ioStreams)) 36 | 37 | return cmds 38 | } 39 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/crds/README.md: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | These CRDs are auto generated by `make/test-integration.mk`. 4 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:deepcopy-gen=package,register 18 | 19 | // +groupName=testgroup.testing.cert-manager.io 20 | package testgroup 21 | 22 | const GroupName = "testgroup.testing.cert-manager.io" 23 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/fuzzer/fuzzer.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package fuzzer 18 | 19 | import ( 20 | fuzz "github.com/google/gofuzz" 21 | runtimeserializer "k8s.io/apimachinery/pkg/runtime/serializer" 22 | "k8s.io/utils/ptr" 23 | 24 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup" 25 | ) 26 | 27 | // Funcs returns the fuzzer functions for the apps api group. 28 | var Funcs = func(codecs runtimeserializer.CodecFactory) []interface{} { 29 | return []interface{}{ 30 | func(s *testgroup.TestType, c fuzz.Continue) { 31 | c.FuzzNoCustom(s) // fuzz self without calling this function again 32 | 33 | if s.TestFieldPtr == nil { 34 | s.TestFieldPtr = ptr.To("teststr") 35 | } 36 | }, 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/install/install.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // Package install installs the API group, making it available as an option to 18 | // all of the API encoding/decoding machinery. 19 | package install 20 | 21 | import ( 22 | "k8s.io/apimachinery/pkg/runtime" 23 | utilruntime "k8s.io/apimachinery/pkg/util/runtime" 24 | 25 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup" 26 | v1 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v1" 27 | v2 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v2" 28 | ) 29 | 30 | // Install registers the API group and adds types to a scheme 31 | func Install(scheme *runtime.Scheme) { 32 | utilruntime.Must(testgroup.AddToScheme(scheme)) 33 | utilruntime.Must(v1.AddToScheme(scheme)) 34 | utilruntime.Must(v2.AddToScheme(scheme)) 35 | } 36 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/install/roundtrip_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package install 18 | 19 | import ( 20 | "testing" 21 | 22 | "k8s.io/apimachinery/pkg/api/apitesting/roundtrip" 23 | 24 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/fuzzer" 25 | ) 26 | 27 | func TestRoundTripTypes(t *testing.T) { 28 | roundtrip.RoundTripTestForAPIGroup(t, Install, fuzzer.Funcs) 29 | } 30 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testgroup 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/apimachinery/pkg/runtime/schema" 22 | ) 23 | 24 | var ( 25 | SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) 26 | AddToScheme = SchemeBuilder.AddToScheme 27 | ) 28 | 29 | // SchemeGroupVersion is group version used to register these objects 30 | var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} 31 | 32 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 33 | func Resource(resource string) schema.GroupResource { 34 | return SchemeGroupVersion.WithResource(resource).GroupResource() 35 | } 36 | 37 | // Adds the list of known types to api.Scheme. 38 | func addKnownTypes(scheme *runtime.Scheme) error { 39 | scheme.AddKnownTypes(SchemeGroupVersion, 40 | &TestType{}, 41 | ) 42 | return nil 43 | } 44 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package testgroup 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 24 | 25 | type TestType struct { 26 | metav1.TypeMeta 27 | metav1.ObjectMeta 28 | 29 | // TestField is used in tests. 30 | // Validation doesn't allow this to be set to the value of TestFieldValueNotAllowed. 31 | TestField string 32 | TestFieldPtr *string 33 | 34 | // TestFieldImmutable cannot be changed after being set to a non-zero value 35 | TestFieldImmutable string 36 | 37 | // TestDefaultingField is used to test defaulting. 38 | TestDefaultingField string 39 | } 40 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v1/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/utils/ptr" 22 | ) 23 | 24 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 25 | return RegisterDefaults(scheme) 26 | } 27 | 28 | func SetDefaults_TestType(obj *TestType) { 29 | if obj.TestFieldPtr == nil { 30 | obj.TestFieldPtr = ptr.To("teststr") 31 | } 32 | if obj.TestDefaultingField == "" { 33 | obj.TestDefaultingField = "set-in-v1" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v1/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup 18 | // +k8s:deepcopy-gen=package,register 19 | // +k8s:defaulter-gen=TypeMeta 20 | 21 | // +groupName=testgroup.testing.cert-manager.io 22 | package v1 23 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v1/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | 24 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup" 25 | ) 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: testgroup.GroupName, Version: "v1"} 29 | 30 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 31 | func Resource(resource string) schema.GroupResource { 32 | return SchemeGroupVersion.WithResource(resource).GroupResource() 33 | } 34 | 35 | var ( 36 | SchemeBuilder runtime.SchemeBuilder 37 | localSchemeBuilder = &SchemeBuilder 38 | AddToScheme = localSchemeBuilder.AddToScheme 39 | ) 40 | 41 | func init() { 42 | // We only register manually written functions here. The registration of the 43 | // generated functions takes place in the generated files. The separation 44 | // makes the code compile even when the generated files are missing. 45 | localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) 46 | } 47 | 48 | // Adds the list of known types to api.Scheme. 49 | func addKnownTypes(scheme *runtime.Scheme) error { 50 | scheme.AddKnownTypes(SchemeGroupVersion, 51 | &TestType{}, 52 | ) 53 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v1/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v1 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 24 | 25 | type TestType struct { 26 | metav1.TypeMeta `json:",inline"` 27 | metav1.ObjectMeta `json:"metadata"` 28 | 29 | // TestField is used in tests. 30 | // Validation doesn't allow this to be set to the value of TestFieldValueNotAllowed. 31 | TestField string `json:"testField"` 32 | TestFieldPtr *string `json:"testFieldPtr,omitempty"` 33 | 34 | // TestFieldImmutable cannot be changed after being set to a non-zero value 35 | TestFieldImmutable string `json:"testFieldImmutable"` 36 | 37 | // TestDefaultingField is used to test defaulting. 38 | // In the v1 API, it defaults to `set-in-v1`. 39 | // In the v2 API, it defaults to `set-in-v2`. 40 | TestDefaultingField string `json:"testDefaultingField,omitempty"` 41 | } 42 | 43 | const ( 44 | TestFieldValueNotAllowed = "not-allowed-value" 45 | ) 46 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v1/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright The cert-manager Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package v1 22 | 23 | import ( 24 | "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 28 | func (in *TestType) DeepCopyInto(out *TestType) { 29 | *out = *in 30 | out.TypeMeta = in.TypeMeta 31 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 32 | if in.TestFieldPtr != nil { 33 | in, out := &in.TestFieldPtr, &out.TestFieldPtr 34 | *out = new(string) 35 | **out = **in 36 | } 37 | } 38 | 39 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. 40 | func (in *TestType) DeepCopy() *TestType { 41 | if in == nil { 42 | return nil 43 | } 44 | out := new(TestType) 45 | in.DeepCopyInto(out) 46 | return out 47 | } 48 | 49 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 50 | func (in *TestType) DeepCopyObject() runtime.Object { 51 | if c := in.DeepCopy(); c != nil { 52 | return c 53 | } 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v1/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v1 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | scheme.AddTypeDefaultingFunc(&TestType{}, func(obj interface{}) { SetObjectDefaults_TestType(obj.(*TestType)) }) 32 | return nil 33 | } 34 | 35 | func SetObjectDefaults_TestType(in *TestType) { 36 | SetDefaults_TestType(in) 37 | } 38 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/convert.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v2 18 | 19 | import ( 20 | "unsafe" 21 | 22 | "k8s.io/apimachinery/pkg/conversion" 23 | 24 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup" 25 | ) 26 | 27 | func Convert_v2_TestType_To_testgroup_TestType(in *TestType, out *testgroup.TestType, s conversion.Scope) error { 28 | if err := autoConvert_v2_TestType_To_testgroup_TestType(in, out, s); err != nil { 29 | return err 30 | } 31 | out.TestFieldPtr = (*string)(unsafe.Pointer(in.TestFieldPtrAlt)) 32 | return nil 33 | } 34 | 35 | func Convert_testgroup_TestType_To_v2_TestType(in *testgroup.TestType, out *TestType, s conversion.Scope) error { 36 | if err := autoConvert_testgroup_TestType_To_v2_TestType(in, out, s); err != nil { 37 | return err 38 | } 39 | out.TestFieldPtrAlt = (*string)(unsafe.Pointer(in.TestFieldPtr)) 40 | return nil 41 | } 42 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/defaults.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v2 18 | 19 | import ( 20 | "k8s.io/apimachinery/pkg/runtime" 21 | "k8s.io/utils/ptr" 22 | ) 23 | 24 | func addDefaultingFuncs(scheme *runtime.Scheme) error { 25 | return RegisterDefaults(scheme) 26 | } 27 | 28 | func SetDefaults_TestType(obj *TestType) { 29 | if obj.TestFieldPtrAlt == nil { 30 | obj.TestFieldPtrAlt = ptr.To("teststr") 31 | } 32 | if obj.TestDefaultingField == "" { 33 | obj.TestDefaultingField = "set-in-v2" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/doc.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | // +k8s:conversion-gen=github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup 18 | // +k8s:deepcopy-gen=package,register 19 | // +k8s:defaulter-gen=TypeMeta 20 | 21 | // +groupName=testgroup.testing.cert-manager.io 22 | package v2 23 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/register.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v2 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/runtime/schema" 23 | 24 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup" 25 | ) 26 | 27 | // SchemeGroupVersion is group version used to register these objects 28 | var SchemeGroupVersion = schema.GroupVersion{Group: testgroup.GroupName, Version: "v2"} 29 | 30 | // Resource takes an unqualified resource and returns a Group qualified GroupResource 31 | func Resource(resource string) schema.GroupResource { 32 | return SchemeGroupVersion.WithResource(resource).GroupResource() 33 | } 34 | 35 | var ( 36 | SchemeBuilder runtime.SchemeBuilder 37 | localSchemeBuilder = &SchemeBuilder 38 | AddToScheme = localSchemeBuilder.AddToScheme 39 | ) 40 | 41 | func init() { 42 | // We only register manually written functions here. The registration of the 43 | // generated functions takes place in the generated files. The separation 44 | // makes the code compile even when the generated files are missing. 45 | localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs) 46 | } 47 | 48 | // Adds the list of known types to api.Scheme. 49 | func addKnownTypes(scheme *runtime.Scheme) error { 50 | scheme.AddKnownTypes(SchemeGroupVersion, 51 | &TestType{}, 52 | ) 53 | metav1.AddToGroupVersion(scheme, SchemeGroupVersion) 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/types.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v2 18 | 19 | import ( 20 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 | ) 22 | 23 | // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 24 | 25 | // +kubebuilder:storageversion 26 | // TestType in v2 is identical to v1, except TestFieldPtr has been renamed to TestFieldPtrAlt 27 | type TestType struct { 28 | metav1.TypeMeta `json:",inline"` 29 | metav1.ObjectMeta `json:"metadata"` 30 | 31 | // TestField is used in tests. 32 | // Validation doesn't allow this to be set to the value of TestFieldValueNotAllowed. 33 | TestField string `json:"testField"` 34 | // +optional 35 | TestFieldPtrAlt *string `json:"testFieldPtrAlt,omitempty"` 36 | 37 | // TestFieldImmutable cannot be changed after being set to a non-zero value 38 | TestFieldImmutable string `json:"testFieldImmutable"` 39 | 40 | // TestDefaultingField is used to test defaulting. 41 | // In the v1 API, it defaults to `set-in-v1`. 42 | // In the v2 API, it defaults to `set-in-v2`. 43 | TestDefaultingField string `json:"testDefaultingField,omitempty"` 44 | } 45 | 46 | const ( 47 | DisallowedTestFieldValue = "not-allowed-in-v2" 48 | ) 49 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/validation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package v2 18 | 19 | import ( 20 | admissionv1 "k8s.io/api/admission/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/util/validation/field" 23 | ) 24 | 25 | func ValidateTestType(_ *admissionv1.AdmissionRequest, obj runtime.Object) (field.ErrorList, []string) { 26 | el := field.ErrorList{} 27 | tt := obj.(*TestType) 28 | if tt.TestField == DisallowedTestFieldValue { 29 | el = append(el, field.Invalid(field.NewPath("testField"), tt.TestField, "value not allowed")) 30 | } 31 | return el, nil 32 | } 33 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright The cert-manager Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package v2 22 | 23 | import ( 24 | "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 28 | func (in *TestType) DeepCopyInto(out *TestType) { 29 | *out = *in 30 | out.TypeMeta = in.TypeMeta 31 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 32 | if in.TestFieldPtrAlt != nil { 33 | in, out := &in.TestFieldPtrAlt, &out.TestFieldPtrAlt 34 | *out = new(string) 35 | **out = **in 36 | } 37 | } 38 | 39 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. 40 | func (in *TestType) DeepCopy() *TestType { 41 | if in == nil { 42 | return nil 43 | } 44 | out := new(TestType) 45 | in.DeepCopyInto(out) 46 | return out 47 | } 48 | 49 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 50 | func (in *TestType) DeepCopyObject() runtime.Object { 51 | if c := in.DeepCopy(); c != nil { 52 | return c 53 | } 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/v2/zz_generated.defaults.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | // +build !ignore_autogenerated 3 | 4 | /* 5 | Copyright The cert-manager Authors. 6 | 7 | Licensed under the Apache License, Version 2.0 (the "License"); 8 | you may not use this file except in compliance with the License. 9 | You may obtain a copy of the License at 10 | 11 | http://www.apache.org/licenses/LICENSE-2.0 12 | 13 | Unless required by applicable law or agreed to in writing, software 14 | distributed under the License is distributed on an "AS IS" BASIS, 15 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | See the License for the specific language governing permissions and 17 | limitations under the License. 18 | */ 19 | // Code generated by defaulter-gen. DO NOT EDIT. 20 | 21 | package v2 22 | 23 | import ( 24 | runtime "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // RegisterDefaults adds defaulters functions to the given scheme. 28 | // Public to allow building arbitrary schemes. 29 | // All generated defaulters are covering - they call all nested defaulters. 30 | func RegisterDefaults(scheme *runtime.Scheme) error { 31 | scheme.AddTypeDefaultingFunc(&TestType{}, func(obj interface{}) { SetObjectDefaults_TestType(obj.(*TestType)) }) 32 | return nil 33 | } 34 | 35 | func SetObjectDefaults_TestType(in *TestType) { 36 | SetDefaults_TestType(in) 37 | } 38 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/validation/validation.go: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2020 The cert-manager Authors. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | package validation 18 | 19 | import ( 20 | admissionv1 "k8s.io/api/admission/v1" 21 | "k8s.io/apimachinery/pkg/runtime" 22 | "k8s.io/apimachinery/pkg/util/validation/field" 23 | 24 | "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup" 25 | v1 "github.com/cert-manager/cmctl/v2/test/integration/testdata/apis/testgroup/v1" 26 | ) 27 | 28 | func ValidateTestType(_ *admissionv1.AdmissionRequest, obj runtime.Object) (field.ErrorList, []string) { 29 | testType := obj.(*testgroup.TestType) 30 | el := field.ErrorList{} 31 | if testType.TestField == v1.TestFieldValueNotAllowed { 32 | el = append(el, field.Invalid(field.NewPath("testField"), testType.TestField, "invalid value")) 33 | } 34 | return el, nil 35 | } 36 | 37 | func ValidateTestTypeUpdate(_ *admissionv1.AdmissionRequest, oldObj, newObj runtime.Object) (field.ErrorList, []string) { 38 | old, ok := oldObj.(*testgroup.TestType) 39 | new := newObj.(*testgroup.TestType) 40 | // if oldObj is not set, the Update operation is always valid. 41 | if !ok || old == nil { 42 | return nil, nil 43 | } 44 | el := field.ErrorList{} 45 | if old.TestFieldImmutable != "" && old.TestFieldImmutable != new.TestFieldImmutable { 46 | el = append(el, field.Forbidden(field.NewPath("testFieldImmutable"), "field is immutable once set")) 47 | } 48 | return el, nil 49 | } 50 | -------------------------------------------------------------------------------- /test/integration/testdata/apis/testgroup/zz_generated.deepcopy.go: -------------------------------------------------------------------------------- 1 | //go:build !ignore_autogenerated 2 | 3 | /* 4 | Copyright The cert-manager Authors. 5 | 6 | Licensed under the Apache License, Version 2.0 (the "License"); 7 | you may not use this file except in compliance with the License. 8 | You may obtain a copy of the License at 9 | 10 | http://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, software 13 | distributed under the License is distributed on an "AS IS" BASIS, 14 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | See the License for the specific language governing permissions and 16 | limitations under the License. 17 | */ 18 | 19 | // Code generated by controller-gen. DO NOT EDIT. 20 | 21 | package testgroup 22 | 23 | import ( 24 | "k8s.io/apimachinery/pkg/runtime" 25 | ) 26 | 27 | // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. 28 | func (in *TestType) DeepCopyInto(out *TestType) { 29 | *out = *in 30 | out.TypeMeta = in.TypeMeta 31 | in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) 32 | if in.TestFieldPtr != nil { 33 | in, out := &in.TestFieldPtr, &out.TestFieldPtr 34 | *out = new(string) 35 | **out = **in 36 | } 37 | } 38 | 39 | // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestType. 40 | func (in *TestType) DeepCopy() *TestType { 41 | if in == nil { 42 | return nil 43 | } 44 | out := new(TestType) 45 | in.DeepCopyInto(out) 46 | return out 47 | } 48 | 49 | // DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. 50 | func (in *TestType) DeepCopyObject() runtime.Object { 51 | if c := in.DeepCopy(); c != nil { 52 | return c 53 | } 54 | return nil 55 | } 56 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/input/resource1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1alpha2 2 | kind: Certificate 3 | metadata: 4 | name: ca-issuer 5 | namespace: sandbox 6 | spec: 7 | isCA: true 8 | secretName: ca-key-pair 9 | commonName: my-csi-app 10 | issuerRef: 11 | name: selfsigned-issuer 12 | kind: Issuer 13 | group: cert-manager.io 14 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/input/resource2.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | # my comment 3 | apiVersion: cert-manager.io/v1alpha2 4 | kind: Certificate 5 | metadata: 6 | name: ca-issuer 7 | namespace: sandbox 8 | spec: 9 | isCA: true 10 | secretName: ca-key-pair 11 | commonName: my-csi-app 12 | issuerRef: 13 | name: selfsigned-issuer 14 | kind: Issuer 15 | group: cert-manager.io 16 | --- 17 | apiVersion: cert-manager.io/v1alpha2 18 | kind: Issuer 19 | metadata: 20 | name: ca-issuer 21 | namespace: sandbox 22 | spec: 23 | ca: 24 | secretName: ca-key-pair 25 | --- 26 | apiVersion: cert-manager.io/v1alpha2 27 | kind: Certificate 28 | metadata: 29 | name: ca-issuer-2 30 | namespace: sandbox 31 | spec: 32 | isCA: true 33 | secretName: ca-key-pair 34 | commonName: my-csi-app 35 | issuerRef: 36 | name: ca-issuer 37 | kind: Issuer 38 | group: cert-manager.io 39 | --- 40 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/input/resource3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Namespace 3 | metadata: 4 | name: sandbox 5 | --- 6 | apiVersion: cert-manager.io/v1alpha2 7 | kind: Issuer 8 | metadata: 9 | name: selfsigned-issuer 10 | namespace: sandbox 11 | spec: 12 | selfSigned: {} 13 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/input/resource_with_organization_v1alpha2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1alpha2 2 | kind: Certificate 3 | metadata: 4 | name: ca-issuer 5 | namespace: sandbox 6 | spec: 7 | isCA: true 8 | secretName: ca-key-pair 9 | organization: 10 | - "hello world" 11 | commonName: my-csi-app 12 | issuerRef: 13 | name: selfsigned-issuer 14 | kind: Issuer 15 | group: cert-manager.io 16 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/input/resources_as_list_v1alpha2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: List 3 | items: 4 | - apiVersion: cert-manager.io/v1alpha2 5 | kind: Certificate 6 | metadata: 7 | name: list-test-1 8 | namespace: default 9 | spec: 10 | dnsNames: 11 | - example.cert-manager.1 12 | duration: 24h 13 | issuerRef: 14 | name: cert-manager-test-1 15 | secretName: cert-manager-test-1 16 | - apiVersion: cert-manager.io/v1alpha2 17 | kind: Certificate 18 | metadata: 19 | name: list-test-1 20 | namespace: default 21 | spec: 22 | dnsNames: 23 | - example.cert-manager.2 24 | duration: 24h 25 | issuerRef: 26 | name: cert-manager-test-2 27 | secretName: cert-manager-test-2 28 | - apiVersion: cert-manager.io/v1alpha2 29 | kind: Issuer 30 | metadata: 31 | name: ca-issuer 32 | namespace: sandbox 33 | spec: 34 | ca: 35 | secretName: ca-key-pair 36 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/no_output_error.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cert-manager/cmctl/a21678ffc10f02e23715dd0c8b5f43c6baaf3acb/test/integration/testdata/convert/output/no_output_error.yaml -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource1_v1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1 2 | kind: Certificate 3 | metadata: 4 | creationTimestamp: null 5 | name: ca-issuer 6 | namespace: sandbox 7 | spec: 8 | commonName: my-csi-app 9 | isCA: true 10 | issuerRef: 11 | group: cert-manager.io 12 | kind: Issuer 13 | name: selfsigned-issuer 14 | secretName: ca-key-pair 15 | status: {} 16 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource1_v1alpha2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1alpha2 2 | kind: Certificate 3 | metadata: 4 | creationTimestamp: null 5 | name: ca-issuer 6 | namespace: sandbox 7 | spec: 8 | commonName: my-csi-app 9 | isCA: true 10 | issuerRef: 11 | group: cert-manager.io 12 | kind: Issuer 13 | name: selfsigned-issuer 14 | secretName: ca-key-pair 15 | status: {} 16 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource1_v1alpha3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1alpha3 2 | kind: Certificate 3 | metadata: 4 | creationTimestamp: null 5 | name: ca-issuer 6 | namespace: sandbox 7 | spec: 8 | commonName: my-csi-app 9 | isCA: true 10 | issuerRef: 11 | group: cert-manager.io 12 | kind: Issuer 13 | name: selfsigned-issuer 14 | secretName: ca-key-pair 15 | status: {} 16 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource2_v1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: ca-issuer 8 | namespace: sandbox 9 | spec: 10 | commonName: my-csi-app 11 | isCA: true 12 | issuerRef: 13 | group: cert-manager.io 14 | kind: Issuer 15 | name: selfsigned-issuer 16 | secretName: ca-key-pair 17 | status: {} 18 | - apiVersion: cert-manager.io/v1 19 | kind: Issuer 20 | metadata: 21 | creationTimestamp: null 22 | name: ca-issuer 23 | namespace: sandbox 24 | spec: 25 | ca: 26 | secretName: ca-key-pair 27 | status: {} 28 | - apiVersion: cert-manager.io/v1 29 | kind: Certificate 30 | metadata: 31 | creationTimestamp: null 32 | name: ca-issuer-2 33 | namespace: sandbox 34 | spec: 35 | commonName: my-csi-app 36 | isCA: true 37 | issuerRef: 38 | group: cert-manager.io 39 | kind: Issuer 40 | name: ca-issuer 41 | secretName: ca-key-pair 42 | status: {} 43 | kind: List 44 | metadata: {} 45 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource2_v1alpha2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1alpha2 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: ca-issuer 8 | namespace: sandbox 9 | spec: 10 | commonName: my-csi-app 11 | isCA: true 12 | issuerRef: 13 | group: cert-manager.io 14 | kind: Issuer 15 | name: selfsigned-issuer 16 | secretName: ca-key-pair 17 | status: {} 18 | - apiVersion: cert-manager.io/v1alpha2 19 | kind: Issuer 20 | metadata: 21 | creationTimestamp: null 22 | name: ca-issuer 23 | namespace: sandbox 24 | spec: 25 | ca: 26 | secretName: ca-key-pair 27 | status: {} 28 | - apiVersion: cert-manager.io/v1alpha2 29 | kind: Certificate 30 | metadata: 31 | creationTimestamp: null 32 | name: ca-issuer-2 33 | namespace: sandbox 34 | spec: 35 | commonName: my-csi-app 36 | isCA: true 37 | issuerRef: 38 | group: cert-manager.io 39 | kind: Issuer 40 | name: ca-issuer 41 | secretName: ca-key-pair 42 | status: {} 43 | kind: List 44 | metadata: {} 45 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource2_v1alpha3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1alpha3 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: ca-issuer 8 | namespace: sandbox 9 | spec: 10 | commonName: my-csi-app 11 | isCA: true 12 | issuerRef: 13 | group: cert-manager.io 14 | kind: Issuer 15 | name: selfsigned-issuer 16 | secretName: ca-key-pair 17 | status: {} 18 | - apiVersion: cert-manager.io/v1alpha3 19 | kind: Issuer 20 | metadata: 21 | creationTimestamp: null 22 | name: ca-issuer 23 | namespace: sandbox 24 | spec: 25 | ca: 26 | secretName: ca-key-pair 27 | status: {} 28 | - apiVersion: cert-manager.io/v1alpha3 29 | kind: Certificate 30 | metadata: 31 | creationTimestamp: null 32 | name: ca-issuer-2 33 | namespace: sandbox 34 | spec: 35 | commonName: my-csi-app 36 | isCA: true 37 | issuerRef: 38 | group: cert-manager.io 39 | kind: Issuer 40 | name: ca-issuer 41 | secretName: ca-key-pair 42 | status: {} 43 | kind: List 44 | metadata: {} 45 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource_with_organization_v1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1 2 | kind: Certificate 3 | metadata: 4 | creationTimestamp: null 5 | name: ca-issuer 6 | namespace: sandbox 7 | spec: 8 | commonName: my-csi-app 9 | isCA: true 10 | issuerRef: 11 | group: cert-manager.io 12 | kind: Issuer 13 | name: selfsigned-issuer 14 | secretName: ca-key-pair 15 | subject: 16 | organizations: 17 | - hello world 18 | status: {} 19 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource_with_organization_v1alpha3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1alpha3 2 | kind: Certificate 3 | metadata: 4 | creationTimestamp: null 5 | name: ca-issuer 6 | namespace: sandbox 7 | spec: 8 | commonName: my-csi-app 9 | isCA: true 10 | issuerRef: 11 | group: cert-manager.io 12 | kind: Issuer 13 | name: selfsigned-issuer 14 | secretName: ca-key-pair 15 | subject: 16 | organizations: 17 | - hello world 18 | status: {} 19 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resource_with_organization_v1beta1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1beta1 2 | kind: Certificate 3 | metadata: 4 | creationTimestamp: null 5 | name: ca-issuer 6 | namespace: sandbox 7 | spec: 8 | commonName: my-csi-app 9 | isCA: true 10 | issuerRef: 11 | group: cert-manager.io 12 | kind: Issuer 13 | name: selfsigned-issuer 14 | secretName: ca-key-pair 15 | subject: 16 | organizations: 17 | - hello world 18 | status: {} 19 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resources_as_list_v1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: list-test-1 8 | namespace: default 9 | spec: 10 | dnsNames: 11 | - example.cert-manager.1 12 | duration: 24h0m0s 13 | issuerRef: 14 | name: cert-manager-test-1 15 | secretName: cert-manager-test-1 16 | status: {} 17 | - apiVersion: cert-manager.io/v1 18 | kind: Certificate 19 | metadata: 20 | creationTimestamp: null 21 | name: list-test-1 22 | namespace: default 23 | spec: 24 | dnsNames: 25 | - example.cert-manager.2 26 | duration: 24h0m0s 27 | issuerRef: 28 | name: cert-manager-test-2 29 | secretName: cert-manager-test-2 30 | status: {} 31 | - apiVersion: cert-manager.io/v1 32 | kind: Issuer 33 | metadata: 34 | creationTimestamp: null 35 | name: ca-issuer 36 | namespace: sandbox 37 | spec: 38 | ca: 39 | secretName: ca-key-pair 40 | status: {} 41 | kind: List 42 | metadata: {} 43 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resources_as_list_v1alpha2.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1alpha2 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: list-test-1 8 | namespace: default 9 | spec: 10 | dnsNames: 11 | - example.cert-manager.1 12 | duration: 24h0m0s 13 | issuerRef: 14 | name: cert-manager-test-1 15 | secretName: cert-manager-test-1 16 | status: {} 17 | - apiVersion: cert-manager.io/v1alpha2 18 | kind: Certificate 19 | metadata: 20 | creationTimestamp: null 21 | name: list-test-1 22 | namespace: default 23 | spec: 24 | dnsNames: 25 | - example.cert-manager.2 26 | duration: 24h0m0s 27 | issuerRef: 28 | name: cert-manager-test-2 29 | secretName: cert-manager-test-2 30 | status: {} 31 | - apiVersion: cert-manager.io/v1alpha2 32 | kind: Issuer 33 | metadata: 34 | creationTimestamp: null 35 | name: ca-issuer 36 | namespace: sandbox 37 | spec: 38 | ca: 39 | secretName: ca-key-pair 40 | status: {} 41 | kind: List 42 | metadata: {} 43 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resources_as_list_v1alpha3.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1alpha3 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: list-test-1 8 | namespace: default 9 | spec: 10 | dnsNames: 11 | - example.cert-manager.1 12 | duration: 24h0m0s 13 | issuerRef: 14 | name: cert-manager-test-1 15 | secretName: cert-manager-test-1 16 | status: {} 17 | - apiVersion: cert-manager.io/v1alpha3 18 | kind: Certificate 19 | metadata: 20 | creationTimestamp: null 21 | name: list-test-1 22 | namespace: default 23 | spec: 24 | dnsNames: 25 | - example.cert-manager.2 26 | duration: 24h0m0s 27 | issuerRef: 28 | name: cert-manager-test-2 29 | secretName: cert-manager-test-2 30 | status: {} 31 | - apiVersion: cert-manager.io/v1alpha3 32 | kind: Issuer 33 | metadata: 34 | creationTimestamp: null 35 | name: ca-issuer 36 | namespace: sandbox 37 | spec: 38 | ca: 39 | secretName: ca-key-pair 40 | status: {} 41 | kind: List 42 | metadata: {} 43 | -------------------------------------------------------------------------------- /test/integration/testdata/convert/output/resources_as_list_v1beta1.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | items: 3 | - apiVersion: cert-manager.io/v1beta1 4 | kind: Certificate 5 | metadata: 6 | creationTimestamp: null 7 | name: list-test-1 8 | namespace: default 9 | spec: 10 | dnsNames: 11 | - example.cert-manager.1 12 | duration: 24h0m0s 13 | issuerRef: 14 | name: cert-manager-test-1 15 | secretName: cert-manager-test-1 16 | status: {} 17 | - apiVersion: cert-manager.io/v1beta1 18 | kind: Certificate 19 | metadata: 20 | creationTimestamp: null 21 | name: list-test-1 22 | namespace: default 23 | spec: 24 | dnsNames: 25 | - example.cert-manager.2 26 | duration: 24h0m0s 27 | issuerRef: 28 | name: cert-manager-test-2 29 | secretName: cert-manager-test-2 30 | status: {} 31 | - apiVersion: cert-manager.io/v1beta1 32 | kind: Issuer 33 | metadata: 34 | creationTimestamp: null 35 | name: ca-issuer 36 | namespace: sandbox 37 | spec: 38 | ca: 39 | secretName: ca-key-pair 40 | status: {} 41 | kind: List 42 | metadata: {} 43 | -------------------------------------------------------------------------------- /test/integration/testdata/create_cr_cert_with_ns1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: cert-manager.io/v1alpha2 3 | kind: Certificate 4 | metadata: 5 | name: testcert-1 6 | namespace: testns-1 7 | spec: 8 | isCA: true 9 | secretName: ca-key-pair 10 | commonName: my-csi-app 11 | issuerRef: 12 | name: selfsigned-issuer 13 | kind: Issuer 14 | group: cert-manager.io 15 | -------------------------------------------------------------------------------- /test/integration/testdata/create_cr_issuer.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: cert-manager.io/v1alpha2 2 | kind: Issuer 3 | metadata: 4 | name: ca-issuer 5 | namespace: testns-1 6 | spec: 7 | ca: 8 | secretName: ca-key-pair 9 | -------------------------------------------------------------------------------- /test/integration/testdata/create_cr_v1alpha3_cert_with_ns1.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | apiVersion: cert-manager.io/v1alpha3 3 | kind: Certificate 4 | metadata: 5 | name: testcert-v1alpha3 6 | namespace: testns-1 7 | spec: 8 | isCA: true 9 | secretName: ca-key-pair 10 | commonName: my-csi-app 11 | issuerRef: 12 | name: selfsigned-issuer 13 | kind: Issuer 14 | group: cert-manager.io 15 | subject: 16 | organizations: 17 | - hello world 18 | --------------------------------------------------------------------------------