-
Notifications
You must be signed in to change notification settings - Fork 263
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
Add DomainMapping CRUD commands #1267
Conversation
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.
@dsimansk: 15 warnings.
In response to this:
Description
This PR adds CRUD operations for
DomainMapping
resource.TODO:
I've covered only Knative Service as the only target, but going through the updated docs I should probably reflect the other targets as well.
knative/serving@8eee938I'll take a look into Servings test, if we can do a real world domain E2E test.
Changes
- 🎁 Add top-level cmd
domain
withcreate, update, describe, delete, list
opsReference
Fixes #1197
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
@julz FYI. |
113b513
to
ff5f028
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.
I gave it a try and it looks good. Just a few nits.
pkg/kn/commands/domain/create.go
Outdated
err = client.CreateDomainMapping(builder.Build()) | ||
if err != nil { | ||
return knerrors.GetError(err) | ||
} |
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.
err = client.CreateDomainMapping(builder.Build()) | |
if err != nil { | |
return knerrors.GetError(err) | |
} | |
if err := client.CreateDomainMapping(builder.Build()); err != nil { | |
return knerrors.GetError(err) | |
} |
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 suggestion. However, I recall from some previous PRs that if-s with inline declarations aren't very popular in client's code.
@maximilien or @rhuss wdyt?
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.
Yeah, I like the simpler none if err := ...
but that's just me :)
pkg/kn/commands/domain/delete.go
Outdated
err = client.DeleteDomainMapping(name) | ||
if err != nil { | ||
return knerrors.GetError(err) | ||
} |
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.
err = client.DeleteDomainMapping(name) | |
if err != nil { | |
return knerrors.GetError(err) | |
} | |
if err := client.DeleteDomainMapping(name); err != nil { | |
return knerrors.GetError(err) | |
} |
pkg/serving/v1alpha1/client.go
Outdated
_, err := cl.client.DomainMappings(cl.namespace).Create(context.TODO(), domainMapping, v1.CreateOptions{}) | ||
if err != nil { | ||
return knerrors.GetError(err) | ||
} |
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.
_, err := cl.client.DomainMappings(cl.namespace).Create(context.TODO(), domainMapping, v1.CreateOptions{}) | |
if err != nil { | |
return knerrors.GetError(err) | |
} | |
if _, err := cl.client.DomainMappings(cl.namespace).Create(context.TODO(), domainMapping, v1.CreateOptions{}); err != nil { | |
return knerrors.GetError(err) | |
} |
Few suggestions
|
FWIW I'm not sure this is what we should do. If the DM is deleted when the ksvc is deleted then it's possible for someone to swoop in and grab a domain mapping that you want to reuse for another ksvc later. I would understand doing this more if we created the ksvc and domain at the same time (eg if we added a field to ksvc to spit out a domainmapping), but it seems a bit surprising to me at first glance for us to do this implicitly. OTOH if this matches the behaviour for things like --sink that'd probably change my mind.. do we automatically set the ksvc as the owner of a source when you pass --sink? |
I have the same concern as @julz that it'd break the reuse use case. In addition to However, such flag can still optional per explicit request to add OwenerRef to the resource. It might prove to be useful elsewhere as well.
Thanks, that's good point I haven't checked the annotations yet. |
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.
Various comments... please address. Great contribution BTW
CC: @julz who did the work on serving side as FYI
docs/cmd/kn_domain_delete.md
Outdated
Delete a domain mapping | ||
|
||
``` | ||
kn domain delete FQDN |
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.
What’s “FQDN”? Can we use something simpler, e.g., ‘hello’
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 intended to promote that fully qualified domain name is expected. It'd be better to explain in the example description probably.
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.
Thx clearer the better
pkg/kn/commands/domain/create.go
Outdated
if err != nil { | ||
return err | ||
} | ||
destination, err := refFlags.ResolveSink(dynamicClient, namespace) |
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.
A bit confuse here. Why are we resolving the destination as an event sink
?
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've reused the sink flag handling here, but it's not entirely correct. I'll come up with something better. :)
+1 |
From the DomainMapping docs:
Therefore I've added the following handling for 3 reference types.
However, per discussion with @navidshaikh and @itsmurugappan yesterday there're some doubts. The addition of Kubernetes Service wtih Should we only support reference as Knative Service for now to keep it simple. And add additional support if there's request for it? Wdyt? @rhuss @maximilien |
@dsimansk : Let's support knative resources, ksvc and kroute ? If we're planning to support prefix for k8s service, let's do it for sink flag as well? This way we've consistent prefix across flags. |
c7fbd6d
to
db96581
Compare
db96581
to
b57b7e3
Compare
Update the resolve func accordingly. In addition the PR is rebased and context param added. |
The following is the coverage report on the affected files.
|
/lgtm |
Let's get that merged now, if now one objects (we can clean up later, but we need to get this in before the release) /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: maximilien, rhuss 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 |
Description
This PR adds CRUD operations for
DomainMapping
resource.TODO:
I've covered only Knative Service as the only target, but going through the updated docs I should probably reflect the other targets as well.
knative/serving@8eee938
I'll take a look into Servings test, if we can do a real world domain E2E test.
Changes
domain
withcreate, update, describe, delete, list
opsReference
Fixes #1197