File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,6 +58,21 @@ func (d *DelegationDriver) ProviderIDFormat() interfaces.ProviderIDFormat {
5858 return interfaces .IDFormatDomainName
5959}
6060
61+ // AdoptionRef lets wfctl adopt an already-delegated domain before creating
62+ // registrar state. Read uses public NS first, so an already-correct delegation
63+ // can plan as no-op without requiring Hover authentication.
64+ func (d * DelegationDriver ) AdoptionRef (spec interfaces.ResourceSpec ) (interfaces.ResourceRef , bool , error ) {
65+ s , err := parseDelegationSpec (spec )
66+ if err != nil {
67+ return interfaces.ResourceRef {}, false , err
68+ }
69+ return interfaces.ResourceRef {
70+ Name : spec .Name ,
71+ Type : "infra.dns_delegation" ,
72+ ProviderID : s .domain ,
73+ }, true , nil
74+ }
75+
6176// dnsDelegationSpec is the parsed config view.
6277type dnsDelegationSpec struct {
6378 domain string
Original file line number Diff line number Diff line change @@ -164,6 +164,27 @@ func TestDelegationDriver_Read_UsesPublicNSBeforeHoverLogin(t *testing.T) {
164164 }
165165}
166166
167+ func TestDelegationDriver_AdoptionRef_UsesSpecDomain (t * testing.T ) {
168+ d := NewDelegationDriverWithClient (& fakeDelegationClient {})
169+ ref , ok , err := d .AdoptionRef (interfaces.ResourceSpec {
170+ Name : "delegation" ,
171+ Type : "infra.dns_delegation" ,
172+ Config : map [string ]any {
173+ "domain" : "example.com" ,
174+ "nameservers" : []any {"ns1.example.com" },
175+ },
176+ })
177+ if err != nil {
178+ t .Fatalf ("AdoptionRef: %v" , err )
179+ }
180+ if ! ok {
181+ t .Fatal ("expected adoption ref" )
182+ }
183+ if ref .Name != "delegation" || ref .Type != "infra.dns_delegation" || ref .ProviderID != "example.com" {
184+ t .Fatalf ("unexpected ref: %+v" , ref )
185+ }
186+ }
187+
167188func TestDelegationDriver_Read_PropagatesError (t * testing.T ) {
168189 fc := & fakeDelegationClient {getErr : errors .New ("API down" )}
169190 d := NewDelegationDriverWithClient (fc )
You can’t perform that action at this time.
0 commit comments