Skip to content

Commit

Permalink
introduce clusterConf struct for config mgmt in cluster.go
Browse files Browse the repository at this point in the history
  • Loading branch information
mrWinston committed Nov 25, 2024
1 parent b0d6987 commit 1a1453f
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 169 deletions.
30 changes: 6 additions & 24 deletions hack/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import (
"github.com/davecgh/go-spew/spew"
"github.com/sirupsen/logrus"

"github.com/Azure/ARO-RP/pkg/env"
"github.com/Azure/ARO-RP/pkg/util/cluster"
msgraph_errors "github.com/Azure/ARO-RP/pkg/util/graph/graphsdk/models/odataerrors"
utillog "github.com/Azure/ARO-RP/pkg/util/log"
"github.com/Azure/ARO-RP/pkg/util/version"

Check failure on line 18 in hack/cluster/cluster.go

View workflow job for this annotation

GitHub Actions / golangci-lint

File is not `gofmt`-ed with `-s` (gofmt)
)

const (
Expand All @@ -28,39 +27,22 @@ func run(ctx context.Context, log *logrus.Entry) error {
return fmt.Errorf("usage: CLUSTER=x %s {create,delete}", os.Args[0])
}

if err := env.ValidateVars(Cluster); err != nil {
return err
}

env, err := env.NewCore(ctx, log, env.COMPONENT_TOOLING)
conf, err := cluster.NewClusterConfigFromEnv()
if err != nil {
return err
}

vnetResourceGroup := os.Getenv("RESOURCEGROUP") // TODO: remove this when we deploy and peer a vnet per cluster create
if os.Getenv("CI") != "" {
vnetResourceGroup = os.Getenv(Cluster)
}
clusterName := os.Getenv(Cluster)

osClusterVersion := os.Getenv("OS_CLUSTER_VERSION")
if osClusterVersion == "" {
osClusterVersion = version.DefaultInstallStream.Version.String()
log.Infof("using default cluster version %s", osClusterVersion)
} else {
log.Infof("using specified cluster version %s", osClusterVersion)
}

c, err := cluster.New(log, env, os.Getenv("CI") != "")
c, err := cluster.New(log, conf)
if err != nil {
return err
}

spew.Dump(c.Config)
switch strings.ToLower(os.Args[1]) {
case "create":
return c.Create(ctx, vnetResourceGroup, clusterName, osClusterVersion)
return c.Create(ctx)
case "delete":
return c.Delete(ctx, vnetResourceGroup, clusterName)
return c.Delete(ctx, conf.VnetResourceGroup, conf.ClusterName)
default:
return fmt.Errorf("invalid command %s", os.Args[1])
}
Expand Down
2 changes: 1 addition & 1 deletion hack/devtools/local_dev_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ assign_role_to_identity() {
echo "INFO: Unable to list role assignments for identity: ${objectId}"
fi

if [ "$roles" == "" ] || [ "$roles" == "[]" ] ; then
if [[ "$roles" == "" ]] || [[ "$roles" == "[]" ]] ; then
echo "INFO: Assigning role to identity: ${objectId}"
az role assignment create --assignee-object-id "${objectId}" --assignee-principal-type "ServicePrincipal" --role "${roleId}" --scope "${scope}" --output json
echo ""
Expand Down
Loading

0 comments on commit 1a1453f

Please sign in to comment.