Skip to content

Commit

Permalink
internal/v1: stop setting azure location
Browse files Browse the repository at this point in the history
osbuild/osbuild-composer#3093 added the ability to let the location of
the resource group be inferred by composer. Since we always passed
"eastus" by default, this prevented images being uploaded to resource
groups outside of that location.
  • Loading branch information
croissanne committed Nov 7, 2022
1 parent 2976f24 commit af5f88e
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 24 deletions.
6 changes: 1 addition & 5 deletions cmd/image-builder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,6 @@ func main() {
Bucket: conf.OsbuildGCPBucket,
}

azure := v1.AzureConfig{
Location: conf.OsbuildAzureLocation,
}

adr, err := distribution.LoadDistroRegistry(conf.DistributionsDir)
if err != nil {
panic(err)
Expand All @@ -78,7 +74,7 @@ func main() {
}

echoServer := echo.New()
err = v1.Attach(echoServer, client, dbase, aws, gcp, azure, conf.QuotaFile, conf.AllowFile, adr)
err = v1.Attach(echoServer, client, dbase, aws, gcp, conf.QuotaFile, conf.AllowFile, adr)
if err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ type ImageBuilderConfig struct {
OsbuildRegion string `env:"OSBUILD_AWS_REGION"`
OsbuildGCPRegion string `env:"OSBUILD_GCP_REGION"`
OsbuildGCPBucket string `env:"OSBUILD_GCP_BUCKET"`
OsbuildAzureLocation string `env:"OSBUILD_AZURE_LOCATION"`
DistributionsDir string `env:"DISTRIBUTIONS_DIR"`
MigrationsDir string `env:"MIGRATIONS_DIR"`
TernExecutable string `env:"TERN_EXECUTABLE"`
Expand Down
6 changes: 3 additions & 3 deletions internal/v1/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,13 +626,13 @@ func (h *Handlers) buildUploadOptions(ur UploadRequest, it ImageTypes) (composer
if err != nil {
return nil, "", echo.NewHTTPError(http.StatusBadRequest, "Unable to unmarshal into AzureUploadRequestOptions")
}
return composer.AzureUploadOptions{
uploadOptions := composer.AzureUploadOptions{
TenantId: azureOptions.TenantId,
SubscriptionId: azureOptions.SubscriptionId,
ResourceGroup: azureOptions.ResourceGroup,
Location: h.server.azure.Location,
ImageName: azureOptions.ImageName,
}, composerImageType, nil
}
return uploadOptions, composerImageType, nil
default:
return nil, "", echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("Unknown UploadRequest type %s", ur.Type))
}
Expand Down
8 changes: 1 addition & 7 deletions internal/v1/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Server struct {
db db.DB
aws AWSConfig
gcp GCPConfig
azure AzureConfig
quotaFile string
allowList common.AllowList
allDistros *distribution.AllDistroRegistry
Expand All @@ -46,16 +45,12 @@ type GCPConfig struct {
Bucket string
}

type AzureConfig struct {
Location string
}

type Handlers struct {
server *Server
}

func Attach(echoServer *echo.Echo, client *composer.ComposerClient, dbase db.DB,
awsConfig AWSConfig, gcpConfig GCPConfig, azureConfig AzureConfig, quotaFile string, allowFile string, allDistros *distribution.AllDistroRegistry) error {
awsConfig AWSConfig, gcpConfig GCPConfig, quotaFile string, allowFile string, allDistros *distribution.AllDistroRegistry) error {
spec, err := GetSwagger()
if err != nil {
return err
Expand Down Expand Up @@ -83,7 +78,6 @@ func Attach(echoServer *echo.Echo, client *composer.ComposerClient, dbase db.DB,
dbase,
awsConfig,
gcpConfig,
azureConfig,
quotaFile,
allowList,
allDistros,
Expand Down
2 changes: 1 addition & 1 deletion internal/v1/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func startServerWithCustomDB(t *testing.T, url string, dbase db.DB, distsDir str
require.NoError(t, err)

echoServer := echo.New()
err = Attach(echoServer, client, dbase, AWSConfig{}, GCPConfig{}, AzureConfig{}, quotaFile, allowFile, adr)
err = Attach(echoServer, client, dbase, AWSConfig{}, GCPConfig{}, quotaFile, allowFile, adr)
require.NoError(t, err)
// execute in parallel b/c .Run() will block execution
go func() {
Expand Down
1 change: 0 additions & 1 deletion schutzbot/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ sudo podman run -d --pull=never --security-opt "label=disable" --net=host \
-e OSBUILD_AWS_REGION="${AWS_REGION:-}" \
-e OSBUILD_GCP_REGION="${GCP_REGION:-}" \
-e OSBUILD_GCP_BUCKET="${GCP_BUCKET:-}" \
-e OSBUILD_AZURE_LOCATION="${AZURE_LOCATION:-}" \
-e PGHOST=localhost -e PGPORT=5432 -e PGDATABASE=imagebuilder \
-e PGUSER=postgres -e PGPASSWORD=foobar \
-e ALLOWED_ORG_IDS="000000" \
Expand Down
6 changes: 0 additions & 6 deletions templates/image-builder.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,6 @@ objects:
value: "${OSBUILD_GCP_REGION}"
- name: OSBUILD_GCP_BUCKET
value: "${OSBUILD_GCP_BUCKET}"
# Azure target specific variables passed to composer
- name: OSBUILD_AZURE_LOCATION
value: "${OSBUILD_AZURE_LOCATION}"
- name: ALLOWED_ORG_IDS
value: "${ALLOWED_ORG_IDS}"
- name: ALLOWED_ACCOUNT_NUMBERS
Expand Down Expand Up @@ -368,9 +365,6 @@ parameters:
- name: OSBUILD_GCP_BUCKET
description: Bucket in GCP to upload to
value: "image-upload-bkt-us"
- name: OSBUILD_AZURE_LOCATION
description: Location in Azure to upload to
value: "eastus"
- name: PGSSLMODE
description: Sslmode for the connection to psql
value: "require"
Expand Down

0 comments on commit af5f88e

Please sign in to comment.