Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement the construction of Kopia CLI REPOSITORY commands using the safecli package. #2646

Closed
wants to merge 6 commits into from

Conversation

plar
Copy link
Contributor

@plar plar commented Feb 1, 2024

Change Overview

This PR introduces several components for building Kopia CLI commands more effectively and safely within the Kanister project. The changes are made across various files, exclusively within the pkg/kopia/cli package. Below is the summary of the changes:

pkg/kopia/cli/internal/flag/*

Defines an Applier interface for applying commands and/or flags to safecli.CommandAppender.
This interface has a single method Apply(cli safecli.CommandAppender) error, which serves as a contract for implementing classes to append commands/flags to safecli.CommandAppender.

It also provides utility functions and types to work with flags more efficiently.
It includes methods to create a collection of flags, handle errors within flags, and apply multiple flags to a CLI command safely.

pkg/kopia/cli/internal/flag/string_flag.go & bool_flag.go

stringFlag and boolFlag structs

These structures implement the Applier interface and provide mechanisms to append flags to a command only if certain conditions (like non-empty values for string flags) are met.
stringFlag includes functionalities for handling redacted output, for hiding sensitive information in logs.
Both stringFlag and boolFlag provide public methods to create new flags conveniently.

pkg/kopia/cli/internal/flag/storage/{azure, fs, gcs, s3}

These packages offer flags specific to various storage backends.

pkg/kopia/cli/repository/*

This package utilizes the new structures and interfaces to implement the Kopia repository-related CLI commands in a more structured and safe manner.

pkg/kopia/cli/internal/test/*

This package implements test suites and utilities to validate the behavior of the new structures and interfaces.

pkg/kopia/cli/errors.go

Adds error messages for different failure scenarios related to flags.

Pull request type

Please check the type of change your PR introduces:

  • 🚧 Work in Progress
  • 🌈 Refactoring (no functional changes, no api changes)
  • 🐹 Trivial/Minor
  • 🐛 Bugfix
  • 🌻 Feature
  • 🗺️ Documentation
  • 🤖 Test

Test Plan

  • 💪 Manual
  • ⚡ Unit test
  • 💚 E2E

@plar plar changed the title Implement the construction of Kopia CLI REPOSITORY commands using the [safecli](https://github.com/kanisterio/safecli) package. Implement the construction of Kopia CLI REPOSITORY commands using the safecli package. Feb 1, 2024
@plar plar force-pushed the add-kopia-cli-repository branch from e22f926 to 9176c93 Compare February 1, 2024 23:59
@plar plar requested a review from julio-lopez February 2, 2024 00:01
@plar plar force-pushed the add-kopia-cli-repository branch from 9176c93 to 406a72f Compare February 2, 2024 18:00
@plar plar marked this pull request as ready for review February 2, 2024 18:13
@plar
Copy link
Contributor Author

plar commented Feb 2, 2024

This PR will be divided into a series of smaller PRs.

@plar plar closed this Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant