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

Support -o json and -o name on get #60

Merged
merged 9 commits into from
Aug 28, 2024
Merged

Support -o json and -o name on get #60

merged 9 commits into from
Aug 28, 2024

Conversation

sderosiaux
Copy link
Member

@sderosiaux sderosiaux commented Aug 27, 2024

  • supports -o or --output json|yaml|name (default yaml)
  • the '---' is now at the beginning of each yaml document, not the end, to follow the standard practice
  • the JSON is the one from the API, no reordering
  • it works on get: on list and single item

Why?

Because JSON is more automatable (?) than YAML.

eg:

$ conduktor get Application -o json | jq -r '.[].metadata.name'
purchase-pipeline
tracker
support

Because single line is more readable at a glance than YAML: (the best thing will be when you can "get all" with that)

$ ./conduktor get ApplicationInstance -o name
ApplicationInstance/tracker-dev
ApplicationInstance/support-dev
ApplicationInstance/purchase-pipeline-dev

Examples:

  • on one item:
$ ./conduktor get Application support -o json
{
  "apiVersion": "v1",
  "kind": "Application",
  "metadata": {
    "name": "support"
  },
  "spec": {
    "title": "The support",
    "description": "The support of our company",
    "owner": "support-project"
  }
}
  • on a list:
./conduktor get Application -o json
[
  {
    "apiVersion": "v1",
    "kind": "Application",
    "metadata": {
      "name": "purchase-pipeline"
    },
    "spec": {
      "title": "Purchase pipeline",
      "description": "money money money",
      "owner": "admin"
    }
  },
  {
    "apiVersion": "v1",
    "kind": "Application",
    "metadata": {
      "name": "tracker"
    },
    "spec": {
      "title": "User tracking",
      "description": "Track our dear customers",
      "owner": "tracker-project"
    }
  },
  {
    "apiVersion": "v1",
    "kind": "Application",
    "metadata": {
      "name": "support"
    },
    "spec": {
      "title": "The support",
      "description": "The support of our company",
      "owner": "support-project"
    }
  }
]
  • default behavior unchanged, yaml (except for the '---'):
$ conduktor get Application
---
apiVersion: v1
kind: Application
metadata:
    name: purchase-pipeline
spec:
    title: Purchase pipeline
    description: money money money
    owner: admin
---
apiVersion: v1
kind: Application
metadata:
    name: tracker
spec:
    title: User tracking
    description: Track our dear customers
    owner: tracker-project
---
apiVersion: v1
kind: Application
metadata:
    name: support
spec:
    title: The support
    description: The support of our company
    owner: support-project

@sderosiaux sderosiaux changed the title Support -o json Support -o json on get Aug 27, 2024
@sderosiaux sderosiaux changed the title Support -o json on get Support -o json and -o name on get Aug 28, 2024
Copy link
Member

@qboileau qboileau left a comment

Choose a reason for hiding this comment

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

Missing tests but I'm not sure if we already have some for get only

cmd/get.go Show resolved Hide resolved
cmd/get.go Outdated Show resolved Hide resolved
@strokyl
Copy link
Collaborator

strokyl commented Aug 28, 2024

Could be great to add some test in test_final_exec.sh
It won't test the output but at least that the command does not crash when using -o

@sderosiaux sderosiaux merged commit 9911cbe into main Aug 28, 2024
4 checks passed
@sderosiaux sderosiaux deleted the feat/output-json branch August 28, 2024 11:16
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.

3 participants