Skip to content

Commit

Permalink
Fixes for declare api (#3325)
Browse files Browse the repository at this point in the history
  • Loading branch information
vklohiya committed Mar 11, 2024
1 parent 06e5d74 commit 8ed7a09
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
10 changes: 2 additions & 8 deletions pkg/controller/as3PostManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -981,14 +981,8 @@ func createTransportServiceDecl(cfg *ResourceConfig, sharedApp as3Application, t
svc.VirtualPort = port

}
ps := strings.Split(cfg.Virtual.PoolName, "/")
poolValue := fmt.Sprintf("/%s/%s/%s",
tenant,
as3SharedApplication,
ps[len(ps)-1],
)

svc.Pool = poolValue

svc.Pool = cfg.Virtual.PoolName

processCommonDecl(cfg, svc)
sharedApp[cfg.Virtual.Name] = svc
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ const BigIPLabel = ""

const CmDocumentApi = "/api/v1/spaces/default/appsvcs/documents/"

const CmDeclareApi = "/api/v1/spaces/default/appsvcs/declare/"
const CmDeclareApi = "/api/v1/spaces/default/appsvcs/declare"

const CmDeclareTaskApi = "/api/v1/spaces/default/appsvcs/task/"

Expand Down
23 changes: 6 additions & 17 deletions pkg/controller/postManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,9 @@ func (postMgr *PostManager) postManager() {
log.Debugf("[AS3] Delaying post to BIG-IP for %v seconds ", postMgr.AS3PostManager.AS3Config.PostDelayAS3)
_ = <-time.After(time.Duration(postMgr.AS3PostManager.AS3Config.PostDelayAS3) * time.Second)
}
// Set the target address to BIG-IP and docID and acceptedID if two step deployment is enabled
if postMgr.AS3Config.DocumentAPI {
config.as3Config.targetAddress = config.BigIpKey.BigIpAddress
}
// Set the target address for the as3 request
config.as3Config.targetAddress = config.BigIpKey.BigIpAddress

//Handle AS3 post
postMgr.publishConfig(&config.as3Config)
//TODO: L3 post manger handling
Expand Down Expand Up @@ -133,9 +132,9 @@ func (postMgr *PostManager) getAS3APIURL(bigipAddress string) string {
//apiURL := postMgr.tokenManager.ServerURL + CmDeclareApi + strings.Join(tenants, ",")
var apiURL string
if !postMgr.AS3Config.DocumentAPI {
apiURL = postMgr.tokenManager.ServerURL + CmDeclareApi
apiURL = postMgr.tokenManager.ServerURL + CmDeclareApi + "?target_address=" + bigipAddress
} else {
apiURL = postMgr.tokenManager.ServerURL + CmDocumentApi + "?target_address=" + bigipAddress
apiURL = postMgr.tokenManager.ServerURL + CmDocumentApi
}
return apiURL
}
Expand Down Expand Up @@ -191,8 +190,7 @@ func (postMgr *PostManager) postConfig(cfg *as3Config) {
log.Errorf("%v[AS3]%v Creating new HTTP request error: %v ", getRequestPrefix(cfg.id), postMgr.postManagerPrefix, err)
return
}

log.Infof("%v[AS3]%v posting request for %v tenants", getRequestPrefix(cfg.id), postMgr.postManagerPrefix, getTenantsFromUri(cfg.as3APIURL))
log.Infof("%v[AS3]%v posting request to %v", getRequestPrefix(cfg.id), postMgr.postManagerPrefix, cfg.as3APIURL)
// add authorization header to the req
req.Header.Add("Authorization", "Bearer "+postMgr.tokenManager.GetToken())
// add content type header to the req
Expand Down Expand Up @@ -889,12 +887,3 @@ func getRequestPrefix(id int) string {
}
return fmt.Sprintf("[Request: %v]", id)
}

// function for returning the tenants from URI
func getTenantsFromUri(uri string) string {
res := strings.Split(uri, "declare/")
if len(res[0]) == 0 {
return "all"
}
return res[1]
}

0 comments on commit 8ed7a09

Please sign in to comment.