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 patches to instead of statusTemplate in Stage #984

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

wzshiming
Copy link
Member

@wzshiming wzshiming commented Mar 4, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

Which issue(s) this PR fixes:

xref #922

Special notes for your reviewer:

// Convert_v1alpha1_StageNext_To_internalversion_StageNext converts a v1alpha1.StageNext to an internal version.
func Convert_v1alpha1_StageNext_To_internalversion_StageNext(in *v1alpha1.StageNext, out *StageNext, s conversion.Scope) error {
err := autoConvert_v1alpha1_StageNext_To_internalversion_StageNext(in, out, s)
if err != nil {
return err
}
if in.StatusTemplate != "" && len(out.Patches) == 0 {
template := in.StatusTemplate
subresource := "status"
if in.StatusSubresource != nil {
subresource = *in.StatusSubresource
}
var impersonation *ImpersonationConfig
if in.StatusPatchAs != nil {
impersonation = &ImpersonationConfig{
Username: in.StatusPatchAs.Username,
}
}
patch := StagePatch{
Subresource: subresource,
Root: "status",
Template: template,
Impersonation: impersonation,
}
out.Patches = []StagePatch{patch}
}
return nil
}
// Convert_internalversion_StageNext_To_v1alpha1_StageNext is an autogenerated conversion function.
func Convert_internalversion_StageNext_To_v1alpha1_StageNext(in *StageNext, out *v1alpha1.StageNext, s conversion.Scope) error {
err := autoConvert_internalversion_StageNext_To_v1alpha1_StageNext(in, out, s)
if err != nil {
return err
}
if len(in.Patches) != 0 {
patch := in.Patches[0]
if patch.Root == "status" {
out.StatusSubresource = &patch.Subresource
out.StatusTemplate = patch.Template
if patch.Impersonation != nil {
out.StatusPatchAs = &v1alpha1.ImpersonationConfig{
Username: patch.Impersonation.Username,
}
}
}
}
return nil
}

Old Structure:

spec:
  next:
    statusTemplate: <string>     # The status template.
    statusSubresource: <string>  # The status subresource. default: 'status'
    statusPatchAs:
      username: <string>         # The username to impersonate.

New Structure:

spec:
  next:
    patches:
    - subresource: <string>  # The subresource to patch. This could be '', 'status', 'spec', 'scale' etc. the '' is used to patch the entire resource. default: ''
      root: <string>         # The root of the template calculation. This could be '', 'status', 'spec', etc. the '' is used to patch the entire resource. default: ''
      template: <string>     # The template to apply. This is a string representation of the desired state.
      impersonation:         # The as section is used to impersonate a user or group.
        username: <string>   # User could be a regular user or a service account in a namespace.

Examples:

Update a replicas through the 'scale' subresource

spec:
  next:
    patches:
    - subresource: scale
      root: spec
      template: |
        replicas: 2

Update the 'status' but not is a subresource

spec:
  next:
    patches:
    - subresource: ''
      root: status
      template: |
        phase: Running

Does this PR introduce a user-facing change?

Add patches to instead of statusTemplate in Stage

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 4, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wzshiming

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

@k8s-ci-robot k8s-ci-robot added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Mar 4, 2024
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 4, 2024
Copy link

netlify bot commented Mar 4, 2024

Deploy Preview for k8s-kwok canceled.

Name Link
🔨 Latest commit c547675
🔍 Latest deploy log https://app.netlify.com/sites/k8s-kwok/deploys/6620b4abef4c86000895d2c7

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 4, 2024
@wzshiming wzshiming force-pushed the feat/stage-api branch 2 times, most recently from a51ed6c to 8c4f226 Compare March 4, 2024 08:37
@k8s-ci-robot k8s-ci-robot added kind/documentation Categorizes issue or PR as related to documentation. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 4, 2024
@wzshiming wzshiming force-pushed the feat/stage-api branch 6 times, most recently from 9439f07 to cd71594 Compare March 5, 2024 08:57
@wzshiming wzshiming changed the title [WIP] Update Stage API Add patches to instead of statusTemplate in Stage API Mar 5, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 5, 2024
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Mar 6, 2024
@wzshiming wzshiming force-pushed the feat/stage-api branch 2 times, most recently from 0b020a4 to d219a08 Compare March 6, 2024 05:43
@wzshiming wzshiming changed the title Add patches to instead of statusTemplate in Stage API Add patches to instead of statusTemplate in Stage Apr 3, 2024
@wzshiming wzshiming force-pushed the feat/stage-api branch 2 times, most recently from 98c06a8 to cd304a6 Compare April 8, 2024 08:11
@wzshiming wzshiming merged commit 9b555d3 into kubernetes-sigs:main Apr 22, 2024
26 of 27 checks passed
@wzshiming wzshiming deleted the feat/stage-api branch April 22, 2024 06:50
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

2 participants