Skip to content

WIP: porting from internal/connect to pkg/ #289

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

Closed
wants to merge 13 commits into from

Conversation

mssola
Copy link
Contributor

@mssola mssola commented Apr 11, 2025

No description provided.

mssola added 4 commits March 24, 2025 15:13
These two utility functions serve as safeguards for our binaries on
`cmd`. This has been abstracted away from original code from
SUSEConnect, but they are good candidates on the other binaries as well.

The EnsureZypper is now being called by `zypper-search-packages` and
`zypper-migration` as these two binaries are useless outside of
non-Linux and non-zypper.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
We are moving away from messy global variables that are littering the
`internal` packages, and which have been bringing problems in the past.

This commit introduces the Options struct, which is in scope similar to
the one on `pkg/` and that will bear all the info needed to conduct all
SUSEConnect operations. This struct will surely need a revisit after all
the move is done, but for now a simple "rename" from Config should cut
it.

Last but not least, notice that we are not yet dropping CFG entirely
from either SUSEConnect nor zypper-migration. This is because the
internal library is still littered with the usage of the CFG global
variable. This is left to be done by subsequent commits.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
There was no need to use the mock library nor testing some corner cases
which will surely never happen. Let's reduce the scope of these tests
and focus on what can actually happen with the function at hand.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
@mssola mssola requested a review from felixsch April 11, 2025 15:10
@mssola mssola force-pushed the rip-cfg-from-suseconnect branch 2 times, most recently from 531ccaa to 0fc05b9 Compare May 5, 2025 06:39
mssola added 9 commits May 7, 2025 09:40
The connection.Credentials interface is an abstraction that we came up
for all sorts of usages, but in the end it was meant to be easily used
by our current implementation on `internal/credentials`, where all sorts
of credential files are being used and parsed.

This commit adds the needed functions to our internal implementation in
order to implement the connection.Credentials interface, which they are
just getters/setters.

In the future a lot of functions from internal's credentials could be
scrapped, but this is left for future functionality.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
A new wrapper has been introduced in order to target the API via the
`pkg/` interfaces. This is a bridge between our internal credentials'
implementation and the Connection interface.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
Product statuses and activations have been moved from `internal` to
`pkg`. This also had as a side-effect the need to change some
other (apparently unrelated) code, but it mainly boils down on using the
new Options (and fields) as new parameters for the functions that were
relying on global state.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
Instead of passing a jsonFlag boolean around, simply add a proper enum
value into the Options struct. This allows for some refactoring on how
messages are to be formatted.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
These two functions have been superseeded by code on `pkg/registration`,
and they are no longer needed.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
The code on `pkg` assumes that the credentials file is either there or
that it can be created when writing to it for the first time, but this
is slightly different from the old `internal` implementation. In there,
upon calling `Register`, the system would be announced and then it would
get the credentials. With that the file would then be created.

To remedy this, if `ReadCredentials` fail when setting up the wrapper on
the `internal/connect` package, then at least the credentials path is
set. This will allow the credentials file to be created whenever
`SetLogin` is called since at least we have the path.

Signed-off-by: Miquel Sabaté Solà <[email protected]>
@mssola mssola force-pushed the rip-cfg-from-suseconnect branch from 0fc05b9 to d057f32 Compare May 7, 2025 07:42
@mssola
Copy link
Contributor Author

mssola commented May 7, 2025

Rebasing to the new next branch.

@mssola mssola closed this May 7, 2025
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.

1 participant