-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into brfole/validateandtransform
- Loading branch information
Showing
12 changed files
with
154 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,32 @@ | ||
package providers | ||
|
||
import ( | ||
"fmt" | ||
"github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" | ||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/authorization/armauthorization/v3" | ||
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/subscription/armsubscription" | ||
"github.com/Azure/draft/pkg/cred" | ||
) | ||
|
||
type AzClient struct { | ||
AzTenantClient azTenantClient | ||
AzTenantClient azTenantClient | ||
RoleAssignClient *armauthorization.RoleAssignmentsClient | ||
} | ||
|
||
//go:generate mockgen -source=./az-client.go -destination=./mock/az-client.go . | ||
type azTenantClient interface { | ||
NewListPager(options *armsubscription.TenantsClientListOptions) *runtime.Pager[armsubscription.TenantsClientListResponse] | ||
} | ||
|
||
func createRoleAssignmentClient(subscriptionId string) (*armauthorization.RoleAssignmentsClient, error) { | ||
credential, err := cred.GetCred() | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get credentials: %w", err) | ||
} | ||
|
||
client, err := armauthorization.NewRoleAssignmentsClient(subscriptionId, credential, nil) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create role assignment client: %w", err) | ||
} | ||
return client, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
templateName: "Service" | ||
description: "This template is used to create a generic Service for an application" | ||
type: "manifest" | ||
variables: | ||
- name: "PORT" | ||
type: "int" | ||
kind: "port" | ||
description: "the port the service uses to make the application accessible from outside the cluster" | ||
default: | ||
value: 80 | ||
- name: "APPNAME" | ||
type: "string" | ||
kind: "kubernetesResourceName" | ||
description: "the name of the application" | ||
- name: "PARTOF" | ||
type: "string" | ||
kind: "label" | ||
description: "the label to identify which project the resource belong to" | ||
- name: "GENERATORLABEL" | ||
type: "string" | ||
kind: "label" | ||
description: "the label to identify who generated the resource" | ||
default: | ||
value: "draft" | ||
- name: "TARGETPORT" | ||
type: "int" | ||
kind: "port" | ||
description: "the port exposed in the application" | ||
default: | ||
referenceVar: "PORT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{.APPNAME}} | ||
labels: | ||
app.kubernetes.io/name: {{.APPNAME}} | ||
app.kubernetes.io/part-of: {{.PARTOF}} | ||
kubernetes.azure.com/generator: {{.GENERATORLABEL}} | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
app: {{.APPNAME}} | ||
ports: | ||
- protocol: TCP | ||
port: {{.PORT}} | ||
targetPort: {{.TARGETPORT}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters