Skip to content

refactor: move code to internal/ - #462

Merged
thde merged 5 commits into
mainfrom
thde/352-05-update-create
Oct 9, 2026
Merged

thde merged 5 commits into
mainfrom
thde/352-05-update-create

Conversation

@thde

@thde thde commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

This MR moves shared code between create and update into their own internal packages.

@thde
thde added this pull request to stack #459 September 17, 2026 11:06
Base automatically changed from thde/352-04-cluster-login to main October 6, 2026 08:17
thde added 5 commits October 6, 2026 10:20
…lication

The application flags of both the create and the update command
interpolate the same defaults and help texts, which create.
ApplicationKongVars provided and update imported create for. The
variables describe the application resource, not the create verb, so
they move to internal/application as application.KongVars together with
DefaultReplicas, the one create constant they reference.

main and the tests of create and update call the new function.

Part of #352.
The bucket flags of the create and the update command interpolate the
same role list and flag syntax examples, which create.BucketKongVars
provided and update imported create for. They describe the bucket
resource, so they move to internal/bucket as bucket.KongVars. The
update-only examples for the delete flags stay in update.BucketKongVars.

create loses the bucketRoles variable and the stringSlice helper, which
only the moved function used.

Part of #352.
Both are kong value types: LabelSelector decodes a label query into a
metav1.LabelSelector and LocalReference decodes a name into a
meta.LocalReference. Neither carries any resource-specific logic, but
they were declared in create next to the first command which used them,
which forced the update verb to import create for its service connection
and opensearch commands.

They move to the new package internal/flag, which holds the kong value
types more than one command declares. The LabelSelector test moves with
the type and LocalReference gets one.

Part of #352.
…l/serviceconnection

KubernetesClusterOptions declares the --source-pod-selector and
--source-namespace-selector flags which the service connection create
and update commands both embed, and converts them to the API type. It
was declared in create, which forced update to import the create verb.

It moves to the new package internal/serviceconnection rather than to
an internal/kubernetescluster package: the type is the flag form of
networking.KubernetesClusterOptions, a field of the service connection's
Source, and configures how a cluster acts as the source of a connection.
It is not a property of the KubernetesCluster resource.

The label_selector_* kong variables its help interpolates move along as
serviceconnection.KongVars, so that the type works wherever it is
embedded; create.ServiceConnectionKongVars keeps the allowed source and
destination kinds, which only the create flags interpolate. main merges
both.

The new package gets a test which parses real arguments through kong.

Part of #352.
The cloudvm, mysql and postgres commands of both create and update read
SSH public keys from the same flags and files: SSHKeysFlags and
DeprecatedKeysFlags declare the flags, ReadAuthorizedKeys and
ParseAuthorizedKeys validate the keys in the authorized_keys format,
AnyFile tells a passed file flag from a nil entry, and
StorageKeysWithDeprecatedFile converts them to the storage API type.
All of it was declared in create, which was the last reason for update
to import the create verb.

It moves unchanged to the new package internal/sshkey, deprecation
warnings included. The verb-specific flag structs stay where they are:
create keeps DatabaseSSHKeysFlags, update keeps OptionalSSHKeysFlags and
its own DatabaseSSHKeysFlags, both now embedding or calling sshkey.

The tests of the moved code move with it and the package gets tests of
its own for ReadAuthorizedKeys, StorageKeysWithDeprecatedFile and the
flag names the embedded structs register under a prefix. The command
level tests stay in create and update.

update no longer imports any verb package, so the last entry of
allowedVerbImports is removed and the map is empty.

Closes the last verb-to-verb import of #352.
@thde
thde force-pushed the thde/352-05-update-create branch from 46c109b to 7422f13 Compare October 6, 2026 08:23

@SaadAssaf SaadAssaf left a comment

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.

looks good to me

@thde
thde merged commit 1a8faf2 into main Oct 9, 2026
3 checks passed
@thde
thde deleted the thde/352-05-update-create branch October 9, 2026 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants