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

utils and utils.create_from_yaml improvements #783

Closed
wants to merge 3 commits into from

Conversation

oz123
Copy link
Contributor

@oz123 oz123 commented Mar 18, 2019

As discussed in #722.

Seems this had quite some positive feedback.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: oz123
To fully approve this pull request, please assign additional approvers.
We suggest the following additional approver: yliaog

If they are not already assigned, you can assign the PR to them by writing /assign @yliaog in a comment when ready.

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 18, 2019
kubernetes/utils/create_from_yaml.py Outdated Show resolved Hide resolved
kubernetes/utils/create_from_yaml.py Outdated Show resolved Hide resolved
performe an action from a valid parsed yaml object (as dict).

:param k8s_client: an ApiClient objcet initialized with the client args
:yml_object dict: a parsed yaml object
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think one needs to explicitly reference yaml here as what the function wants is a kubernetes manifest in python dictionary form
though it probably also does not harm as yaml is the most common representation form of that data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is why I added create_from_map

@roycaihw
Copy link
Member

/cc @micw523

test-requirements.txt Outdated Show resolved Hide resolved
@micw523
Copy link
Contributor

micw523 commented Mar 19, 2019

I think I'm still holding my original position in #722: we don't need many function names. We should be able to do everything in create_from_yaml (potentially with an extra input parameter), since the word yaml isn't specific to a file anyway. If absolutely needed we can make an alias on create_from_yaml.

Also, we're pushing to merge 673, so it's likely that you'll need a rebase soon...

Copy link
Contributor

@micw523 micw523 left a comment

Choose a reason for hiding this comment

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

See comments.

Copy link
Contributor Author

@oz123 oz123 left a comment

Choose a reason for hiding this comment

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

I think I'm still holding my original position in #722: we don't need many function names. We should be able to do everything in create_from_yaml (potentially with an extra input parameter), since the word yaml isn't specific to a file anyway. If absolutely needed we can make an alias on create_from_yaml.

Also, we're pushing to merge 673, so it's likely that you'll need a rebase soon...

I agree with you about creating an alias. IMHO it's better to be explicit . Since "yaml" isn't necessary a file it's better to specify when expect a file\stream and specify when we don't.

Concerning backwards compatibility, I now suggest the following, check if yaml_path is a file on the filesystem, if it is, proceed as in the past. If it is a string, try and parse it to yaml object.

isort
adal
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked again:

$ grep -nr adal kubernetes | grep -v \.pyc
kubernetes/base/config/kube_config.py:24:import adal
kubernetes/base/config/kube_config.py:223:        context = adal.AuthenticationContext(

jwt is a dependency of adal, and I'm not sure adal is specifically required here.
I removed jwt. How do you want me to proceed with adal?

@oz123 oz123 force-pushed the apply branch 3 times, most recently from 36de28b to ce11548 Compare March 19, 2019 14:46
@micw523
Copy link
Contributor

micw523 commented Mar 19, 2019

Which branch did you fork it from? If you forked it from the current master I’ll need to do some investigation.

Adal as a requirement got moved to optional in a previous PR so that might be the problem.

@oz123
Copy link
Contributor Author

oz123 commented Mar 19, 2019

Which branch did you fork it from? If you forked it from the current master I’ll need to do some investigation.

Adal as a requirement got moved to optional in a previous PR so that might be the problem.

I forked from the master on a fresh clone I did yesterday.

@micw523
Copy link
Contributor

micw523 commented Mar 20, 2019

I just had a fresh fork from the master branch. adal is not required for testing. Is it breaking anything that you submitted?

@micw523
Copy link
Contributor

micw523 commented Mar 20, 2019

I checked your past Travis builds. It doesn't seem like adal is affecting you. Please remove the added packages.

@micw523
Copy link
Contributor

micw523 commented Mar 20, 2019

/assign

This keeps the function backwords compatible.

Changed the parameter yaml to yml in order not to mask
the imported module.
@oz123
Copy link
Contributor Author

oz123 commented Mar 20, 2019

I checked your past Travis builds. It doesn't seem like adal is affecting you. Please remove the added packages.

done. I completely removed that commit.

@oz123
Copy link
Contributor Author

oz123 commented Mar 20, 2019

@micw523 the new master branch includes create_from_yaml_single_item which obsoletes my work.
I think a lot of people would appreciate a more explicit function name, because create_from_yaml is still misleading. A better name would have been create_from_yaml_file. In order to keep backward compatabilty create_from_yaml_file could be added in the future as a thin wrapper around create_from_yaml_file and if people use create_from_yaml use a warning, but still read the file and parse the yaml.
My two cents.

@oz123 oz123 closed this Mar 20, 2019
@oz123 oz123 deleted the apply branch March 20, 2019 20:25
@micw523
Copy link
Contributor

micw523 commented Mar 20, 2019

I’m not sure. The create_from_single_item is there for a multi-resource yaml and / or yaml lists. It is NOT imported into the package nor you can use it directly with inputs from a string if your yaml string / dict contains a list type or multiple resources. This idea is not obsolete if these cases are handled.

Do you still want to work on this, or you’re going to leave it in my hands?

@oz123
Copy link
Contributor Author

oz123 commented Mar 20, 2019

@micw523 I would prefer starting on a clean branch and a clean PR. This has become too opaque for me. Do you mind if I submit a new PR?

@micw523
Copy link
Contributor

micw523 commented Mar 20, 2019

That’s cool, go for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants