Skip to content

Conversation

@VinozzZ
Copy link
Contributor

@VinozzZ VinozzZ commented Jan 24, 2023

This PR updated the porter dependency and the default porter-agent to v1.0.6. This allows us to take advantage of the new plugin file installing feature.
To match with the new plugins file schema, I had to update the AgentConfig resource definition. This will be a breaking change.
closes: #123

@VinozzZ VinozzZ changed the title wip Allow installing multiple plugins Jan 24, 2023
@VinozzZ VinozzZ force-pushed the multiple-plugins branch 4 times, most recently from fada74f to 586a77d Compare January 25, 2023 23:23
@codecov
Copy link

codecov bot commented Jan 25, 2023

Codecov Report

Merging #141 (057a737) into main (bb4eaef) will increase coverage by 1.16%.
The diff coverage is 92.00%.

@@            Coverage Diff             @@
##             main     #141      +/-   ##
==========================================
+ Coverage   75.58%   76.75%   +1.16%     
==========================================
  Files          13       13              
  Lines        1536     1540       +4     
==========================================
+ Hits         1161     1182      +21     
+ Misses        242      227      -15     
+ Partials      133      131       -2     
Flag Coverage Δ
unit-tests 76.75% <92.00%> (+1.16%) ⬆️

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

Impacted Files Coverage Δ
controllers/agentconfig_controller.go 72.45% <71.42%> (+1.41%) ⬆️
api/v1/agentconfig_types.go 69.76% <100.00%> (+10.79%) ⬆️
controllers/agentaction_controller.go 83.29% <100.00%> (ø)

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

@VinozzZ VinozzZ force-pushed the multiple-plugins branch 3 times, most recently from 9157c8c to 2c4adfa Compare January 26, 2023 21:27
@VinozzZ VinozzZ marked this pull request as ready for review January 26, 2023 23:00
SchemaVersion string `json:"schemaVersion,omitempty" mapstructure:"schemaVersion,omitempty"`

// Configs is a map of plugin configuration using plugin name as the key.
Configs map[string]Plugin `json:"configs,omitempty" mapstructure:"configs,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit confused about why this representation of the document uses configs instead of plugins?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

spec:
  plugins:
    schemaVersion: 1.0.0
    configs:
      kubernetes: {}

This is what the schema looks like with the current implementation
If we change from Configs to Plugins, I find it a bit confusing to have Plugins under Spec.Plugins

Copy link
Member

Choose a reason for hiding this comment

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

The goal for any of our file formats is that they are copy pastable between when you are using them with the porter cli and the operator. Ideally, if someone had the following plugins.yaml they were using with porter,

schemaType: Plugins
schemaVersion: 1.0.0
plugins:
  azure:
    version: 1.0.1

Then they should be able to copy/paste it into a k8s manifest and use it without modifying (though they do need to paste it under the spec portion). So based on that I would expect the following to work

apiGroup: getporter.org/v1
Kind: AgentConfig
metadata:
  name: myconfig
spec:
  # normal agent config stuff
  plugins:
    # Copy/paste the plugins.yaml here
    schemaType: Plugins
    schemaVersion: 1.0.0
    plugins:
      azure:
        version: 1.0.1

I agree that the double plugins is a bit unwieldy. How about we rename AgentConfigSpec.Plugins to AgentConfigSpec.PluginConfigFile, which would also help clarify what goes under plugins? This way you would have a hint that the entire plugins file should be included in the field and not to just immediately start listing the plugins you want.

```yaml
apiGroup: getporter.org/v1
Kind: AgentConfig
metadata:
  name: myconfig
spec:
  # normal agent config stuff
  pluginConfigFile:
    # Copy/paste the plugins.yaml here
    schemaType: Plugins
    schemaVersion: 1.0.0
    plugins:
      azure:
        version: 1.0.1

What do you think?

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 a very good point. I changed it based on your suggestions

@VinozzZ VinozzZ requested a review from carolynvs January 30, 2023 15:48
Signed-off-by: Yingrong Zhao <[email protected]>
Signed-off-by: Yingrong Zhao <[email protected]>
// In order to utilize mapstructure omitempty tag with an embedded struct, this field needs to be a pointer
// +optional
Plugins map[string]Plugin `json:"plugins,omitempty" mapstructure:"plugins,omitempty"`
PluginConfigFile *PluginFileSpec `json:"pluginConfigFile,omitempty" mapstructure:"pluginsConfigFile,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

You are using both plugins plural and singular here in the json/mapsturcture tags. I'm not sure which one you want to use?

SchemaVersion string `json:"schemaVersion" yaml:"schemaVersion"`

// Plugins is a map of plugin configuration using plugin name as the key.
Plugins map[string]Plugin `json:"configs,omitempty" mapstructure:"configs,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

I thought you were going to make it match the suggested schema from my last comment but this wasn't updated to be plugins so I'm a bit confused if you intended to match the suggestion or ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, the rebasing with the latest main really messed it up. I will fix it

Copy link
Member

Choose a reason for hiding this comment

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

Next time, if you leave the rebase for after the review is done, it's easier for me to review since I don't have to go over the entire thing again from scratch.

Signed-off-by: Yingrong Zhao <[email protected]>
* Using the AgentConfig with the name "default" defined in the operator namespace.
* By default, using a reasonable set of defaults for the default installation of the Operator, assuming that the default RBAC roles exist in the cluster.

🚨 WARNING: Currently, only one plugin per AgentConfig can be installed through the plugins configuration.
Copy link
Member

Choose a reason for hiding this comment

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

🎉

Copy link
Member

@carolynvs carolynvs left a comment

Choose a reason for hiding this comment

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

Looks great, thanks! 💖

@VinozzZ VinozzZ merged commit 5ec0b5e into getporter:main Jan 31, 2023
@VinozzZ VinozzZ deleted the multiple-plugins branch January 31, 2023 15:25
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.

Ability to install multiple plugins defined in one agent config

2 participants