Skip to content
This repository was archived by the owner on Nov 20, 2024. It is now read-only.

Commit 765d65d

Browse files
authored
Add zap option flags (#106)
1 parent 7d42ada commit 765d65d

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,16 @@ func main() {
3737
flag.BoolVar(&enableLeaderElection, "enable-leader-election", false,
3838
"Enable leader election for controller manager. "+
3939
"Enabling this will ensure there is only one active controller manager.")
40+
opts := zap.Options{}
41+
opts.BindFlags(flag.CommandLine)
42+
err := flag.Set("zap-devel", "true")
43+
if err != nil {
44+
setupLog.Error(err, "unable to set zap flag")
45+
}
46+
4047
flag.Parse()
4148

42-
ctrl.SetLogger(zap.New(zap.UseDevMode(true)))
49+
ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))
4350

4451
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
4552
Namespace: namespaceName,

workspacehelper/tfc_org.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,12 @@ func (t *TerraformCloudClient) updateAgentPoolID(instance *appv1alpha1.Workspace
167167
func (t *TerraformCloudClient) CheckWorkspace(workspace string, instance *appv1alpha1.Workspace) (*tfc.Workspace, error) {
168168
ws, err := t.Client.Workspaces.Read(context.TODO(), t.Organization, workspace)
169169
if err != nil && err == tfc.ErrResourceNotFound {
170-
id, err := t.CreateWorkspace(workspace, instance)
171-
if err != nil {
172-
return nil, err
170+
id, wsErr := t.CreateWorkspace(workspace, instance)
171+
if wsErr != nil {
172+
return nil, wsErr
173+
} else {
174+
ws = &tfc.Workspace{ID: id}
175+
err = nil
173176
}
174177
ws = &tfc.Workspace{ID: id}
175178
} else if err != nil {

0 commit comments

Comments
 (0)