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

Add datasources CLI stubs #5020

Merged
merged 9 commits into from
Nov 22, 2024
Merged

Add datasources CLI stubs #5020

merged 9 commits into from
Nov 22, 2024

Conversation

teodor-yanev
Copy link
Contributor

@teodor-yanev teodor-yanev commented Nov 21, 2024

Summary

Provide a brief overview of the changes and the issue being addressed.
Explain the rationale and any background necessary for understanding the changes.
List dependencies required by this change, if any.

Fixes https://github.com/stacklok/minder-stories/issues/135

Change Type

Mark the type of change your PR introduces:

  • Bug fix (resolves an issue without affecting existing features)
  • Feature (adds new functionality without breaking changes)
  • Breaking change (may impact existing functionalities or require documentation updates)
  • Documentation (updates or additions to documentation)
  • Refactoring or test improvements (no bug fixes or new functionality)

Testing

Outline how the changes were tested, including steps to reproduce and any relevant configurations.
Attach screenshots if helpful.

Review Checklist:

  • Reviewed my own code for quality and clarity.
  • Added comments to complex or tricky code sections.
  • Updated any affected documentation.
  • Included tests that validate the fix or feature.
  • Checked that related changes are merged.

@coveralls
Copy link

coveralls commented Nov 21, 2024

Coverage Status

coverage: 54.585% (-0.04%) from 54.627%
when pulling 41592cd on add-datasources-cli-stubs
into c8469dd on main.

cmd/cli/app/datasource/create.go Outdated Show resolved Hide resolved
cmd/cli/app/datasource/create.go Outdated Show resolved Hide resolved
@teodor-yanev teodor-yanev marked this pull request as ready for review November 21, 2024 13:33
@teodor-yanev teodor-yanev requested a review from a team as a code owner November 21, 2024 13:33
@teodor-yanev
Copy link
Contributor Author

We can ignore the "proto-breaking-changes" check as the code is not used and still under development.

defer closer()

ds := &minderv1.DataSource{}
if err := minderv1.ParseResource(reader, ds); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use ParseResourceProto instead. This won't work because of the oneof usage.

cmd/cli/app/datasource/get.go Show resolved Hide resolved
cmd/cli/app/datasource/delete.go Show resolved Hide resolved
}

message ListDataSourcesRequest {
ContextV2 context = 1;
}

message ListDataSourcesResponse {
// TODO
repeated DataSource data_sources = 1;
}

message UpdateDataSourceRequest {
ContextV2 context = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, do we need the Context here since we have it as part of the DataSource?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true, I missed this. Thanks

@teodor-yanev
Copy link
Contributor Author

---Testing locally---

Results are as expected:

./bin/minder datasource get -n something
WARNING: Running against a test environment (127.0.0.1) and may not be stable
Message: Failed to get data source
Details: The service is currently unavailable
This is a most likely a transient condition and may be corrected
by retrying with a backoff.
./bin/minder datasource get
WARNING: Running against a test environment (127.0.0.1) and may not be stable
Usage:
  minder datasource get [flags]

Flags:
  -h, --help            help for get
  -i, --id string       ID of the data source to get info from
  -n, --name string     Name of the data source to get info from
  -o, --output string   Output format (one of json,yaml,table) (default "table")

Global Flags:
      --config string            Config file (default is $PWD/config.yaml)
      --grpc-host string         Server host (default "api.stacklok.com")
      --grpc-insecure            Allow establishing insecure connections
      --grpc-port int            Server port (default 443)
      --identity-client string   Identity server client ID (default "minder-cli")
      --identity-url string      Identity server issuer URL (default "https://auth.stacklok.com")
  -v, --verbose                  Output additional messages to STDERR

Details: at least one of the flags in the group [id name] is required
./bin/minder datasource list
WARNING: Running against a test environment (127.0.0.1) and may not be stable
Message: Failed to list data sources
Details: The service is currently unavailable
This is a most likely a transient condition and may be corrected
by retrying with a backoff.
./bin/minder datasource create
WARNING: Running against a test environment (127.0.0.1) and may not be stable
Usage:
  minder datasource create [flags]

Flags:
  -f, --file stringArray   Path to the YAML defining the data source (or - for stdin). Can be specified multiple times. Can be a directory.
  -h, --help               help for create

Global Flags:
      --config string            Config file (default is $PWD/config.yaml)
      --grpc-host string         Server host (default "api.stacklok.com")
      --grpc-insecure            Allow establishing insecure connections
      --grpc-port int            Server port (default 443)
      --identity-client string   Identity server client ID (default "minder-cli")
      --identity-url string      Identity server issuer URL (default "https://auth.stacklok.com")
  -v, --verbose                  Output additional messages to STDERR

Details: required flag(s) "file" not set
./bin/minder datasource delete -n something
WARNING: Running against a test environment (127.0.0.1) and may not be stable
Message: Failed to delete data source
Details: The service is currently unavailable
This is a most likely a transient condition and may be corrected
by retrying with a backoff.

Server message

"exception.message":"rpc error: code = Unavailable desc = DataSources feature is disabled"

@JAORMX Thanks for #5025

@teodor-yanev teodor-yanev merged commit 3ae9f53 into main Nov 22, 2024
24 of 26 checks passed
@teodor-yanev teodor-yanev deleted the add-datasources-cli-stubs branch November 22, 2024 13:49
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.

4 participants