Skip to content

Backend supporting changes for Bot creation flow#37348

Merged
mcbattirola merged 14 commits into
masterfrom
mcbattirola/supporting-changes-bot-creation
Jan 31, 2024
Merged

Backend supporting changes for Bot creation flow#37348
mcbattirola merged 14 commits into
masterfrom
mcbattirola/supporting-changes-bot-creation

Conversation

@mcbattirola
Copy link
Copy Markdown
Contributor

@mcbattirola mcbattirola commented Jan 26, 2024

This PR includes two changes that will be used in a future PR implementing the Github Actions Machine ID flow:

  1. Add a new endpoint to create bot join tokens.
  2. Add a label teleport.internal/ui-flow: github-actions to the bot and the github join token

For flexibility, I've made a new endpoint for bot-specific join tokens, rather than using the existing join tokens endpoint. Bots will have their particularities and we decided that having a separate endpoint will be easier to handle.

Note that the bot backend does not apply the label yet, it is just ignored (this will be implemented in the future by @strideynet #37423)

Contributes to #34300

@strideynet strideynet self-requested a review January 29, 2024 11:54
@mcbattirola mcbattirola marked this pull request as ready for review January 29, 2024 12:10
@github-actions
Copy link
Copy Markdown
Contributor

The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with changelog: followed by the changelog entries for the PR.

@mcbattirola mcbattirola added the no-changelog Indicates that a PR does not require a changelog entry label Jan 29, 2024
Copy link
Copy Markdown
Contributor

@strideynet strideynet left a comment

Choose a reason for hiding this comment

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

Generally looks good but just a few thoughts.

I've raised #37423 for the outstanding work I need to address on label propagation.

Comment thread lib/web/machineid.go Outdated
Comment thread lib/web/machineid.go Outdated
Comment thread lib/web/join_tokens.go Outdated
@mcbattirola mcbattirola force-pushed the mcbattirola/supporting-changes-bot-creation branch 2 times, most recently from ae77aaa to d6d187a Compare January 29, 2024 17:11
@mcbattirola mcbattirola force-pushed the mcbattirola/supporting-changes-bot-creation branch from d6d187a to 1260da9 Compare January 29, 2024 17:19
Comment thread api/types/provisioning.go
GetRoles() SystemRoles
// SetRoles sets teleport roles
SetRoles(SystemRoles)
// SetLabels sets the tokens labels
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Comment doesn't add value, consider skipping.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even when not adding value, it seems we always add a godoc comment to any public field.

Comment thread lib/web/apiserver.go Outdated
Comment thread lib/web/apiserver.go
assistantLimiterCapacity = assistantTokensPerHour * 24 * 7
// webUIFlowLabelKey is a label added may be added to resources
// created via the web UI
webUIFlowLabelKey = "teleport.internal/ui-flow"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Neither the comment, nor the name actually explains what is the general purpose of this label, and thus, I'm confused. What does "web UI flow" mean in this context? So far, there's just one value, could you give a speculative example of what other values may be? What decision will we make using this label's value?

Copy link
Copy Markdown
Contributor Author

@mcbattirola mcbattirola Jan 31, 2024

Choose a reason for hiding this comment

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

The initial purpose of this is showing icons in the Bot listing pages based on the workflow used to create the bot, and providing a special editing page to those bots.

I've updated the comment daff149:

// webUIFlowLabelKey is a label that may be added to resources
// created via the web UI, indicating which flow the resource was created on.
// This label is used for enhancing UX in the web app, by showing icons related,
// to the workflow it was added, or providing unique features to those resources.
// Example values:
// - github-actions-ssh: indicates that the resource was added via the Bot GitHub Actions SSH flow

Please let me know if we should add more context.

Comment thread lib/web/machineid.go Outdated
mcbattirola and others added 3 commits January 31, 2024 09:53
Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
@mcbattirola mcbattirola requested a review from bl-nero January 31, 2024 13:04
@mcbattirola mcbattirola added this pull request to the merge queue Jan 31, 2024
Merged via the queue into master with commit a904721 Jan 31, 2024
@mcbattirola mcbattirola deleted the mcbattirola/supporting-changes-bot-creation branch January 31, 2024 14:25
michellescripts pushed a commit that referenced this pull request Feb 12, 2024
* Add bot ui labels and github join token

* Use strings.HasPrefix instead of includes

* Add `ssh` to label

* Add bot join token endpoint

* Lint

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Improve webUIFlowLabelKey comment

---------

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
michellescripts pushed a commit that referenced this pull request Feb 13, 2024
* Add bot ui labels and github join token

* Use strings.HasPrefix instead of includes

* Add `ssh` to label

* Add bot join token endpoint

* Lint

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Improve webUIFlowLabelKey comment

---------

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
michellescripts pushed a commit that referenced this pull request Feb 16, 2024
* Add bot ui labels and github join token

* Use strings.HasPrefix instead of includes

* Add `ssh` to label

* Add bot join token endpoint

* Lint

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Improve webUIFlowLabelKey comment

---------

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
github-merge-queue Bot pushed a commit that referenced this pull request Feb 16, 2024
* Add endpoint to get bots by name (#37412)

* Add endpoint to get bots by name

* Lint

* Fix test method's name

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

---------

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* Backend supporting changes for Bot creation flow (#37348)

* Add bot ui labels and github join token

* Use strings.HasPrefix instead of includes

* Add `ssh` to label

* Add bot join token endpoint

* Lint

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Fix comment typo

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* Improve webUIFlowLabelKey comment

---------

Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>

* add bots UI, disabled (#36845)

- in original data table view

* Add Bot + GitHub Actions SSH UI Flow (#37443)

* add bots UI, disabled

- in original data table view

* Add bot creation UI

* Remove duplicated types

* add bots UI, disabled

- in original data table view

* Fix types and tests

* Use bot join token api endpoint

* Fix tests

* Linting and small fixes

* Fix tests

* Add missing licenses

* Improve styles, error messages, etc

* Remove clusterId from bot routes

* Undo enabling feature

* Remove unused join role bot

* Rename var

* Reuse makeListBot

* Add missing type

* Revert MachineIDIntegrationSection for now

* Lint

* Apply suggestions from code review - fix typos

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* Remove kubernetes section fromm example yaml

* Remove border color from reftype selector

* Small changes to address code review

* Use setAttempt

* add try/catch block when parsing repo addresses

* Improve tests;remove unecessary fragment

* Use gap in flex. Fix typo

* Lint fix

* Drop "ex" from input placeholders

* Add stories for no perm and bot picker

* Add copy to explain wrkflow name limits

* fix setCurentStep

* Fix invalid host error rendering

* Use PascalCase for error components

* Improve field name validation

* Remove unecessary comments

* Update copy and minor style change

---------

Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com>
Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* add bot edit-role flow (#37828)

* add bot edit-role flow

* only send masked/updated fields

* Add GitHub Actions bot view (#37852)

* add bots UI, disabled

- in original data table view

* Add bot creation UI

* Remove duplicated types

* add bots UI, disabled

- in original data table view

* Fix types and tests

* Use bot join token api endpoint

* Fix tests

* Linting and small fixes

* Fix tests

* Add missing licenses

* Improve styles, error messages, etc

* Remove clusterId from bot routes

* Undo enabling feature

* Remove unused join role bot

* Rename var

* Reuse makeListBot

* Add missing type

* Revert MachineIDIntegrationSection for now

* Lint

* Apply suggestions from code review - fix typos

Co-authored-by: Noah Stride <noah.stride@goteleport.com>

* Remove kubernetes section fromm example yaml

* Remove border color from reftype selector

* Small changes to address code review

* Use setAttempt

* add try/catch block when parsing repo addresses

* Improve tests;remove unecessary fragment

* Use gap in flex. Fix typo

* Lint fix

* Drop "ex" from input placeholders

* Add stories for no perm and bot picker

* Add copy to explain wrkflow name limits

* fix setCurentStep

* Fix invalid host error rendering

* Use PascalCase for error components

* Improve field name validation

* Remove unecessary comments

* Add bot type by label

* Add bot view...

* Show view gh actions yaml only for gh bots

* Use existing pattern for operations

* Add story and missing license

* Fix typos

Co-authored-by: Michelle Bergquist <11967646+michellescripts@users.noreply.github.com>

---------

Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com>
Co-authored-by: Noah Stride <noah.stride@goteleport.com>
Co-authored-by: Michelle Bergquist <11967646+michellescripts@users.noreply.github.com>

* Add buttons to download and copy to clipboard content to `TextEditor` (#37333)

* Add editor buttons

* Set icon size

* Move downloadObject to OSS

* remove unused test-id

* Use values from theme

* Fix buttons positioning

* Convert jsx files to tsx

* Use const instead of var

* Add z-index to buttons

* Add license

* Improvements to Bot resource (additional validation and label propagation) (#38013)

* PRevent creating bots with an empty string role

* Propagate labels to Bot user and vice versa

* Extract slice declaration for nonPropagatedLabels

* Fixed web tests relying on empty string roles

* Use "set" instead of slice for nonPropagatedLabels

* Make testing of empty string handling more thorough

* add role assertions to create

* Appease linter as to want/got order

---------

Co-authored-by: Michelle Bergquist <michelle.bergquist@goteleport.com>

* Add bot permissions and turn on feature (#37943)

* Fix makeBot labels (#38176)

---------

Co-authored-by: matheus <matheus.battirola@goteleport.com>
Co-authored-by: Noah Stride <noah.stride@goteleport.com>
Co-authored-by: Bartosz Leper <bartosz.leper@goteleport.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants