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 edit mode for karmadactl interpreter command #2831

Merged
merged 1 commit into from
Jan 10, 2023

Conversation

ikaven1024
Copy link
Member

@ikaven1024 ikaven1024 commented Nov 18, 2022

Signed-off-by: yingjinhui yingjinhui@didiglobal.com

What type of PR is this?
/kind feature

What this PR does / why we need it:
add edit mode for karmadactl interpreter command.

Which issue(s) this PR fixes:
part of #2371

Special notes for your reviewer:

Example

Prepare customization.yml

apiVersion: config.karmada.io/v1alpha1
kind: ResourceInterpreterCustomization
metadata:
  creationTimestamp: null
  name: get-replica
spec:
  customizations:
    replicaResource:
      luaScript: |-
        function GetReplicas(obj)
          replica = obj.spec.replicas
          requirement = {}
          return replica, requirement
        end
  target:
    apiVersion: apps/v1
    kind: Deployment
karmadactl interpret -f customization.yml --edit

Will open a default editor:

-- Please edit the object below. Lines beginning with a '--' will be ignored,
-- and an empty file will abort the edit. If an error occurs while saving this file will be
-- reopened with the relevant failures.
--
---@TARGET: apps/v1 Deployment
---@RULE: retention
---@RULE: replicaResource
function GetReplicas(obj)
  replica = obj.spec.replicas + 2
  requirement = {}
  return replica, requirement
end
---@RULE: replicaRevision
---@RULE: statusReflection
---@RULE: statusAggregation
---@RULE: healthInterpretation
---@RULE: dependencyInterpretation

./karmadactl interpret -f get-replica.yml --edit

Does this PR introduce a user-facing change?:

`karmadactl`: add edit mod for interpret command.

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Nov 18, 2022
@ikaven1024 ikaven1024 changed the title add edit mode for karmadactl interpreter command [WIP] add edit mode for karmadactl interpreter command Nov 18, 2022
@karmada-bot karmada-bot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 18, 2022
@codecov-commenter
Copy link

codecov-commenter commented Nov 18, 2022

Codecov Report

Merging #2831 (c6dff4b) into master (32291df) will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2831      +/-   ##
==========================================
- Coverage   37.72%   37.71%   -0.02%     
==========================================
  Files         200      200              
  Lines       18435    18435              
==========================================
- Hits         6955     6952       -3     
- Misses      11075    11078       +3     
  Partials      405      405              
Flag Coverage Δ
unittests 37.71% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/search/proxy/store/util.go 92.89% <0.00%> (-1.43%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@RainbowMango
Copy link
Member

A question, why user want to edit the script by this command?

@ikaven1024
Copy link
Member Author

A question, why user want to edit the script by this command?

Because it's hard to edit Lua script in yaml. This command helps user edit it in a Lua file. I will demonstrate it in tomorrow's meeting.

@karmada-bot karmada-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 29, 2022
@ikaven1024 ikaven1024 changed the title [WIP] add edit mode for karmadactl interpreter command add edit mode for karmadactl interpreter command Nov 29, 2022
@karmada-bot karmada-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Nov 29, 2022
@XiShanYongYe-Chang
Copy link
Member

Thanks a lot~
/assign

pkg/karmadactl/interpret/edit.go Outdated Show resolved Hide resolved
pkg/karmadactl/interpret/edit.go Show resolved Hide resolved
pkg/karmadactl/interpret/edit.go Outdated Show resolved Hide resolved
pkg/karmadactl/interpret/edit.go Show resolved Hide resolved
@ikaven1024 ikaven1024 force-pushed the interpret-ctl-edit branch 2 times, most recently from 9ada9ee to ad7caad Compare December 29, 2022 12:59
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks~
/lgtm

/cc @RainbowMango @lonelyCZ

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 30, 2022
@RainbowMango RainbowMango added this to the v1.5 milestone Dec 30, 2022
go.mod Outdated Show resolved Hide resolved
@karmada-bot karmada-bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 30, 2022
Signed-off-by: yingjinhui <yingjinhui@didiglobal.com>
@XiShanYongYe-Chang
Copy link
Member

Hi @RainbowMango, can you help rerun the CI, it failed for deleting the kind node.

Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2023
@ikaven1024
Copy link
Member Author

Hi @XiShanYongYe-Chang , your LGTM is removed, plz take a look again.

@XiShanYongYe-Chang
Copy link
Member

OK
/lgtm

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 10, 2023
@karmada-bot karmada-bot merged commit 07bb65b into karmada-io:master Jan 10, 2023
@ikaven1024 ikaven1024 deleted the interpret-ctl-edit branch January 10, 2023 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants