Skip to content

Commit

Permalink
Added tagging and flags mechanisms
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenkndinh authored and saurav-agarwalla committed May 11, 2022
1 parent 2563a4e commit e3a440f
Show file tree
Hide file tree
Showing 12 changed files with 218 additions and 216 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ docs/book/_book/
site/
.vscode/
e2e.test
.idea/
20 changes: 17 additions & 3 deletions cmd/aws-cloud-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.
package main

import (
"k8s.io/cloud-provider-aws/pkg/controllers/tagging"
"math/rand"
"os"
"time"
Expand All @@ -43,8 +44,6 @@ import (
"k8s.io/klog/v2"

cloudcontrollerconfig "k8s.io/cloud-provider/app/config"

awscontrollers "k8s.io/cloud-provider-aws/pkg/controllers"
)

const (
Expand All @@ -64,8 +63,23 @@ func main() {
klog.Fatalf("unable to initialize command options: %v", err)
}

controllerInitializers := awscontrollers.BuildControllerInitializers()
controllerInitializers := app.DefaultInitFuncConstructors
taggingControllerWrapper := tagging.TaggingControllerWrapper{}
fss := cliflag.NamedFlagSets{}
taggingControllerWrapper.Options.AddFlags(fss.FlagSet("tagging controller"))

taggingControllerConstructor := app.ControllerInitFuncConstructor{
InitContext: app.ControllerInitContext{
ClientName: tagging.TaggingControllerClientName,
},
Constructor: taggingControllerWrapper.StartTaggingControllerWrapper,
}

controllerInitializers[tagging.TaggingControllerKey] = taggingControllerConstructor

// TODO: remove the following line to enable the route controller
delete(controllerInitializers, "route")

command := app.NewCloudControllerManagerCommand(opts, cloudInitializer, controllerInitializers, fss, wait.NeverStop)

if err := command.Execute(); err != nil {
Expand Down
6 changes: 0 additions & 6 deletions pkg/config/cloud_config.go

This file was deleted.

56 changes: 0 additions & 56 deletions pkg/config/controller_config.go

This file was deleted.

5 changes: 0 additions & 5 deletions pkg/config/runtime_config.go

This file was deleted.

89 changes: 0 additions & 89 deletions pkg/controllers/aws_controller_manager.go

This file was deleted.

22 changes: 22 additions & 0 deletions pkg/controllers/options/tagging_controller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package options

import (
"fmt"
"github.com/spf13/pflag"
)

type TaggingControllerOptions struct {
Tags map[string]string
}

func (o *TaggingControllerOptions) AddFlags(fs *pflag.FlagSet) {
fs.StringToStringVar(&o.Tags, "tags", o.Tags, "Tags to apply to AWS resources in the tagging controller.")
}

func (o *TaggingControllerOptions) Validate() error {
if len(o.Tags) == 0 {
return fmt.Errorf("--tags must not be empty.")
}

return nil
}
Loading

0 comments on commit e3a440f

Please sign in to comment.