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 support for Nirmata,cloud-native application management #298

Closed
wants to merge 5 commits into from

Conversation

itsCheithanya
Copy link
Contributor

Overview

Type of change

  • Created a new plugin
  • Improved an existing plugin
  • Fixed a bug in an existing plugin
  • Improved contributor utilities or experience

Related Issue(s)

  • Resolves: #
  • Relates: #

How To Test

Download nctl CLI from here
Run the command
nctl info
to get

image
image

Changelog

@arunsathiya arunsathiya self-requested a review June 23, 2023 20:28
@arunsathiya arunsathiya added the in-progress this PR is being worked on/comments are in the process of being addressed by the contributor label Jun 23, 2023
@arunsathiya
Copy link
Contributor

As noted on the other comment, we'd like to see the "Overview" section of the PR description filled out.

Copy link
Member

@hculea hculea left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution! I've left some suggestions, please let us know if you have any questions! 😄

Comment on lines 64 to 71
if section.HasKey("address") && section.Key("address").Value() != "" {
fields[fieldname.Address] = section.Key("address").Value()
}
if section.HasKey("email") && section.Key("email").Value() != "" {
fields[fieldname.Email] = section.Key("email").Value()
}
if section.HasKey("token") && section.Key("token").Value() != "" {
fields[fieldname.Token] = section.Key("token").Value()
Copy link
Member

Choose a reason for hiding this comment

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

I see there is a reference to fieldname.URL in the default envvar mapping, but we never import this field.

Let's make sure that our import candidates comply with the structure that the provider expects. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah I've done the change

Comment on lines +16 to +17
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
Copy link
Member

Choose a reason for hiding this comment

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

Let's opt out of authentication for nctl login as well. 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yess getit!!

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I'm not familiar with the Nirmata CLI, are there any other commands which do not require authentication?

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe version does not require authentication, but could you confirm the rest, @itsCheithanya?

Comment on lines 49 to 52
var defaultEnvVarMapping = map[string]sdk.FieldName{
"NIRMATA_TOKEN": fieldname.Token,
"NIRMATA_URL": fieldname.URL,
}
Copy link
Member

Choose a reason for hiding this comment

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

I see we import and require an email, but only provision the token and URL. Is the email something that is required as well?

Otherwise, let's consider making it optional, or, alternatively, omitting it from the importer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup done!

Copy link
Member

@hculea hculea left a comment

Choose a reason for hiding this comment

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

Thanks! Moving in the right direction, let's go 🚀

Comment on lines +33 to +34
Name: fieldname.Email,
MarkdownDescription: "Email address registered in Nirmata.",
Copy link
Member

Choose a reason for hiding this comment

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

Is the email required in the item, since it's not provisioned?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But it should be used for this command nctl login which prompts for all these fields including email

Copy link
Member

Choose a reason for hiding this comment

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

With this shell plugin, the user should no longer have to run nctl login. From what I can find in the documentation (Alternatively, you can use global flags or set the NIRMATA_TOKEN and NIRMATA_URL environment variables.), this is an alternative to the email-based authentication.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay in that way makes sense

Copy link
Contributor Author

@itsCheithanya itsCheithanya Jun 27, 2023

Choose a reason for hiding this comment

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

So should we now make the URL field required and not optional?

Copy link
Member

Choose a reason for hiding this comment

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

No, since the docs state that the URL has a default:

      --url string     the URL address for Nirmata (env NIRMATA_URL) (default "https://nirmata.io")

so not provisioning it would not break the users' workflows.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh okay so should I only import token from the config file?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's okay to also import url from the config file. At provisioning time, if there's nothing to provision for the url, then we can use the default value

Comment on lines 17 to 18
DocsURL: sdk.URL("https://nirmata.com/docs/api_token"), // TODO: Replace with actual URL
ManagementURL: sdk.URL("https://console.nirmata.com/user/security/tokens"), // TODO: Replace with actual URL
Copy link
Member

Choose a reason for hiding this comment

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

These URLs don't work for me 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ohh yeahh I should change it,I didn't find proper documentation about the CLI ,this is the only where it is mentioned
https://downloads.nirmata.io/nctl/downloads/

Comment on lines 68 to 70
if section.HasKey("email") && section.Key("email").Value() != "" {
fields[fieldname.Email] = section.Key("email").Value()
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to import this, since it's not provisioned to the commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yess i feel you are correct ill try without email

Comment on lines +16 to +17
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I'm not familiar with the Nirmata CLI, are there any other commands which do not require authentication?

Name: "nirmata",
Platform: schema.PlatformInfo{
Name: "Nirmata",
Homepage: sdk.URL("https://nirmata.com"), // TODO: Check if this is correct
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the TODO from here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yess into it

Copy link
Contributor

Choose a reason for hiding this comment

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

@itsCheithanya This does not seem to be removed yet, could we make sure to remove it, please?

Name: "nirmata",
Platform: schema.PlatformInfo{
Name: "Nirmata",
Homepage: sdk.URL("https://nirmata.com"), // TODO: Check if this is correct
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the TODO from here.

func TestAPITokenImporter(t *testing.T) {
plugintest.TestImporter(t, APIToken().Importer, map[string]plugintest.ImportCase{
"environment": {
Environment: map[string]string{ // TODO: Check if this is correct
Copy link
Member

Choose a reason for hiding this comment

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

Let's remove the TODO from here.

@itsCheithanya
Copy link
Contributor Author

image
@arunsathiya @hculea you can review it

@arunsathiya arunsathiya added waiting-on-reviewer signals that a certain PR is waiting for a review from a 1Password team member hashnode hackathon Ideas and inspiration for the hackathon running from June 1st - June 30th and removed in-progress this PR is being worked on/comments are in the process of being addressed by the contributor labels Jul 6, 2023
Copy link
Contributor

@arunsathiya arunsathiya left a comment

Choose a reason for hiding this comment

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

I have just had a chance to review the code, and it looks like a good start, @itsCheithanya. Thank you. A lot of functional testing will be required though and for us to do it, could you help us with some details?

  • What is Nirmata?
  • How does nirmata.com differ from nirmata.io?
  • From this page, nctl and nadm are different CLI. Would you know what each does?
  • And from this page, Nirmata Enterprise for Kyverno and Nirmata Policy Manager are two different things as well. Which of those two platforms is the proposed shell plugin targeting?

Lastly but not the least, could you share some screenshots of the shell plugin in action? It'd help a ton with the reviews.

I usually recommend sharing some screenshots/videos to back up the proposed changes in any PR, thanks Cheithanya!

Name: "nirmata",
Platform: schema.PlatformInfo{
Name: "Nirmata",
Homepage: sdk.URL("https://nirmata.com"), // TODO: Check if this is correct
Copy link
Contributor

Choose a reason for hiding this comment

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

@itsCheithanya This does not seem to be removed yet, could we make sure to remove it, please?

return schema.Executable{
Name: "Nirmata CLI",
Runs: []string{"nctl"},
DocsURL: sdk.URL("https://nirmata.com/docs/cli"), // TODO: Replace with actual URL
Copy link
Contributor

Choose a reason for hiding this comment

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

This todo as well.

Comment on lines +16 to +17
needsauth.NotForHelpOrVersion(),
needsauth.NotWithoutArgs(),
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe version does not require authentication, but could you confirm the rest, @itsCheithanya?

if section.HasKey("address") && section.Key("address").Value() != "" {
fields[fieldname.Address] = section.Key("address").Value()
}
// if section.HasKey("email") && section.Key("email").Value() != "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's completely remove this block instead of leaving them as commented sections.

Copy link
Contributor

Choose a reason for hiding this comment

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

@itsCheithanya this is still commented

plugins/nirmata/api_token.go Show resolved Hide resolved
Fields: fields,
})
}

Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of empty lines in this file as well.

},
},
},

Copy link
Contributor

Choose a reason for hiding this comment

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

An empty line here. Let's remove it.

Name: "nirmata",
Platform: schema.PlatformInfo{
Name: "Nirmata",
Homepage: sdk.URL("https://nirmata.com"), // TODO: Check if this is correct
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like nirmata.com and nirmata.io are two different products/services, but from the same company? Could you share some specifics of what you know about Nirmata? That'd help us reviewers jumpstart the process, vs having to understand the Nirmata concepts manually. Thanks @itsCheithanya!

@arunsathiya arunsathiya added in-progress this PR is being worked on/comments are in the process of being addressed by the contributor and removed waiting-on-reviewer signals that a certain PR is waiting for a review from a 1Password team member labels Jul 6, 2023
@arunsathiya arunsathiya self-requested a review July 6, 2023 16:29
@itsCheithanya
Copy link
Contributor Author

itsCheithanya commented Jul 7, 2023

I have just had a chance to review the code, and it looks like a good start, @itsCheithanya. Thank you. A lot of functional testing will be required though and for us to do it, could you help us with some details?

* What is Nirmata?

* How does nirmata.com differ from nirmata.io?

* From [this page](https://downloads.nirmata.io/), nctl and nadm are different CLI. Would you know what each does?

* And from [this page](https://www.nirmata.io/security/signup.html?referrer=homepage), Nirmata Enterprise for Kyverno and Nirmata Policy Manager are two different things as well. Which of those two platforms is the proposed shell plugin targeting?

Lastly but not the least, could you share some screenshots of the shell plugin in action? It'd help a ton with the reviews.

I usually recommend sharing some screenshots/videos to back up the proposed changes in any PR, thanks Cheithanya!
nirmata.com is used for the company's main website, providing information about the products, solutions, and services offered by Nirmata. On the other hand, nirmata.io is used to login to nirmata platform

nctl: nctl is used to interact with the Nirmata platform and perform various management tasks related to deploying and managing applications, environments, and other resources. It offers commands for managing application lifecycle, cluster provisioning, user management, and more.
nadm: nadm is another CLI tool provided by Nirmata to install Nirmata software

This plugin is focussed on Nirmata Policy Manager as it supports api keys with nctl cli

@arunsathiya arunsathiya added waiting-on-reviewer signals that a certain PR is waiting for a review from a 1Password team member and removed in-progress this PR is being worked on/comments are in the process of being addressed by the contributor labels Jul 24, 2023
@AndyTitu
Copy link
Contributor

@itsCheithanya as next steps, it would be awesome if you could share a video of the plugin working as expected.

There are also a couple of comments which are pending resolution.

@AndyTitu AndyTitu added in-progress this PR is being worked on/comments are in the process of being addressed by the contributor and removed waiting-on-reviewer signals that a certain PR is waiting for a review from a 1Password team member labels Aug 30, 2023
@hculea
Copy link
Member

hculea commented Sep 19, 2023

Hey @itsCheithanya - reaching out again, is there anything that we can help with to move this forward? 🚀

@hculea
Copy link
Member

hculea commented Sep 22, 2023

Closing because of inactivity - please feel free to re-open the PR if you'd like to pick this back up @itsCheithanya 🚀

@hculea hculea closed this Sep 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashnode hackathon Ideas and inspiration for the hackathon running from June 1st - June 30th in-progress this PR is being worked on/comments are in the process of being addressed by the contributor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants