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

Installationoutputs custom resource #246

Merged
merged 4 commits into from
Aug 17, 2023

Conversation

troy0820
Copy link
Member

@troy0820 troy0820 commented Aug 9, 2023

What does this change

Sets up work to be accomplished in #245 which will fully resolve #63.
This sets up the crd and the rbac associated with the new custom resource installation outputs

What issue does it fix

Partially Closes #63

Notes for the reviewer

NOTE: Most of the work is being done in the draft PR from above. The PR was getting to big and decided to break it up.

Checklist

  • Did you write tests?
  • Did you write documentation?
  • Did you make any API changes? Update the corresponding API documentation.

@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Merging #246 (125623c) into main (a734060) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #246      +/-   ##
==========================================
+ Coverage   71.75%   71.78%   +0.02%     
==========================================
  Files          13       14       +1     
  Lines        2160     2162       +2     
==========================================
+ Hits         1550     1552       +2     
  Misses        477      477              
  Partials      133      133              
Flag Coverage Δ
unittests 71.78% <100.00%> (+0.02%) ⬆️

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

Files Changed Coverage Δ
controllers/installation_controller.go 68.13% <ø> (ø)
api/v1/installationoutput_types.go 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@troy0820 troy0820 force-pushed the troy0820/installation-outputs-crd branch from 837e765 to 2619064 Compare August 10, 2023 13:26
@troy0820 troy0820 added the enhancement New code, ahoy! label Aug 10, 2023
@troy0820 troy0820 force-pushed the troy0820/installation-outputs-crd branch from 2619064 to 4723947 Compare August 11, 2023 17:08
@troy0820 troy0820 requested a review from schristoff as a code owner August 11, 2023 17:08
@troy0820 troy0820 force-pushed the troy0820/installation-outputs-crd branch from 4723947 to 2d24d8f Compare August 14, 2023 17:26
Copy link
Member

@devigned devigned left a comment

Choose a reason for hiding this comment

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

I had one suggestion, but otherwise lgtm!


// +kubebuilder:printcolumn:name="Porter Name",type="string",JSONPath=".spec.name"
// +kubebuilder:printcolumn:name="Porter Namespace",type="string",JSONPath=".spec.namespace"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"
Copy link
Member

Choose a reason for hiding this comment

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

Would you want to show the outputs with -o wide? Might be nice to add the outputs field with a priority=1.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a good idea. I can update this and resolve when it's pushed.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't believe that I can do this being that the column that would display the outputs would need to be able to handle the "array/slice" of "output". Currently the only supported fields are

integer – non-floating-point numbers
number – floating point numbers
string – strings
boolean – true or false
date – rendered differentially as time since this timestamp

I was thinking a list of strings comma separated would do but wouldn't be able to be surfaced from the kubebuilder directive.

Would the first output be sufficient?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I think you'd have to define another field where you format the string you'd want from the outputs, reconcile it each time, and have the print column reference the new field.

I don't think this should hold up this PR. I was just thinking about how it would feel using kubectl.

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's worth having for the user experience, the handling of that could be valuable for the user. That would be great to add in the WIP PR. I'm willing to add it there if it makes sense.

 type InstallationOutputStatus struct {
     Phase AgentPhase `json:"phase,omitempty"`
  
     Conditions []metav1.Condition `json:"conditions,omitempty"`
  
     Outputs []Output `json:"outputs,omitempty"`
     
     OutputNames string `json:"outputNames, omitempty"` // <-- new field with priority=1 for wide output.
  }
}


//logic in reconciler 
//Something like this

names := []string{}

for _, name := range inst.Status.Outputs {
    names = append(names, name.Name)
}
outputNames := strings.Join(names, ",")  

// Add to install.Status, etc 
```

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

  • outputNames as a new field,
  • scaffold CRD
  • added the printercolumn to be priority 1.

kubectl get installationoutput -A

NAMESPACE   NAME                        PORTER NAME   PORTER NAMESPACE   PHASE
default     installationoutput-sample

kubectl get installationoutput -A -o wide

NAMESPACE   NAME                        PORTER NAME   PORTER NAMESPACE   PHASE   OUTPUT NAMES
default     installationoutput-sample

Copy link
Member Author

@troy0820 troy0820 Aug 15, 2023

Choose a reason for hiding this comment

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

More realistic version of what is to be expected:
kubectl get installationoutput -A -o wide

NAMESPACE   NAME                      PORTER NAME               PORTER NAMESPACE   PHASE       OUTPUT NAMES
demo        test-install-1691504789   test-install-1691504789   demo               Succeeded   outAction,outDelay,outExitStatus,outInsecureValue

Copy link
Member

@devigned devigned left a comment

Choose a reason for hiding this comment

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

lgtm!

@troy0820 troy0820 merged commit 8f2af86 into getporter:main Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New code, ahoy!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose bundle outputs inside a cluster
4 participants