jbw976 / provider-nop

The least useful @crossplane provider

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

provider-nop

provider-nop is a Crossplane provider that does nothing. It provides one managed resource - a NopResource that does not orchestrate any external system. Each NopResource can be configured to emit arbitrary status conditions after a specified period of time. A NopResource can also emit arbitrary connection details.

The main value of a NopResource is that it can be used to create a Crossplane Composition that can satisfy any kind of composite resource by doing nothing. This can be useful for systems that automatically create a real composite resource (one that composes real cloud infrastructure) when running in production, but that wish to avoid creating real infrastructure when running in development. It can also be useful for developing and testing Crossplane itself.

The below Composition satisfies the SQLInstance composite resource kind by by composing a NopResource. When an SQLInstance is created it will become ready and write fake data to a connection secret.

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: nop.sqlinstances.example.org
spec:
  writeConnectionSecretsToNamespace: crossplane-system
  compositeTypeRef:
    apiVersion: example.org/v1alpha1
    kind: SQLInstance
  resources:
    - name: nop
      base:
        apiVersion: nop.crossplane.io/v1alpha1
        kind: NopResource
        spec:
          forProvider:
            # The NopResource spec.forProvider.fields is an arbitrary,
            # schemaless object. Use it to patch to and from.
            # status.atProvider.fields works the same.
            fields:
              integerField: 42
              stringField: "cool"
              objectField:
                stringField: "cool"
              arrayField:
              - stringField: "cool"
            # This NopResource will set its 'Ready' status condition to 'True'
            # after 30 seconds, etc. Note that these conditions will only be processed
            # as frequently as the provider's --poll-interval, which defaults to 10s.
            # This means that by default granularity of less than 10s is ignored.
            conditionAfter:
            - time: 30s
              conditionType: Ready
              conditionStatus: "True"
            - time: 60s
              conditionType: Ready
              conditionStatus: "False"
            - time: 90s
              conditionType: Ready
              conditionStatus: "True"
            - time: 90s
              conditionType: Green
              conditionStatus: "True"
            # The NopResource will emit whatever connection details it is told
            # to have. These are all plaintext - for testing only.
            connectionDetails:
            - name: username
              value: fakeuser
            - name: password
              value: verysecurepassword
            - name: endpoint
              value: 127.0.0.1
          # Like all managed resources the NopResource allows you to configure a
          # provider config. It ignores the configured value.
          providerConfigRef:
            name: default
          # Simulating connection details (see connectionDetails above) works
          # only when the NopResource writes a connection secret.
          writeConnectionSecretToRef:
            namespace: crossplane-system
            name: nop-example-resource
      patches:
        # You can use the schemaless 'fields' objects to patch to and from.
        - type: FromCompositeFieldPath
          fromFieldPath: spec.parameters.storageGB
          toFieldPath: spec.forProvider.fields.storageGB
          transforms:
            - type: string
              string:
                fmt: "%d"
        - type: ToCompositeFieldPath
          fromFieldPath: status.atProvider.fields.health
          toFieldPath: status.health

About

The least useful @crossplane provider

License:Apache License 2.0


Languages

Language:Go 69.8%Language:Makefile 17.1%Language:Shell 12.5%Language:Dockerfile 0.6%