Skip to content

Commit 15752e8

Browse files
author
Patrick J. McNerthney
committed
Configure logging after pip install is run
1 parent 2a0e3b2 commit 15752e8

File tree

28 files changed

+42
-62
lines changed

28 files changed

+42
-62
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
workflow_dispatch:
1010
inputs:
1111
version:
12-
description: Package version (e.g. v0.1.0)
12+
description: Package version (e.g. v0.1.2)
1313
required: false
1414

1515
env:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ kind: Function
5757
metadata:
5858
name: function-pythonic
5959
spec:
60-
package: ghcr.io/fortra/function-pythonic:v0.1.1
60+
package: ghcr.io/fortra/function-pythonic:v0.1.2
6161
```
6262
## Composed Resource Dependencies
6363
@@ -384,7 +384,7 @@ metadata:
384384
annotations:
385385
render.crossplane.io/runtime: Development
386386
spec:
387-
package: ghcr.io/fortra/function-pythonic:v0.1.1
387+
package: ghcr.io/fortra/function-pythonic:v0.1.2
388388
```
389389
In one terminal session, run function-pythonic:
390390
```shell
@@ -486,7 +486,7 @@ kind: Function
486486
metadata:
487487
name: function-pythonic
488488
spec:
489-
package: ghcr.io/fortra/function-pythonic:v0.1.1
489+
package: ghcr.io/fortra/function-pythonic:v0.1.2
490490
runtimeConfigRef:
491491
name: function-pythonic
492492
---

crossplane/pythonic/composite.py

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def __init__(self, request, logger):
4141
self.kind = self.observed.kind
4242
self.metadata = self.observed.metadata
4343
self.spec = self.observed.spec
44-
self.status = Status(self.observed.status, self.desired.status)
44+
self.status = self.desired.status
4545
self.conditions = Conditions(observed, self.response)
4646
self.connection = Connection(observed, desired)
4747
self.events = Events(self.response)
@@ -217,10 +217,9 @@ def kind(self, kind):
217217

218218
@property
219219
def externalName(self):
220-
name = self.metadata.annotations['crossplane.io/external-name']
221-
if not name:
222-
name = self.observed.metadata.annotations['crossplane.io/external-name']
223-
return name
220+
if 'crossplane.io/external-name' in self.metadata.annotations:
221+
return self.metadata.annotations['crossplane.io/external-name']
222+
return self.observed.metadata.annotations['crossplane.io/external-name']
224223

225224
@externalName.setter
226225
def externalName(self, name):
@@ -409,27 +408,6 @@ def __bool__(self):
409408
return bool(self.observed)
410409

411410

412-
class Status:
413-
def __init__(self, observed, desired):
414-
self.__dict__['_observed'] = observed
415-
self.__dict__['_desired'] = desired
416-
417-
def __getattr__(self, key):
418-
return self[key]
419-
420-
def __getitem__(self, key):
421-
value = self._desired[key]
422-
if value is None:
423-
value = self._observed[key]
424-
return value
425-
426-
def __setattr__(self, key, value):
427-
self[key] = value
428-
429-
def __setitem__(self, key, value):
430-
self._desired[key] = value
431-
432-
433411
class Conditions:
434412
def __init__(self, observed, response=None):
435413
self._observed = observed

crossplane/pythonic/main.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,20 +102,20 @@ async def main(self):
102102
print('Either --tls-certs-dir or --insecure must be specified', file=sys.stderr)
103103
sys.exit(1)
104104

105-
self.configure_logging(args)
106-
# enables read only volumes or mismatched uid volumes
107-
sys.dont_write_bytecode = True
108-
await self.run(args)
109-
110-
# Allow for independent running of function-pythonic
111-
async def run(self, args):
112105
if args.pip_install:
113106
import pip._internal.cli.main
114107
pip._internal.cli.main.main(['install', '--user', *shlex.split(args.pip_install)])
115108

116109
for path in reversed(args.python_path):
117110
sys.path.insert(0, str(pathlib.Path(path).expanduser().resolve()))
118111

112+
self.configure_logging(args)
113+
# enables read only volumes or mismatched uid volumes
114+
sys.dont_write_bytecode = True
115+
await self.run(args)
116+
117+
# Allow for independent running of function-pythonic
118+
async def run(self, args):
119119
if args.allow_oversize_protos:
120120
from google.protobuf.internal import api_implementation
121121
if api_implementation._c_module:
@@ -166,7 +166,7 @@ def configure_logging(self, args):
166166
handler = logging.StreamHandler()
167167
handler.setFormatter(formatter)
168168
logger = logging.getLogger()
169-
logger.addHandler(handler)
169+
logger.handlers = [handler]
170170
logger.setLevel(logging.DEBUG if args.debug else logging.INFO)
171171

172172

examples/.dev/functions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ metadata:
1010
render.crossplane.io/runtime: Development
1111
render.crossplane.io/runtime-development-target: localhost:9443
1212
spec:
13-
package: ghcr.io/fortra/function-pythonic:v0.1.1
13+
package: ghcr.io/fortra/function-pythonic:v0.1.2

examples/aks-cluster/cluster-function-pythonic.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Function
33
metadata:
44
name: function-pythonic
55
spec:
6-
package: ghcr.io/fortra/function-pythonic:v0.1.1
6+
package: ghcr.io/fortra/function-pythonic:v0.1.2
77
runtimeConfigRef:
88
name: function-pythonic
99
---

examples/aks-cluster/functions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ metadata:
55
annotations:
66
render.crossplane.io/runtime: Development
77
spec:
8-
package: ghcr.io/fortra/function-pythonic:v0.1.1
8+
package: ghcr.io/fortra/function-pythonic:v0.1.2
99
runtimeConfigRef:
1010
name: function-pythonic

examples/eks-cluster/functions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ metadata:
55
annotations:
66
render.crossplane.io/runtime: Development
77
spec:
8-
package: ghcr.io/fortra/function-pythonic:v0.1.1
8+
package: ghcr.io/fortra/function-pythonic:v0.1.2

examples/filing-system/function.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ kind: Function
33
metadata:
44
name: function-pythonic
55
spec:
6-
package: ghcr.io/fortra/function-pythonic:v0.1.1
6+
package: ghcr.io/fortra/function-pythonic:v0.1.2
77
runtimeConfigRef:
88
apiVersion: pkg.crossplane.io/v1beta1
99
kind: DeploymentRuntimeConfig

examples/function-go-templating/conditions/functions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ metadata:
1515
# This tells crossplane beta render to connect to the function locally.
1616
render.crossplane.io/runtime: Development
1717
spec:
18-
package: ghcr.io/fortra/function-pythonic:v0.1.1
18+
package: ghcr.io/fortra/function-pythonic:v0.1.2
1919
---
2020
apiVersion: pkg.crossplane.io/v1beta1
2121
kind: Function

0 commit comments

Comments
 (0)