Skip to content

Commit daba3ce

Browse files
authored
Merge pull request #56 from Escape-Technologies/fix/k8s-asset
fix: k8s asset
2 parents 6119b26 + 916738c commit daba3ce

5 files changed

+92
-4
lines changed

pkg/api/escape/assets.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,22 @@ func UpdateAsset(
132132
return nil
133133
}
134134

135+
// normalizeAssetType normalizes asset type tokens to match generated method names
136+
// e.g. KUBERNETES_CLUSTER -> KUBERNETESCLUSTER, http-endpoint -> HTTPENDPOINT
137+
func normalizeAssetType(s string) string {
138+
upper := strings.ToUpper(s)
139+
upper = strings.ReplaceAll(upper, "_", "")
140+
upper = strings.ReplaceAll(upper, "-", "")
141+
return upper
142+
}
143+
135144
// CreateAsset creates an asset
136145
func CreateAsset(ctx context.Context, data []byte, assetType string) (interface{}, error) {
137146
typ := reflect.TypeOf((*v3.AssetsAPIService)(nil))
138147
for i := 0; i < typ.NumMethod(); i++ {
139148
method := typ.Method(i)
140-
if strings.HasPrefix(method.Name, "Create") && !strings.HasSuffix(method.Name, "Execute") {
141-
if strings.Contains(method.Name, strings.ToUpper(assetType)) {
149+
if strings.HasPrefix(method.Name, "Create") && !strings.HasSuffix(method.Name, "Execute") {
150+
if strings.Contains(method.Name, normalizeAssetType(assetType)) {
142151
client, err := newAPIV3Client()
143152
if err != nil {
144153
return nil, fmt.Errorf("unable to init client: %w", err)

pkg/api/v3/model_create_asset_github_organization_request.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/v3/model_create_asset_github_repository_request_org.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/v3/model_enum_properties_content_properties_rule_0_properties_transform_properties_trigger_items_7_properties_type_properties_is.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/locations/kube/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,11 @@ func connectAndRun(ctx context.Context, cfg *rest.Config, isConnected *atomic.Bo
7777
}
7878
log.Info("Connected to K8s API")
7979
log.Trace("Upserting K8s integration")
80-
asset := v3.NewCreateAssetKUBERNETESCLUSTERRequestWithDefaults()
81-
asset.PrivateLocationId = locationID
80+
asset := v3.NewCreateAssetKUBERNETESCLUSTERRequest(
81+
v3.ENUMCLOUDHOSTING_CLOUD_HOSTING,
82+
v3.ENUMKUBERNETESCLUSTER_KUBERNETES_CLUSTER,
83+
locationID,
84+
)
8285
asset.Name = &locationName
8386
data, err := asset.MarshalJSON()
8487
if err != nil {

0 commit comments

Comments
 (0)