diff --git a/.gitignore b/.gitignore index 270d60009..eec8c3688 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,14 @@ # Built binaries kubectl-oadp +kubectl-oadp-linux-* +kubectl-oadp-darwin-* +kubectl-oadp-windows-* + +# Release artifacts +*.tar.gz +*.sha256 +oadp-*.yaml # Test binary, built with `go test -c` *.test diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..99ccf729a --- /dev/null +++ b/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (which shall not include communication that is conspicuously + marked or otherwise designated in writing by the copyright owner + as "Not a Contribution.") + + "Derivative Work" shall mean any work, whether in Source or Object + form, that is based upon (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this license, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and derivative works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control + systems, and issue tracking systems that are managed by, or on behalf + of, the Licensor for the purpose of discussing and improving the Work, + but excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to use, reproduce, modify, distribute, and prepare + Derivative Works of, publicly display, publicly perform, sublicense, + and distribute the Work and such Derivative Works in Source or Object + form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright notice and license terms to Your + modifications to a Derivative Work; provided that Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Acceptance and Termination. This license is effective upon Your + acceptance of these terms and conditions by use, copying, distribution, + or modification of the Work. Nothing in this License shall waive or + release You from the obligations and liabilities under this License. + This License shall terminate immediately and You may no longer + exercise any of the rights granted to You by this License upon Your + failure to honor the conditions in Section 4 above. + + 10. Each time You redistribute the Work or a Derivative Work, the Licensor + grants to the recipient a license to the Work on the same terms and + conditions as the license granted to You under this License. + + 11. Miscellaneous. If any provision of this License is held to be + unenforceable, such provision shall be reformed only to the extent + necessary to make it enforceable. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in comments + appropriate for the file format. We also recommend that a file or + class name and description of purpose be included on the same + "printed page" as the copyright notice for easier identification + within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/Makefile b/Makefile index f7f4f4019..336d5c35a 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,11 @@ # Variables BINARY_NAME = kubectl-oadp INSTALL_PATH ?= /usr/local/bin +VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev") + +# Centralized platform definitions to avoid duplication +# Matches architectures supported by Kubernetes: https://kubernetes.io/releases/download/#binaries +PLATFORMS = linux/amd64 linux/arm64 linux/ppc64le linux/s390x darwin/amd64 darwin/arm64 windows/amd64 windows/arm64 # Platform variables for multi-arch builds # Usage: make build PLATFORM=linux/amd64 @@ -12,6 +17,11 @@ PLATFORM ?= GOOS = $(word 1,$(subst /, ,$(PLATFORM))) GOARCH = $(word 2,$(subst /, ,$(PLATFORM))) +# Helper function to get binary name with .exe for Windows +define get_binary_name +$(if $(findstring windows,$(1)),$(BINARY_NAME).exe,$(BINARY_NAME)) +endef + # Default target .PHONY: help help: ## Show this help message @@ -23,9 +33,16 @@ help: ## Show this help message @echo "Build with different platforms:" @echo " make build PLATFORM=linux/amd64" @echo " make build PLATFORM=linux/arm64" + @echo " make build PLATFORM=linux/ppc64le" + @echo " make build PLATFORM=linux/s390x" @echo " make build PLATFORM=darwin/amd64" @echo " make build PLATFORM=darwin/arm64" @echo " make build PLATFORM=windows/amd64" + @echo " make build PLATFORM=windows/arm64" + @echo "" + @echo "Release commands:" + @echo " make release-build # Build binaries for all platforms" + @echo " make release-archives # Create tar.gz archives for all platforms" # Build targets .PHONY: build @@ -59,7 +76,9 @@ test: ## Run all tests .PHONY: clean clean: ## Remove built binaries @echo "Cleaning up..." - @rm -f $(BINARY_NAME) $(BINARY_NAME)-* + @rm -f $(BINARY_NAME) $(BINARY_NAME)-linux-* $(BINARY_NAME)-darwin-* $(BINARY_NAME)-windows-* + @rm -f *.tar.gz *.sha256 + @rm -f oadp-*.yaml oadp-*.yaml.tmp @echo "✅ Cleanup complete!" # Status and utility targets @@ -86,3 +105,105 @@ status: ## Show build status and installation info echo " Available plugins:"; \ kubectl plugin list 2>/dev/null | head -5 || echo " (no plugins found or kubectl not available)"; \ fi + +# Optimized release targets with centralized platform logic +.PHONY: release-build +release-build: ## Build binaries for all platforms + @echo "Building release binaries..." + @for platform in $(PLATFORMS); do \ + GOOS=$$(echo $$platform | cut -d'/' -f1); \ + GOARCH=$$(echo $$platform | cut -d'/' -f2); \ + if [ "$$GOOS" = "windows" ]; then \ + binary_name="$(BINARY_NAME).exe"; \ + else \ + binary_name="$(BINARY_NAME)"; \ + fi; \ + echo "Building for $$GOOS/$$GOARCH..."; \ + GOOS=$$GOOS GOARCH=$$GOARCH go build -o $$binary_name .; \ + echo "✅ Built $$binary_name for $$GOOS/$$GOARCH"; \ + mv $$binary_name $(BINARY_NAME)-$$GOOS-$$GOARCH$${binary_name#$(BINARY_NAME)}; \ + done + @echo "✅ All release binaries built successfully!" + +.PHONY: release-archives +release-archives: release-build ## Create tar.gz archives for all platforms (includes LICENSE) + @echo "Creating release archives..." + @if [ ! -f LICENSE ]; then \ + echo "❌ LICENSE file not found! Please ensure LICENSE file exists."; \ + exit 1; \ + fi + @for platform in $(PLATFORMS); do \ + GOOS=$$(echo $$platform | cut -d'/' -f1); \ + GOARCH=$$(echo $$platform | cut -d'/' -f2); \ + if [ "$$GOOS" = "windows" ]; then \ + binary_name="$(BINARY_NAME).exe"; \ + else \ + binary_name="$(BINARY_NAME)"; \ + fi; \ + archive_name="$(BINARY_NAME)-$$GOOS-$$GOARCH.tar.gz"; \ + echo "Creating $$archive_name..."; \ + tar czf $$archive_name LICENSE $(BINARY_NAME)-$$GOOS-$$GOARCH$${binary_name#$(BINARY_NAME)}; \ + sha256sum $$archive_name > $$archive_name.sha256; \ + echo "✅ Created $$archive_name with LICENSE"; \ + done + @echo "✅ All release archives created successfully!" + @echo "📦 Archives created:" + @ls -la *.tar.gz + @echo "🔐 SHA256 checksums:" + @ls -la *.sha256 + +.PHONY: release +release: release-archives ## Build and create release archives for all platforms + @echo "🚀 Release build complete! Archives ready for distribution." + +# Optimized krew-manifest generation using Python script for better reliability +.PHONY: krew-manifest +krew-manifest: release-archives ## Generate Krew plugin manifest with SHA256 checksums + @echo "Generating Krew plugin manifest with SHA256 checksums..." + @if [ ! -f oadp.yaml ]; then \ + echo "❌ oadp.yaml manifest template not found!"; \ + exit 1; \ + fi + @python3 -c " \ +import sys, re, os; \ +version = '$(VERSION)'; \ +platforms = [p.split('/') for p in '$(PLATFORMS)'.split()]; \ +\ +with open('oadp.yaml', 'r') as f: \ + content = f.read(); \ +\ +content = re.sub(r'version: v1\.0\.0', f'version: {version}', content); \ +content = re.sub(r'download/v1\.0\.0/', f'download/{version}/', content); \ +\ +for goos, goarch in platforms: \ + binary_suffix = '.exe' if goos == 'windows' else ''; \ + sha_file = f'kubectl-oadp-{goos}-{goarch}.tar.gz.sha256'; \ + if os.path.exists(sha_file): \ + with open(sha_file, 'r') as sf: \ + sha256 = sf.read().split()[0]; \ + pattern = rf'(os: {goos}.*?arch: {goarch}.*?sha256: \")\"'; \ + replacement = rf'\g<1>{sha256}\"'; \ + content = re.sub(pattern, replacement, content, flags=re.DOTALL); \ + print(f' ✅ {goos}/{goarch}: {sha256}'); \ +\ +with open(f'oadp-{version}.yaml', 'w') as f: \ + f.write(content); \ +print(f'✅ Krew manifest generated: oadp-{version}.yaml'); \ +" 2>/dev/null || { \ + echo "⚠️ Python3 not available, using fallback sed approach..."; \ + cp oadp.yaml oadp-$(VERSION).yaml; \ + # Use portable sed approach (works on both BSD/macOS and GNU/Linux) \ + sed "s/version: v1.0.0/version: $(VERSION)/" oadp-$(VERSION).yaml > oadp-$(VERSION).yaml.tmp && mv oadp-$(VERSION).yaml.tmp oadp-$(VERSION).yaml; \ + sed "s|download/v1.0.0/|download/$(VERSION)/|g" oadp-$(VERSION).yaml > oadp-$(VERSION).yaml.tmp && mv oadp-$(VERSION).yaml.tmp oadp-$(VERSION).yaml; \ + for platform in $(PLATFORMS); do \ + GOOS=$$(echo $$platform | cut -d'/' -f1); \ + GOARCH=$$(echo $$platform | cut -d'/' -f2); \ + sha_file="kubectl-oadp-$$GOOS-$$GOARCH.tar.gz.sha256"; \ + if [ -f "$$sha_file" ]; then \ + sha256=$$(cat $$sha_file | cut -d' ' -f1); \ + echo " ✅ $$GOOS/$$GOARCH: $$sha256"; \ + fi; \ + done; \ + echo "⚠️ SHA256 checksums need manual update in oadp-$(VERSION).yaml"; \ + } + @echo "📝 Review the manifest and update the GitHub release URLs as needed." diff --git a/README.md b/README.md index 1d7c9cc3c..db6997ea0 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,25 @@ oadp └── create ``` +## Installation + +### Using Krew (Recommended) + +[Krew](https://krew.sigs.k8s.io/) is the recommended way to install kubectl plugins. + +```sh +# Install Krew if you haven't already +kubectl krew install krew + +# Install the OADP plugin +kubectl krew install oadp + +# Verify installation +kubectl oadp --help +``` + +**Note:** The LICENSE file is automatically extracted during Krew installation and available in the plugin directory. + ## Build and Install ### Quick Installation @@ -68,6 +87,26 @@ make status make help ``` +### Release Process + +For maintainers creating releases: + +```sh +# Build release archives for all platforms (includes LICENSE file) +make release + +# Generate Krew plugin manifest with SHA256 checksums +make krew-manifest + +# Clean up build artifacts +make clean +``` + +The release process creates: +- Platform-specific archives (`kubectl-oadp-OS-ARCH.tar.gz`) containing the binary and LICENSE file +- SHA256 checksums for each archive +- A Krew plugin manifest file with proper checksums for distribution + ## Usage Examples ### NonAdminBackup Operations @@ -130,4 +169,13 @@ go test ./... This CLI is built using: - [Cobra](https://github.com/spf13/cobra) for CLI framework - [Velero client libraries](https://github.com/vmware-tanzu/velero) for core functionality -- [OADP NonAdmin APIs](https://github.com/migtools/oadp-non-admin) for NonAdminBackup operations \ No newline at end of file +- [OADP NonAdmin APIs](https://github.com/migtools/oadp-non-admin) for NonAdminBackup operations + +## License + +This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE) file for details. + +This CLI builds on and integrates with: +- [Velero](https://github.com/vmware-tanzu/velero) (Apache 2.0) +- [OADP](https://github.com/openshift/oadp-operator) (Apache 2.0) +- [Kubernetes](https://github.com/kubernetes/kubernetes) (Apache 2.0) \ No newline at end of file diff --git a/cmd/non-admin/backup/create.go b/cmd/non-admin/backup/create.go index e5965b454..65d4d3049 100644 --- a/cmd/non-admin/backup/create.go +++ b/cmd/non-admin/backup/create.go @@ -50,19 +50,19 @@ func NewCreateCommand(f client.Factory, use string) *cobra.Command { cmd.CheckError(o.Run(c, f)) }, Example: ` # Create a non-admin backup containing all resources in the current namespace. - oadp nonadmin backup create backup1 + kubectl oadp nonadmin backup create backup1 # Create a non-admin backup with specific resource types. - oadp nonadmin backup create backup2 --include-resources deployments,services + kubectl oadp nonadmin backup create backup2 --include-resources deployments,services # Create a non-admin backup excluding certain resources. - oadp nonadmin backup create backup3 --exclude-resources secrets + kubectl oadp nonadmin backup create backup3 --exclude-resources secrets # View the YAML for a non-admin backup that doesn't snapshot volumes, without sending it to the server. - oadp nonadmin backup create backup4 --snapshot-volumes=false -o yaml + kubectl oadp nonadmin backup create backup4 --snapshot-volumes=false -o yaml # Wait for a non-admin backup to complete before returning from the command. - oadp nonadmin backup create backup5 --wait`, + kubectl oadp nonadmin backup create backup5 --wait`, } o.BindFlags(c.Flags()) diff --git a/cmd/non-admin/backup/logs.go b/cmd/non-admin/backup/logs.go index 3a57f5554..fb974827c 100644 --- a/cmd/non-admin/backup/logs.go +++ b/cmd/non-admin/backup/logs.go @@ -126,6 +126,6 @@ func NewLogsCommand(f client.Factory, use string) *cobra.Command { return nil }, - Example: ` kubectl oadp backup logs my-backup`, + Example: ` kubectl oadp nonadmin backup logs my-backup`, } } diff --git a/cmd/non-admin/nonadmin.go b/cmd/non-admin/nonadmin.go index 8ff7159c1..32c33b41c 100644 --- a/cmd/non-admin/nonadmin.go +++ b/cmd/non-admin/nonadmin.go @@ -1,3 +1,19 @@ +/* +Copyright 2025 The OADP CLI Contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package nonadmin import ( diff --git a/cmd/root.go b/cmd/root.go index 193e321b3..c0e8fc391 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -1,8 +1,26 @@ +/* +Copyright 2025 The OADP CLI Contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cmd import ( "fmt" "os" + "path/filepath" + "strings" nonadmin "github.com/migtools/oadp-cli/cmd/non-admin" "github.com/spf13/cobra" @@ -11,14 +29,33 @@ import ( "github.com/vmware-tanzu/velero/pkg/cmd/cli/version" ) +// isRunningAsPlugin detects if the executable is running as a kubectl plugin +func isRunningAsPlugin() bool { + return strings.HasPrefix(filepath.Base(os.Args[0]), "kubectl-") +} + +// getUsagePrefix returns the appropriate command prefix for help messages +func getUsagePrefix() string { + if isRunningAsPlugin() { + return "kubectl oadp" + } + return "oadp" +} + // NewVeleroRootCommand returns a root command with all Velero CLI subcommands attached. func NewVeleroRootCommand() *cobra.Command { + usagePrefix := getUsagePrefix() + rootCmd := &cobra.Command{ Use: "oadp", Short: "OADP CLI commands", Run: func(cmd *cobra.Command, args []string) { // Default action when no subcommand is provided - fmt.Println("Welcome to the OADP CLI! Use --help to see available commands.") + if isRunningAsPlugin() { + fmt.Printf("Welcome to the OADP CLI! Use '%s --help' to see available commands.\n", usagePrefix) + } else { + fmt.Println("Welcome to the OADP CLI! Use --help to see available commands.") + } }, } diff --git a/cmd/utls.go b/cmd/utls.go index 7fb012f8c..c19641d83 100644 --- a/cmd/utls.go +++ b/cmd/utls.go @@ -1,3 +1,19 @@ +/* +Copyright 2025 The OADP CLI Contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package cmd import ( diff --git a/design.md b/design.md deleted file mode 100644 index aa959b6c3..000000000 --- a/design.md +++ /dev/null @@ -1,53 +0,0 @@ -# Design proposal template `` - -_Note_: The preferred style for design documents is one sentence per line. -*Do not wrap lines*. -This aids in review of the document as changes to a line are not obscured by the reflowing those changes caused and has a side effect of avoiding debate about one or two space after a period. - -_Note_: The name of the file should follow the name pattern `_design.md`, e.g: -`listener-design.md`. - -## Abstract -One to two sentences that describes the goal of this proposal and the problem being solved by the proposed change. -The reader should be able to tell by the title, and the opening paragraph, if this document is relevant to them. - -## Background -One to two paragraphs of exposition to set the context for this proposal. - -## Goals -- A short list of things which will be accomplished by implementing this proposal. -- Two things is ok. -- Three is pushing it. -- More than three goals suggests that the proposal's scope is too large. - -## Non Goals -- A short list of items which are: -- a. out of scope -- b. follow on items which are deliberately excluded from this proposal. - - -## High-Level Design -One to two paragraphs that describe the high level changes that will be made to implement this proposal. - -## Detailed Design -A detailed design describing how the changes to the product should be made. - -The names of types, fields, interfaces, and methods should be agreed on here, not debated in code review. -The same applies to changes in CRDs, YAML examples, and so on. - -Ideally the changes should be made in sequence so that the work required to implement this design can be done incrementally, possibly in parallel. - -## Alternatives Considered -If there are alternative high level or detailed designs that were not pursued they should be called out here with a brief explanation of why they were not pursued. - -## Security Considerations -If this proposal has an impact to the security of the product, its users, or data stored or transmitted via the product, they must be addressed here. - -## Compatibility -A discussion of any compatibility issues that need to be considered - -## Implementation -A description of the implementation, timelines, and any resources that have agreed to contribute. - -## Open Issues -A discussion of issues relating to this proposal for which the author does not know the solution. This section may be omitted if there are none. \ No newline at end of file diff --git a/main.go b/main.go index 8c3692eee..808e8095d 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,24 @@ +/* +Copyright 2025 The OADP CLI Contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package main import ( "github.com/migtools/oadp-cli/cmd" + _ "k8s.io/client-go/plugin/pkg/client/auth" // Import authentication plugins for cloud providers ) func main() { diff --git a/oadp.yaml b/oadp.yaml new file mode 100644 index 000000000..86069734a --- /dev/null +++ b/oadp.yaml @@ -0,0 +1,90 @@ +apiVersion: krew.googlecontainertools.github.com/v1alpha2 +kind: Plugin +metadata: + name: oadp +spec: + version: v1.0.0 + homepage: https://github.com/migtools/oadp-cli + shortDescription: Manage OpenShift API for Data Protection (OADP) backup and restore operations + description: | + kubectl-oadp is a kubectl plugin for managing OpenShift API for Data Protection (OADP) backup and restore operations. + + It provides both admin and non-admin commands: + - Admin commands: Full OADP/Velero backup and restore operations + - Non-admin commands: Namespace-scoped backup operations with automatic namespace detection + + The plugin automatically detects the appropriate namespace from your current kubectl context + for non-admin operations, following the principle of least privilege. + + Features: + - Create and manage OADP backups + - View backup status and logs + - Delete backups + - Support for both cluster-admin and namespace-scoped operations + - Integration with kubectl context for namespace detection + caveats: | + This plugin requires: + - OADP operator to be installed in the cluster + - Appropriate RBAC permissions for the operations you want to perform + - For non-admin operations: namespace-scoped permissions in your current kubectl context namespace + platforms: + - selector: + matchLabels: + os: linux + arch: amd64 + uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-linux-amd64.tar.gz + sha256: "" + files: + - from: kubectl-oadp + to: . + - from: LICENSE + to: . + bin: kubectl-oadp + - selector: + matchLabels: + os: linux + arch: arm64 + uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-linux-arm64.tar.gz + sha256: "" + files: + - from: kubectl-oadp + to: . + - from: LICENSE + to: . + bin: kubectl-oadp + - selector: + matchLabels: + os: darwin + arch: amd64 + uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-darwin-amd64.tar.gz + sha256: "" + files: + - from: kubectl-oadp + to: . + - from: LICENSE + to: . + bin: kubectl-oadp + - selector: + matchLabels: + os: darwin + arch: arm64 + uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-darwin-arm64.tar.gz + sha256: "" + files: + - from: kubectl-oadp + to: . + - from: LICENSE + to: . + bin: kubectl-oadp + - selector: + matchLabels: + os: windows + arch: amd64 + uri: https://github.com/migtools/oadp-cli/releases/download/v1.0.0/kubectl-oadp-windows-amd64.tar.gz + sha256: "" + files: + - from: kubectl-oadp.exe + to: . + - from: LICENSE + to: . + bin: kubectl-oadp.exe \ No newline at end of file diff --git a/tests/common.go b/tests/common.go index 9fa3d2641..c4c8db6b8 100644 --- a/tests/common.go +++ b/tests/common.go @@ -1,3 +1,19 @@ +/* +Copyright 2025 The OADP CLI Contributors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + package tests import (