Giter Site home page Giter Site logo

yetics / armkit Goto Github PK

View Code? Open in Web Editor NEW
53.0 5.0 13.0 4.49 MB

Define infrastructure resources using programming constructs and provision them using Azure ARM templates

License: Apache License 2.0

JavaScript 0.01% TypeScript 99.98% Dockerfile 0.01% Shell 0.01%
azure arm-templates azure-arm-template infrastructure azure-services deploy-stacks cloud-development-kit

armkit's Issues

Split resources domains in testable pieces

Is your feature request related to a problem? Please describe.

Developing against a 1k-10k LOC resource file is too hard to debug and rather guessing.
Breaking up this files in representable single resources could lead to a simplifies testing and development approach.

Case: Modifications in the core logic of type-generator.ts lack dedicated test cases to validate each piece of logic.

Describe the solution you'd like
Create representable single resource files with certain logic blocks ( for tesing purpose only).
E.g.

{
"id": "https://schema.management.azure.com/schemas/2019-12-01/Microsoft.ContainerInstance.json#",
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Microsoft.ContainerInstance",
"description": "Microsoft ContainerInstance Resource Types",
"resourceDefinitions": {
    "containerGroups": {
    "type": "object",
    "properties": {
    "apiVersion": {
    "type": "string",
    "enum": [
    "2019-12-01"
    ]
    },
    "identity": {
    "oneOf": [
    {
    "$ref": "#/definitions/ContainerGroupIdentity"
    },
    {
    "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
    }
    ],
    "description": "Identity for the container group."
    },
    "location": {
    "type": "string",
    "description": "The resource location."
    },
    "name": {
    "type": "string",
    "description": "The name of the container group."
    },
    "properties": {
    "oneOf": [
    {
    "$ref": "#/definitions/ContainerGroupProperties"
    },
    {
    "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
    }
    ],
    "description": "The container group properties"
    },
    "tags": {
    "oneOf": [
    {
    "type": "object",
    "additionalProperties": {
    "type": "string"
    },
    "properties": {}
    },
    {
    "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
    }
    ],
    "description": "The resource tags."
    },
    "type": {
    "type": "string",
    "enum": [
    "Microsoft.ContainerInstance/containerGroups"
    ]
    }
    },
    "required": [
    "apiVersion",
    "name",
    "properties",
    "type"
    ],
    "description": "Microsoft.ContainerInstance/containerGroups"
    }
    }
  }
}

expected test artifast

import { ArmResource } from '@armkit/core';
import { Construct } from 'constructs';

/**
 * Microsoft.ContainerInstance/containerGroups
 *
 * @schema Microsoft.ContainerInstance.containerGroups
 */
export class ContainerGroups extends ArmResource {
  /**
   * Defines a "Microsoft.ContainerInstance.containerGroups" Arm Template object
   * @param scope the scope in which to define this object
   * @param name a scope-local name for the object
   * @param options configuration options
   */
  public constructor(scope: Construct, name: string, options: ContainerGroupsOptions) {
    super(scope, name, {
      ...options,
      armResourceType: 'containerGroups',
    });
  }
}
export interface ContainerGroupsOptions {
  /**
   * @schema Microsoft.ContainerInstance.containerGroups#apiVersion
   */
  readonly apiVersion?: MicrosoftContainerInstanceContainerGroupsApiVersionEnum;

  /**
   * Identity for the container group.
   *
   * @schema Microsoft.ContainerInstance.containerGroups#identity
   */
  readonly identity?: ContainerGroupIdentity;

  /**
   * The resource location.
   *
   * @schema Microsoft.ContainerInstance.containerGroups#location
   */
  readonly location?: string;

  /**
   * The name of the container group.
   *
   * @schema Microsoft.ContainerInstance.containerGroups#name
   */
  readonly name: string;

  /**
   * The container group properties
   *
   * @schema Microsoft.ContainerInstance.containerGroups#properties
   */
  readonly properties: ContainerGroupProperties;

  /**
   * The resource tags.
   *
   * @schema Microsoft.ContainerInstance.containerGroups#tags
   */
  readonly tags?: MicrosoftContainerInstanceContainerGroupsTags;

  /**
   * @schema Microsoft.ContainerInstance.containerGroups#type
   */
  readonly type: MicrosoftContainerInstanceContainerGroupsTypeEnum;

}

export enum MicrosoftContainerInstanceContainerGroupsApiVersionEnum {
  "2019_12_01" = '2019-12-01',
}

core: resource - delete props doesn't make sense

arm-resource_ts_—Untitled__Workspace

Why delete it as soon as it's constructed? If you are going to do that, then the property needs to be optional aka a '?' otherwise the Interface contract is broken hence the typescript error.

Some services get a 404 from https://schema.management.azure.com

Describe the bug
Some services get a 404 when trying to retrieve their schema from https://schema.management.azure.com. You can see this in the snapshot tests added in #68 .

Here's the error:

    Not Found: https://schema.management.azure.com/schemas/2021-06-01/Microsoft.AVS.json

      34 |     const req = https.get(url, res => {
      35 |       if (res.statusCode !== 200) {
    > 36 |         throw new Error(`${res.statusMessage}: ${url}`);
         |               ^
      37 |       }
      38 |       const data = new Array<Buffer>();
      39 |       res.on('data', chunk => data.push(chunk));

      at ClientRequest.<anonymous> (lib/util.ts:36:15)

The following services are effected by this issue:

["2021-06-01/Microsoft.AVS", "AVS"],
["2021-04-01/Microsoft.Storage", "Storage"],
["2021-02-01/Microsoft.NetApp", "NetApp"],
["2020-12-01/Microsoft.Cache", "Cache"],
["2021-03-31/Microsoft.Devices", "Devices"],

To Reproduce
Steps to reproduce the behavior:

  1. Add an effected service to the test fixture added in #68
  2. Run tests
  3. See error

Generating Microsoft.Network throws errors on handling '#/definitions/FirewallPolicyRuleCollectionGroupProperties'

Describe the bug

=== Start === 
{ '$ref': '#/definitions/FirewallPolicyRuleCollection' }
 
Using def.$ref
 
 === END === 
 
 === Start === 
{
  type: 'object',
  oneOf: [
    { properties: [Object] },
    { allOf: [Array], properties: [Object] },
    { allOf: [Array], properties: [Object] }
  ],
  properties: {
    name: { type: 'string', description: 'The name of the rule collection.' },
    priority: {
      oneOf: [Array],
      description: 'Priority of the Firewall Policy Rule Collection resource.'
    },
    ruleCollectionType: { type: 'string' }
  },
  required: [ 'ruleCollectionType' ],
  description: 'Properties of the rule collection.'
}
 
Using emitUnion

result in

/**
 * Properties of the rule collection.
 *
 * @schema #/definitions/FirewallPolicyRuleCollection
 */
export class FirewallPolicyRuleCollection {
  public static from(value: ): FirewallPolicyRuleCollection {
    return new FirewallPolicyRuleCollection(value);
  }
  public static from(value: ): FirewallPolicyRuleCollection {
    return new FirewallPolicyRuleCollection(value);
  }
  public static from(value: ): FirewallPolicyRuleCollection {
    return new FirewallPolicyRuleCollection(value);
  }
  private constructor(value: any) {
    Object.defineProperty(this, 'resolve', { value: () => value });
  }
}

Expected behavior
A clear and concise description of what you expected to happen.

"FirewallPolicyRuleCollection": {
      "type": "object",
      "oneOf": [
        {
          "properties": {
            "ruleCollectionType": {
              "oneOf": [
                { "type": "string", "enum": ["FirewallPolicyRuleCollection"] },
                {
                  "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
                }
              ]
            }
          }
        },
        {
          "allOf": [
            { "$ref": "#/definitions/FirewallPolicyNatRuleCollection" }
          ],
          "properties": {
            "ruleCollectionType": {
              "oneOf": [
                {
                  "type": "string",
                  "enum": ["FirewallPolicyNatRuleCollection"]
                },
                {
                  "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
                }
              ]
            }
          }
        },
        {
          "allOf": [
            { "$ref": "#/definitions/FirewallPolicyFilterRuleCollection" }
          ],
          "properties": {
            "ruleCollectionType": {
              "oneOf": [
                {
                  "type": "string",
                  "enum": ["FirewallPolicyFilterRuleCollection"]
                },
                {
                  "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
                }
              ]
            }
          }
        }
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the rule collection."
        },
        "priority": {
          "oneOf": [
            { "type": "integer", "minimum": 100, "maximum": 65000 },
            {
              "$ref": "https://schema.management.azure.com/schemas/common/definitions.json#/definitions/expression"
            }
          ],
          "description": "Priority of the Firewall Policy Rule Collection resource."
        },
        "ruleCollectionType": { "type": "string" }
      },
      "required": ["ruleCollectionType"],
      "description": "Properties of the rule collection."
    },

Developer tooling

Is your feature request related to a problem? Please describe.
As a developer i want to have hook streamline my standard task like

  • yarn build (done ?)
  • armkit generate
  • translate and run examples with new api

Describe the solution you'd like

  • have a local script section
  • GH flow would do

`arm-stack` should support input variables/parameters resources

Is your feature request related to a problem? Please describe.
Since just the resource section of the ARM template schema is implemented arm-stack has no support for arm-variables

Describe the solution you'd like
Arm template variables should be suported as

export class MyStack extends ArmStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);

    const myvar = new ArmVariable(this, 'registryurl', {
      value: `https://asdf.registries.azure.con/`,
    });

    new ContainerGroups(this, 'MyContainerGroup', {
      name: 'azurecdktest',
      location: 'westeurope',
      apiVersion: MicrosoftContainerInstanceContainerGroupsApiVersion["MicrosoftContainerInstanceContainerGroupsApiVersion_2021_03_01"],
      type: MicrosoftContainerInstanceContainerGroupsType.MicrosoftContainerInstanceContainerGroupsType_MICROSOFT_CONTAINER_INSTANCE_CONTAINER_GROUPS,
      properties: {
        containers: [{
          name: 'ubuntu-server',
          properties: {
            image: 'ubuntu:18.04',
            command: ['sleep infinity'],
            resources: {
              requests: {
                cpu: 1,
                memoryInGB: 2
              },
              limits: {
                cpu: 1,
                memoryInGB: 2
              }
            }

          }
        }],
        osType: ContainerGroupPropertiesOsType.LINUX,
      }
    })
  }
}

Build fails on initial repo clone

The initial yarn build on a freshly cloned repo fails since the .generated files in the basic example are missing. To reproduce, clone the repo in a new directory and run yarn build.
You will get

$ tsc
lerna ERR! yarn run build exited 1 in '@examples/basic'
lerna ERR! yarn run build stdout:
$ tsc
index.ts(5,8): error TS2307: Cannot find module './.generated/ContainerInstance'.
index.ts(8,8): error TS2307: Cannot find module './.generated/ContainerRegistry'.

To resolve this, one can change the build script for the example to armkit generate && tsc, or add a new script, e.g. bootstrap that will be used only once, is the same as build for the other packages, and will run armkit generate && tsc for the example. First approach is simpler, but I am not sure what the overhead of running generate each time would be.

Create development workflow

Is your feature request related to a problem? Please describe.
As a developer i want to have hook streamline my standard task like

  • yarn build (done ?)
  • armkit generate
  • translate and run examples with new api

Describe the solution you'd like

  • have a local script section
  • GH flow would do

SCHEMA_DEFINITION_URL and schema-config.json are conflicting.

Describe the bug
SCHEMA_DEFINITION_URL and schema-config.json are conflicting.
if SCHEMA_DEFINITION_URL is set the API from SCHEMA_DEFINITION_URL is translated in each of the targets defined in schema-config.json

To Reproduce
Steps to reproduce the behavior:

  1. Go to armkit/examples/basic
  2. Ensure schema-config.json has siome targets defined
  3. run yarn generate
    4.Take a look at the classed generated in armkit/examples/basic.generated/

Expected behavior
``SCHEMA_DEFINITION_URL should override the targets defined inschema-config.json`

Developer standard tooling

Is your feature request related to a problem? Please describe.
As a developer i want to have hook streamline my standard task like

  • yarn build (done ?)
  • armkit generate
  • translate and run examples with new api

Describe the solution you'd like

  • have a local script section
  • GH flow would do

Schema 2014-04-01/Microsoft.Insights.ManuallyAuthored does not have a definitions property

Describe the bug
Schema 2014-04-01/Microsoft.Insights.ManuallyAuthored apparently doesn't have a definitions property. You can see this when running snapshot tests with it:

schema does not have "definitions"

  396 |
  397 |     if (!schema.definitions) {
> 398 |       throw new Error(`schema does not have "definitions"`);
      |             ^
  399 |     }
  400 |
  401 |     found = schema.definitions[lookup];

  at TypeGenerator.resolveReference (lib/type-generator.ts:398:13)
  at TypeGenerator.typeForRef (lib/type-generator.ts:374:25)
  at TypeGenerator.emitType (lib/type-generator.ts:82:19)
  at TypeGenerator.typeForProperty (lib/type-generator.ts:366:17)
  at TypeGenerator.emitProperty (lib/type-generator.ts:330:31)
  at lib/type-generator.ts:307:14
  at TypeGenerator.generate (lib/type-generator.ts:194:7)
  at ImportArmSchema.make (lib/import.ts:26:19)
  at ImportArmSchema.generateTypeScript (lib/import.ts:10:10)
  at ImportArmSchema.import (lib/base.ts:61:7)
  at test/schema.test.ts:143:3

To Reproduce
Steps to reproduce the behavior:

  1. Add 2014-04-01/Microsoft.Insights.ManuallyAuthored to the fixtures list created in #68
  2. Run tests
  3. See error

`arm-resource` class should reflect the full arm template schema

Is your feature request related to a problem? Please describe.
Since just the resource section of the ARM template schema is implemented arm-resouce doesnt implents the full azure common/default but only the resouce properties .

Since this thing like depensOn: [] are not possible
.
Describe the solution you'd like
Arm template variables should be suported as

const   asp  = new AppServicePlan(this, 'armkit-asp', { ... }

const appsvc = new AppService(this, 'docker-armkit', {
      name: 'amkit',
      appServicePlanId: `${asp.id}`,
      location: rg.location,
      resourceGroupName: rg.name,
      clientAffinityEnabled: false,
      httpsOnly: true,
      dependsOn: [asp],
});
appsvc.addOverride('site_config', [
{
        linux_fx_version: `DOCKER|${imagename}`,
        use_32_bit_worker_process: true,
      },
]);

Some schemas have local references that can't be resolved

Describe the bug
When running snapshot tests for some services, this error is thrown:

    cannot resolve local reference https://schema.management.azure.com/schemas/2020-12-01/Microsoft.Compute.Extensions.json#/definitions/genericExtension

      402 |
      403 |     if (!found) {
    > 404 |       throw new Error(`cannot resolve local reference ${ref}`);
          |             ^
      405 |     }
      406 |
      407 |     return found;

      at TypeGenerator.resolveReference (lib/type-generator.ts:404:13)
      at TypeGenerator.typeForRef (lib/type-generator.ts:374:25)
      at lib/type-generator.ts:218:23
      at TypeGenerator.generate (lib/type-generator.ts:194:7)
      at ImportArmSchema.make (lib/import.ts:26:19)
      at ImportArmSchema.generateTypeScript (lib/import.ts:10:10)
      at ImportArmSchema.import (lib/base.ts:61:7)
      at test/schema.test.ts:143:3
      ```

This issue effects the following services:
["2020-12-01/Microsoft.Compute", "Compute"],
["2020-09-18/Microsoft.Kusto", "Kusto"],

**To Reproduce**
Steps to reproduce the behavior:
1. Add one of the effected services to the fixture added in #68 
2. Run tests
3. See error

Generated class constructor options values are undefined

Describe the bug

in public constructor(scope: Construct, name: string, options: containerGroupsOptions) {} containerGroupsOptions is undefined.

/Codebox/src/github.com/yetics/armkit/examples/basic$ yarn exec tsc index.ts
yarn exec v1.22.5
.generated/ContainerInstance.ts:17:63 - error TS2304: Cannot find name 'containerGroupsOptions'.

17   public constructor(scope: Construct, name: string, options: containerGroupsOptions) {
                                                                 ~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

error Command failed.
Exit code: 2
Command: tsc
Arguments: index.ts
Directory: /home/aheumaier/Codebox/src/github.com/yetics/armkit/examples/basic
Output:

info Visit https://yarnpkg.com/en/docs/cli/exec for documentation about this command.

To Reproduce
Steps to reproduce the behavior:

  1. Go to armkit/examples/basic
  2. yarn generate
  3. yarn exec tsc index.ts
  4. `See the error

Expected behavior
no error output
Screenshots

Microsoft.Compute throws resource undefined error

Describe the bug
yarn generate produces the following errror on translating Microsoft.Compute :

(node:1611264) UnhandledPromiseRejectionWarning: Error: cannot resolve local reference https://schema.management.azure.com/schemas/2019-07-01/Microsoft.Compute.Extensions.json#/definitions/genericExtension
    at TypeGenerator.resolveReference (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/type-generator.js:336:19)
    at TypeGenerator.typeForRef (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/type-generator.js:312:29)
    at /home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/type-generator.js:175:33
    at TypeGenerator.generate (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/type-generator.js:153:13)
    at ImportArmSchema.make (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/import.js:21:23)
    at ImportArmSchema.generateTypeScript (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/import.js:9:14)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ImportArmSchema.import (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/base.js:41:13)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1611264) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
No errors

Sub-service implementations overwrite their parents

Describe the bug
We presently build the output filename by splitting the second part of the fqn (e.g. Microsoft.Compute, by ., and then taking the second part. (e.g. Compute). That's fine for most services, but sub-services are also separated by . in the fqn. e.g. Microsoft.Compute.Galleries will also get the filename Compute. It will therefore overwrite the parent implementation.

This is also why all sub-services fail the snapshot tests added in #68 : the test is looking for a file called /tmp/KeyVault.Secrets.testQycoiN/KeyVault.Secrets.ts, when the importer created /tmp/KeyVault.Secrets.testQycoiN/KeyVault.ts.

To Reproduce
Steps to reproduce the behavior:

  1. Add a sub-service (e.g. 2019-03-01/Microsoft.Compute.Galleries) to the services fixture.
  2. Run tests in armkit-cli
  3. See error

Expected behavior
The filename should account for the entire service name, including sub-services.

This error effects the following services:

["2021-03-01/Microsoft.Cache.Enterprise", "Cache.Enterprise"],
["2016-10-01/Microsoft.StorSimple.1200", "StorSimple.1200"],
["2021-03-01/Microsoft.RecoveryServices.Backup", "RecoveryServices.Backup"],
["2019-03-01/Microsoft.Compute.Galleries", "Compute.Galleries"],
["2017-06-01/Microsoft.StorSimple.8000", "StorSimple.8000"],
["2021-03-01/Microsoft.RecoveryServices.SiteRecovery", "RecoveryServices.SiteRecovery"],
["2020-12-01/Microsoft.Compute.Extensions", "Compute.Extensions"],
["2016-06-01/Microsoft.RecoveryServices.legacy", "RecoveryServices.legacy"],
["2020-03-01/Microsoft.Devices.Provisioning", "Devices.Provisioning"],
["2020-11-01/Microsoft.Network.FrontDoor", "Network.FrontDoor"],
["2021-03-08/Microsoft.Insights.Application", "Insights.Application"],
["2015-06-01/Microsoft.KeyVault.Secrets", "KeyVault.Secrets"],

[Security] Workflow stale.yml is using vulnerable action actions/stale

The workflow stale.yml is referencing action actions/stale using references v1. However this reference is missing the commit af4072615903a8b031f986d25b1ae3bf45ec44d4 which may contain fix to the some vulnerability.
The vulnerability fix that is missing by actions version could be related to:
(1) CVE fix
(2) upgrade of vulnerable dependency
(3) fix to secret leak and others.
Please consider to update the reference to the action.

Developer tooling

As a developer i want to have hook streamline my standard task like

  • yarn build (done ?)
  • armkit generate
  • translate and run examples with new api

Describe the solution you'd like

  • have a local script section
  • GH flow would do

Add node packaging tooling

Is your feature request related to a problem? Please describe.
Helpers to create and publish packages for @armkit/core and armkit-cli are needed.

Describe the solution you'd like
Add package.sh helper in the individual packages and add a global hook to collect an ship all of them .

def.properties are left empty instead of returning a string

Describe the bug
On executing ~/packages /packages/armkit-cli/bin$ ./armkit import def.properties is left empty instead of returning a string
To Reproduce
Steps to reproduce the behavior:

  1. run /packages/armkit-cli/bin$ ./armkit import
    1. watch out for { struct: '' } log messages

Expected behavior

{ struct: 'MICROSOFT_CONTAINER_REGISTRY_REGISTRIES_TASKS_TAGS' }
{ cleantypeName: 'MicrosoftContainerRegistryRegistriesTasksType' }

Be able to select specific Azure Arm build tagets

I want to be able to select the build scope of on or multiple of this targets e.g i a .schema-config.json:

["Microsoft.AAD.json#",
 "Microsoft.AnalysisServices.json#",
 "Microsoft.ApiManagement.json#",
 "Microsoft.AppConfiguration.json#",
 "Microsoft.AppPlatform.json#",
 "Microsoft.Authorization.json#",
 "Microsoft.Automation.json#",
 "Microsoft.AzureStack.json#",
 "Microsoft.BareMetal.json#",
 "Microsoft.Batch.json#",
 "Microsoft.BatchAI.json#",
 "Microsoft.Cache.json#",
 "Microsoft.Cdn.json#",
 "Microsoft.CertificateRegistration.json#",
 "Microsoft.CognitiveServices.json#",
 "Microsoft.Compute.Extensions.json#",
 "Microsoft.Compute.Galleries.json#",
 "Microsoft.Compute.json#",
 "Microsoft.Consumption.json#",
 "Microsoft.ContainerInstance.json#",
 "Microsoft.ContainerRegistry.json#",
 "Microsoft.ContainerService.json#",
 "Microsoft.DBforMariaDB.json#",
 "Microsoft.DBforMySQL.json#",
 "Microsoft.DBforPostgreSQL.json#",
 "Microsoft.DataCatalog.json#",
 "Microsoft.DataFactory.json#",
 "Microsoft.DataLakeAnalytics.json#",
 "Microsoft.DataLakeStore.json#",
 "Microsoft.DataMigration.json#",
 "Microsoft.DevTestLab.json#",
 "Microsoft.Devices.Provisioning.json#",
 "Microsoft.Devices.json#",
 "Microsoft.DocumentDB.json#",
 "Microsoft.DomainRegistration.json#",
 "Microsoft.EventGrid.json#",
 "Microsoft.EventHub.json#",
 "Microsoft.Genomics.json#",
 "Microsoft.HDInsight.json#",
 "Microsoft.HealthcareApis.json#",
 "Microsoft.ImportExport.json#",
 "Microsoft.Insights.json#",
 "Microsoft.IotCentral.json#",
 "Microsoft.KeyVault.json#",
 "Microsoft.Kusto.json#",
 "Microsoft.Logic.json#",
 "Microsoft.MachineLearning.json#",
 "Microsoft.MachineLearningExperimentation.json#",
 "Microsoft.MachineLearningServices.json#",
 "Microsoft.ManagedIdentity.json#",
 "Microsoft.ManagedServices.json#",
 "Microsoft.Maps.json#",
 "Microsoft.Media.json#",
 "Microsoft.Migrate.json#",
 "Microsoft.NetApp.json#",
 "Microsoft.Network.json#",
 "Microsoft.NotificationHubs.json#",
 "Microsoft.OperationalInsights.json#",
 "Microsoft.OperationsManagement.json#",
 "Microsoft.Peering.json#",
 "Microsoft.PowerBI.json#",
 "Microsoft.PowerBIDedicated.json#",
 "Microsoft.RecoveryServices.json#",
 "Microsoft.Relay.json#",
 "Microsoft.ResourceGraph.json#",
 "Microsoft.Resources.json#",
 "Microsoft.Scheduler.json#",
 "Microsoft.Search.json#",
 "Microsoft.Security.json#",
 "Microsoft.ServiceBus.json#",
 "Microsoft.ServiceFabric.json#",
 "Microsoft.SignalRService.json#",
 "Microsoft.Solutions.json#",
 "Microsoft.Sql.json#",
 "Microsoft.StorSimple.json#",
 "Microsoft.Storage.json#",
 "Microsoft.StreamAnalytics.json#",
 "Microsoft.TimeSeriesInsights.json#",
 "Microsoft.VMwareCloudSimple.json#",
 "Microsoft.VMwareVirtustream.json#",
 "Microsoft.Web.json#",
 "Microsoft.WindowsESU.json#",
 "Sendgrid.Email.json#",
 "definitions.json#",
 "microsoft.visualstudio.json#"]

Document use of SCHEMA_DEFINITION_URL

Is your feature request related to a problem? Please describe.
SCHEMA_DEFINITION_URL has to be documented and declared in a more obvious way

Describe the solution you'd like
Document var sets and provide a runtime setting file

Describe alternatives you've considered
SCHEMA_DEFINITION_URL has to be documented and declared in a more obvious way

Additional context
At the moment this var is set in the armkit package.json

Generating Microsoft.Network throws errors on handling 'undefined' types

Describe the bug
A clear and concise description of what the bug is.

To Reproduce

Run yarn generate

yarn run v1.22.5
$ armkit generate
(node:1614299) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'toUpperCase' of undefined
    at /home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/type-generator.js:213:53
    at TypeGenerator.generate (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/type-generator.js:153:13)
    at ImportArmSchema.make (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/import.js:21:23)
    at ImportArmSchema.generateTypeScript (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/import.js:9:14)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async ImportArmSchema.import (/home/aheumaier/Codebox/src/github.com/yetics/armkit/packages/armkit-cli/lib/base.js:41:13)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1614299) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1614299) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 0.61s.

Expected behavior
no errors

Some services have type undefined

Describe the bug
When running snapshot tests, some services come back with this error:

    TypeError: Cannot read property 'toUpperCase' of undefined

      248 |           }
      249 |         }
    > 250 |         const methodName = 'from' + type[0].toUpperCase() + type.substr(1);
          |                                             ^
      251 |         code.openBlock(`public static ${methodName}(value: ${type}${list}): ${typeName}`);
      252 |         code.line(`return new ${typeName}(value);`);
      253 |         code.closeBlock();

      at lib/type-generator.ts:250:45
      at TypeGenerator.generate (lib/type-generator.ts:194:7)
      at ImportArmSchema.make (lib/import.ts:26:19)
      at ImportArmSchema.generateTypeScript (lib/import.ts:10:10)
      at ImportArmSchema.import (lib/base.ts:61:7)
      at test/schema.test.ts:143:3

The following services are effected by this issue:

["2018-07-01/Microsoft.Media", "Media"],
["2020-11-01/Microsoft.Network", "Network"],
["2020-12-01/Microsoft.ApiManagement", "ApiManagement"],
["2018-11-01/Microsoft.Web", "Web"],
["2019-06-01/Microsoft.Automation", "Automation"],

To Reproduce
Steps to reproduce the behavior:

  1. Add one of the effected services to the fixtures file from #68
  2. Run tests
  3. See error

Armkit installation error

When trying the GitHub instructions to install Armkit, it throws an error:

steps to reproduce the behavior:

  1. Checked the npm and node versions (NodeJS > 12.6 and npm - 6.14.4)
  2. Type "npm i -g armkit"
  3. See error screenshot
    image

Expected behavior
Installation should succeed.

Desktop (please complete the following information):

  • Device: Laptop Win 10
  • OS: Win 10 Enterprise
  • Version: NodeJS > 12.6 & npm - 6.14.4

RFC: Refactor to projen

Projen and every other CDK uses projen already.

To Accomplish:

  • [ ] Remove lerna
  • [ ] Remove yarn.lock s
  • [. ] tsconfig.json moves to tsconfig.eslint.json and tsconfig.jest.json
  • [ ] Remove package.json s (might keep some fragements)
  • [ ] Rename packages to src/
  • [ ] Move examples into src/
  • [. ] packages/armkit-cli/tests can/should? move to toplevel/test?
  • [. ] Move from Azure Pipelines to GitHub Actions (for community visibility of PR builds)
  • [ ] Distribute the construct library and the cli as 1 mono pkg like the aws-cdk
  • [. ] Enable gitpod, docgen, typedocs? (not codecov), codeql (ts)
  • [. ] Enable mergify

In .projenrc.js

  • Publish to NPM, PYPI, MAVEN, Github (golang)
  • Hook build to run armkit generate which fixes #42

If this sounds good, I'll open a PR.

Incremental Schema Generation

Let's do the schema generation in incremental steps.

We could add a schema-config.json and define the targets for the schema generator:

{
  "buildTargets": [
    "Microsoft.ContainerService"
  ]
}

By default, we'll assume latest as the version. We could support specifying the version like this:

{
  "buildTargets": [
    "Microsoft.ContainerService@2019-06-01"
  ]
}

This will allow to add schemas one by one. That's gonna be way easier than making sure that all the schemas are compiling at once.

Implementation

The generator / import step will have to do the following steps:

  • Build the full Schema except resources
  • Build Common
  • Build the build targets from the config files

In the first step, we should just make sure it compiles.

For a full example, we'll have to make sure that it's actually deployable. This doesn't have to work right away, though.

Prerequisites

  • Refactoring of CLI importer
  • Fully understand the versioning of the schema

`arm-stack` should support template outputs section resources

Is your feature request related to a problem? Please describe.
Since just the resource section of the ARM template schema is implemented arm-stack has no support for arm-outputs

Describe the solution you'd like
Arm template output should be suported as

export class MyStack extends ArmStack {
  constructor(scope: Construct, name: string) {
    super(scope, name);

    new ContainerGroups(this, 'MyContainerGroup', {
      name: 'azurecdktest',
      location: 'westeurope',
      apiVersion: MicrosoftContainerInstanceContainerGroupsApiVersion["MicrosoftContainerInstanceContainerGroupsApiVersion_2021_03_01"],
      type: MicrosoftContainerInstanceContainerGroupsType.MicrosoftContainerInstanceContainerGroupsType_MICROSOFT_CONTAINER_INSTANCE_CONTAINER_GROUPS,
      properties: {
        containers: [{
          name: 'ubuntu-server',
          properties: {
            image: 'ubuntu:18.04',
            command: ['sleep infinity'],
            resources: {
              requests: {
                cpu: 1,
                memoryInGB: 2
              },
              limits: {
                cpu: 1,
                memoryInGB: 2
              }
            }

          }
        }],
        osType: ContainerGroupPropertiesOsType.LINUX,
      }
    })

    new ArmOutput(this, 'registryurl', {
      value: `https://asdf.registries.azure.con/`,
    });
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.