-
Notifications
You must be signed in to change notification settings - Fork 18
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
feat: register with content templates #168
Conversation
/packit build |
ef842be
to
d443851
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your PR. Overall, it works. 👍
I have to apologize. We agreed that we will support only environment with type == content-template. Thus, it will be possible to simplify your PR on some places. You can find more details in my comments.
I have some other requests.
rhsm.go
Outdated
if len(environments) > 0 && organization != "" { | ||
var useEnvIDs = false | ||
envList, err := getEnvironmentsList(privConn, username, password, organization) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If err
is not nil
, then orgs
with error should be returned. We will not allow to use content-templates on the systems, where D-Bus method GetEnvironments()
is not available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree this is a nice simplification. And now I'm thinking alternating to using the ID would not be useful in the case of content templates. @ptoscano wrote the ticket so he may want to provide some input here.
rhsm.go
Outdated
return environments, nil | ||
} | ||
|
||
func mapEnvironmentIDsToNames(names []string, environmentList []Environment, contentTemplates bool) ([]string, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few notes:
- The name of this function is not correct. You try to get environment IDs from environment names. Thus the name should be something like
mapEnvironmentNamesToIds()
orgetContentTemplateIds()
. You return list (not map) of environments with type == "content-template". I vote forgetContentTemplateIds()
. - This method is missing doc string with description.
- Variable
contentTemplates bool
could be removed. - You can also name returned variables. Something like:
func getContentTemplateIds()(names []string, environmentList []Environment, contentTemplates bool) (envIDs []string, err error) {
// Body of function
rhsm.go
Outdated
typeString := "environment" | ||
if contentTemplates { | ||
typeString = "content template" | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be removed, because we will support only environments with type == "content-template"
rhsm.go
Outdated
if contentTemplates { | ||
typeString = "content template" | ||
} | ||
return nil, fmt.Errorf(typeString+" named \"%s\" was not found", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error should be modified and the logic of error detection should be also modified.
I claim that we should return error if any of provided environment is not found or the type is not "content-type".
rhsm.go
Outdated
return environments, nil | ||
} | ||
|
||
func getEnvironmentsList(conn *dbus.Conn, username, password, organization string) ([]Environment, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc string is missing of this function.
rhsm.go
Outdated
return e.Type == "content-template" | ||
} | ||
|
||
func unpackEnvironments(s string) ([]Environment, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc string is missing.
Following change in
|
d443851
to
100b773
Compare
Made the changes based on the new subscription manager PR! |
@rverdile I just merged candlepin/subscription-manager#3480 to main ... I will review your PR tomorrow. |
/packit build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update 👍 . It looks good. We are almost there. Can you please rebase your PR? We started to use meson build system and your branch does not reflect it. I also have three small requests.
rhsm.go
Outdated
options := make(map[string]string) | ||
if len(environments) != 0 { | ||
options["environment_names"] = strings.Join(environments, ",") | ||
options["environment_type"] = environmentType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is not necessary to pass environmentType
as an argument to this function and you can use:
options["environment_type"] = EnvTypeContentTemplate
because we will use only "content-template"
.
rhsm.go
Outdated
options := make(map[string]string) | ||
if len(environments) != 0 { | ||
options["environment_names"] = strings.Join(environments, ",") | ||
options["environment_type"] = environmentType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that it is not necessary to pass environmentType
as an argument to this function and you can use:
options["environment_type"] = EnvTypeContentTemplate
because we will use only "content-template"
.
.gitignore
Outdated
@@ -7,3 +7,4 @@ BUILDROOT | |||
RPMS | |||
SOURCES | |||
SRPMS | |||
.idea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not add this line to .gitignore
as part of this PR. Such change is not related to this PR.
4b28a76
to
1884313
Compare
* card ID: CCT-769 * register to templates with --content-template <name>
1884313
to
7447497
Compare
updated, thanks! |
/packit build |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Card ID: CCT-769.
This is dependent on this PR, which the requirements are still being discussed, so I'm leaving this in draft for now.
This PR implements a new option to register with a content template, given the content template name. Since content templates are implemented as environments in candlepin, I've tried to implement this such that some code could be re-used in the future for registering with environments.
Feedback is appreciated and welcome :)
Still needs