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 Kopia core flag handling data structures and flag testing suite #2649

Closed
wants to merge 3 commits into from

Conversation

plar
Copy link
Contributor

@plar plar commented Feb 3, 2024

Change Overview

This PR is the first in the series of PRs that will add a new way to build Kopia CLI commands.
The functionality of this PR provides the foundation for subsequent PRs and introduces a implementation of Kopia parameters handling in the CLI using the safecli package.

The Kopia flags can be represented in three ways:

  • As an argument, i.e., /restore/dir or 01234566789abcdef.
  • As a string flag, i.e., --flag=value, where the value can be a sensitive field for log output.
  • As a boolean/switch flag, i.e., --readonly, where the flag is present without any value.

To support this behavior, this PR introduces two primary data structures:

  • The pkg/kopia/cli/internal/flag/stringFlag and pkg/kopia/cli/internal/flag/boolFlag structs provide a structured approach to managing flags, encapsulating their properties and behaviors.
  • The redacted flag handling in stringFlag ensures that sensitive information is managed safely.

Functions such as pkg/kopia/cli/internal/flag/NewStringFlag, pkg/kopia/cli/internal/flag/NewBoolFlag, etc will be utilized in upcoming PRs for creating Kopia CLI commands.

pkg/kopia/cli/internal/flag/test/FlagTest struct and related methods provide a framework for defining and executing flag tests (see pkg/kopia/cli/internal/flag/flag_test.go).

pkg/kopia/cli/errors.go will serve as a centralized location for error definitions.

Looking forward for any feedback/suggestions!

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 requested review from Shrekster and pavannd1 February 3, 2024 03:11
@plar plar force-pushed the kopia-cli-core-infra branch from 6fd71e1 to c7eedee Compare February 3, 2024 03:15
@plar plar self-assigned this Feb 3, 2024
@plar plar force-pushed the kopia-cli-core-infra branch from af7fce3 to 618c926 Compare February 5, 2024 23:18
@plar plar closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant