-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(apim): crds and controller for configuring apis in apim (#1175)
* feat: api and apiversion reconcile logic Still some work to be done with the tests. Committing to not loose work * feat: add base64 encoded string of content add base64-encoded string of api spec (content) to status. refactor internal/utils after new methods are added. fix bug in long_running_operations checker * rewrite api controller tests * rewrite all controller tests using manager instead of simulating reconciliation * remove commented code * fix linting errors * add test for long_running_operations * fixes after coderabbit review * fixes after coderabbit review * fixes after coderabbit review * fixes after coderabbit review * added utils.go test for status code !200 * fixes after coderabbit review * replace Fprintln with Fprint * Update services/dis-apim-operator/internal/controller/apiversion_controller.go Co-authored-by: Sebastian Duran <[email protected]> * fix: handle non-not-found policyErr --------- Co-authored-by: tjololo <[email protected]> Co-authored-by: Sebastian Duran <[email protected]>
- Loading branch information
1 parent
0f668fc
commit 3a1e7d3
Showing
35 changed files
with
2,862 additions
and
672 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,5 @@ go.work | |
*.swp | ||
*.swo | ||
*~ | ||
|
||
*.ignore.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
157 changes: 157 additions & 0 deletions
157
services/dis-apim-operator/api/v1alpha1/apiversion_enums.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
package v1alpha1 | ||
|
||
import ( | ||
"github.com/Altinn/altinn-platform/services/dis-apim-operator/internal/utils" | ||
apim "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/apimanagement/armapimanagement/v2" | ||
) | ||
|
||
// INSERT ADDITIONAL TYPES | ||
// Important: Run "make" to regenerate code after modifying this file | ||
|
||
// ContentFormat - Format of the Content in which the API is getting imported. | ||
type ContentFormat string | ||
|
||
const ( | ||
// ContentFormatGraphqlLink - The GraphQL API endpoint hosted on a publicly accessible internet address. | ||
ContentFormatGraphqlLink ContentFormat = "graphql-link" | ||
// ContentFormatOpenapi - The contents are inline and Content Type is a OpenAPI 3.0 YAML Document. | ||
ContentFormatOpenapi ContentFormat = "openapi" | ||
// ContentFormatOpenapiJSON - The contents are inline and Content Type is a OpenAPI 3.0 JSON Document. | ||
ContentFormatOpenapiJSON ContentFormat = "openapi+json" | ||
// ContentFormatOpenapiJSONLink - The OpenAPI 3.0 JSON document is hosted on a publicly accessible internet address. | ||
ContentFormatOpenapiJSONLink ContentFormat = "openapi+json-link" | ||
// ContentFormatOpenapiLink - The OpenAPI 3.0 YAML document is hosted on a publicly accessible internet address. | ||
ContentFormatOpenapiLink ContentFormat = "openapi-link" | ||
// ContentFormatSwaggerJSON - The contents are inline and Content Type is a OpenAPI 2.0 JSON Document. | ||
ContentFormatSwaggerJSON ContentFormat = "swagger-json" | ||
// ContentFormatSwaggerLinkJSON - The OpenAPI 2.0 JSON document is hosted on a publicly accessible internet address. | ||
ContentFormatSwaggerLinkJSON ContentFormat = "swagger-link-json" | ||
// ContentFormatWadlLinkJSON - The WADL document is hosted on a publicly accessible internet address. | ||
ContentFormatWadlLinkJSON ContentFormat = "wadl-link-json" | ||
// ContentFormatWadlXML - The contents are inline and Content type is a WADL document. | ||
ContentFormatWadlXML ContentFormat = "wadl-xml" | ||
) | ||
|
||
func (c ContentFormat) AzureContentFormat() *apim.ContentFormat { | ||
contentFormat := apim.ContentFormat(c) | ||
return &contentFormat | ||
} | ||
|
||
type APIContactInformation struct { | ||
// The email address of the contact person/organization. MUST be in the format of an email address | ||
Email *string `json:"email,omitempty"` | ||
|
||
// The identifying name of the contact person/organization | ||
Name *string `json:"name,omitempty"` | ||
|
||
// The URL pointing to the contact information. MUST be in the format of a URL | ||
URL *string `json:"url,omitempty"` | ||
} | ||
|
||
func (a *APIContactInformation) AzureAPIContactInformation() *apim.APIContactInformation { | ||
if a == nil { | ||
return nil | ||
} | ||
return &apim.APIContactInformation{ | ||
Email: a.Email, | ||
Name: a.Name, | ||
URL: a.URL, | ||
} | ||
} | ||
|
||
type APIVersionScheme string | ||
|
||
const ( | ||
// APIVersionSetContractDetailsVersioningSchemeHeader - The API Version is passed in a HTTP header. | ||
APIVersionSetContractDetailsVersioningSchemeHeader APIVersionScheme = "Header" | ||
// APIVersionSetContractDetailsVersioningSchemeQuery - The API Version is passed in a query parameter. | ||
APIVersionSetContractDetailsVersioningSchemeQuery APIVersionScheme = "Query" | ||
// APIVersionSetContractDetailsVersioningSchemeSegment - The API Version is passed in a path segment. | ||
APIVersionSetContractDetailsVersioningSchemeSegment APIVersionScheme = "Segment" | ||
) | ||
|
||
func (a *APIVersionScheme) AzureAPIVersionScheme() *apim.VersioningScheme { | ||
if a == nil { | ||
return nil | ||
} | ||
apiVersionScheme := apim.VersioningScheme(*a) | ||
return &apiVersionScheme | ||
} | ||
|
||
func (a *APIVersionScheme) AzureAPIVersionSetContractDetailsVersioningScheme() *apim.APIVersionSetContractDetailsVersioningScheme { | ||
if a == nil { | ||
return nil | ||
} | ||
apiVersionScheme := apim.APIVersionSetContractDetailsVersioningScheme(*a) | ||
return &apiVersionScheme | ||
} | ||
|
||
type Protocol string | ||
|
||
const ( | ||
ProtocolHTTP Protocol = "http" | ||
ProtocolHTTPS Protocol = "https" | ||
ProtocolWs Protocol = "ws" | ||
ProtocolWss Protocol = "wss" | ||
) | ||
|
||
func (p *Protocol) AzureProtocol() *apim.Protocol { | ||
if p == nil { | ||
return nil | ||
} | ||
protocol := apim.Protocol(*p) | ||
return &protocol | ||
} | ||
|
||
func ToApimProtocolSlice(protocols []Protocol) []*apim.Protocol { | ||
apimProtocols := make([]*apim.Protocol, len(protocols)) | ||
for i, protocol := range protocols { | ||
apimProtocols[i] = utils.ToPointer(apim.Protocol(protocol)) | ||
} | ||
return apimProtocols | ||
} | ||
|
||
type PolicyFormat string | ||
|
||
const ( | ||
// PolicyContentFormatRawxml - The contents are inline and Content type is a non XML encoded policy document. | ||
PolicyContentFormatRawxml PolicyFormat = "rawxml" | ||
// PolicyContentFormatRawxmlLink - The policy document is not XML encoded and is hosted on a HTTP endpoint accessible from | ||
// the API Management service. | ||
PolicyContentFormatRawxmlLink PolicyFormat = "rawxml-link" | ||
// PolicyContentFormatXML - The contents are inline and Content type is an XML document. | ||
PolicyContentFormatXML PolicyFormat = "xml" | ||
// PolicyContentFormatXMLLink - The policy XML document is hosted on a HTTP endpoint accessible from the API Management service. | ||
PolicyContentFormatXMLLink PolicyFormat = "xml-link" | ||
) | ||
|
||
func (p *PolicyFormat) AzurePolicyFormat() *apim.PolicyContentFormat { | ||
if p == nil { | ||
return nil | ||
} | ||
policyFormat := apim.PolicyContentFormat(*p) | ||
return &policyFormat | ||
} | ||
|
||
// APIType - Type of API. | ||
type APIType string | ||
|
||
const ( | ||
APITypeGraphql APIType = "graphql" | ||
APITypeHTTP APIType = "http" | ||
APITypeWebsocket APIType = "websocket" | ||
) | ||
|
||
func (a APIType) AzureApiType() *apim.APIType { | ||
apiType := apim.APIType(a) | ||
return &apiType | ||
} | ||
|
||
type ProvisioningState string | ||
|
||
const ( | ||
ProvisioningStateSucceeded ProvisioningState = "Succeeded" | ||
ProvisioningStateFailed ProvisioningState = "Failed" | ||
ProvisioningStateUpdating ProvisioningState = "Updating" | ||
ProvisioningStateDeleting ProvisioningState = "Deleting" | ||
) |
Oops, something went wrong.